--- url: /api/@warp-drive/core.md --- [Documentation](../../index.md) / @warp-drive/core # @warp-drive/core This package provides the core [*Warp***Drive**](https://warp-drive.io) experience. Head over to the [guides](/guide) for an introduction to *Warp***Drive** ## Installation ```sh pnpm install -E @warp-drive/core@latest ``` See [Configuration](/guide/1-configuration/1-overview) for full installation and configuration instructions. ## Bare Bones Setup ```ts [services/store.ts] import { RequestManager, Store, Fetch } from '@warp-drive/core'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]); } ``` ## Basic Usage ```ts const { content } = await store.request({ url: '/api/users' }); ``` ## Modules * [build-config](build-config/index.md) * [build-config/babel-macros](build-config/babel-macros/index.md) * [build-config/canary-features](build-config/canary-features/index.md) * [build-config/debugging](build-config/debugging/index.md) * [build-config/deprecations](build-config/deprecations/index.md) * [build-config/env](build-config/env/index.md) * [build-config/macros](build-config/macros/index.md) * [configure](configure/index.md) * [reactive](reactive/index.md) * [request](request/index.md) * [store](store/index.md) * [types](types/index.md) * [types/cache](types/cache/index.md) * [types/cache/aliases](types/cache/aliases/index.md) * [types/cache/change](types/cache/change/index.md) * [types/cache/mutations](types/cache/mutations/index.md) * [types/cache/operations](types/cache/operations/index.md) * [types/cache/relationship](types/cache/relationship/index.md) * [types/graph](types/graph/index.md) * [types/identifier](types/identifier/index.md) * [types/json/raw](types/json/raw/index.md) * [types/params](types/params/index.md) * [types/record](types/record/index.md) * [types/request](types/request/index.md) * [types/runtime](types/runtime/index.md) * [types/schema/concepts](types/schema/concepts/index.md) * [types/schema/fields](types/schema/fields/index.md) * [types/schema/fields.type-test](types/schema/fields.type-test/index.md) * [types/spec/document](types/spec/document/index.md) * [types/spec/error](types/spec/error/index.md) * [types/spec/json-api-raw](types/spec/json-api-raw/index.md) * [types/symbols](types/symbols/index.md) * [types/utils](types/utils/index.md) * [utils/string](utils/string/index.md) ## Classes * [Document](classes/Document.md) * [Fetch](classes/Fetch.md) * [RequestManager](classes/RequestManager.md) * [Store](classes/Store.md) ## Interfaces * [CachePolicy](interfaces/CachePolicy.md) * [StoreRequestContext](interfaces/StoreRequestContext.md) ## Type Aliases * [CacheOperation](type-aliases/CacheOperation.md) * [DocumentCacheOperation](type-aliases/DocumentCacheOperation.md) * [NotificationType](type-aliases/NotificationType.md) * [StoreRequestInput](type-aliases/StoreRequestInput.md) ## Variables * [CacheHandler](variables/CacheHandler.md) ## Functions * [recordIdentifierFor](functions/recordIdentifierFor.md) * [setIdentifierForgetMethod](functions/setIdentifierForgetMethod.md) * [setIdentifierGenerationMethod](functions/setIdentifierGenerationMethod.md) * [setIdentifierResetMethod](functions/setIdentifierResetMethod.md) * [setIdentifierUpdateMethod](functions/setIdentifierUpdateMethod.md) * [setKeyInfoForResource](functions/setKeyInfoForResource.md) * [storeFor](functions/storeFor.md) --- --- url: /api/@ember-data/tracking.md --- [Documentation](../../index.md) / @ember-data/tracking # ~~@ember-data/tracking~~ Using ***Warp*Drive** with EmberJS requires configuring it to use Ember's reactivity system. ::: warning The use of the package **@ember-data/tracking** is now deprecated. It historically provided the bindings into Ember's reactivity system. This package is no longer needed as the configuration is now provided by the package [@warp-drive/ember](../../@warp-drive/ember). ::: To resolve this deprecation, follow these steps: ## 1. Remove @ember-data/tracking * Remove `@ember-data/tracking` from package.json (if using `ember-data` this may not be present) * Remove type imports for `@ember-data/tracking` from tsconfig.json * If using `untracked`, change to using `untrack` from `@glimmer/validator` ## 2. Add @warp-drive/ember * Add `@warp-drive/ember` to package.json - the version to install should match the version of `ember-data` or `@ember-data/store` * Do NOT add `@warp-drive/ember` to tsconfig.json - the types in this package install automatically, you can remove any entry for this if it is there * Add `import '@warp-drive/ember/install';` to the top of your `app.js` or `app.ts` file ## 3. Clear the deprecation Once the above steps are complete, the deprecation can be silenced and the automatic fallback registration of reactivity from `@ember-data/tracking` can be removed by updating your [WarpDrive build config](../../@warp-drive/build-config) in your `ember-cli-build` file. ```js [ember-cli-build.js] 'use strict'; const EmberApp = require('ember-cli/lib/broccoli/ember-app'); const { compatBuild } = require('@embroider/compat'); module.exports = async function (defaults) { const { setConfig } = await import('@warp-drive/build-config'); // [!code focus] const { buildOnce } = await import('@embroider/vite'); const app = new EmberApp(defaults, {}); setConfig(app, __dirname, { // [!code focus:9] // this should be the most recent . version for // which all deprecations have been fully resolved // and should be updated when that changes compatWith: '4.12' deprecations: { // ... list individual deprecations that have been resolved here DEPRECATE_TRACKING_PACKAGE: false // [!code highlight] } }); return compatBuild(app, buildOnce); }; ``` ## Deprecated in version 5.5.0 ## Functions * [~~buildSignalConfig~~](functions/buildSignalConfig.md) --- --- url: /guide/misc/2-typescript/1-overview.md --- # 💚 TypeScript Guide Before getting started, we recommend reading the following two sections * [Notice on Type Maturity](#type-maturity) * [Contributing Type Fixes](#contributing-type-fixes) *** * Installation * [Using Versions That Supply Types](./0-installation.md#using-versions-that-supply-types) * [Using Types Packages](./0-installation.md#using-types-packages) * Configuration * [Using Native Types](./1-configuration.md#using-native-types) * [Using Types Packages](./1-configuration.md#using-types-packages) * Usage * [Why Brands](./2-why-brands.md) * [Typing Models & Transforms](./3-typing-models.md) * [Typing Requests & Builders](./4-typing-requests.md) * [Typing Includes](./5-typing-includes.md) * Typing Handlers * Using Store APIs *** ## Type Maturity We publish types in stages, just like `canary | beta | stable` channels for code. * `private` we don't ship types (yet), even if typed in the repo * `alpha` we expect high churn on type signatures and users must opt-in to use these types. * `beta` we expect moderate churn on type signatures and users must opt-in to use these types. * `stable` we feel the types story is robust enough to attempt to follow semver when changing these types. Each package in the project can choose its own stage for types. > \[!TIP] > TypeScript support for all EmberData and WarpDrive packages is currently `alpha`. > > **This means that you must opt-in to be able use EmberData's types.** ## Contributing Type Fixes Even though EmberData/WarpDrive is typed, what makes for good types for a project doesn't necessarily make for good types for that project's consumers (your application). Currently, TypeScript support is `alpha` largely because we expect to need to improve **a lot** of type signatures to make them more useful and correct for your app. Both strategies for installing and consuming types listed in [installation](./0-installation.md) pull their types from the `main` branch (canary). Every commit to main can be one-click published by us as a new canary version for both installation strategies, this means we can ship type fixes as quickly as folks contribute them, letting us dogfood our way to robust stable types. --- --- url: /guide/misc/3-requests/examples/1-auth.md --- # Auth Handler * Previous ← [Requests](./0-basic-usage.md) * Next → [Not sure what next?](./something.md) * ⮐ [Requests Guide](../index.md) ## In This Guide EmberData is flexible enough to work with any request authentication strategy. This guide will show you how you might implement some common strategies. * [JWT Token](#jwt-token) * [CSRF Token](#csrf-token) * [Secure Cookie](#secure-cookie) ### JWT Token > **Note** > This example uses [Ember](https://emberjs.com/) for convenience. > > `@ember-data/request` works with raw javascript or any framework of your choosing. Many public APIs require authentication. A common pattern nowadays is the use of an `Authorization` header with a bearer token. ```HTTP GET /api/companies?fields[company]=name&fields[employee]=name,profileImage&included=ceo&page[size]=10 HTTP/2 Accept: application/vnd.api+json; profile="https://jsonapi.org/profiles/ethanresnick/cursor-pagination" Authorization: Bearer ``` #### Basic example In Ember Data we can create our own custom handler to add authentication header to all requests ```ts import type { Handler, NextFn, RequestContext } from '@ember-data/request'; const ourSecureToken = '' const AuthHandler: Handler = { async request(context: RequestContext, next: NextFn) { const headers = new Headers(context.request.headers); headers.append( 'Authorization', `Bearer ${ourSecureToken}`, ); return next(Object.assign({}, context.request, { headers })); } } ``` This handler would need to be added to the request manager configuration: ```ts import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import AuthHandler from './auth-handler.js'; const manager = new RequestManager() .use([AuthHandler, Fetch]); ``` This way every request that was made using this request manager will have `Authorization` header added to it. #### Class based Handler Handlers can also be defined as classes. This is useful when you need to inject some services into your handler. Lets imagine we are using [Ember Simple Auth](https://github.com/simplabs/ember-simple-auth) addon to handle authentication. In this case we need to inject `session` service to get the token. **app/services/auth-handler.js** ```ts import { service } from '@ember/service'; import type { NextFn, RequestContext } from '@ember-data/request'; export default class AuthHandler { @service session; request(context: RequestContext, next: NextFn) { const headers = new Headers(context.request.headers); headers.append( 'Authorization', `Bearer ${this.session.accessToken}`, ); return next(Object.assign({}, context.request, { headers })); } } ``` > **Note** > This is just a native javascript class, so it is not aware of Ember's dependency injection system. To use this handler we need to register it in our request manager service, but also we need to tell Ember's dependency injection system to provide context for `@service session;` to work. **app/services/request-manager.js** ```ts import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import { getOwner, setOwner } from '@ember/owner'; import AuthHandler from './auth-handler'; export default { create(args) { const authHandler = new AuthHandler(); setOwner(authHandler, getOwner(args)); return new RequestManager() .use([authHandler, Fetch]); } } ``` Apart of this little twist with dependency injection, everything else is the same as in previous example. ### CSRF Token ### Simple The easy way of protecting against Cross Site Request Forgery (CSRF) is to set a static custom header in every HTTP Request (for example `X-CSRF-Protection: static`), check for it on the backend and make sure that CORS is only accepting data from trusted domains. If you do this, you don't have to generate dynamic CSRF tokens for every request. More information at [MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#simple_requests). ### Advanced > **Note** > This example uses [Ember](https://emberjs.com/) for convenience. > > `@ember-data/request` works with raw javascript or any framework of your choosing. Some APIs require CSRF token to be sent with every request. This token is usually stored in a cookie and needs to be extracted from it. ```HTTP GET /api/companies?fields[company]=name&fields[employee]=name,profileImage&included=ceo&page[size]=10 HTTP/2 Accept: application/vnd.api+json; profile="https://jsonapi.org/profiles/ethanresnick/cursor-pagination" X-CSRF-Token: ``` Usually this token is stored in a cookie, so we need to extract it from there. Also this token is usually sent only with `POST`, `PUT`, `PATCH` and `DELETE` requests. Let's create a handler that will do just that. ```ts import type { Handler, NextFn, RequestContext } from '@ember-data/request'; const MUTATION_OPS = new Set(['createRecord', 'updateRecord', 'deleteRecord']); const AuthHandler: Handler = { async request(context: RequestContext, next: NextFn) { if (MUTATION_OPS.has(context.request.op)) { const headers = new Headers(context.request.headers); headers.append( 'X-CSRF-Token', document.cookie.match(/csrfToken=([^;]+)/)[1], ); return next(Object.assign({}, context.request, { headers })); } return next(context.request); } } ``` This handler would need to be added to request manager configuration: ```ts import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import AuthHandler from './auth-handler'; const manager = new RequestManager() .use([AuthHandler, Fetch]); ``` This way every request that was made using this request manager will have `X-CSRF-Token` header added to it when needed. ### Secure Cookie Secure cookies are automatically managed by the browser, so we don't need to do anything special to send them with our requests when using native fetch (as for instance the provided `Fetch` handler does). We just need to make sure that we are requesting our API from the same domain that it is served from. There are a few scenarios where you may need to manage the cookie yourself, in these cases you could write a handler and take the same approach as the JWT Token example above. For instance, using a WebView to deploy a mobile or desktop app or if you are using a custom fetch library that doesn't automatically send cookies (potentially for something like SSR). *** * Previous ← [Requests](./0-basic-usage.md) * Next → [Not sure what next?](./something.md) * ⮐ [Requests Guide](../index.md) --- --- url: /guide/contributing/become-a-contributor.md --- # Become A Contributor Anyone can contribute to WarpDrive. Contributing can be as simple as opening an issue or helping to track down the cause of one. Or as involved as contributing a fix, helping with routine maintenance, or implementing a big new feature. In addition to holding discussions on individual [issues](https://github.com/emberjs/data/issues) or [RFCs](https://github.com/emberjs/rfcs/labels/T-ember-data), we coordinate work when needed in the `#dev-ember-data` channel on [Ember's Discord Server](https://discord.gg/zT3asNS). ### 🔗 Next Steps * [Setting Up The Project](./setting-up-the-project.md) * [Project Architecture](./project-architecture.md) * [Writing API Docs](./writing-api-docs.md) * [Key Concepts](./key-concepts.md) * [Terminology](./terminology.md) * [RFC Process](./rfc-process.md) --- --- url: /guide/2-requests/2-builders.md --- # Builders ## What Is A Builder ## When To Use A Builder ### Builders That Follow General API Patterns ### Builders That Follow Domain Logic ### {x,t}RPC with WarpDrive ### GraphQL with WarpDrive ## Best Practices For Builders ## Composing Builders ## Builder Utilities ## Type Utilities --- --- url: /guide/3-caching.md --- # Caching When a Store makes a Request, the Response is inserted into the Store's Cache. When the same Request is made again, the CacheHandler checks the Request's options as well as the Store's CachePolicy to decide if the version in the Store's Cache can be reused, or if updated data should be fetched. ## Determining If A Request Can Use The Cache * `store.request` decorates the request with the store instance in use, and passes the request to the RequestManager * The RequestManager invokes its handler chain, starting with the CacheHandler * If the request has no Store or `cacheOptions[SkipCache] === true`, the CacheHandler passes along the request to the handler chain and will not attempt to handle the request or the response. ## Determining The CacheKey And Checking If The Response Is Stale * The CacheHandler uses the attached store's IdentifierCache (a CacheKey manager) to determine the Request's CacheKey * this service will use `cacheOptions.key` if present * for `GET` requests if `cacheOptions.key` is not present it will use the url * for all other requests it will return `null` indicating the request is not one that can ever be served from cache * Note: this resolution is configurable * The CacheHandler uses the `CacheKey` as well as `cacheOptions` to determine if there is an existing cache entry * if there is a cache entry, it uses the `cacheOptions` and else the Store's `CachePolicy` to determine if the Response is stale. * If there is no cache entry or the Response is stale, the CacheHandler calls `next` and the Request continues down the handler chain. ## Updating The Cache With New Response Data * When the CacheHandler receives a response from the handler chain, it puts it in the cache. This occurs regardless of whether there is an associated `CacheKey` so that all responses are able to update the state of cached resources even if the request as a whole cannot be cached. For instance, when using `DELETE` to remove a record or a `POST` to create a new record. * The Cache processes the response, updating its state as needed, and returns a list of the resources found * If the request was configured to return a reactive response, the cache's list is turned into a reactive document. * Else the raw list is returned. ## How The Cache Works The Store's cache is an in-memory cache that handles the concerns needed to support the rich, reactive layer. By default, it does not persist into any form of more permanent storage, though implementations can do so and `@warp-drive/experiments` contains several primitives through which we've been exploring a persisted cache by-default design. The internal specifics of how a Cache chooses to store data are up to it. The below guide will be *generally* true of any implementation given the requirements a cache must fulfill. Since most applications will use the `JSONAPICache`, we describe the specific caching strategy it uses in detail. Caching is tiered by the kind of data being stored. Depending on how you look at it, there are either 3 or 4 tiers. Each tier operates on either `replace semantics` or `upsert semantics`. * **Replace Semantics:** receiving a new value for a key entirely overwrites the prior value * **Upsert Semantics:** new values received for a key merge with the existing value for the key ## Responses Are Cached By Their CacheKey With Replace Semantics ::: tip 💡 Resources within a Response are cached separately from the Response Read on to understand what this means. ::: When a response has a CacheKey, the Cache stores it using that CacheKey. If an entry was already present for that CacheKey, it is entirely overwritten. The same CacheKey applies to a request, its response, and its parsed content. We refer to this as a `RequestCacheKey`. In ***Warp*Drive** CacheKeys are objects with a string `lid` property and either the object or the string can be used as a unique key (the store's `identifierCache` is what provides cache keys and guarantees these properties). ::: code-group ```ts [Interface] interface RequestCacheKey { lid: string; } ``` ```ts [Example] { lid: 'https://api.example.com/v1/users/1?fields=name,age,dob' } ``` ::: The response supplied to the Cache is a StructuredDocument (an object containing the original `Request`, `Response` and variably the processed `content` or `error`). ```ts interface Result { request: Request; response: Response; } interface SuccessResult extends Result { content: object; } interface ErrorResult extends Result { error: Error; } type StructuredDocument = SuccessResult | ErrorResult; ``` The Cache expects that the data within `content` or `error` is in a format that it understands how to process. For the JSONAPICache implementation, this is [{json:api}](https://json-api.org). The `content` (or respectively `error`) property of the StructuredDocument will be processed by the Cache and replaced with a `ResponseDocument`. This data structure is similar to the top-level document structured defined by JSON:API for convenience. ```ts interface ResponseDocument { meta?: object; links?: object; data?: ResourceCacheKey | ResourceCacheKey[]; included?: object[]; errors?: ResourceCacheKey[]; } ``` ### Resource Extraction During content processing, the cache extracts any resources it finds in the payload. The returned response document includes a list of the Resource CacheKeys representing resources extracted. Like RequestCacheKey, a ResourceCacheKey is a stable object with a string `lid` property. ResourceCacheKey also encoudes the `ResourceType` and the primary key of the resource. ::: code-group ```ts [Interface] interface ResourceCacheKey { id: string | null; type: string; lid: string; } ``` ```ts [Example] { id: "1", type: "user", lid: '@lid:user:1' } ``` ::: Resources that were part of the primary data of the response are listed under the `data` property, while secondary (or sideloaded) resourrces are listed under included. For example ::: code-group ```ts [Original Content] { data: { type: 'user', id: '1', attributes: { name: 'Chris' }, relationships: { bestFriend: { data: { type: 'user', id: '2' } } } }, included: [ { type: 'user', id: '2', attributes: { name: 'Wes' }, relationships: { bestFriend: { data: { type: 'user', id: '1' } } } } ] } ``` ```ts [ResponseDocument] { data: { type: 'user', id: '1', lid: '@lid:user:1' }, included: [ { type: 'user', id: '2', lid: '@lid:user:2' } ] } ``` ::: ## Resources Are Cached By Their CacheKey With Upsert Semantics When the Cache finds a Resource in a Response, it generates a CacheKey for the Resource using the Store's IdentifierCache (a CacheKey manager). If an entry was already present for that CacheKey, the existing data and new data are merged together. During a merge, the value of individual fields in the new data fully-replaces the prior value for that field, but existing fields without updates are preserved. Any ancillary information about the resource such as links or meta is fully replaced if new values are present. Here's an example: ::: code-group ```ts [Previous Value] { type: 'user', id: '1', meta: { revision: 'ae54g' }, links: { self: 'api/v1/users/1' }, attributes: { firstName: 'James', lastName: 'Thoburn', age: 37 } } ``` ```ts [New Value] { type: 'user', id: '1', meta: { lastAccessed: '2025-05-13' }, attributes: { firstName: 'Chris', lastName: 'Thoburn', nickname: '@runspired' } } ``` ```ts [Merged Result] { type: 'user', id: '1', meta: { // [!code --] revision: 'ae54g' // [!code --] }, // [!code --] meta: { // [!code ++] lastAccessed: '2025-05-13' // [!code ++] }, // [!code ++] links: self: 'api/v1/users/1' }, attributes: { firstName: 'James', // [!code --] firstName: 'Chris', // [!code ++] lastName: 'Thoburn', age: 37, nickname: '@runspired' // [!code ++] } } ``` ::: ## Fields Are Cached By ResourceCacheKey + FieldName with Replace Semantics Where this really matters is for deep objects. Generally, we support partial resource representations due to the upsert strategy, but this also means that out-of-the-box we only support partials only one level deep. E.g. if a field's value is an object, that object should be the full state of the field not a partial state of the field, we will not deep-merge during upsert. ## Relationships Are Cached By ResourceCacheKey + FieldName The Cache delegates relationship caching to the Graph Storage primitive provided by `@ember-data/graph`. The Graph is a powerful and highly optimized relational map that maintains the connections between ResourceCacheKeys. By default, The Graph uses **upsert semantics** for a relationship payload with **replace semantics** for each of `links` `meta` and `data` fields within it. This means that relationship payloads are expected to have complete representations for each of these if present (aside: this will somewhat change to support paginated collections in the near future). This means that a field being absent from a relationship payload is semantically different from that field being present but with a value of `null` or an empty array. Being not-present means we do not replace the existing value. The Graph also has the ability to receive op-codes that deliver more granular modifications to relationships to add or remove specific values. For instance, if your application were to use WebSockets to receive streaming changes to a relationship, those changes could be applied directly without needing to fully replace the existing value. We'll cover these operations in the guide for [RealTime Support](./9-realtime.md). ## What about Mutation? Call all of the above what the Cache refers to as "remote state". Mutations to fields (both relationships and non-relationships) are stored separately in the Cache from the underlying remote state as a diff. The "local" or "mutated" state then is the remote state + this diff. Updates to remote state will "commit" any changes in the diff that match the new remote state. A field is dirty if it has a value in the diff. In order for a mutation to be "committed", either a request needs to include the updated value in a response or the remote state needs to be manually updated to the new value via an operation. The ability to control the timing of when this occurs allows for both optimistic and pessimistic UX patterns. --- --- url: /api/@warp-drive/build-config/canary-features.md --- [Documentation](../../../index.md) / [@warp-drive/build-config](../index.md) / canary-features # Canary Features ***Warp*Drive** allows users to test upcoming features that are implemented but not yet activated in canary builds. Typically these features represent work that carries higher risk of breaking changes, or are not yet fully ready for production use. Such features have their implementations guarded by a "feature flag", and the flag is only activated once the core-data team is prepared to ship the work in a canary release, beginning the process of it landing in a stable release. ### Installing Canary ::: warning To test a feature guarded behind a flag, you MUST be using a canary build. ::: Canary builds are published to `npm` and can be installed using a precise tag (such as `@warp-drive/core@5.6.0-alpha.1`) or by installing the latest dist-tag published to the `canary` channel. Because ***Warp*Drive** packages operate on a strict lockstep policy with each other, you must install the matching canary version of all ***Warp*Drive** packages. Below is an example of installing the latest canary version of all the primary packages that are part of the ***Warp*Drive** project. Add/remove packages from this list to match your project. ::: code-group ```sh [pnpm] pnpm add -E @ember-data/store@canary \ @ember-data/json-api@canary \ @ember-data/debug@canary \ @ember-data/graph@canary \ @ember-data/request@canary \ @ember-data/request-utils@canary \ @warp-drive/schema-record@canary \ @warp-drive/build-config@canary \ @warp-drive/core-types@canary; ``` ```sh [npm] npm add -E @ember-data/store@canary \ @ember-data/json-api@canary \ @ember-data/debug@canary \ @ember-data/graph@canary \ @ember-data/request@canary \ @ember-data/request-utils@canary \ @warp-drive/schema-record@canary \ @warp-drive/build-config@canary \ @warp-drive/core-types@canary; ``` ```sh [yarn] yarn add -E @ember-data/store@canary \ @ember-data/json-api@canary \ @ember-data/debug@canary \ @ember-data/graph@canary \ @ember-data/request@canary \ @ember-data/request-utils@canary \ @warp-drive/schema-record@canary \ @warp-drive/build-config@canary \ @warp-drive/core-types@canary; ``` ```sh [bun] bun add --exact @ember-data/store@canary \ @ember-data/json-api@canary \ @ember-data/debug@canary \ @ember-data/graph@canary \ @ember-data/request@canary \ @ember-data/request-utils@canary \ @warp-drive/schema-record@canary \ @warp-drive/build-config@canary \ @warp-drive/core-types@canary; ``` ::: ### Activating a Feature Once you have installed canary, feature-flags can be activated at build-time ```ts setConfig(app, __dirname, { features: { FEATURE_A: false, // utilize existing behavior FEATURE_B: true // utilize the new behavior } }) ``` by setting an environment variable: ```sh # Activate a single flag export WARP_DRIVE_FEATURE_OVERRIDE=SOME_FLAG; # Activate multiple flags by separating with commas export WARP_DRIVE_FEATURE_OVERRIDE=SOME_FLAG,OTHER_FLAG; # Activate all flags export WARP_DRIVE_FEATURE_OVERRIDE=ENABLE_ALL_OPTIONAL; ``` ::: warning To test a feature guarded behind a flag, you MUST be running a development build. ::: ### Preparing a Project to use a Canary Feature For most projects and features, simple version detection should be enough. Using the provided version compatibility helpers from [embroider-macros](https://github.com/embroider-build/embroider/tree/main/packages/macros#readme) the following can be done: ```js if (macroCondition(dependencySatisfies('@ember-data/store', '5.0'))) { // do thing } ``` For more complex projects and migrations, configure [@warp-drive/build-config/babel-macros](./babel-macros) The current list of features used at build time for canary releases is defined below. ::: tip 💡 If empty there are no features currently gated by feature flags. ::: The valid values are: * `true` | The feature is **enabled** at all times, and cannot be disabled. * `false` | The feature is **disabled** at all times, and cannot be enabled. * `null` | The feature is **disabled by default**, but can be enabled via configuration. ## Variables * [JSON\_API\_CACHE\_VALIDATION\_ERRORS](variables/JSON_API_CACHE_VALIDATION_ERRORS.md) --- --- url: /guide/misc/2-typescript/3-configuration.md --- # Configuration There are currently two ways to gain access to EmberData's native types. Follow the configuration guide below for the [installation](./0-installation.md) option you chose. 1. [Use A Version That Has Types](#using-native-types) 2. [Use Official Types Packages](#using-types-packages) with releases `>= 4.12.*` > \[!IMPORTANT] > EmberData's Native Types require the use of Ember's > Native Types, the configuration below will also setup > Your application to consume Ember's Native Types. ### Using Native Types To consume `alpha` stage types, you must import the types in your project's `tsconfig.json`. For alpha stage types, we add `unstable-preview-types` to the path to help you remember the potential volatility. ```diff { "compilerOptions": { + "types": [ + "ember-source/types", + "ember-data/unstable-preview-types", + "@ember-data/store/unstable-preview-types", + "@ember-data/adapter/unstable-preview-types", + "@ember-data/graph/unstable-preview-types", + "@ember-data/json-api/unstable-preview-types", + "@ember-data/legacy-compat/unstable-preview-types", + "@ember-data/request/unstable-preview-types", + "@ember-data/request-utils/unstable-preview-types", + "@ember-data/model/unstable-preview-types", + "@ember-data/serializer/unstable-preview-types", + "@warp-drive/core-types/unstable-preview-types" + ] } } ``` ### Using Types Packages To consume `alpha` stage types, you must import the types in your project's `tsconfig.json`. For alpha stage types, we add `unstable-preview-types` to the path to help you remember the potential volatility. ```diff { "compilerOptions": { + "types": [ + "ember-source/types", + "ember-data-types/unstable-preview-types", + "@ember-data-types/store/unstable-preview-types", + "@ember-data-types/adapter/unstable-preview-types", + "@ember-data-types/graph/unstable-preview-types", + "@ember-data-types/json-api/unstable-preview-types", + "@ember-data-types/legacy-compat/unstable-preview-types", + "@ember-data-types/request/unstable-preview-types", + "@ember-data-types/request-utils/unstable-preview-types", + "@ember-data-types/model/unstable-preview-types", + "@ember-data-types/serializer/unstable-preview-types", + "@warp-drive-types/core-types/unstable-preview-types" + ] } } ``` --- --- url: /guide/misc/7-cookbook.md --- # Cookbook * [Incremental Adoption Guide](./incremental-adoption-guide.md) * [Naming Conventions: Should resource types be singular or plural? What to choose? Why is that?](./naming-conventions.md) --- --- url: /api/@warp-drive/build-config/deprecations.md --- [Documentation](../../../index.md) / [@warp-drive/build-config](../index.md) / deprecations # Deprecations This guide is intended to help you understand both how to address an active deprecation and how to eliminate the code that supports the deprecation once it has been resolved. Eliminating the associated code reduces the size of your application, often opts applications into more performant fast-paths, and ensures your application does not revert to using the deprecated behavior in the future. ## Active Deprecation IDs * [ember-data:deprecate-non-strict-types](variables/DEPRECATE_NON_STRICT_TYPES.md) * [ember-data:deprecate-non-strict-id](variables/DEPRECATE_NON_STRICT_ID.md) * [ember-data:deprecate-legacy-imports](variables/DEPRECATE_LEGACY_IMPORTS.md) * [ember-data:deprecate-non-unique-collection-payloads](variables/DEPRECATE_NON_UNIQUE_PAYLOADS.md) * [ember-data:deprecate-relationship-remote-update-clearing-local-state](variables/DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE.md) * [ember-data:deprecate-many-array-duplicates](variables/DEPRECATE_MANY_ARRAY_DUPLICATES.md) * [ember-data:deprecate-store-extends-ember-object](variables/DEPRECATE_STORE_EXTENDS_EMBER_OBJECT.md) * [ember-data:schema-service-updates](variables/ENABLE_LEGACY_SCHEMA_SERVICE.md) * [warp-drive.ember-inflector](variables/DEPRECATE_EMBER_INFLECTOR.md) * [warp-drive:deprecate-tracking-package](variables/DEPRECATE_TRACKING_PACKAGE.md) ## Removing Code for Deprecated Features ***Warp*Drive** enables applications to opt-in to fully eliminating the code for a deprecated feature once the application has taken the necessary steps to ensure that it no longer requires the use of the code which triggers the deprecation. Each deprecation ID is associated to a deprecation flag which is used to instrument the library for build-time removal of the deprecated code. Some flags have multiple deprecation IDs associated to them, in which case to remove the deprecated code all of the deprecation IDs must be resolved. There are two modes for opting into deprecated code removal: * by version * by deprecation flag If your app has resolved all deprecations present in a given version, you may specify that version as your "compatWith" version. This will remove the code for all deprecations that were introduced in or before that version. ::: code-group ```ts [ember-cli-build.js] setConfig(app, __dirname, { compatWith: '5.0', // [!code highlight] }); ``` ```ts [babel.config.mjs] setConfig(context, { compatWith: '5.0', // [!code highlight] }); ``` ::: For instance, if a deprecation was introduced in 5.3, and the app specifies 5.2 as its minimum version compatibility, any deprecations introduced in or before 5.2 will be removed, but any deprecations introduced in 5.3 will remain. You may also specify that specific deprecations are resolved. These approaches may be used together. ::: code-group ```ts [ember-cli-build.js] setConfig(app, __dirname, { deprecations: { DEPRECATE_NON_STRICT_TYPES: false, // [!code highlight] DEPRECATE_NON_STRICT_ID: false, // [!code highlight] } }); ``` ```ts [babel.config.mjs] setConfig(context, { deprecations: { DEPRECATE_NON_STRICT_TYPES: false, // [!code highlight] DEPRECATE_NON_STRICT_ID: false, // [!code highlight] } }); ``` ::: ::: info 💡 Report Bugs if You Find Them ***Warp*Drive** does not test against permutations of deprecations being stripped, our tests run against "all deprecated code included" and "all deprecated code removed". Unspecified behavior may sometimes occur when removing code for only specific deprecations. If this happens, we'd like to know 💜 ::: ## Variables * [DEPRECATE\_COMPUTED\_CHAINS](variables/DEPRECATE_COMPUTED_CHAINS.md) * [DEPRECATE\_EMBER\_INFLECTOR](variables/DEPRECATE_EMBER_INFLECTOR.md) * [DEPRECATE\_LEGACY\_IMPORTS](variables/DEPRECATE_LEGACY_IMPORTS.md) * [DEPRECATE\_MANY\_ARRAY\_DUPLICATES](variables/DEPRECATE_MANY_ARRAY_DUPLICATES.md) * [DEPRECATE\_NON\_STRICT\_ID](variables/DEPRECATE_NON_STRICT_ID.md) * [DEPRECATE\_NON\_STRICT\_TYPES](variables/DEPRECATE_NON_STRICT_TYPES.md) * [DEPRECATE\_NON\_UNIQUE\_PAYLOADS](variables/DEPRECATE_NON_UNIQUE_PAYLOADS.md) * [DEPRECATE\_RELATIONSHIP\_REMOTE\_UPDATE\_CLEARING\_LOCAL\_STATE](variables/DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE.md) * [DEPRECATE\_STORE\_EXTENDS\_EMBER\_OBJECT](variables/DEPRECATE_STORE_EXTENDS_EMBER_OBJECT.md) * [DEPRECATE\_TRACKING\_PACKAGE](variables/DEPRECATE_TRACKING_PACKAGE.md) * [DISABLE\_7X\_DEPRECATIONS](variables/DISABLE_7X_DEPRECATIONS.md) * [ENABLE\_LEGACY\_SCHEMA\_SERVICE](variables/ENABLE_LEGACY_SCHEMA_SERVICE.md) --- --- url: /guide/1-configuration/2-setup/2-ember.md --- # Ember.js ## Add TypeScript Types TypeScript will automatically discover the types these packages provide. If you're using `ember-source`, you should also configure and use Ember's native types. ## Configure Reactivity 1. Ensure `@warp-drive/ember` is [installed](../1-overview.md#installation) with the proper version 2. In the main entry point for your app add the following side-effect import ```ts [app/app.ts] import '@warp-drive/ember/install'; ``` 3. If you have tests, such as unit tests, which make use of WarpDrive directly and not via an app container you may also need to add the side-effect import to `tests/test-helper.{js,ts}` 4. If it is installed, remove the package `@ember-data/tracking`. 5. Change any usage of `untracked` ```ts import { untracked } from '@ember-data/tracking'; // [!code --] import { untrack as untracked } from '@glimmer/validator'; // [!code ++] ``` ::: tip 💡 @glimmer/validator is a virtual dep You do not need to add a dependency on `@glimmer/validator`, this is a virtual package provided by `ember-source`. ::: 6. Remove the deprecation for use of @ember-data/tracking by setting the deprecation to `false` in your build config: ```ts [ember-cli-build.js] 'use strict'; const EmberApp = require('ember-cli/lib/broccoli/ember-app'); const { compatBuild } = require('@embroider/compat'); module.exports = async function (defaults) { const { setConfig } = await import('@warp-drive/build-config'); const { buildOnce } = await import('@embroider/vite'); const app = new EmberApp(defaults, {}); setConfig(app, __dirname, { // this should be the most recent . version for // which all deprecations have been fully resolved // and should be updated when that changes compatWith: '4.12' deprecations: { // [!code focus:3] DEPRECATE_TRACKING_PACKAGE: false } }); return compatBuild(app, buildOnce); }; ``` ## Setup Legacy Support This guide presumes you've already gone through the [setup steps that apply to all applications](./1-universal.md) "Legacy" is a term that applies to a fairly broad set of patterns that ***Warp*Drive**/***Ember*Data** is migrating away from. The previous guide showed how to configure schemas and reactivity to work with the legacy `Model` approach. You may also wish to configure legacy support for `Adapters` and `Serializers`. Reasons to configure this legacy support include: * You have an existing application that has not migrated all requests away from this pattern * You are creating a new application and [LinksMode](../../misc/links-mode.md) is not sufficient 1. Ensure `@ember-data/legacy-compat` is [installed](../1-overview.md#installation) with the proper version 2. Add desired hooks to the store. The below example builds from the `Model` example in the prior guide. ```ts [app/services/store.ts] import Store, { CacheHandler } from '@ember-data/store'; import type { CacheCapabilitiesManager, ModelSchema, SchemaService } from '@ember-data/store/types'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import { CachePolicy } from '@ember-data/request-utils'; import JSONAPICache from '@ember-data/json-api'; import type { ResourceKey } from '@warp-drive/core-types'; import type { TypeFromInstance } from '@warp-drive/core-types/record'; import type Model from '@ember-data/model'; import { buildSchema, instantiateRecord, modelFor, teardownRecord } from '@ember-data/model'; import { // [!code focus:9] adapterFor, cleanup, LegacyNetworkHandler, normalize, pushPayload, serializeRecord, serializerFor, } from '@ember-data/legacy-compat'; export default class AppStore extends Store { requestManager = new RequestManager() .use([LegacyNetworkHandler, Fetch]) // [!code focus] .useCache(CacheHandler); lifetimes = new CachePolicy({ apiHardExpires: 15 * 60 * 1000, // 15 minutes apiSoftExpires: 1 * 30 * 1000, // 30 seconds constraints: { 'X-WarpDrive-Expires': true, 'Cache-Control': true, 'Expires': true, } }); createSchemaService(): SchemaService { return buildSchema(this); } createCache(capabilities: CacheCapabilitiesManager) { return new JSONAPICache(capabilities); } instantiateRecord(identifier: ResourceKey, createRecordArgs: Record) { return instantiateRecord.call(this, identifier, createRecordArgs); } teardownRecord(record: unknown): void { return teardownRecord.call(this, record as Model); } modelFor(type: TypeFromInstance): ModelSchema; modelFor(type: string): ModelSchema; modelFor(type: string): ModelSchema { return (modelFor.call(this, type) as ModelSchema) || super.modelFor(type); } adapterFor = adapterFor; // [!code focus:5] serializerFor = serializerFor; pushPayload = pushPayload; normalize = normalize; serializeRecord = serializeRecord; destroy() { // [!code focus:4] cleanup.call(this); super.destroy(); } } ``` --- --- url: /guide/1-configuration/4-old-package-setup/2-setup/2-ember.md --- # Ember.js ## Configure Reactivity 1. Ensure `@warp-drive/ember` is [installed](../1-overview.md#installation) with the proper version 2. In the main entry point for your app add the following side-effect import ```ts [app/app.ts] import '@warp-drive/ember/install'; ``` 3. If you have tests, such as unit tests, which make use of WarpDrive directly and not via an app container you may also need to add the side-effect import to `tests/test-helper.{js,ts}` 4. If it is installed, remove the package `@ember-data/tracking`. 5. Change any usage of `untracked` ```ts import { untracked } from '@ember-data/tracking'; // [!code --] import { untrack as untracked } from '@glimmer/validator'; // [!code ++] ``` ::: tip 💡 @glimmer/validator is a virtual dep You do not need to add a dependency on `@glimmer/validator`, this is a virtual package provided by `ember-source`. ::: 6. Remove the deprecation for use of @ember-data/tracking by setting the deprecation to `false` in your build config: ```ts [ember-cli-build.js] 'use strict'; const EmberApp = require('ember-cli/lib/broccoli/ember-app'); const { compatBuild } = require('@embroider/compat'); module.exports = async function (defaults) { const { setConfig } = await import('@warp-drive/build-config'); const { buildOnce } = await import('@embroider/vite'); const app = new EmberApp(defaults, {}); setConfig(app, __dirname, { // this should be the most recent . version for // which all deprecations have been fully resolved // and should be updated when that changes compatWith: '4.12' deprecations: { // [!code focus:3] DEPRECATE_TRACKING_PACKAGE: false } }); return compatBuild(app, buildOnce); }; ``` ## Setup Legacy Support This guide presumes you've already gone through the [setup steps that apply to all applications](./1-universal.md) "Legacy" is a term that applies to a fairly broad set of patterns that ***Warp*Drive**/***Ember*Data** is migrating away from. The previous guide showed how to configure schemas and reactivity to work with the legacy `Model` approach. You may also wish to configure legacy support for `Adapters` and `Serializers`. Reasons to configure this legacy support include: * You have an existing application that has not migrated all requests away from this pattern * You are creating a new application and [LinksMode](../../misc/links-mode.md) is not sufficient 1. Ensure `@ember-data/legacy-compat` is [installed](../1-overview.md#installation) with the proper version 2. Add desired hooks to the store. The below example builds from the `Model` example in the prior guide. ```ts [app/services/store.ts] import Store, { CacheHandler } from '@ember-data/store'; import type { CacheCapabilitiesManager, ModelSchema, SchemaService } from '@ember-data/store/types'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import { CachePolicy } from '@ember-data/request-utils'; import JSONAPICache from '@ember-data/json-api'; import type { ResourceKey } from '@warp-drive/core-types'; import type { TypeFromInstance } from '@warp-drive/core-types/record'; import type Model from '@ember-data/model'; import { buildSchema, instantiateRecord, modelFor, teardownRecord } from '@ember-data/model'; import { // [!code focus:9] adapterFor, cleanup, LegacyNetworkHandler, normalize, pushPayload, serializeRecord, serializerFor, } from '@ember-data/legacy-compat'; export default class AppStore extends Store { requestManager = new RequestManager() .use([LegacyNetworkHandler, Fetch]) // [!code focus] .useCache(CacheHandler); lifetimes = new CachePolicy({ apiHardExpires: 15 * 60 * 1000, // 15 minutes apiSoftExpires: 1 * 30 * 1000, // 30 seconds constraints: { 'X-WarpDrive-Expires': true, 'Cache-Control': true, 'Expires': true, } }); createSchemaService(): SchemaService { return buildSchema(this); } createCache(capabilities: CacheCapabilitiesManager) { return new JSONAPICache(capabilities); } instantiateRecord(identifier: ResourceKey, createRecordArgs: Record) { return instantiateRecord.call(this, identifier, createRecordArgs); } teardownRecord(record: unknown): void { return teardownRecord.call(this, record as Model); } modelFor(type: TypeFromInstance): ModelSchema; modelFor(type: string): ModelSchema; modelFor(type: string): ModelSchema { return (modelFor.call(this, type) as ModelSchema) || super.modelFor(type); } adapterFor = adapterFor; // [!code focus:5] serializerFor = serializerFor; pushPayload = pushPayload; normalize = normalize; serializeRecord = serializeRecord; destroy() { // [!code focus:4] cleanup.call(this); super.destroy(); } } ``` --- --- url: /guide/misc/2-typescript/4-why-brands.md --- # EmberData's Types Strategy If you previously used the EmberData types provided by DefinitelyTyped, one MASSIVE difference you will notice immediately is that EmberData does not use any registries for types. Instead, EmberData uses Symbol keys to brand objects with additional type information. For example: ```ts import Model, { attr } from '@ember-data/model'; import { Type } from '@warp-drive/core-types/symbols'; export default class User extends Model { @attr declare name: string; [Type] = 'user' as const; } ``` This means that when calling an API that takes in a resource type, we pass this branded class as a generic instead of relying on registries. For example: ```ts import type User from 'my-app/models/user'; // ... const user = await store.findRecord('user', '1'); ``` We chose this direction over registries or objects for a number of reasons we'll detail below. ### Why not registries? We found registries had 5 significant drawbacks. First, registries have a max number of entries before TypeScript begins resolving unions based on the registry as `any`. This limit is relatively low (in the hundreds) so many applications hit into this relatively quickly. Second, constructing registries is brittle. Conflicts often arise when attempting to source models from additional libraries, and often result in `never` types due to an empty registry. Third, we couldn't type EmberData itself using registries without adopting extreme complexity. This is because while DefinitelyTyped could assume one single global registry, EmberData cannot. This arises for a myriad of reasons: EmberData supports multiple stores, multiple sources of schema, and our own test suite defines Models for each test that would conflict with each other if we were forced to use a single global registry. Fourth, and possibly most importantly, registries assume that for a given resource-type (like `'user'`) that only a single type signature exists. While this has *mostly* been true historically in EmberData, it is no longer true and will become increasingly less true as we roll out additional features we have planned. Supporting different type signatures for Create/Edit/Delete as well as for partials and actions means if we stuck with registries, we'd need tons of them and things would get complicated quickly. Fifth, the registry approach prevents static analysis from easily determining where in the application a Model or Schema is in use, making it difficult for bundlers to optimize while code-splitting. ### Ok, so then why not objects? A common alternative to registries is to pass classes as tokens into an API. For instance, we could have redesigned EmberData to take a class instead of a string in the call to `findRecord` below. ```ts import type User from 'my-app/models/user'; // ... const user = await store.findRecord(User, '1'); ``` There are two significant drawbacks to this approach. The first is one of the same reasons as "why not registries": we expect that lots of type signatures will satisfy a single resource-type in the future. The second is related and more important: it forces you to use classes or other objects to represent data, which we don't want to do. In the near future, EmberData will switch the default story for presenting data from `Model` which is a class-per-resource approach to `SchemaRecord`, which is a single class capable of presenting the data for any associated schema. Schema's are defined in `json` and can be loaded into the app in any number of ways. That means when using SchemaRecord, there never would be a class to import and use as a token for such a call. ### Ok, Brands! Brands solve the various issues mentioned above, and a bit more! Over time, they should enable us to curate a great experience for working with partials, actions, contrained edit signatures, query syntaxes like GraphQL and more. --- --- url: /guide/2-requests/4-handlers.md --- # Handlers ## What Is A Handler ## When To Use A Handler ## Best Practices For Handlers ## Composing Handlers ## Typing Handlers --- --- url: /guide/misc/7-cookbook/incremental-adoption-guide.md --- # Incremental adoption guide for existing projects * ⮐ [Cookbook](./index.md) This guide is for existing projects that want to adopt the new APIs of the EmberData incrementally. ## Step 1: Upgrade to EmberData 4.12.x This version of EmberData is the first version that supports the new APIs. It is also a LTS version, so you can stay on it for a while. You can refer the [EmberData Compatibility table](https://github.com/emberjs/data/blob/main/README.md#compatibility) to see which version of EmberData is compatible with your Ember version. ## Step 2: Add `Store` service to your application You will need to create your own store service. Before, a store service was automatically injected by EmberData. Here is how you do it: ```js // eslint-disable-next-line ember/use-ember-data-rfc-395-imports import Store from 'ember-data/store'; export default class AppStore extends Store {} ``` Notice we still want to import the `Store` class from `ember-data/store` package. You might have a lint rule that says don't do it. You can disable it for this import. The reason we want to import it from `ember-data/store` is because we want to use EmberData models, serializers, adapters, etc. while alongside we want to start utilizing new APIs. > Note: You can also use `@ember-data/store` package, but you will need to configure a lot more to make things work to use old APIs. We recommend using `ember-data/store` package to avoid confusion. > Note: Because we are extending `ember-data/store`, it is still v1 addon, so things might not work for you if you are using typescript. We recommend to have `store.js` file for now. ## Step 3: Add `RequestManager` to your application Now let's configure a `RequestManager` for our store. The RequestManager is responsible for sending requests to the server. It fulfills requests using a chain-of-responsibility pipeline, which means you can add your own request handlers to it. First you need to install [`@ember-data/request`](https://github.com/emberjs/data/tree/main/packages/request) and [`@ember-data/legacy-compat`](https://github.com/emberjs/data/tree/main/packages/legacy-compat) packages. The first contains the `RequestManager` service and a few request handlers, while the second has `LegacyNetworkHandler` that will handle all old-style `this.store.*` calls. Here is how your own `RequestManager` service may look like: ```ts // eslint-disable-next-line ember/use-ember-data-rfc-395-imports import Store from 'ember-data/store'; import { CacheHandler } from '@ember-data/store'; import { LegacyNetworkHandler } from '@ember-data/legacy-compat'; import type { Handler, NextFn, RequestContext } from '@ember-data/request'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; /* eslint-disable no-console */ const TestHandler: Handler = { async request(context: RequestContext, next: NextFn) { console.log('TestHandler.request', context.request); const result = await next(Object.assign({}, context.request)); console.log('TestHandler.response after fetch', result.response); return result; }, }; export default class AppStore extends Store { requestManager = new RequestManager() .use([LegacyNetworkHandler, TestHandler, Fetch]) .useCache(CacheHandler); } ``` Let's go over the code above: 1. `LegacyNetworkHandler` is the handler that is responsible for sending requests to the server using the old APIs. It will interrupt handlers chain if it detects request using old APIs. It will process it as it used to be doing with Adapters/Fetch/Serializers workflow. 2. Next is `TestHandler`. It is a handler that is responsible for logging requests. It is a quick example of how you can add your own handlers to the request manager. We will take a look at more useful examples later. 3. Lastly `Fetch`. It is a handler that sends requests to the server using the `fetch` API. It expects responses to be JSON and when in use it should be the last handler you put in the chain. After finishing each request it will convert the response into json and pass it back to the handlers chain in reverse order as the request context's response. So `TestHandler` will receive `response` property first, and so on if we would have any. The CacheHandler is a special handler that enables requests to fulfill from and update the cache associated to this store. You can read more about request manager in the [request manager guide](../requests/index.md). ## Step 4: Install `@ember-data/json-api`, `@ember-data/request-utils` packages If you were using JSON:API adapter/serializer for your backend communication, you can use `@ember-data/json-api` package. It is a package that contains predefined builders for JSON:API requests. You can read more about it in the [`@ember-data/json-api`](https://github.com/emberjs/data/tree/main/packages/json-api). If you have different backend format - EmberData provides you with builders for `REST`([`@ember-data/rest`](https://github.com/emberjs/data/tree/main/packages/rest)) and `ActiveRecord`([`@ember-data/active-record`](https://github.com/emberjs/data/tree/main/packages/active-record)). `@ember-data/request-utils` package contains a lot of useful utilities for building requests. You can read more about it in its [Readme](https://github.com/emberjs/data/tree/main/packages/request-utils#readme). It has request builders for all type of requests. ## Step 5: Off you go! Start using new APIs Now you can start refactoring old code to use new APIs. You can start with the `findAll` method. It is the easiest one to refactor. Here is how you do it: ```diff app/components/projects/list.ts + import { query } from '@ember-data/json-api/request'; loadProjects: Task = task(async () => { - const projects = await this.store.findAll('project'); - this.projects = [...projects]; + const { content } = await this.store.request(query('project', {}, { host: config.api.host })); + this.projects = content.data; }); ``` You most likely would need to add Auth Handler to your request manager to add `accessToken` to your requests. Let's say you have your `accessToken` in the `session` service. Here is how you can add it to the request manager: ```js import { service } from '@ember/service'; export default class AuthHandler { @service session; request({ request }, next) { const headers = new Headers(request.headers); headers.append( 'Authorization', `Bearer ${this.session.accessToken}`, ); return next(Object.assign({}, request, { headers })); } } ``` You can read more about auth topic [here](../requests/examples/1-auth.md). Another good thing to do is to configure default host and namespace for your requests. There is an utility for that out of the box of `@ember-data/request-utils` called [`setBuildURLConfig`](https://github.com/emberjs/data/blob/main/packages/request-utils/src/index.ts#L67). You can do it anywhere in your app theoretically, but we recommend doing it in the `app/app.js` file. Here is how you can do it: ```diff app/app.js import Application from '@ember/application'; import Resolver from 'ember-resolver'; import loadInitializers from 'ember-load-initializers'; import config from 'base-ember-typescript-app/config/environment'; +import { setBuildURLConfig } from '@ember-data/request-utils'; + +setBuildURLConfig({ + host: 'https://api.example.com', + namespace: 'v1', +}); export default class App extends Application { modulePrefix = config.modulePrefix; podModulePrefix = config.podModulePrefix; Resolver = Resolver; } loadInitializers(App, config.modulePrefix); ``` *** * ⮐ [Cookbook](./index.md) --- --- url: /guide/misc/2-typescript/2-installation.md --- # Installation WarpDrive now provides a cli that will handle installation and configuration for you when installing the types-packages for native types to use with older releases (such as 4.12). ```cli npx warp-drive retrofit types@canary ``` The cli will * uninstall DT packages for ember-source and ember-data * add native types as sources to your ts-config for both ember-source and ember-data * install all required types packages for ember-data based on the dependencies in your package.json The cli may also be used to update to the latest canary versions of the types by simply running the command again. For additional documentation or to manuall install and configure, continue reading the below guide. *** > \[!CAUTION] > EmberData does not maintain the DefinitelyTyped types for > EmberData (e.g. the `@types/ember-data__*`). If you were > previously using these, you should uninstall them first. > \[!IMPORTANT] > EmberData's Native Types require the use of Ember's > Native Types. > > Type definitions need to be installed top-level, this means > you have to install every EmberData package `ember-data` > depends on. > \[!TIP] > When installing packages, use an NPM dist tag to get the latest > version for a given channel. E.g. `pnpm install ember-data@latest` > valid channels with types are `latest`, `canary`, `v4-latest` and `v4-canary` There are currently two ways to gain access to EmberData's native types. 1. [Use A Version That Has Types](#using-native-types) 2. [Use Official Types Packages](#using-types-packages) with releases `>= 4.12.*` *** ### Using Versions That Supply Types The following versions supply their own type definitions. These type definitions will still need to be configured for use in tsconfig. * Versions of 4.x >= 4.13.0-alpha.0 * Versions of 5.x >= 5.3.8 In order to use the types for these versions, the dependencies of `ember-data` (and their peer-dependencies) must also be added to `package.json`. Generally that means the following packages are needed, though you may need fewer (or more!) depending on if you have migrated away from Adapter/Serializer and replaced Model with SchemaRecord: | Name | Latest | Canary | V4 | | ---- | -------| ------ | -- | | [ember-data](https://github.com/emberjs/data/blob/main/packages/-ember-data/README.md) | ![NPM Stable Version](https://img.shields.io/npm/v/ember-data/latest?label=\&color=90EE90) | ![NPM Canary Version](https://img.shields.io/npm/v/ember-data/canary?label=\&color=90EE90) | ![NPM V4 Version](https://img.shields.io/npm/v/ember-data/v4-canary?label=\&color=90EE90) | | [@ember-data/adapter](https://github.com/emberjs/data/blob/main/packages/adapter/README.md) | ![NPM Stable Version](https://img.shields.io/npm/v/%40ember-data/adapter/latest?label=\&color=90EE90) | ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data/adapter/canary?label=\&color=90EE90) | ![NPM V4 Version](https://img.shields.io/npm/v/%40ember-data/adapter/v4-canary?label=\&color=90EE90) | | [@ember-data/graph](https://github.com/emberjs/data/blob/main/packages/graph/README.md) | ![NPM Stable Version](https://img.shields.io/npm/v/%40ember-data/graph/latest?label=\&color=90EE90) | ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data/graph/canary?label=\&color=90EE90) | ![NPM V4 Version](https://img.shields.io/npm/v/%40ember-data/graph/v4-canary?label=\&color=90EE90) | | [@ember-data/json-api](https://github.com/emberjs/data/blob/main/packages/json-api/README.md) | ![NPM Stable Version](https://img.shields.io/npm/v/%40ember-data/json-api/latest?label=\&color=90EE90) | ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data/json-api/canary?label=\&color=90EE90) | ![NPM V4 Version](https://img.shields.io/npm/v/%40ember-data/json-api/v4-canary?label=\&color=90EE90) | | [@ember-data/legacy-compat](https://github.com/emberjs/data/blob/main/packages/legacy-compat/README.md) | ![NPM Stable Version](https://img.shields.io/npm/v/%40ember-data/legacy-compat/latest?label=\&color=90EE90) | ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data/legacy-compat/canary?label=\&color=90EE90) | ![NPM V4 Version](https://img.shields.io/npm/v/%40ember-data/legacy-compat/v4-canary?label=\&color=90EE90) | | [@ember-data/model](https://github.com/emberjs/data/blob/main/packages/model/README.md) | ![NPM Stable Version](https://img.shields.io/npm/v/%40ember-data/model/latest?label=\&color=90EE90) | ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data/model/canary?label=\&color=90EE90) | ![NPM V4 Version](https://img.shields.io/npm/v/%40ember-data/model/v4-canary?label=\&color=90EE90) | | [@ember-data/request](https://github.com/emberjs/data/blob/main/packages/request/README.md) | ![NPM Stable Version](https://img.shields.io/npm/v/%40ember-data/request/latest?label=\&color=90EE90) | ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data/request/canary?label=\&color=90EE90) | ![NPM V4 Version](https://img.shields.io/npm/v/%40ember-data/request/v4-canary?label=\&color=90EE90) | | [@ember-data/request-utils](https://github.com/emberjs/data/blob/main/packages/request-utils/README.md) | ![NPM Stable Version](https://img.shields.io/npm/v/%40ember-data/request-utils/latest?label=\&color=90EE90) | ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data/request-utils/canary?label=\&color=90EE90) | ![NPM V4 Version](https://img.shields.io/npm/v/%40ember-data/request-utils/v4-canary?label=\&color=90EE90) | | [@ember-data/serializer](https://github.com/emberjs/data/blob/main/packages/serializer/README.md) | ![NPM Stable Version](https://img.shields.io/npm/v/%40ember-data/serializer/latest?label=\&color=90EE90) | ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data/serializer/canary?label=\&color=90EE90) | ![NPM V4 Version](https://img.shields.io/npm/v/%40ember-data/serializer/v4-canary?label=\&color=90EE90) | | [@ember-data/store](https://github.com/emberjs/data/blob/main/packages/store/README.md) | ![NPM Stable Version](https://img.shields.io/npm/v/%40ember-data/store/latest?label=\&color=90EE90) | ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data/store/canary?label=\&color=90EE90) | ![NPM V4 Version](https://img.shields.io/npm/v/%40ember-data/store/v4-canary?label=\&color=90EE90) | | [@warp-drive/core-types](https://github.com/emberjs/data/blob/main/packages/core-types/README.md) | ![NPM Latest Version](https://img.shields.io/npm/v/%40warp-drive/core-types/latest?label=\&color=90EE90) | ![NPM Canary Version](https://img.shields.io/npm/v/%40warp-drive/core-types/canary?label=\&color=90EE90) | ![NPM V4 Version](https://img.shields.io/npm/v/%40warp-drive/core-types/v4-canary?label=\&color=90EE90) | Here's a single install command for pnpm. Swap pnpm for yarn or npm as needed. ``` PACKAGES=("@types/ember" "@types/ember-data" "@types/ember-data__adapter" "@types/ember-data__model" "@types/ember-data__serializer" "@types/ember-data__store" "@types/ember__application" "@types/ember__array" "@types/ember__component" "@types/ember__controller" "@types/ember__debug" "@types/ember__destroyable" "@types/ember__engine" "@types/ember__error" "@types/ember__helper" "@types/ember__modifier" "@types/ember__object" "@types/ember__owner" "@types/ember__routing" "@types/ember__runloop" "@types/ember__service" "@types/ember__string" "@types/ember__template" "@types/ember__test" "@types/ember__utils" "ember-data" ); for pkg in "${PACKAGES[@]}"; do pnpm remove "$pkg"; done pnpm install ember-data@latest @ember-data/adapter@latest @ember-data/graph@latest @ember-data/json-api@latest @ember-data/legacy-compat@latest @ember-data/model@latest @ember-data/request@latest @ember-data/request-utils@latest @ember-data/serializer@latest @ember-data/store@latest @warp-drive/core-types@latest ``` Here's an example change to package.json which drops all use of types from `@types/` for both Ember and EmberData and adds the appropriate canary packages. ```diff - "@types/ember": "4.0.11", - "@types/ember-data": "4.4.16", - "@types/ember-data__adapter": "4.0.6", - "@types/ember-data__model": "4.0.5", - "@types/ember-data__serializer": "4.0.6", - "@types/ember-data__store": "4.0.7", - "@types/ember__application": "4.0.11", - "@types/ember__array": "4.0.10", - "@types/ember__component": "4.0.22", - "@types/ember__controller": "4.0.12", - "@types/ember__debug": "4.0.8", - "@types/ember__destroyable": "4.0.5", - "@types/ember__engine": "4.0.11", - "@types/ember__error": "4.0.6", - "@types/ember__helper": "4.0.7", - "@types/ember__modifier": "4.0.9", - "@types/ember__object": "4.0.12", - "@types/ember__owner": "4.0.9", - "@types/ember__routing": "4.0.22", - "@types/ember__runloop": "4.0.10", - "@types/ember__service": "4.0.9", - "@types/ember__string": "3.16.3", - "@types/ember__template": "4.0.7", - "@types/ember__test": "4.0.6", - "@types/ember__utils": "4.0.7", - "ember-data": "~5.3.3", + "ember-data": "5.4.1-alpha.64", + "@ember-data/store": "5.4.1-alpha.64", + "@ember-data/adapter": "5.4.1-alpha.64", + "@ember-data/graph": "5.4.1-alpha.64", + "@ember-data/json-api": "5.4.1-alpha.64", + "@ember-data/legacy-compat": "5.4.1-alpha.64", + "@ember-data/request": "5.4.1-alpha.64", + "@ember-data/request-utils": "5.4.1-alpha.64", + "@ember-data/serializer": "5.4.1-alpha.64", + "@ember-data/model": "5.4.1-alpha.64", + "@warp-drive/core-types": "0.0.0-alpha.50", ``` > \[!TIP] > If your package manager enables deduping, we recommend deduping types as much as possible. > \[!TIP] > It is best to ensure no other dependencies are still bringing `@types/*` packages as this will cause weird type bugs. *** ### Using Types Packages > \[!WARNING] > When consuming types in this way, you may sometimes > encounter a misalignment between the types and the actual API. These misalignments should be rare for 4.12.\* => 5.4.\*. Overall, even when these misalignments occur, we suspect there are fewer mistakes or issues with these types than in the DefinitelyTyped types. Every package in the project that ships types also publishes its types under a second package name. This enables older releases to consume these types instead of relying on the DefinitelyTyped project. These types-only packages have the same version number as the version they were published with, and their org or name is suffixed with `-types`. **Required Packages for Types** | Name | Types Package | Version | | ---- | ------- | ------- | | [ember-data](https://github.com/emberjs/data/blob/main/packages/-ember-data/README.md) | ember-data-types | ![NPM Canary Version](https://img.shields.io/npm/v/ember-data-types/canary?label=\&color=90EE90) | | [@ember-data/adapter](https://github.com/emberjs/data/blob/main/packages/adapter/README.md) | @ember-data-types/adapter | ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data-types/adapter/canary?label=\&color=90EE90) | | [@ember-data/graph](https://github.com/emberjs/data/blob/main/packages/graph/README.md) | @ember-data-types/graph | ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data-types/graph/canary?label=\&color=90EE90) | | [@ember-data/json-api](https://github.com/emberjs/data/blob/main/packages/json-api/README.md) | @ember-data-types/json-api | ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data-types/json-api/canary?label=\&color=90EE90) | | [@ember-data/legacy-compat](https://github.com/emberjs/data/blob/main/packages/legacy-compat/README.md) | @ember-data-types/legacy-compat | ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data-types/legacy-compat/canary?label=\&color=90EE90) | | [@ember-data/model](https://github.com/emberjs/data/blob/main/packages/model/README.md) | @ember-data-types/model | ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data-types/model/canary?label=\&color=90EE90) | | [@ember-data/request](https://github.com/emberjs/data/blob/main/packages/request/README.md) | @ember-data-types/request | ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data-types/request/canary?label=\&color=90EE90) | | [@ember-data/request-utils](https://github.com/emberjs/data/blob/main/packages/request-utils/README.md) | @ember-data-types/request-utils | ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data-types/request-utils/canary?label=\&color=90EE90) | | [@ember-data/serializer](https://github.com/emberjs/data/blob/main/packages/serializer/README.md) | @ember-data-types/serializer | ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data-types/serializer/canary?label=\&color=90EE90) | | [@ember-data/store](https://github.com/emberjs/data/blob/main/packages/store/README.md) | @ember-data-types/store | ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data-types/store/canary?label=\&color=90EE90) | | [@warp-drive/core-types](https://github.com/emberjs/data/blob/main/packages/core-types/README.md) | @warp-drive-types/core-types | ![NPM Canary Version](https://img.shields.io/npm/v/%40warp-drive-types/core-types/canary?label=\&color=90EE90) | Here's a single install command for pnpm. Swap pnpm for yarn or npm as needed. ``` pnpm install ember-data-types@canary @ember-data-types/adapter@canary @ember-data-types/graph@canary @ember-data-types/json-api@canary @ember-data-types/legacy-compat@canary @ember-data-types/model@canary @ember-data-types/request@canary @ember-data-types/request-utils@canary @ember-data-types/serializer@canary @ember-data-types/store@canary @warp-drive-types/core-types@canary ``` Here's an example change to package.json which drops all use of types from `@types/` for both Ember and EmberData and adds the appropriate canary packages. ```diff - "@types/ember": "4.0.11", - "@types/ember-data": "4.4.16", - "@types/ember-data__adapter": "4.0.6", - "@types/ember-data__model": "4.0.5", - "@types/ember-data__serializer": "4.0.6", - "@types/ember-data__store": "4.0.7", - "@types/ember__application": "4.0.11", - "@types/ember__array": "4.0.10", - "@types/ember__component": "4.0.22", - "@types/ember__controller": "4.0.12", - "@types/ember__debug": "4.0.8", - "@types/ember__destroyable": "4.0.5", - "@types/ember__engine": "4.0.11", - "@types/ember__error": "4.0.6", - "@types/ember__helper": "4.0.7", - "@types/ember__modifier": "4.0.9", - "@types/ember__object": "4.0.12", - "@types/ember__owner": "4.0.9", - "@types/ember__routing": "4.0.22", - "@types/ember__runloop": "4.0.10", - "@types/ember__service": "4.0.9", - "@types/ember__string": "3.16.3", - "@types/ember__template": "4.0.7", - "@types/ember__test": "4.0.6", - "@types/ember__utils": "4.0.7", + "@ember-data-types/adapter": "^5.4.1-alpha.64", + "@ember-data-types/model": "^5.4.1-alpha.64", + "@ember-data-types/serializer": "^5.4.1-alpha.64", + "@ember-data-types/store": "^5.4.1-alpha.64", + "@ember-data-types/graph": "^5.4.1-alpha.64", + "@ember-data-types/json-api": "^5.4.1-alpha.64", + "@ember-data-types/legacy-compat": "^5.4.1-alpha.64", + "@ember-data-types/request": "^5.4.1-alpha.64", + "@ember-data-types/request-utils": "^5.4.1-alpha.64", + "@warp-drive-types/core-types": "^0.0.0-alpha.50", "ember-data": "^4.12.7", + "ember-data-types": "^5.4.1-alpha.64", ``` --- --- url: /guide.md --- # Introduction ***Warp*Drive** is the data framework for building ambitious applications. By ambitious, we mean that ***Warp*Drive** is ideal for both small and large applications that strive to be best-in-class. ***Warp*Drive** seamlessly handles and simplifies the hardest parts of state management when building an app, helping you focus on creating the features and user experiences that drive value. ## Reactivity That Just Works {#reactivity} ```hbs Hello {{@user.name}}! ``` Our innovative approach to [fine grained reactivity](https://dev.to/ryansolid/a-hands-on-introduction-to-fine-grained-reactivity-3ndf) enables rapidly developing robust, performant web applications using any [Signals](https://github.com/tc39/proposal-signals#readme) compatible framework such as [Ember](https://guides.emberjs.com/release/in-depth-topics/autotracking-in-depth/), [Svelte](https://svelte.dev/docs/svelte/what-are-runes), [Angular](https://angular.dev/guide/signals), [Vue.js](https://vuejs.org/guide/extras/reactivity-in-depth.html), [SolidJS](https://www.solidjs.com/tutorial/introduction_signals), [Preact](https://preactjs.com/guide/v10/signals/) or [Lit](https://lit.dev/docs/data/signals/). No more boxing/unboxing, extra methods, funny syntaxes, or other boilerplate. Your data is reactive without any ceremony, and has the same shape you'd expect if it were "just an object" or "just an array". ## Requests Without The Fuss {#requests} ```ts const { content } = await store.request({ url: '/api/users' }); ``` By building around the same interface as the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API), ***Warp*Drive** makes powerful request management features like caching, deduping, errors and data normalization feel simple to use. ```ts{1} const { content } = await store.request({ url: '/api/users/1' }); ``` `request` takes a generic that can be used to set the [return type](./2-requests/3-typing-requests.md) of the content of the associated request. [Builders](./2-requests/2-builders.md) – functions that return RequestInfo – can supply the return type via a special [brand](https://egghead.io/blog/using-branded-types-in-typescript). ```ts import { withBrand } from '@warp-drive/core-types/request'; // [!code focus] import type { User } from './types/data'; export function getUser(id: string) { return withBrand({ // [!code focus] method: 'GET', url: `/api/users/${id}`, }); // [!code focus] } // ... const { content } = await store.request(getUser('1')); // [!code focus] ``` ## Build Quickly and Robustly with Reactive Control Flow {#reactive-control-flow} ```glimmer-ts import { Request } from '@warp-drive/ember'; import { findRecord } from '@ember-data/json-api/request'; import { Spinner } from './spinner'; export default ``` We pair the JS API with a headless component API providing [reactive control flow](./concepts/reactive-control-flow.md) to give apps the ability to declaratively derive states with safety. The component API is a thin framework-specific binding overtop of the framework-agnostic JS API. Don't see your framework yet? Let's add it! ## ORM Powers Without ORM Problems {#relational-data} ```ts const { content } = await store.request({ url: '/api/user/1?include=organizations' }); content.data.organizations.map(organization => { }); ``` **Web clients are like high-latency, remotely distributed, often-stale partial replicas of server state**. ***Warp*Drive** provides an [advanced relational cache](./3-caching.md) that simplifies these problems--solving them when it can and providing intelligent escape valves for when it can't. No matter what, you can quickly **get the data you need in the right state**. ## Schema Driven Reactivity {#schemas} ***Warp*Drive**'s reactive objects transform raw cached data into rich, reactive data. The resulting objects are immutable, always displaying the latest state in the cache while preventing accidental or unsafe mutation in your app. The output and [transformation](./concepts/transformation.md) is controlled by a simple JSON [ResourceSchema](./concepts/schemas.md). ```ts import { withDefaults } from '@warp-drive/schema-record'; store.schema.registerResource( withDefaults({ type: 'user', fields: [ { kind: 'field', name: 'firstName' }, { kind: 'field', name: 'lastName' }, { kind: 'field', name: 'birthday', type: 'luxon-date' }, { kind: 'derived', name: 'age', type: 'duration', options: { field: 'birthday', format: 'y' } }, { kind: 'derived', name: 'fullName', type: 'concat', options: { fields: ['firstName', 'lastName'], separator: ' ' } }, ] }) ) ``` ## Immutability Without The Performative Hassle {#immutability} Derivations, transformations, and immutability-by-default prevent the need for verbose allocation and compute heavy immutability tricks such as spread, slice, and map. ## Mutation Management {#mutations} [Mutation](./concepts/mutations.md) is handled within controlled contexts. The data to edit is "checked out" for editing, giving access to a mutable version. Local edits are seamlessly preserved if the user navigates away and returns without saving, and the changes are buffered from appearing elsewhere in your app until they are also committed to the server. ```ts import { Checkout } from '@warp-drive/schema-record'; // ... const editable = await user[Checkout](); editable.firstName = 'Chris'; ``` ## Broad Compatibility {#api-compatibility} ***Warp*Drive** is only semi-opinionated about your API. Almost every API is compatible just by authoring a [request handler](./2-requests/4-handlers.md) to ensure that the responses are normalized into the cache format. ```ts const NormalizeKeysHandler = { request(context, next) { return next(context.request).then((result) => { return convertUnderscoredKeysToCamelCase(result.content); }); } } ``` *** ## Completely Customizable {#customization} If using an app-specific cache format would work better for the demands of your API, the [cache](https://github.com/emberjs/data/blob/main/packages/core-types/src/cache.ts) the store should use is customizable: ```ts import Store from '@ember-data/store'; import { CustomCache } from './my-custom-cache'; class AppStore extends Store { createCache(capabilities) { return new CustomCache(capabilities); } } ``` ## Ready for RealTime {#realtime} Realtime subscriptions are supported through an extensive list of [operations](./concepts/operations.md) for surgically updating cache state, as well as by a comprehensive [notifications service]() which alerts us to when data has been added, updated or removed from the cache allowing subscriptions to dynamically adjust as needed. ```ts store.cache.patch({ op: 'add', record: User1Key, field: 'friends', value: User2Key }); ``` ## And a Universe of More {#explore} ***Warp*Drive** has been designed as a series of interfaces following the single-responsibility principle with well defined boundaries and configuration points. Because of this, nearly every aspect of the library is configurable, extensible, composable, replaceable or all of the above: meaning that if something doesn't meet your needs out-of-the-box, you can configure it to. The list of features doesn't end here. This guide will teach you the basics of everything you need to know, but if you find yourself needing more help or with a question you can't find the answer to, ask on [GitHub](https://github.com/emberjs/data/issues), in our [forum](https://discuss.emberjs.com/) or on [discord](https://discord.gg/zT3asNS). --- --- url: /guide/contributing/key-concepts.md --- # Key Concepts * [Identity](#-identity) *** ## 🔸 Identity ### Working with Identifiers and TypeScript Identifying information can be encountered in several different manners depending on which APIs are being worked with and whether the code is "internal" or "public facing". * The "ResourceIdentifier" type is used when the identifying information is end-user-supplied and not guaranteed to have "lid". Example: `findRecord({ type: 'user', id: '1' })` Most commonly this is the case when a record has not been encountered yet or when processing a payload received from the API. * The "RecordIdentifier" type is used when identifying information MUST have "lid" but may not be the "stable" identifier object instance. Example: `saveRecord({ type: 'user', id: null, lid: 'user:1' })` Most commonly this is the case when the user might manually construct an identifier. Often this is the result of having previously serialized record state and later attempting to restore it. * The "StableRecordIdentifier" type is used when identifying information MUST have "lid" AND MUST be the "stable" identifier object instance produced and managed by the `IdentifierCache` associated to a specific `Store` instance. Example: ```ts const identifier = recordIdentifierFor(record); unloadRecord(identifier); ``` Any identifier supplied by a WarpDrive API will always be the stable variant. APIs which are operating based on identity and which can reasonably presume that the data exists expect stable identifiers and should error if an unknown identifier is encountered to prevent potential system-correctness errors. --- --- url: /guide/misc/4-reactivity/legacy/overview.md --- # LegacyMode * ⮐ [ReactiveData](../index.md) *** SchemaRecord has two modes: `legacy` and `polaris`. **LegacyMode** can be used to emulate the behaviors and capabilities of The `Model` class from `@ember-data/model` that was the default way to define reactive objects with schemas for much of EmberData's history. The advantage of using SchemaRecord in LegacyMode is that it allows adopting many newer schema-driven behaviors before fully refactoring away from behaviors of Model that aren't supported by PolarisMode. Because there is little-to-no distinction between the base features of Model and SchemaRecord in LegacyMode we refer to both of these approaches as LegacyMode. This mode remains the default experience in V5. ## Feature Overview In LegacyMode: * records are mutable * local changes immediately reflect app wide * records have all the APIs of Model (references, state props, currentState, methods etc) * limited reactivity for attribute fields (same as Model) * the continued use of `@ember-data/model` and `@ember-data/legacy-compat` packages is required (though most imports from them can be removed) * `async: true` relationships are supported (but not recommended outside of [LinksMode](https://github.com/emberjs/data/blob/main/guides/relationships/features/links-mode.md)) ## Usage with SchemaRecord ### Installation Ensure the following packages are installed: * `@warp-drive/schema-record` * `@ember-data/model` * `@ember-data/legacy-compat` > \[!TIP] > Not sure what other packages you need? We're [working to simplify installation and setup](https://rfcs.emberjs.com/id/1075-warp-drive-package-unification/) but until then [this guide explains when various packages are necessary](). ### Configuration LegacyMode works by defining a series of derived fields on a resource's schema that replicate the behaviors of Model from `@ember-data/model` exactly. This is done by sharing the underlying implementation code of these features that Model also uses, and thus for as long as your application uses records in LegacyMode the `@ember-data/model` and `@ember-data/legacy-compat` packages must be installed. The derivations for these fields need to be registered with the schema service. ```ts import { registerDerivations } from '@ember-data/model/migration-support'; // ... somewhere with access to the store registerDerivations(store.schema); ``` A common way to do this is to register the derivations while initializing the schema service. ```ts import Store from '@ember-data/store'; import { SchemaService } from '@warp-drive/schema-record'; import { registerDerivations } from '@ember-data/model/migration-support'; export default class AppStore extends Store { // ... other config createSchemaService() { const schema = new SchemaService(); registerDerivations(schema); return schema; } } ``` ### Defining Legacy Schemas Below we show both how to define a resource schema in LegacyMode and how to obtain a type for a record that contains the types for these legacy fields and methods: ```ts import { withDefaults, WithLegacy } from '@ember-data/model/migration-support'; import { Type } from '@warp-drive/core-types/symbols'; import type { HasMany } from '@ember-data/model'; export const UserSchema = withDefaults({ type: 'user', fields: [ { name: 'firstName', kind: 'attribute' }, { name: 'lastName', kind: 'attribute' }, { name: 'age', kind: 'attribute' }, { name: 'friends', kind: 'hasMany', type: 'user', options: { inverse: 'friends', async: false } }, { name: 'bestFriend', kind: 'belongsTo', type: 'user', options: { inverse: null, async: false } }, ], }); export type User = WithLegacy<{ firstName: string; lastName: string; age: number; friends: HasMany; bestFriend: User | null; [Type]: 'user'; }> ``` ### Migration Several migration paths from Models to PolarisMode records exist. * [The Two Store Approach](../../migrating/two-store-migration.md) enables migrating while also upgrading versions and starting relatively fresh. This enables the same resource type (for instance `user`) to be used in legacymode in some areas of the app and in polaris mode in others by sourcing data from separately configured store instances. * **The Jump To SchemaRecord Approach** is best for apps that do not have many properties or methods on models beyond `attr` `belongsTo` and `hasMany` defined fields. In this approach, all models are converted to types and schemas in LegacyMode in one push. * **The Incremental Model Migration Approach** is best for apps that have added complex logic, computed fields, methods, and overrides to their Models. Models and SchemaRecords can work with each other, including via relationships. In this approach, all records for each `type` of resource will always be either a legacy `Model` instance or a `SchemaRecord` instance depending on if the resource has been migrated yet or not. The store's schema service is configured to understand both Models and raw schemas as sources of schema, and is configured to instantiate model classes. We have ideas on several additional incremental migration paths we might add in the near future, including adding decorators that support new field kinds that can be used with `Model`, and a new utility class that would let you proxy an underlying schema-record but wrap it with properties and methods you'd previously added to your Model definitions. Both of these approaches would similarly be intended to support temporary transition states while working towards all of your data being used in [PolarisMode](../polaris/overview.md). --- --- url: /guide/misc/links-mode.md --- # LinksMode *** **LinksMode** is a special feature that can be activated for any `belongsTo` or `hasMany` relationship. It allows that relationship to be fetched using the standard `request` experience instead of via the legacy `adapter` interface. LinksMode behaves *slightly* differently depending on whether you are using Model (including via [LegacyMode](./4-reactivity/legacy/overview.md)) or [PolarisMode](./4-reactivity/polaris/overview.md). We'll explain this nuance below. > \[!TIP] > The next-generation of reactive data which replaces Model is SchemaRecord. > SchemaRecord has two modes, Legacy - which emulates all of Model's > behaviors and APIs, and Polaris - a new experience which we intend > to make default in Version 6. ## How Does It Work? ### Related Link Becomes Required Relationships in WarpDrive are stored using the same top-level structure as resource documents, a structure adopted from the [JSON:API](https://jsonapi.org) specification. * **data**: the membership (state of) the relationship * **links** *(optional)*: an object containing various links for fetching and managing the relationship * **meta** *(optional)*: an object of arbitrary extra information about the relationship This is roughly described by the interface below: ```ts interface Relationship { meta?: Record; links?: Links; } interface ResourceRelationship extends Relationship { data: { type: string; id: string | null; lid: string } | null; } interface CollectionRelationship extends Relationship { data: { type: string; id: string | null; lid: string }[] } ``` When `linksMode` is activated for a relationship, it is required that a related link is present. ```ts interface LinksModeRelationship { meta?: Record; // no longer optional links: { related: string | { href: string }; // other links as desired } } ``` ### Related Links May Be Provided by Handlers This means that, in order to use links mode, a relationship payload given to the cache MUST contain this related link. If your API does not provide this link, a [request handler](https://api.emberjs.com/ember-data/release/classes/%3Cinterface%3E%20handler/) could be utilized to decorate an API response to add them provided that your handlers (or your API) are able to understand that link. Note that this approach can even work if your API requires you to send a POST request to fetch the relationship. [This blog post](https://runspired.com/2025/02/26/exploring-advanced-handlers.html) contains an overview of advanced request handling to achieve a similar aim for pagination. ### When a Relationship Is Fetched, the Related Link Is Used Fetching a relationship via any of `relationship.reload`, `reference.reload`, `reference.load` or `await record.relationship` will issue a request to your handler chain. That request will look like the following: ```ts interface FetchRelationshipRequest { op: 'findHasMany' | 'findBelongsTo'; store: Store; url: string; // the related link method: 'GET'; records: StableRecordIdentifier[]; // the current membership of the relationship data: { field: LegacyBelongsToField | LegacyHasManyField; links: Links; meta: Meta; options: unknown; // any options passed to `reload` or `load` record: StableRecordIdentifier; // the parent record }; // tells the store to not automatically convert the response into something reactive // since the reactive relationship class itself will do that [EnableHydration]: false; } ``` The three most important things in this request are: * the `op` code: this is how the cache will know to use the response to update the state of a relationship * `data.field`: this is how the cache will know which field it should update * `data.record`: this is how the cache will know which record to associate the response to. The normalized API response (what your handler must return either directly from your API or with some normalization on the client) that should be passed to the JSON:API cache should be a standard JSON:API document. The contents of `data` will be inserted into the resource cache and the list of records contained therein will be used to update the state of the relationship. The `meta` and `links` of the response will become the `meta` and `links` available for the relationship as well. Sideloads (included records) are valid to include in these responses. ## Activating LinksMode LinksMode is activated by adding `linksMode: true` to the relationship's options. Read on below for examples and nuances specific to Model vs SchemaRecord ### For a Relationship on a Model ```ts import Model, { belongsTo, hasMany } from '@ember-data/model'; export default class User extends Model { @belongsTo('address', { async: false, inverse: 'residents', linksMode: true }) homeAddress; } ``` This works for both `async` and `non-async` relationships and only changes the fetching behavior of the field it is defined on. For instance, in the example above, `homeAddress` is fetched in links mode while `
.residents` might still be using the legacy adapter experience. ### For a SchemaRecord in LegacyMode ```ts import type { ResourceSchema } from '@warp-drive/core-types/schema/fields'; const UserSchema = { type: 'user', // this is what puts the record instance into LegacyMode legacy: true, fields: [ { kind: 'belongsTo', name: 'homeAddress', options: { async: false, inverse: 'residents', linksMode: true } } ] } satisfies ResourceSchema; ``` The behavior of a relationship for a SchemaRecord in LegacyMode is always identical to that of a the same relationship defined on a Model. ### For a SchemaRecord in PolarisMode ```ts import type { ResourceSchema } from '@warp-drive/core-types/schema/fields'; const UserSchema = { type: 'user', fields: [ { kind: 'belongsTo', name: 'homeAddress', options: { async: false, inverse: 'residents', linksMode: true } } ] } satisfies ResourceSchema; ``` The only difference here is that we don't mark the resource schemas as `legacy`. This puts us in the standard/default mode (`polaris`); When using PolarisMode, `hasMany` and `belongsTo` relationships have additional constraints: * 1. They MUST use linksMode. Nothing except linksMode is supported. * 2. They MUST be `async: false`. Async relationships will never be supported in PolarisMode (read more on this below) * 3. There is no `autofetch` behavior (because relationships are `async: false`) You can load this link to fetch the relationship, though it is less easy to because the utility methods and links are not as readily exposed via references as they are with Model. For `belongsTo` this is a particularly large drawback. `belongsTo` has no mechanism by which to expose its links or a reload method. There are work arounds via the cache API / via derivations if needed, but cumbersome. For `hasMany`, this restriction is not too difficult as it can be loaded via its link by calling `reload`, e.g. `user.friends.reload()`. As with hasMany in LegacyMode, its links are also available via `user.friends.links`. This makes PolarisMode relationships intentionally limited. This limitation is not permanent – there is a replacement in the works for `belongsTo` and `hasMany` that aligns relationships with the intended Polaris experience. In the meantime, we've enabled synchronous linksMode relationships in order to allow folks to experiment with the polaris experience while still staying generally aligned with the direction relationships will evolve. If this limitation is too great we would recommend continuing to use `LegacyMode` until the full story for relationships in PolarisMode is shipped. *** #### What To Expect from PolarisMode Relationships in the Future We intend to replace `belongsTo` and `hasMany` fields with the (as yet not implemented) `resource` and `collection` fields. These fields will have no `autofetch` behavior, and no async proxy. There will still be `sync` and `async` variations of the field but this flag will take on a better meaning. An `async` relationship represents a POTENTIALLY asynchronous boundary in your API, meaning that even if sometimes the data for that relationship is included as a sideload, it may not always be and may require its own request. Async collection relationships can be paginated. A `sync` relationship represents an ALWAYS synchronous boundary, meaning that the full state of the relationship is ALWAYS included as a sideload and cannot ever be loaded as its own request. Sync relationships can never be paginated, and generally require use of a request which fetches their parent record to get updated state. In LegacyMode, sync relationships gave direct access to the record or array while async relationships gave access to a promisified proxy to the record/array. In PolarisMode using `resource` and `collection`, sync relationships will also give direct access while async relationships will instead provide access to a [reactive document](https://api.emberjs.com/ember-data/release/classes/Document). So for instance, if `user.homeAddress` were `async: false`, then its value would be an instance of an `Address` record. But if `user.homeAddress` were `asunc: true`, it would instead be a reactive class with `links`, `meta` and (only-if-loaded) `data`. * `user.homeAddress.links` would provide access to its associated links * `user.homeAddress.meta` would provide access to any associated meta * `user.homeAddress.data` would provide access to the address record instance IF (and only if) the relationship data had been included as part of the response for a parent record previously OR fetched explicitly via its link. --- --- url: /api/@warp-drive/build-config/debugging.md --- [Documentation](../../../index.md) / [@warp-drive/build-config](../index.md) / debugging # Log Instrumentation Many portions of the internals are helpfully instrumented with logging. This instrumentation is always removed from production builds. Log instrumentation is "regionalized" to specific concepts and concerns to enable you to enable/disable just the areas you are interested in. To activate a particular group of logs set the appropriate flag to `true` either in your build config or via the runtime helper. ## Runtime Activation ::: tip 💡 Just Works in browser Dev Tools! No import is needed, and the logging config is preserved when the page is refreshed ::: ```ts setWarpDriveLogging({ LOG_CACHE: true, LOG_REQUESTS: true, }) ``` A runtime helper is attached to `globalThis` to enable activation of the logs from anywhere in your application including from the devtools panel. The runtime helper overrides any build config settings for the given flag for the current browser tab. It stores the configuration you give it in `sessionStorage` so that it persists across page reloads of the current tab, but not across browser tabs or windows. If you need to deactivate the logging, you can call the helper again with the same flag set to `false` or just open a new tab/window. ## Buildtime Activation ```ts setConfig(__dirname, app, { debug: { LOG_CACHE: true, LOG_REQUESTS: false, LOG_NOTIFICATIONS: true, } }); ``` The build config settings are used to set the default values for the logging flags. Any logging flag that is not set in the build config will default to `false`. ## Variables * [DEBUG\_RELATIONSHIP\_NOTIFICATIONS](variables/DEBUG_RELATIONSHIP_NOTIFICATIONS.md) * [LOG\_CACHE](variables/LOG_CACHE.md) * [LOG\_CACHE\_POLICY](variables/LOG_CACHE_POLICY.md) * [LOG\_GRAPH](variables/LOG_GRAPH.md) * [LOG\_IDENTIFIERS](variables/LOG_IDENTIFIERS.md) * [LOG\_INSTANCE\_CACHE](variables/LOG_INSTANCE_CACHE.md) * [LOG\_METRIC\_COUNTS](variables/LOG_METRIC_COUNTS.md) * [~~LOG\_MUTATIONS~~](variables/LOG_MUTATIONS.md) * [LOG\_NOTIFICATIONS](variables/LOG_NOTIFICATIONS.md) * [~~LOG\_OPERATIONS~~](variables/LOG_OPERATIONS.md) * [~~LOG\_PAYLOADS~~](variables/LOG_PAYLOADS.md) * [LOG\_REQUEST\_STATUS](variables/LOG_REQUEST_STATUS.md) * [LOG\_REQUESTS](variables/LOG_REQUESTS.md) --- --- url: /guide/2-requests/1-overview.md --- # Making Requests Requests are how your application fetches or updates data stored remotely. ***What Does Remote Mean?*** Most commonly remote data refers to data that is stored on your server and accessed and updated via your backend API. But it doesn't have to be! Remote really boils down to [persistence](https://en.wikipedia.org/wiki/Persistence_\(computer_science\)) - the ability for data to be reliably stored and retrieved again at a later time. ## Request Options *Warp***Drive** uses the native [Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) interface for [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) and as the foundation upon which requests are made. This ensures that if the platform supports it, *Warp***Drive** exposes it: platform APIs are never hidden away. ::: code-group ```ts [Simple GET] const { content } = await store.request({ url: '/api/users' }); ``` ```ts [QUERY with POST] const { content } = await store.request({ url: '/api/users', method: 'POST', headers: new Headers({ 'Accept': 'application/json', 'Content-Type': 'application/json', }), body: JSON.stringify({ filter: { $in: { teams: ['1', '9', '42'] } }, search: { name: 'chris' } }) }); ``` ```ts [RPC Style Update] const { content } = await store.request({ url: '/actions/like', method: 'POST', headers: new Headers({ 'Accept': 'application/json', 'Content-Type': 'application/json', }), body: JSON.stringify({ actor: { type: 'user', id: '1' }, content: { type: 'comment', id: '42' } }) }); ``` ::: Of course, writing requests so manually quickly gets repetitive. *Warp***Drive** offers two abstractions for helping to write organized, reusable requests. * [Builders](./3-builders.md) - simple functions that produce a json request object * [Handlers](./4-handlers.md) - middleware that enable enhancing, modifying, or responding to requests Here's an example of how the requests above could be expressed as builders: ::: code-group ```ts [Simple GET] function getUsers() { return { url: '/api/users' } } const { content } = await store.request(getUsers()); ``` ```ts [QUERY with POST] function queryUsers(query) { return { url: '/api/users', method: 'POST', headers: new Headers({ 'Accept': 'application/json', 'Content-Type': 'application/json', }), body: JSON.stringify(query) } } const { content } = await store.request( queryUsers({ filter: { $in: { teams: ['1', '9', '42'] } }, search: { name: 'chris' } }) ) ``` ```ts [RPC Style Update] function createContentLike(actor, content) { return { url: '/actions/like', method: 'POST', headers: new Headers({ 'Accept': 'application/json', 'Content-Type': 'application/json', }), body: JSON.stringify({ actor, content }) } } const { content } = await store.request(createContentLike({ actor: { type: 'user', id: '1' }, content: { type: 'comment', id: '42' } })); ``` ::: Builders make it easy to quickly write shareable, reusable requests with [typed responses](./2-typing-requests.md) that mirror your application's capabilities and critical business logic. ## Requests Do Not Need To Use Fetch The native [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) interface provides a convenient, feature-rich way to describe the data you want to retrieve or update – but ultimately request handlers get to decide how that occurs. Request handlers can be used to connect to any data source via any mechanism. Besides fetch, this might be localStorage, [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest), [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket), [ServerEvents](https://developer.mozilla.org/en-US/docs/Web/API/EventSource), [MessageChannel](https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel), or something else entirely! ```ts import Store from '@ember-data/store'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import { // [!code focus:4] [!code ++] SessionSettingsHandler, // [!code ++] FileSystemHandler // [!code ++] } from './app/handlers'; // [!code ++] export default class AppStore extends Store { requestManager = new RequestManager() .use([ // [!code focus:5] SessionSettingsHandler, // [!code ++] FileSystemHandler, // [!code ++] Fetch ]); } ``` ## Requests Aren't Just For APIs Requests are a manner of expressing what data you want to use or an update to data you want to make. [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket), [ServerEvents](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) [WebSockets](), [ServerEvents](), The [File System](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system), browser managed storage mediums such as [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) and [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage), or [WebAssembly](https://webassembly.org/) builds of [sqlite3](https://sqlite.org/wasm/doc/trunk/index.md) are all common examples of persistent or remote data sources that aren't accessed via connecting to a server. ### The Chain of Responsibility When we configured the `RequestManager` above, you may have noticed that when we gave it an array of handlers with which to respond to requests. `RequestManager` follows the [chain-of-responsibility pattern](https://en.wikipedia.org/wiki/Chain-of-responsibility_pattern): each handler in our array may choose to respond to the request, modify it, or pass it along unchanged to the next handler in the array, in array order. --- --- url: /guide/misc/5-relational-data/configuration/5-many-to-many.md --- # Many To Many Relationships * Previous ← [Many To One Relationships](./4-one-to-many.md) * ⮐ [Relationships Guide](../index.md) *** Imagine our social network for trail runners 🏃🏃🏾‍♀️ allows runners to connect with friends, other trail runners! ```mermaid graph LR; A(TrailRunner) <== friends ==> B(TrailRunner) ``` > **Note** In our charts we use dotted lines for singular relationships and thick solid lines for collection relationships. Or, maybe more accurately since this is a [*reflexive*](../terminology.md#reflexive) relationship: ```mermaid graph LR; A(TrailRunner) <== friends ==> A ``` There are two ways we can model this relationship: bidirectionally with managed [inverses](../features/inverses.md), or unidirectionally without managed inverses. In the bidirectional configuration, changes to one side of the relationship change the other side as well. This includes both updates from remote state (a payload for the resource received from the API) as well as mutations to the local state (application code setting a new, unsaved value for the relationship). ```mermaid graph LR; A(TrailRunnerA.friends) <==> B(TrailRunnerB.friends) ``` In the unidirectional configuration, we effectively have two separate distinct [many-to-none](./3-many-to-none.md) relationships. ```mermaid graph LR; A(TrailRunnerA) == friends ==> B(TrailRunnerB) ``` ```mermaid graph LR; A(TrailRunnerB) == friends ==> B(TrailRunnerA) ``` With distinct relationships, we may edit one side without affecting the state of the inverse. This is especially useful when the collections might be very large, paginated, or not bidirectional in nature. For an example of a non-bidirectional relationship of this sort, it might be that Chris lists Thomas as a friend, but sadly Thomas does not feel the same. This Thomas being in Chris' friends does not mean that Chris should be in the list of Thomas' friends. Head over to [many-to-none](./3-many-to-none.md) if this is the setup that is best for you. Else, here's how we can define such a relationship via various mechanisms. * [Using @ember-data/model](#using-ember-datamodel) * [Using json schemas](#using-json-schemas) * [🚧 Using @warp-drive/schema-record](#using-warp-driveschema-record-🚧-coming-soon) * [Legacy Compat Mode](#legacycompat-mode) *** ## Using `@ember-data/model` > **Note** Models are currently the primary way that users of EmberData define "schema". > > Models are not the only way to define schema today, but they > are the most immediately available ergonomic way to do so. When using Models, EmberData parses schema from them at runtime, converting static information defined on the class into the json schema format needed by the rest of the system. This is handled by the implementation of the [schema service](https://api.emberjs.com/ember-data/release/classes/SchemaService) provided by the `@ember-data/model` package. The service converts the class definitions into the json definitions described in the next section. 🌲 *TrailRunner* ```ts import Model, { hasMany } from '@ember-data/model'; export default class TrailRunner extends Model { @hasMany('trail-runner', { inverse: 'friends', async: false }) friends; } ``` Note, the [many-to-none](./3-many-to-none.md) variation of this would be: ```ts import Model, { hasMany } from '@ember-data/model'; export default class TrailRunner extends Model { @hasMany('trail-runner', { inverse: null, async: false }) friends; } ``` *** ## Using JSON Schemas EmberData doesn't care where your schemas come from, how they are authored, or how you load them into the system so long as when it asks the [schema service](https://api.emberjs.com/ember-data/release/classes/SchemaService) for information it gets back field definitions in the right json shape. Here, we show how the above trail runner relationship is described by a field definition. **Current** 🌲 *TrailRunner* ```json { "kind": "hasMany", "name": "friends", "options": { "async": false, "inverse": "friends" }, "type": "trail-runner", } ``` Note, the [many-to-none](./3-many-to-none.md) variation of this would be: ```json { "kind": "hasMany", "name": "friends", "options": { "async": false, "inverse": null }, "type": "trail-runner", } ``` **🚧 Coming Soon** Because we deprecated implicit option values in 4.x, we are now able to change defaults. This means that the next iteration of Schema will be able to reliably use the The lack of an option like "async" or "inverse" as a false-y value. We also are shifting the value for "kind" from "belongsTo" to "resource" to make it more readil clear that relationships do not (by default) have directionality or ownership over their inverse. 🌲 *TrailRunner* ```json { "kind": "collection", "name": "friends", "options": { "inverse": "friends" }, "type": "trail-runner", } ``` Note, the [many-to-none](./3-many-to-none.md) variation of this would be: ```json { "kind": "collection", "name": "friends", "type": "trail-runner", } ``` *** ## Using `@warp-drive/schema-record` (🚧 Coming Soon) Working with schemas in a raw json format is far more flexible, lightweight and performant than working with bulky classes that need to be shipped across the wire,parsed, and instantiated. Even relatively small apps can quickly find themselves shipping large quantities of JS just to describe their data. No one wants to author schemas in raw JSON though (we hope 😬), and the ergonomics of typed data and editor autocomplete based on your schemas are vital to productivity and code quality. For this, we offer a way to express schemas as typescript using types, classes and decorators which are then compiled into json schemas and typescript interfaces for use by your project. 🌲 *TrailRunner* ```ts import { collection } from '@warp-drive/schema'; export class TrailRunner { @collection(TrailRunner, { inverse: "friends" }) friends; } ``` Note, the [many-to-none](./3-many-to-none.md) variation of this would be: ```ts import { collection } from '@warp-drive/schema'; export class TrailRunner { @collection(TrailRunner) friends; } ``` ### LegacyCompat Mode Support for migrating from `@ember-data/model` on a more granular basis is provided by decorators that preserve the semantics of the quirks of that class. This allows you to begin eliminating models and adopting other features of schemas sooner. 🌲 *TrailRunner* ```ts import { hasMany } from '@warp-drive/schema/legacy'; export class TrailRunner { @hasMany(TrailRunner, { inverse: "friends" }) friends; } ``` Note, the [many-to-none](./3-many-to-none.md) variation of this would be: ```ts import { hasMany } from '@warp-drive/schema/legacy'; export class TrailRunner { @hasMany(TrailRunner) friends; } --- - Previous ← [Many To One Relationships](./4-one-to-many.md) - ⮐ [Relationships Guide](../index.md) ``` --- --- url: /guide/misc/5-relational-data/configuration/3-many-to-none.md --- # Many To None Relationships * Previous ← [One To Many Relationships](./2-one-to-many.md) * Next → [Many To One Relationships](./4-many-to-one.md) * ⮐ [Relationships Guide](../index.md) *** Imagine our social network for trail runners 🏃🏃🏾‍♀️ allows runners to tag their activities. [#runday](https://www.instagram.com/explore/tags/runday/?hl=en) [#justdoit](https://www.instagram.com/explore/tags/justdoit/?hl=en) In this model, the ActivityData might have multiple tags, but given that millions if not billions if not trillions of activities might use a tag like [#neverstopexploring](https://www.instagram.com/explore/tags/neverstopexploring/?hl=en), it turns out we definitely don't want the tag to keep track of every activity that ever referenced it. ```mermaid graph LR; A(ActivityData) == tags ==> B(Hashtag) ``` > **Note** In our charts we use dotted lines for singular relationships and thick solid lines for collection relationships. Often `ManyToNone` is used for exactly this sort of case, where conceptually the relationship is [many-to-many](./5-many-to-many.md) in nature, but one side would be so large that modeling it as such is prohibitive. Here's how we can define such a relationship via various mechanisms. * [Using @ember-data/model](#using-ember-datamodel) * [Using json schemas](#using-json-schemas) * [🚧 Using @warp-drive/schema-record](#using-warp-driveschema-record-🚧-coming-soon) * [Legacy Compat Mode](#legacycompat-mode) *** ## Using `@ember-data/model` > **Note** Models are currently the primary way that users of EmberData define "schema". > > Models are not the only way to define schema today, but they > are the most immediately available ergonomic way to do so. When using Models, EmberData parses schema from them at runtime, converting static information defined on the class into the json schema format needed by the rest of the system. This is handled by the implementation of the [schema service](https://api.emberjs.com/ember-data/release/classes/SchemaService) provided by the `@ember-data/model` package. The service converts the class definitions into the json definitions described in the next section. 🏷️ *Hashtag* ```ts import Model, { attr } from '@ember-data/model'; export default class Hashtag extends Model { @attr name; } ``` 🏃🏾‍♀️ *ActivityData* ```ts import Model, { hasMany } from '@ember-data/model'; export default class ActivityData extends Model { @hasMany('hashtag', { async: false, inverse: null }) tags; } ``` *** ## Using JSON Schemas EmberData doesn't care where your schemas come from, how they are authored, or how you load them into the system so long as when it asks the [schema service](https://api.emberjs.com/ember-data/release/classes/SchemaService) for information it gets back field definitions in the right json shape. Here, we show how the above trail runner relationship is described by a field definition. **Current** 🏃🏾‍♀️ *ActivityData* ```json { "kind": "hasMany", "name": "tags", "options": { "async": false, "inverse": null }, "type": "hashtag", } ``` **🚧 Coming Soon** Because we deprecated implicit option values in 4.x, we are now able to change defaults. This means that the next iteration of Schema will be able to reliably use the The lack of an option like "async" or "inverse" as a false-y value. We also are shifting the value for "kind" from "belongsTo" to "resource" to make it more readil clear that relationships do not (by default) have directionality or ownership over their inverse. 🏃🏾‍♀️ *ActivityData* ```json { "kind": "collection", "name": "tags", "type": "hashtag", } ``` *** ## Using `@warp-drive/schema-record` (🚧 Coming Soon) Working with schemas in a raw json format is far more flexible, lightweight and performant than working with bulky classes that need to be shipped across the wire,parsed, and instantiated. Even relatively small apps can quickly find themselves shipping large quantities of JS just to describe their data. No one wants to author schemas in raw JSON though (we hope 😬), and the ergonomics of typed data and editor autocomplete based on your schemas are vital to productivity and code quality. For this, we offer a way to express schemas as typescript using types, classes and decorators which are then compiled into json schemas and typescript interfaces for use by your project. 🏷️ *Hashtag* ```ts import { field } from '@warp-drive/schema'; export class Hashtag extends Model { @field name: string; } ``` 🏃🏾‍♀️ *ActivityData* ```ts import { collection } from '@warp-drive/schema'; import { Hashtag } from './hashtag'; export class ActivityData extends Model { @collection(Hashtag) tags; } ``` ### LegacyCompat Mode Support for migrating from `@ember-data/model` on a more granular basis is provided by decorators that preserve the semantics of the quirks of that class. This allows you to begin eliminating models and adopting other features of schemas sooner. 🏷️ *Hashtag* ```ts import { attr } from '@warp-drive/schema/legacy'; export class Hashtag extends Model { @attr name: string; } ``` 🏃🏾‍♀️ *ActivityData* ```ts import { hasMany } from '@warp-drive/schema/legacy'; import { Hashtag } from './hashtag'; export class ActivityData extends Model { @hasMany(Hashtag) tags; } --- - Previous ← [One To Many Relationships](./2-one-to-many.md) - Next → [Many To One Relationships](./4-many-to-one.md) - ⮐ [Relationships Guide](../index.md) ``` --- --- url: /guide/misc/5-relational-data/configuration/4-many-to-one.md --- # Many To One Relationships * Previous ← [Many To None Relationships](./3-many-to-none.md) * Next → [Many To Many Relationships](./5-many-to-many.md) * ⮐ [Relationships Guide](../index.md) *** Many To One Relationships are the same as [One to Many relationships](./2-one-to-many.md). Just flip the order in how you conceptualize the relationship. --- --- url: /markdown-examples.md --- # Markdown Extension Examples This page demonstrates some of the built-in markdown extensions provided by VitePress. ## Syntax Highlighting VitePress provides Syntax Highlighting powered by [Shiki](https://github.com/shikijs/shiki), with additional features like line-highlighting: **Input** ````md ```js{4} export default { data () { return { msg: 'Highlighted!' } } } ``` ```` **Output** ```js{4} export default { data () { return { msg: 'Highlighted!' } } } ``` ## Custom Containers **Input** ```md ::: info This is an info box. ::: ::: tip This is a tip. ::: ::: warning This is a warning. ::: ::: danger This is a dangerous warning. ::: ::: details This is a details block. ::: ``` **Output** ::: info This is an info box. ::: ::: tip This is a tip. ::: ::: warning This is a warning. ::: ::: danger This is a dangerous warning. ::: ::: details This is a details block. ::: ## More Check out the documentation for the [full list of markdown extensions](https://vitepress.dev/guide/markdown). --- --- url: /guide/misc/6-migrating/two-store-migration.md --- # Migrating Between Versions Using The Two Store Approach Sometimes apps build over features, private APIs 🙈, or 3rd party libraries that later become deprecated and removed. Most deprecations are relatively easy to resolve, but sometimes APIs change that had been central to the way an app was built. A good example of a difficult to resolve change is the switch away from per-record caching internally, which should have been transparent to apps but left users of a popular 3rd party libary (ModelFragments) stuck on the 4.6 release. An example of such a shift in public APIs is the move away from Ember's ArrayLike interface for collections of records and away from promise-proxy wrappers surrounding async relationships. While lots of new patterns exist to replace those APIs, users that made heavy use of these features have a harder time migrating from version 4 to version 5, and thus stop being able to adopt new features in newer parts of their application until a substantial cleanup has occurred. This is where the two-store-approach can be useful. In the two-store approach, an application configures a second store service under a different service name (for instance `v2-store`) enabling some portions of the app to use modern features without immediately being required to upgrade all of the existing application code to match. Any application can configure more than one store using whatever version of EmberData/WarpDrive is installed, but to maximize this approach it is useful to be able to have the second store also use a more recent version of the library. This is why we publish **"mirror"** versions of every package. ## Mirror Versions Every package we publish has a **"mirror"** package equivalent. For packages that have an org name (e.g. `@ember-data/store` or `@warp-drive/ember`) we add `-mirror` to the org name. E.g. `@ember-data/store` has the mirror `@ember-data-mirror/store`. For packages without an org we add `-mirror` to the name e.g. `ember-data` has the mirror `ember-data-mirror`. Mirror packages are configured to work with other mirror packages as a wholly distinct package ecosystem. For instance, the mirror of `@ember-data/model` is `@ember-data-mirror/model` and instead of having a peer-dependency on `@ember-data/store` it has a peer-dependency on `@ember-data-mirror/store`. When importing code, you import from the mirror path e.g. `import Model, { attr } from '@ember-data-mirror/model';`. For convenience, some types, constants and symbols that are safe to interop between versions will do so if you have both mirror and non-mirror versions available. Mirror packages are available for versions `^4.13.0 | >=5.3.8`. ## TypeScript All mirror packages are also versions which ship their own types. To use those types, configure your `tsconfig.json` to be able to find them [as shown here](../typescript/1-configuration.md#using-native-types), adding the appropriate `-mirror` appendage to each package name (PS: you can have distinct types for both your older and your newer version!). ## Caveat Umptor Utilizing the two-store approach has a few tradeoffs: 1. If you want compatible type signatures for use by your components, you should upgrade your app to make use of native types first, likely using the [types-package approach](../typescript/0-installation.md#using-types-packages). In fact, it is likely that if you want typescript for the v2 store that you are *forced* to remove the `@types/ember*` packages from your project entirely and upgrade to using native types for ember-source and ember-data. This is because the native types for EmberData/WarpDrive depend on ember's native types. 2. You should not use both `ember-data` and `ember-data-mirror` or there will be an unresolveable race condition for which one is the `store` service. Instead one of the stores, usually the mirror, MUST import and fully configure the store. E.g. ```ts import Store from '@ember-data-mirror/store'; export default class V2Store extends Store { // ... config here } ``` Configuring the store generally means you need to do *at least* four things: * setup the hooks for presentation (instantiateRecord/teardownRecord) * setup the schema source * setup and configure the request-manager * *optionally* configure a cache policy * setup the cache We recommend the source-code for [ember-data/store](https://github.com/emberjs/data/blob/main/packages/-ember-data/src/store.ts) if you are curious what the configuration used "by default" historically looks like. If you wanted to exactly match the behaviors of your existing store (but perhaps without deprecated features) this is what would be required. However, if taking the two-store approach it is likely you want to use a different configuration. For instance: * perhaps you want to fully drop support for adapters and serializers * perhaps you want to drop support for Model and only use SchemaRecord (or use some of both to give yourself some flexibility) 3. Due to (#2) above, your ember-cli-build file MUST call `setConfig` to configure the build config for the library. ```ts const EmberApp = require('ember-cli/lib/broccoli/ember-app'); module.exports = async function (defaults) { const { setConfig } = await import('@warp-drive-mirror/build-config'); const app = new EmberApp(defaults, {}); setConfig(app, __dirname, { // settings here if desired }); return app.toTree(); } ``` 4. Record instances created by one store may not be used by another store, this primarily means they cannot be set as values of relationships. The records (and data) of each store is a wholly distinct context. You may find [ember-provide-consume-context](https://github.com/customerio/ember-provide-consume-context) useful for helping to manage this. Migrating "leaf first" or well-encapsulated parts of your app will generally lead to the pit-of-success. --- --- url: /guide/misc/7-cookbook/naming-conventions.md --- # Model Name: singular or plural? What to choose? Why is that? * ⮐ [Cookbook](./index.md) ## Resource Type (model name) conventions – or, why it was singular If you have been working with EmberData for a while, you might remember a convention about singular-dasherized resource types (or modelNames). It was a convention that model names should be singular. But why is that? Why not plural? And why dasherized? There is no longer any strict rule in EmberData governing what naming convention to use for resource types. Before, you may have been using singular names, because you had default Serializer configured in your app. The default serializers assume types should be singular and dasherized, and since they do the job of data normalization for you, they would singularize and dasherize the `types` received from your server. ### So what to choose? When using EmberData without Legacy setup, you are responsible for data normalization. You can choose whatever you want. You can use singular or plural names. It is up to you. Or up to your backend to be precise, as it would be beneficial for you to not do all that normalization on frontend. Just have it as a part of API contract of your app. But remember, you need to be consistent. If you choose singular names, stick with it. If you choose plural names, stick with it. **Be Consistent!** What does consistency look like? #### Let's say your convention is singular dasherized, e.g. `user-setting` * the API should respond with `user-setting` (or your handler/serializer should normalize the type to) * calls to store methods should use the same format: `store.findRecord('user-setting', '1')` * relationship definitions should also use this format: ```ts class User extends Model { @hasMany('user-setting', { async: false, inverse: null }) userSettings; } ``` * The model files should also use this format, e.g. the model would be located in `app/models/user-setting.{js,ts}` #### But what about plural and snake case? * the API should respond with `user_settings` * calls to store methods: `store.findRecord('user_settings', '1')` * relationship definitions: ```ts class User extends Model { @hasMany('user_settings', { async: false, inverse: null }) userSettings; } ``` * The model file would be located in `app/models/user_settings.{js,ts}` ### But what about JSON:API spec? It's pretty simple, JSON:API spec agnostic about the `type` field convention. Here is the quote from the spec: > Note: This spec is agnostic about inflection rules, so the value of type can be either plural or singular. However, the same value should be used consistently throughout an implementation. You can read more about it in the [JSON:API spec](https://jsonapi.org/format/#document-resource-object-identification). *** * ⮐ [Cookbook](./index.md) --- --- url: /guide/misc/5-relational-data/configuration/2-one-to-many.md --- # One To Many Relationships * Previous ← [One To One Relationships](./1-one-to-one.md) * Next → [Many To None Relationships](./3-many-to-none.md) * ⮐ [Relationships Guide](../index.md) *** Imagine our social network for trail runners 🏃🏃🏾‍♀️ allows runners to upload their runs as activities. In this model, the ActivityData only pertains on one TrailRunner ```mermaid graph LR; A(ActivityData) -. runner ..-> B(TrailRunner) ``` While the Trail Runner has many such activies. ```mermaid graph LR; A(TrailRunner) == activities ==> B(ActivityData) A(TrailRunner) == activities ==> C(ActivityData) A(TrailRunner) == activities ==> D(ActivityData) ``` > **Note** In our charts we use dotted lines for singular relationships and thick solid lines for collection relationships. Let's workout! There are two ways we can model this relationship: bidirectionally with managed [inverses](../features/inverses.md), or unidirectionally without managed inverses. In the bidirectional configuration, changes to one side of the relationship change the other side as well. This includes both updates from remote state (a payload for the resource received from the API) as well as mutations to the local state (application code setting a new, unsaved value for the relationship). ```mermaid graph LR; A(TrailRunner.activities) ==> B(ActivityData.runner) B -.-> A ``` In the unidirectional configuration, we effectively have two separate distinct relationships. A [many-to-none](./4-many-to-none.md) relationship from TrailRunner to ActivityData. ```mermaid graph LR; A(TrailRunner) == activities ==> B(ActivityData) ``` And a [one-to-none](./0-one-to-none.md) relationship from ActivityData to TrailRunner. ```mermaid graph LR; A(ActivityData) -. runner .-> B(TrailRunner) ``` With distinct relationships, we may edit one side without affecting the state of the inverse. This is particularly useful in two situations. First, it may be the case that the user has thousands or tens of thousands of activities. In this case, you likely don't want whichever individual activities you happen to load to create an incomplete list of the TrailRunner's activities. It's better to load and work with the activities list in isolation, ideally in a paginated manner. Second, it may be the case that runner is able to share the activity data with another runner that forgot to record. By not coupling the relationship, the ActivityData can still be owned by the first runner by included in the second runner's list of activities as well. Head over to [many-to-none](./4-many-to-none.md) and [one-to-none](./0-one-to-none.md) if this is the setup that is best for you. Else, here's how we can define such a relationship via various mechanisms. * [Using @ember-data/model](#using-ember-datamodel) * [Using json schemas](#using-json-schemas) * [🚧 Using @warp-drive/schema-record](#using-warp-driveschema-record-🚧-coming-soon) * [Legacy Compat Mode](#legacycompat-mode) *** ## Using `@ember-data/model` > **Note** Models are currently the primary way that users of EmberData define "schema". > > Models are not the only way to define schema today, but they > are the most immediately available ergonomic way to do so. When using Models, EmberData parses schema from them at runtime, converting static information defined on the class into the json schema format needed by the rest of the system. This is handled by the implementation of the [schema service](https://api.emberjs.com/ember-data/release/classes/SchemaService) provided by the `@ember-data/model` package. The service converts the class definitions into the json definitions described in the next section. 🏃🏾‍♀️ *ActivityData* ```ts import Model, { belongsTo } from '@ember-data/model'; export default class ActivityData extends Model { @belongsTo('trail-runner', { inverse: 'activities', async: false }) runner; } ``` 🌲 *TrailRunner* ```ts import Model, { hasMany } from '@ember-data/model'; export default class TrailRunner extends Model { @hasMany('activity-data', { inverse: 'runner', async: false }) activities; } ``` *** ## Using JSON Schemas EmberData doesn't care where your schemas come from, how they are authored, or how you load them into the system so long as when it asks the [schema service](https://api.emberjs.com/ember-data/release/classes/SchemaService) for information it gets back field definitions in the right json shape. Here, we show how the above trail runner relationship is described by a field definition. **Current** 🏃🏾‍♀️ *ActivityData* ```json { "kind": "belongsTo", "name": "runner", "options": { "async": false, "inverse": "activities" }, "type": "trail-runner", } ``` 🌲 *TrailRunner* ```json { "kind": "hasMany", "name": "activities", "options": { "async": false, "inverse": "runner" }, "type": "activity-data", } ``` **🚧 Coming Soon** Because we deprecated implicit option values in 4.x, we are now able to change defaults. This means that the next iteration of Schema will be able to reliably use the The lack of an option like "async" or "inverse" as a false-y value. We also are shifting the value for "kind" from "belongsTo" to "resource" to make it more readil clear that relationships do not (by default) have directionality or ownership over their inverse. 🏃🏾‍♀️ *ActivityData* ```json { "kind": "resource", "name": "runner", "options": { "inverse": "activities" }, "type": "trail-runner", } ``` 🌲 *TrailRunner* ```json { "kind": "collection", "name": "activities", "options": { "inverse": "runner" }, "type": "activity-data", } ``` *** ## Using `@warp-drive/schema-record` (🚧 Coming Soon) Working with schemas in a raw json format is far more flexible, lightweight and performant than working with bulky classes that need to be shipped across the wire,parsed, and instantiated. Even relatively small apps can quickly find themselves shipping large quantities of JS just to describe their data. No one wants to author schemas in raw JSON though (we hope 😬), and the ergonomics of typed data and editor autocomplete based on your schemas are vital to productivity and code quality. For this, we offer a way to express schemas as typescript using types, classes and decorators which are then compiled into json schemas and typescript interfaces for use by your project. 🏃🏾‍♀️ *ActivityData* ```ts import { resource } from '@warp-drive/schema'; import { TrailRunner } from './trail-runner'; export class ActivityData { @resource(TrailRunner, { inverse: "activities" }) runner; } ``` 🌲 *TrailRunner* ```ts import { collection } from '@warp-drive/schema'; import { ActivityData } from './activity-data'; export class TrailRunner { @collection(ActivityData, { inverse: "runner" }) activities; } ``` ### LegacyCompat Mode Support for migrating from `@ember-data/model` on a more granular basis is provided by decorators that preserve the semantics of the quirks of that class. This allows you to begin eliminating models and adopting other features of schemas sooner. 🏃🏾‍♀️ *ActivityData* ```ts import { belongsTo } from '@warp-drive/schema/legacy'; import { TrailRunner } from './trail-runner'; export class ActivityData { @belongsTo(TrailRunner, { inverse: "activities" }) runner; } ``` 🌲 *TrailRunner* ```ts import { hasMany } from '@warp-drive/schema/legacy'; import { ActivityData } from './activity-data'; export class TrailRunner { @hasMany(ActivityData, { inverse: "runner" }) activities; } ``` *** * Previous ← [One To One Relationships](./1-one-to-one.md) * Next → [Many To None Relationships](./3-many-to-none.md) * ⮐ [Relationships Guide](../index.md) --- --- url: /guide/misc/5-relational-data/configuration/0-one-to-none.md --- # One To None Relationships * Next → [One To One Relationships](./1-one-to-one.md) * ⮐ Go Back [Relationships Guide](../index.md) *** Pretend we're building a social network for trail runners 🏃🏃🏾‍♀️, and a TrailRunner (maybe [@runspired](https://github.com/runspired)) can have a favorite Trail to run on . While the TrailRunner has a favorite trail, the trail has no concept of a TrailRunner. ```mermaid graph LR; A(TrailRunner) -. favoriteTrail ..-> B(Trail) ``` > **Note** In our charts we use dotted lines for singular relationships and thick solid lines for collection relationships. Such a relationship is singular and unidirectional (it only points to one resource, and only points in one direction). When a relationship only points in one direction, we say it has no [inverse](../features/inverses.md). You'll note that effectively this setup implicitly indicates a "many" relationship. A Trail "implicitly" has many runners (for whom it is their favorite trail). Internally, EmberData will keep track of this implicit relationship such that if the trail were to be destroyed in a landslide its deletion would result in removing it as the favoriteTrail for each associated runner. Implicit relationships are not available as a public API, because they represent a highly incomplete view of the data, but the book-keeping produces benefits such as the ability to efficiently disassociate the record from relationships when it is destroyed. Here's how we can define such a relationship via various mechanisms. * [Using @ember-data/model](#using-ember-datamodel) * [Using json schemas](#using-json-schemas) * [🚧 Using @warp-drive/schema-record](#using-warp-driveschema-record-🚧-coming-soon) * [Legacy Compat Mode](#legacycompat-mode) *** ## Using `@ember-data/model` > **Note** Models are currently the primary way that users of EmberData define "schema". > > Models are not the only way to define schema today, but they > are the most immediately available ergonomic way to do so. When using Models, EmberData parses schema from them at runtime, converting static information defined on the class into the json schema format needed by the rest of the system. This is handled by the implementation of the [schema service](https://api.emberjs.com/ember-data/release/classes/SchemaService) provided by the `@ember-data/model` package. The service converts the class definitions into the json definitions described in the next section. ⛰️ *Trail* ```ts import Model, { attr } from '@ember-data/model'; export default class Trail extends Model { @attr name; } ``` 🌲 *TrailRunner* ```ts import Model, { belongsTo } from '@ember-data/model'; export default class TrailRunner extends Model { @belongsTo('trail', { inverse: null, async: false }) favoriteTrail; } ``` *** ## Using JSON Schemas EmberData doesn't care where your schemas come from, how they are authored, or how you load them into the system so long as when it asks the [schema service](https://api.emberjs.com/ember-data/release/classes/SchemaService) for information it gets back field definitions in the right json shape. Here, we show how the above trail runner relationship is described by a field definition. **Current** ```json { "kind": "belongsTo", "name": "favoriteTrail", "options": { "async": false, "inverse": null }, "type": "trail", } ``` **🚧 Coming Soon** Because we deprecated implicit option values in 4.x, we are now able to change defaults. This means that the next iteration of Schema will be able to reliably use the The lack of an option like "async" or "inverse" as a false-y value. We also are shifting the value for "kind" from "belongsTo" to "resource" to make it more readil clear that relationships do not (by default) have directionality or ownership over their inverse. ```json { "kind": "resource", "name": "favoriteTrail", "type": "trail", } ``` *** ## Using `@warp-drive/schema-record` (🚧 Coming Soon) Working with schemas in a raw json format is far more flexible, lightweight and performant than working with bulky classes that need to be shipped across the wire,parsed, and instantiated. Even relatively small apps can quickly find themselves shipping large quantities of JS just to describe their data. No one wants to author schemas in raw JSON though (we hope 😬), and the ergonomics of typed data and editor autocomplete based on your schemas are vital to productivity and code quality. For this, we offer a way to express schemas as typescript using types, classes and decorators which are then compiled into json schemas and typescript interfaces for use by your project. ⛰️ *Trail* ```ts import { field } from '@warp-drive/schema'; export class Trail { @field name: string; } ``` 🌲 *TrailRunner* ```ts import { resource } from '@warp-drive/schema'; import { Trail } from './trail'; export class TrailRunner { @resource(Trail) favoriteTrail; } ``` ### LegacyCompat Mode Support for migrating from `@ember-data/model` on a more granular basis is provided by decorators that preserve the semantics of the quirks of that class. This allows you to begin eliminating models and adopting other features of schemas sooner. ⛰️ *Trail* ```ts import { attr } from '@warp-drive/schema/legacy'; export default class Trail { @attr name: string; } ``` 🌲 *TrailRunner* ```ts import { belongsTo } from '@warp-drive/schema/legacy'; import Trail from './trail'; export default class TrailRunner { @belongsTo(Trail) favoriteTrail; } ``` *** * Next → [One To One Relationships](./1-one-to-one.md) * ⮐ [Relationships Guide](../index.md) --- --- url: /guide/misc/5-relational-data/configuration/1-one-to-one.md --- # One To One Relationships * Previous ← [One To None Relationships](./0-one-to-none.md) * Next → [One To Many Relationships](./2-one-to-many.md) * ⮐ [Relationships Guide](../index.md) *** Imagine our social network for trail runners 🏃🏃🏾‍♀️ allows runners to add their other social accounts. For instance, the TrailRunner [@runspired](https://github.com/runspired) might add their Instagram account. Here, the coupling goes both ways. In this model, the 📸 Instagram account can only belong to one Trail Runner, and the Trail Runner only has one Instagram Account. Let's take a selfie: ```mermaid graph LR; A(TrailRunner) -. instagram ..-> B(InstagramAccount) B -. runner .-> A ``` There are two ways we can model this relationship: bidirectionally with managed [inverses](../features/inverses.md), or unidirectionally without managed inverses. In the bidirectional configuration, changes to one side of the relationship change the other side as well. This includes both updates from remote state (a payload for the resource received from the API) as well as mutations to the local state (application code setting a new, unsaved value for the relationship). ```mermaid graph LR; A(TrailRunner.instagram) <-.-> B(InstagramAccount.runner) ``` > **Note** In our charts we use dotted lines for singular relationships and thick solid lines for collection relationships. In the unidirectional configuration, we effectively have two separate distinct [one-to-none](./0-one-to-none.md) relationships. ```mermaid graph LR; A(TrailRunner) -. instagram .-> B(InstagramAccount) ``` ```mermaid graph LR; A(InstagramAccount) -. runner .-> B(TrailRunner) ``` With distinct relationships, we may edit one side without affecting the state of the inverse. Note, modeling this setup as two "one-to-none" relationships has the advantage of creating an implicit "many" relationship in both directions. Imagine that many runners could have the same instagram account and that at the same time many instagram accounts could belong to the same runner. You might be tempted to think of this as a [many-to-many](./5-many-to-many.md) or two [many-to-none](./4-many-to-one.md), but sometimes this is effectively modeled as two `one-to-none` relationships. ```mermaid graph LR; A(TrailRunner1) -. account .-> D(InstagramAccount1) B(TrailRunner2) -. account .-> D(InstagramAccount1) C(TrailRunner3) -. account .-> D(InstagramAccount1) ``` ```mermaid graph LR; A(InstagramAccount1) -. runner .-> D(TrailRunner1) B(InstagramAccount2) -. runner .-> D(TrailRunner1) C(InstagramAccount3) -. runner .-> D(TrailRunner1) ``` Head over to [one-to-none](./0-one-to-none.md) if this is the setup that is best for you. Else, here's how we can define such a relationship via various mechanisms. * [Using @ember-data/model](#using-ember-datamodel) * [Using json schemas](#using-json-schemas) * [🚧 Using @warp-drive/schema-record](#using-warp-driveschema-record-🚧-coming-soon) * [Legacy Compat Mode](#legacycompat-mode) *** ## Using `@ember-data/model` > **Note** Models are currently the primary way that users of EmberData define "schema". > > Models are not the only way to define schema today, but they > are the most immediately available ergonomic way to do so. When using Models, EmberData parses schema from them at runtime, converting static information defined on the class into the json schema format needed by the rest of the system. This is handled by the implementation of the [schema service](https://api.emberjs.com/ember-data/release/classes/SchemaService) provided by the `@ember-data/model` package. The service converts the class definitions into the json definitions described in the next section. 📸 *InstagramAccount* ```ts import Model, { belongsTo } from '@ember-data/model'; export default class InstagramAccount extends Model { @belongsTo('trail-runner', { inverse: 'instagram', async: false }) runner; } ``` 🌲 *TrailRunner* ```ts import Model, { belongsTo } from '@ember-data/model'; export default class TrailRunner extends Model { @belongsTo('instagram-account', { inverse: 'runner', async: false }) instagram; } ``` *** ## Using JSON Schemas EmberData doesn't care where your schemas come from, how they are authored, or how you load them into the system so long as when it asks the [schema service](https://api.emberjs.com/ember-data/release/classes/SchemaService) for information it gets back field definitions in the right json shape. Here, we show how the above trail runner relationship is described by a field definition. **Current** 📸 *InstagramAccount* ```json { "kind": "belongsTo", "name": "runner", "options": { "async": false, "inverse": "instagram" }, "type": "trail-runner", } ``` 🌲 *TrailRunner* ```json { "kind": "belongsTo", "name": "instagram", "options": { "async": false, "inverse": "runner" }, "type": "instagram-account", } ``` **🚧 Coming Soon** Because we deprecated implicit option values in 4.x, we are now able to change defaults. This means that the next iteration of Schema will be able to reliably use the The lack of an option like "async" or "inverse" as a false-y value. We also are shifting the value for "kind" from "belongsTo" to "resource" to make it more readil clear that relationships do not (by default) have directionality or ownership over their inverse. 📸 *InstagramAccount* ```json { "kind": "resource", "name": "runner", "options": { "inverse": "instagram" }, "type": "trail-runner", } ``` 🌲 *TrailRunner* ```json { "kind": "resource", "name": "instagram", "options": { "inverse": "runner" }, "type": "instagram-account", } ``` *** ## Using `@warp-drive/schema-record` (🚧 Coming Soon) Working with schemas in a raw json format is far more flexible, lightweight and performant than working with bulky classes that need to be shipped across the wire,parsed, and instantiated. Even relatively small apps can quickly find themselves shipping large quantities of JS just to describe their data. No one wants to author schemas in raw JSON though (we hope 😬), and the ergonomics of typed data and editor autocomplete based on your schemas are vital to productivity and code quality. For this, we offer a way to express schemas as typescript using types, classes and decorators which are then compiled into json schemas and typescript interfaces for use by your project. 📸 *InstagramAccount* ```ts import { resource } from '@warp-drive/schema'; import { TrailRunner } from './trail-runner'; export class InstagramAccount { @resource(TrailRunner) runner; } ``` 🌲 *TrailRunner* ```ts import { resource } from '@warp-drive/schema'; import { InstagramAccount } from './instagram-account'; export class TrailRunner { @resource(InstagramAccount) instagram; } ``` ### LegacyCompat Mode Support for migrating from `@ember-data/model` on a more granular basis is provided by decorators that preserve the semantics of the quirks of that class. This allows you to begin eliminating models and adopting other features of schemas sooner. 📸 *InstagramAccount* ```ts import { belongsTo } from '@warp-drive/schema/legacy'; import { TrailRunner } from './trail-runner'; export class InstagramAccount { @belongsTo(TrailRunner, { inverse: "instagram" }) runner; } ``` 🌲 *TrailRunner* ```ts import { belongsTo } from '@warp-drive/schema/legacy'; import { InstagramAccount } from './instagram-account'; export class TrailRunner { @belongsTo(InstagramAccount, { inverse: "reunnter" }) instagram; } ``` *** * Previous ← [One To None Relationships](./0-one-to-none.md) * Next → [One To Many Relationships](./2-one-to-many.md) * ⮐ [Relationships Guide](../index.md) --- --- url: /guide/1-configuration/1-overview.md --- ::: tip EmberData/WarpDrive Packages Have Been [Simplified](https://rfcs.emberjs.com/id/1075-warp-drive-package-unification/) Looking for the [Old Package Setup Guide?](./4-old-package-setup/1-overview.md) ::: # Configuration ***Warp*Drive** is highly configurable. The library is designed as a series of small packages and primitives with clear interface-driven boundaries between each other and brought together by configuration. Below, we detail the installation for the most common configurations. ## Installation {#installation} ::: info 💡 TIP WarpDrive uses npm channel tags to simplify installation. Available channels include: * `@lts` | `@latest` | `@beta` | `@canary` Replace `@latest` in the commands below with a different channel as desired. ::: ::: code-group ```sh [pnpm] pnpm add -E @warp-drive/core@latest @warp-drive/json-api@latest ``` ```sh [npm] npm add -E @warp-drive/core@latest @warp-drive/json-api@latest ``` ```sh [yarn] yarn add -E @warp-drive/core@latest @warp-drive/json-api@latest ``` ```sh [bun] bun add --exact @warp-drive/core@latest @warp-drive/json-api@latest ``` ::: ### Lockstep Versioning ::: warning ⚠️ Caution WarpDrive packages follow lockstep: dependencies and peer-dependencies between WarpDrive packages are version-locked at the time of publish. We find this means its best to use exact versions instead of ranges as all WarpDrive packages should be upgraded together at once. All of the installation commands listed in this guide pin the version for this reason. ::: ## Other Packages Install `@warp-drive/utilities` for commonly needed request builder, handler and string utils. ::: code-group ```sh [pnpm] pnpm add -E @warp-drive/utilities@latest ``` ```sh [npm] npm add -E @warp-drive/utilities@latest ``` ```sh [yarn] yarn add -E @warp-drive/utilities@latest ``` ```sh [bun] bun add --exact @warp-drive/utilities@latest ``` ::: Install `@warp-drive/experiments` for bleeding edge unstable features we're prototyping like SharedWorker and PersistedCache. ::: code-group ```sh [pnpm] pnpm add -E @warp-drive/experiments@latest ``` ```sh [npm] npm add -E @warp-drive/experiments@latest ``` ```sh [yarn] yarn add -E @warp-drive/experiments@latest ``` ```sh [bun] bun add --exact @warp-drive/experiments@latest ``` ::: ## 🐹 For Ember.js Only Install `@warp-drive/ember` ::: code-group ```sh [pnpm] pnpm add -E @warp-drive/ember@latest ``` ```sh [npm] npm add -E @warp-drive/ember@latest ``` ```sh [yarn] yarn add -E @warp-drive/ember@latest ``` ```sh [bun] bun add --exact @warp-drive/ember@latest ``` ::: Optionally, for Ember Inspector support install `@ember-data/debug` ::: code-group ```sh [pnpm] pnpm add -E @ember-data/debug@latest ``` ```sh [npm] npm add -E @ember-data/debug@latest ``` ```sh [yarn] yarn add-E @ember-data/debug@latest ``` ```sh [bun] bun add --exact @ember-data/debug@latest ``` ::: Optionally, to use the legacy concepts such as Models, Adapters, or Serializers install the following packages: ::: tip Also Install These Packages To Use `LegacyMode` Schemas ::: ::: code-group ```sh [pnpm] pnpm add -E @warp-drive/utilities@latest @warp-drive/legacy@latest ``` ```sh [npm] npm add -E @warp-drive/utilities@latest @warp-drive/legacy@latest ``` ```sh [yarn] yarn add -E @warp-drive/utilities@latest @warp-drive/legacy@latest ``` ```sh [bun] bun add --exact @warp-drive/utilities@latest @warp-drive/legacy@latest ``` ::: --- --- url: /guide/1-configuration/4-old-package-setup/1-overview.md --- ::: tip Boilerplate Sucks 👎🏽 We're re-aligning our packages into a new streamlined installation and setup experience. Below you'll find the current *boilerplate heavy* setup. Curious? Read the [RFC](https://rfcs.emberjs.com/id/1075-warp-drive-package-unification/) ::: # Configuration ***Warp*Drive** is highly configurable. The library is designed as a series of small packages with clear interface-driven boundaries between each other and brought together by configuration. Below, we detail the installation for the most common configurations. ::: warning ⚠️ Caution WarpDrive packages follow lockstep: dependencies and peer-dependencies between WarpDrive packages are version-locked at the time of publish. We find this means its best to use exact versions instead of ranges as all WarpDrive packages should be upgraded together at once. All of the installation commands below pin the version for this reason. ::: ## Installation {#installation} Install the core packages: ::: info 💡 TIP WarpDrive uses npm channel tags to simplify installation. * `@lts` is the latest LTS release * `@latest` is the latest stable release * `@beta` is the latest beta release * `@canary` is the latest canary release Replace `@latest` in the commands below with the desired channel if needed. ::: ::: code-group ```sh [pnpm] pnpm add -E \ @warp-drive/core-types@latest \ @warp-drive/build-config@latest \ @warp-drive/schema-record@latest \ @ember-data/store@latest \ @ember-data/request@latest \ @ember-data/request-utils@latest \ @ember-data/graph@latest \ @ember-data/json-api@latest; ``` ```sh [npm] npm add -E \ @warp-drive/core-types@latest \ @warp-drive/build-config@latest \ @warp-drive/schema-record@latest \ @ember-data/store@latest \ @ember-data/request@latest \ @ember-data/request-utils@latest \ @ember-data/graph@latest \ @ember-data/json-api@latest; ``` ```sh [yarn] yarn add -E \ @warp-drive/core-types@latest \ @warp-drive/build-config@latest \ @warp-drive/schema-record@latest \ @ember-data/store@latest \ @ember-data/request@latest \ @ember-data/request-utils@latest \ @ember-data/graph@latest \ @ember-data/json-api@latest; ``` ```sh [bun] bun add --exact \ @warp-drive/core-types@latest \ @warp-drive/build-config@latest \ @warp-drive/schema-record@latest \ @ember-data/store@latest \ @ember-data/request@latest \ @ember-data/request-utils@latest \ @ember-data/graph@latest \ @ember-data/json-api@latest; ``` ::: Optionally, install the ESLint plugin `eslint-plugin-warp-drive` ::: code-group ```sh [pnpm] pnpm add -E eslint-plugin-warp-drive@latest ``` ```sh [npm] npm add -E eslint-plugin-warp-drive@latest ``` ```sh [yarn] yarn add -E eslint-plugin-warp-drive@latest ``` ```sh [bun] bun add --exact eslint-plugin-warp-drive@latest ``` ::: ### 🐹 For Ember.js Only Install `@warp-drive/ember` ::: code-group ```sh [pnpm] pnpm add -E @warp-drive/ember@latest ``` ```sh [npm] npm add -E @warp-drive/ember@latest ``` ```sh [yarn] yarn add -E @warp-drive/ember@latest ``` ```sh [bun] bun add --exact @warp-drive/ember@latest ``` ::: Optionally, for Ember Inspector support install `@ember-data/debug` ::: code-group ```sh [pnpm] pnpm add -E @ember-data/debug@latest ``` ```sh [npm] npm add -E @ember-data/debug@latest ``` ```sh [yarn] yarn add-E @ember-data/debug@latest ``` ```sh [bun] bun add --exact @ember-data/debug@latest ``` ::: Optionally, to use the legacy `@ember-data/model` experience (via Model or via SchemaRecord) install the following packages: ::: code-group ```sh [pnpm] pnpm add -E \ @ember-data/model@latest \ @ember-data/legacy-compat@latest; ``` ```sh [npm] npm add -E \ @ember-data/model@latest \ @ember-data/legacy-compat@latest; ``` ```sh [yarn] yarn add -E \ @ember-data/model@latest \ @ember-data/legacy-compat@latest; ``` ```sh [bun] bun add --exact \ @ember-data/model@latest \ @ember-data/legacy-compat@latest; ``` ::: Optionally, to use the legacy **Adapter/Serializer** experience, install the following packages: ::: code-group ```sh [pnpm] pnpm add -E \ @ember-data/adapter@latest \ @ember-data/serializer@latest \ @ember-data/legacy-compat@latest; ``` ```sh [npm] npm add -E \ @ember-data/adapter@latest \ @ember-data/serializer@latest \ @ember-data/legacy-compat@latest; ``` ```sh [yarn] yarn add -E \ @ember-data/adapter@latest \ @ember-data/serializer@latest \ @ember-data/legacy-compat@latest; ``` ```sh [bun] bun add --exact \ @ember-data/adapter@latest \ @ember-data/serializer@latest \ @ember-data/legacy-compat@latest; ``` ::: ### Other Packages Install `@ember-data/rest` for utilities for working with requests that follow common REST API patterns. ::: code-group ```sh [pnpm] pnpm add -E @ember-data/rest@latest ``` ```sh [npm] npm add -E @ember-data/rest@latest ``` ```sh [yarn] yarn add -E @ember-data/rest@latest ``` ```sh [bun] bun add --exact @ember-data/rest@latest ``` ::: Install `@ember-data/active-record` for utilities for working with requests that follow the rails ActiveRecord structure. ::: code-group ```sh [pnpm] pnpm add -E @ember-data/active-record@latest ``` ```sh [npm] npm add -E @ember-data/active-record@latest ``` ```sh [yarn] yarn add -E @ember-data/active-record@latest ``` ```sh [bun] bun add --exact @ember-data/active-record@latest ``` ::: Install `@warp-drive/experiments` for bleeding edge unstable features we're prototyping like SharedWorker and PersistedCache. ::: code-group ```sh [pnpm] pnpm add -E @warp-drive/experiments@latest ``` ```sh [npm] npm add -E @warp-drive/experiments@latest ``` ```sh [yarn] yarn add -E @warp-drive/experiments@latest ``` ```sh [bun] bun add --exact @warp-drive/experiments@latest ``` ::: ## What about the `ember-data` package? The `ember-data` package declares the core and ember.js packages including all legacy packages as its dependencies. It configures and automatically provides a store service configured for the maximal legacy experience, This auto-bundled experience sounds useful, however, this approach works poorly with vite, typescript and peer dependency grouping. If you're curious, the exact list of packages to replicate `ember-data` including all deprecations is: ::: code-group ```sh [pnpm] pnpm add -E \ @warp-drive/core-types@latest \ @warp-drive/build-config@latest \ @ember-data/store@latest \ @ember-data/request@latest \ @ember-data/request-utils@latest \ @ember-data/graph@latest \ @ember-data/json-api@latest \ @ember-data/adapter \ @ember-data/debug \ @ember-data/legacy-compat \ @ember-data/model \ @ember-data/serializer \ @embroider/macros \ @ember-data/tracking \ @warp-drive/ember; ``` ```sh [npm] npm add -E \ @warp-drive/core-types@latest \ @warp-drive/build-config@latest \ @ember-data/store@latest \ @ember-data/request@latest \ @ember-data/request-utils@latest \ @ember-data/graph@latest \ @ember-data/json-api@latest \ @ember-data/adapter \ @ember-data/debug \ @ember-data/legacy-compat \ @ember-data/model \ @ember-data/serializer \ @embroider/macros \ @ember-data/tracking \ @warp-drive/ember; ``` ```sh [yarn] yarn add -E \ @warp-drive/core-types@latest \ @warp-drive/build-config@latest \ @ember-data/store@latest \ @ember-data/request@latest \ @ember-data/request-utils@latest \ @ember-data/graph@latest \ @ember-data/json-api@latest \ @ember-data/adapter \ @ember-data/debug \ @ember-data/legacy-compat \ @ember-data/model \ @ember-data/serializer \ @embroider/macros \ @ember-data/tracking \ @warp-drive/ember; ``` ```sh [bun] bun add --exact \ @warp-drive/core-types@latest \ @warp-drive/build-config@latest \ @ember-data/store@latest \ @ember-data/request@latest \ @ember-data/request-utils@latest \ @ember-data/graph@latest \ @ember-data/json-api@latest \ @ember-data/adapter \ @ember-data/debug \ @ember-data/legacy-compat \ @ember-data/model \ @ember-data/serializer \ @embroider/macros \ @ember-data/tracking \ @warp-drive/ember; ``` ::: --- --- url: /guide/misc/4-reactivity/polaris/overview.md --- # PolarisMode * ⮐ [ReactiveData](../index.md) *** 🚧 This guide is under active construction, it will talk about the below points 🚧 In PolarisMode records are: * immutable (unless creating or checking out for editing) * local changes only show where you want them to on the editable version * none of the APIs of Model (references, state props, currentState, methods etc) * deep reactivity for fields * advanced derivations, aliasing and transformations * \[currently] limited support for relationships * no promise proxies for relationships --- --- url: /guide/misc/4-reactivity.md --- # Reactive Data In addition to request and cache management, WarpDrive provides a reactive access layer for data in the cache. Data in the cache is conceptualized as belonging to one of three forms * **Documents** - the response to a request * **Resources** - a unique cacheable entity within the response to a request * **Fields** - the data for an individual property on a resource Each form of data can be accessed and managed reactively through one of two modes * *(upcoming, default in v6)* [PolarisMode](./polaris/overview.md) * *(current, default in v5)* [LegacyMode](./legacy/overview.md) These modes are interopable. The reactive object (record) for a resource in PolarisMode can relate to a record in LegacyMode and vice-versa. This interopability is true whether the record in LegacyMode is a SchemaRecord or a Model. These reactive primitives use fine-grained signals-based reactivity. Currently, we use glimmer's (Ember's) implementation of `Signal` (`@tracked`) and `Computed` (`@cached`); however, we've architected our use to be pluggable and will soon enable configuration of any desired implementation, thus making WarpDrive compatible with any signals compatible library or framework. --- --- url: /guide/misc/5-relational-data/features/inverses.md --- # Relationship Inverses * ⮐ [Relationships Guide](../index.md) *** ## 🚧 Under Construction 🚧 🔜 Check back soon! --- --- url: /guide/misc/5-relational-data/features/polymorphism.md --- # Relationship Polymorphism * ⮐ [Relationships Guide](../index.md) *** Polymorphic relationships are relationships where the value can be more than one type of resource. For instance, say a human has pets, where a pet can be any furry friend: ```ts interface Human { pets: FurryFriend[]; } ``` That furry friend may be a cat, a zebra, a monkey or best a dog! Each furry friend comes with their own unique characteristics and personalities, but they have one thing in common: YOU. ```ts interface FurryFriend { owner: Human; } interface Cat extends FurryFriend { color: 'calico' | 'tabby' | 'black'; personality: 'indoor' | 'outdoor'; name: 'you only wish you knew'; } interface Zebra extends FurryFriend { speed: number; weight: number; name: string; } interface Monkey extends FurryFriend { throwPoop: boolean; stealsHats: boolean; sitsOnShoulder: boolean; bananaCache: number; } interface Dog extends FurryFriend { isGood: true; goesToHeaven: 'always'; } ``` It isn't very useful to think of your pets as just furry friends, because you want to use the unique characteristics of each. In reality, our relationship is a union: ```ts interface Human { pets: Array; } ``` We can look at each pet and immediately see their distinctly loveable traits. Of course, sometimes we're a bit too giving of our love and accept anything that shows up at our door, in our car, above our kitchen cabinent, or in our attic as our pet. We can model that too: ```ts interface Human { pets: unknown[]; } ``` *** ## How To Implement WarpDrive implements polymorphism structurally: as long as records on both sides of the relationship agree to the same structural contract, it works. In other words, you do not need inheritance, mixins, decorators or any other compositional primitive to achieve polymorphism (though sometimes these compositional patterns are useful in their own right). There are two polymorphic modes in WarpDrive: * **open** - any type of record can be a value (this is like our last example above of `pets: unknown[]`) * **closed** - only types of records that conform to a specific contract can be a value ### Open Polymorphism To make any relationship an open polymorphic relationship, its options should include both `inverse: null` and `polymorphic: true`. The related type can be any meaningful string, and does not need to be a resource type ever encountered. So for instance, to implement our pets relationship using open polymorphism using `Model`: ```ts import Model, { hasMany } from '@ember-data/model'; export default class Human extends Model { @hasMany('abstract-pet', { async: false, inverse: null, polymorphic: true }) declare pets: unknown[]; } ``` That same relationship using a schema: ```ts store.schema.registerResource({ type: 'human', identity: { kind: '@id', name: 'id' }, fields: [ { kind: 'hasMany', name: 'pets', type: 'abstract-pet', options: { async: false, inverse: null, polymorphic: true } } ] }) ``` ### Closed/Structural Polymorphism To make any relationship a closed polymorphic relationship based on structural contract, its options should include both an explicit non-null inverse and `polymorphic: true`. The related type can be any meaningful string, and does not need to be a resource type ever encountered. The inverse relationship on any record looking to adhere to the structural contract MUST be implemented exactly the same each time. So for instance, to implement our pets relationship using closed polymorphism using `Model`: ```ts import Model, { hasMany } from '@ember-data/model'; export default class Human extends Model { @hasMany('abstract-pet', { async: false, inverse: 'owner', polymorphic: true }) declare pets: Array } ``` And on *every* model that can be a pet, this same relationship as shown below for cat: ```ts import Model, { belongsTo } from '@ember-data/model'; export default class Cat extends Model { @belongsTo('human', { async: false, inverse: 'pets', as: 'abstract-pet' }) declare owner: Human; } ``` By "same" we mean the entirety of the below with zero changes: ```ts @belongsTo('human', { async: false, inverse: 'pets', as: 'abstract-pet' }) declare owner: Human; ``` E.g. if the relationship is `async: false` it must always be `async: false`, if it is named `owner` it must always be named `owner`, if it is a `belongsTo` is must always be a `belongsTo` and so-on. Enforcing this consistency is why often teams will choose to use a class decorator, inheritance or similar as a compositional pattern to provide the relationship definition. But it is not the mechanism of composition but the shape of the field that actually drives the behavior. For completeness: the above relationships using schemas: ```ts store.schema.registerResources([ { type: 'human', identity: { kind: '@id', name: 'id' }, fields: [ { kind: 'hasMany', name: 'pets', type: 'abstract-pet', options: { async: false, inverse: 'owner', polymorphic: true } } ] }, { type: 'cat', identity: { kind: '@id', name: 'id' }, fields: [ { kind: 'belongsTo', name: 'owner', type: 'human', options: { async: false, inverse: 'pets', as: 'abstract-pet' } } ] }, ]); ``` In the schema approach, the entirety of the below field definition is what must be the same on each resource schema: ```js { kind: 'belongsTo', name: 'owner', type: 'human', options: { async: false, inverse: 'pets', as: 'abstract-pet' } } ``` *** ## Fetching Polymorphic Data When working with a polymorphic relationship, the resource data for each related resource should use its concrete type, not the abstract type. For instance, `cat` in our example is a concrete type, while `abstract-pet` is the abstract type. The happy path for polymorphism is to always use the concrete type when possible in relationship and resource data. But if your app does not take the happy path, all is not lost! It is fine to request data via the abstract type provided the API response returns the concrete types. Most of the time WarpDrive will just do the right thing and understand what you did. Figuring out "the right thing" even extends to automatically detecting and upgrading the identity of a record from the abstract type to the concrete type. For instance: say you said you had one pet in your pets relationship, specified as `{ type: 'abstract-pet', id: '1' }`. For whatever reason, at the point you got this data the concrete type was unknown. Later, you make a request to get this data: ```ts await store.request(findRecord('abstract-pet', '1')); /* response json => { data: { type: 'dog', id: '1', attributes: { ... } } } */ ``` The response returns a resource with the type `'dog'` (still with id `'1'`). This is what is often referred to as single-table polymorphism (single shared id index, multiple potential types). By default, WarpDrive will *usually* recognize that `'abstract-pet'` was the abstract type and upgrade the type to `'dog'`, ensuring any relationships that relate to `{ type: 'abstract-pet', id: '1' }` point at the dog resource. When WarpDrive doesn't get it right, or when your API uses multi-table polymorphism and exposes relationships via the abstract and not the concrete type, there are several escape valves to be aware of. * 1. Your most powerful ally is requests and request handlers. You can post-process responses and convert the concrete types back to abstract types in relationships and assign the `lid` of the abstract type to the resource so that the cache understands to associated the abstract identity to the concrete identity. * 2. Alternatively (or in conjunction with option 1) you can implement the identity generation hook to teach the cache how to understand which identities are actually the same identity. This generally works best in scenarios where `id` is globally unique (such as a uuid). --- --- url: /guide/misc/5-relational-data.md --- # Relationships Guide ## Feature Overview * [Inverses](./features/inverses.md) * [LinksMode](./features/links-mode.md) * [Polymorphism](./features/polymorphism.md) ## Configuration * [1:none](./configuration/0-one-to-none.md) (One To None) * [1:1](./configuration/1-one-to-one.md) (One To One) * [1:Many](./configuration/2-one-to-many.md) (One To Many) * [Many:None](./configuration/3-many-to-none.md) (Many To None) * [Many:1](./configuration/4-many-to-one.md) (Many To One) * [Many:Many](./configuration/5-many-to-many.md) (Many To Many) # Misc * [Terminology](./terminology.md#relationships) --- --- url: /guide/misc/3-requests.md --- # Request Guide ## Examples * [Basic Usage](./examples/0-basic-usage.md) * [Dealing with Auth](./examples/1-auth.md) ## Overview * Intro: [What Is a Request?](./overview/0-intro.md) * [Request Management](./overview/1-request-management.md) ## Usage ```ts const userList = await manager.request({ url: `/api/v1/users.list` }); const users = userList.content; ``` *** ### Making Requests `RequestManager` has a single asynchronous method as it's API: `request` ```ts class RequestManager { request(req: RequestInfo): Future; } ``` `manager.request()` accepts an object containing the information necessary for the request to be handled successfully. These options extend the [options](https://developer.mozilla.org/en-US/docs/Web/API/fetch#parameters) provided to `fetch`, and can accept a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request). All properties accepted by Request options and fetch options are valid. ```ts interface RequestInfo extends FetchOptions { op?: string; store?: Store; url: string; /** * data that a handler should convert into * the query (GET) or body (POST) */ data?: Record; /** * options specifically intended for handlers * to utilize to process the request */ options?: Record; } ``` > **note** > providing a `signal` is unnecessary as an `AbortController` is automatically provided if none is present. *** #### Using the Response `manager.request` returns a `Future`, which allows access to limited information about the request while it is still pending and fulfills with the final state when the request completes and the response has been read. ```ts const usersFuture = manager.request({ url: `/api/v1/users.list` }); ``` A `Future` is cancellable via `abort`. ```ts usersFuture.abort(); ``` Handlers may *optionally* expose a `ReadableStream` to the `Future` for streaming data; however, when doing so the handler should not resolve until it has fully read the response stream itself. ```ts interface Future extends Promise> { abort(): void; async getStream(): ReadableStream | null; } ``` A Future resolves or rejects with a `StructuredDocument`. ```ts interface StructuredDocument { request: RequestInfo; response: ResponseInfo | null; content?: T; error?: Error; } ``` The `RequestInfo` specified by `document.request` is the same as originally provided to `manager.request`. If any handler fulfilled this request using different request info it is not represented here. This contract helps to ensure that `retry` and `caching` are possible since the original arguments are correctly preserved. This also allows handlers to "fork" the request or fulfill from multiple sources without the details of fulfillment muddying the original request. The `ResponseInfo` is a serializable fulfilled subset of a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) if set via `setResponse`. If no response was ever set this will be `null`. ```ts /** * All readonly properties available on a Response * */ interface ResponseInfo { headers?: Record; ok?: boolean; redirected?: boolean; status?: HTTPStatusCode; statusText?: string; type?: 'basic' | 'cors'; url?: string; } ``` *** ### Request Handlers Requests are fulfilled by handlers. A handler receives the request context as well as a `next` function with which to pass along a request to the next handler if it so chooses. A handler may be any object with a `request` method. This allows both stateful and non-stateful handlers to be utilized. If a handler calls `next`, it receives a `Future` which resolves to a `StructuredDocument` that it can then compose how it sees fit with its own response. ```ts type NextFn

= (req: RequestInfo) => Future

; interface Handler { async request(context: RequestContext, next: NextFn

): T; } ``` `RequestContext` contains a readonly version of the `RequestInfo` as well as a few methods for building up the `StructuredDocument` and `Future` that will be part of the response. ```ts interface RequestContext { readonly request: RequestInfo; setStream(stream: ReadableStream | Promise): void; setResponse(response: Response | ResponseInfo): void; } ``` A basic `fetch` handler with support for streaming content updates while the download is still underway might look like the following, where we use [`response.clone()`](https://developer.mozilla.org/en-US/docs/Web/API/Response/clone) to `tee` the `ReadableStream` into two streams. A more efficient handler might read from the response stream, building up the response content before passing along the chunk downstream. ```ts import type { Handler, RequestContext } from '@ember-data/request'; const FetchHandler: Handler = { async request(context: RequestContext) { const response = await fetch(context.request); context.setResponse(response); context.setStream(response.clone().body); return response.json(); } } ``` Request handlers are registered by configuring the manager via `use` ```ts manager.use([Handler1, Handler2]) ``` Handlers will be invoked in the order they are registered ("fifo", first-in first-out), and may only be registered up until the first request is made. It is recommended, but not required to register all handlers at one time in order to ensure explicitly visible handler ordering. *** #### Handling Errors Each handler in the chain can catch errors from upstream and choose to either handle the error, re-throw the error, or throw a new error. ```ts import type { Handler, NextFn, RequestContext } from '@ember-data/request'; const MAX_RETRIES = 5; const AuthHandler: Handler = { async request(context: RequestContext, next: NextFn) { let attempts = 0; while (attempts < MAX_RETRIES) { attempts++; try { const response = await next(context.request); return response; } catch (e) { if (isTimeoutError(e) && attempts < MAX_RETRIES) { // retry request continue; } // rethrow if it is not a timeout error throw e; } } } } ``` *** #### Handling Abort Aborting a request will reject the current handler in the chain. However, every handler can potentially catch this error. If your handler needs to separate AbortError from other Error types, it is recommended to check `context.request.signal.aborted` (or if a custom controller was supplied `controller.signal.aborted`). In this manner it is possible for a request to recover from an abort and still proceed; however, as a best practice this should be used for necessary cleanup only and the original AbortError re-thrown if the abort signal comes from the root controller. **AbortControllers are Always Present and Always Entangled** If the initial request does not supply an [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController), one will be generated. The [signal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) for this controller is automatically added to the request passed into the first handler. Each handler has the option to supply a new controller to the request when calling `next`. If a new controller is provided it will be automatically entangled with the root controller. If the root controller aborts, so will any entangled controllers. If an entangled controller aborts, the root controller will not abort. This allows for advanced request-flow scenarios to abort subsections of the request tree without aborting the entire request. *** #### Stream Currying `RequestManager.request` and `next` differ from `fetch` in one **crucial detail** in that the outer Promise resolves only once the response stream has been processed. For context, it helps to understand a few of the use-cases that RequestManager is intended to allow. * to manage and return streaming content (such as video files) * to fulfill a request from multiple sources or by splitting one request into multiple requests * for instance one API call for a user and another for the user's friends * or e.g. fulfilling part of the request from one source (one API, in-memory, localStorage, IndexedDB etc.) and the rest from another source (a different API, a WebWorker, etc.) * to coalesce multiple requests * to decorate a request with additional info * e.g. an Auth handler that ensures the correct tokens or headers or cookies are attached. `await fetch()` resolves at the moment headers are received. This allows for the body of the request to be processed as a stream by application code *while chunks are still being received by the browser*. When an app chooses to `await response.json()` what occurs is the browser reads the stream to completion and then returns the result. Additionally, this stream may only be read **once**. The `RequestManager` preserves this ability to subscribe to and utilize the stream by either the application or the handler – thereby delivering the full power and flexibility of native APIs – without restricting developers in ways that lead to complicated workarounds. Each handler may call `setStream` only once, but may do so *at any time* until the promise that the handler returns has resolved. The associated promise returned by calling `future.getStream` will resolve with the stream set by `setStream` if that method is called, or `null` if that method has not been called by the time that the handler's request method has resolved. Handlers that do not create a stream of their own, but which call `next`, should defensively pipe the stream forward. While this is not required (see automatic currying below) it is better to do so in most cases as otherwise the stream may not become available to downstream handlers or the application until the upstream handler has fully read it. ```ts context.setStream(future.getStream()); ``` Handlers that either call `next` multiple times or otherwise have reason to create multiple fetch requests should either choose to return no stream, meaningfully combine the streams, or select a single prioritized stream. Of course, any handler may choose to read and handle the stream, and return either no stream or a different stream in the process. *** #### Automatic Currying of Stream and Response In order to simplify the common case for handlers which decorate a request, if `next` is called only a single time and `setResponse` was never called by the handler, the response set by the next handler in the chain will be applied to that handler's outcome. For instance, this makes the following pattern possible `return (await next()).content;`. Similarly, if `next` is called only a single time and neither `setStream` nor `getStream` was called, we automatically curry the stream from the future returned by `next` onto the future returned by the handler. Finally, if the return value of a handler is a `Future`, we curry `content` and `errors` as well, thus enabling the simplest form `return next()`. In the case of the `Future` being returned, `Stream` proxying is automatic and immediate and does not wait for the `Future` to resolve. *** #### Using with `@ember-data/store` To have a request service unique to a Store: ```ts import Store, { CacheHandler } from '@ember-data/store'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; class extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); } ``` *** ### Using as a Service Some applications will desire to have direct service-level access to the `RequestManager`, which can be achieved using module-state patterns for singletons, or for [Ember](https://emberjs.com) applications by exporting the manager as a [service](https://guides.emberjs.com/release/services/). *services/request.ts* ```ts import { CacheHandler } from '@ember-data/store'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import Auth from 'app/services/ember-data-handler'; export default { create() { return new RequestManager() .use([Auth, Fetch]) .useCache(CacheHandler); } } ``` *** #### Using with `ember-data` If using the package [ember-data](https://github.com/emberjs/data/tree/main/packages/-ember-data), the following configuration will automatically be done in order to preserve the legacy [Adapter](https://github.com/emberjs/data/tree/main/packages/adapter) and [Serializer](https://github.com/emberjs/data/tree/main/packages/serializer) behavior. Additional handlers or a service injection like the above would need to be done by the consuming application in order to make broader use of `RequestManager`. ```ts import Store from 'ember-data/store'; import { CacheHandler } from '@ember-data/store'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import { LegacyNetworkHandler } from '@ember-data/legacy-compat'; export default class extends Store { requestManager = new RequestManager() .use([LegacyNetworkHandler, Fetch]) .useCache(CacheHandler); } ``` To provide a different configuration, import and extend `ember-data/store`. The default configuration will be ignored if the `requestManager` property is set, though the store will still register the CacheHandler. For usage of the store's `requestManager` via `store.request()` see the [Store](https://api.emberjs.com/ember-data/release/modules/@ember-data%2Fstore) documentation. --- --- url: /guide/misc/3-requests/overview/0-intro.md --- # Request Guide | Overview * Next → [Request Management](./1-request-management.md) * ⮐ [Requests Guide](../index.md) *** ## What Is a Request? A request is the process of fetching data from a source or asking a source to update data to a new state. Sources can be anything that has the ability for you to store and retrieve data, for example your API or IndexedDB. Though the actual source and transport do not matter, in a typical app requests are handled by [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). Irrespective of source or transport, it still helps to conceptualize requests as a formalization of fetch [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) / [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) lifecycles, and for convenience we adopt those APIs. *** * Next → [Request Management](./1-request-management.md) * ⮐ [Requests Guide](../index.md) --- --- url: /guide/misc/3-requests/overview/1-request-management.md --- # Request Guide | Overview * Previous ← Intro: [What Is a Request?](./0-intro.md) * Next → [?](./2-.md) * ⮐ [Requests Guide](../index.md) *** ## Request Management A `RequestManager` receives a request and manages fulfillment via configured handlers. It may be used standalone from the rest of *Ember***Data** and is not specific to any library or framework. ```mermaid flowchart LR A[fa:fa-terminal App] <--> B{{fa:fa-sitemap RequestManager}} B <--> C[(fa:fa-database Source)] ``` Each handler may choose to fulfill the request using some source of data or to pass the request along to other handlers. ```mermaid flowchart LR A[fa:fa-terminal App] <--> B{{fa:fa-sitemap RequestManager}} B <--> C(handler) C <--> E(handler) E <--> F(handler) C <--> D[(fa:fa-database Source)] E <--> G[(fa:fa-database Source)] F <--> H[(fa:fa-database Source)] ``` The same or a separate instance of a `RequestManager` may also be used to fulfill requests issued by [*Ember***Data**{Store}](https://github.com/emberjs/data/tree/main/packages/store) ```mermaid flowchart LR A[fa:fa-terminal App] <--> D{fa:fa-code-fork Store} B{{fa:fa-sitemap RequestManager}} <--> C[(fa:fa-database Source)] D <--> E[(fa:fa-archive Cache)] D <--> B click D href "https://github.com/emberjs/data/tree/main/packages/store" "Go to @ember-data/store" _blank click E href "https://github.com/emberjs/data/tree/main/packages/json-api" "Go to @ember-data/json-api" _blank style D color:#58a6ff; style E color:#58a6ff; ``` When the same instance is used by both this allows for simple coordination throughout the application. Requests issued by the `Store` will use the in-memory cache and return hydrated responses, requests issued directly to the `RequestManager` will skip the in-memory cache and return raw responses. ```mermaid flowchart LR A[fa:fa-terminal App] <--> B{{fa:fa-sitemap RequestManager}} B <--> C[(fa:fa-database Source)] A <--> D{fa:fa-code-fork Store} D <--> E[(fa:fa-archive Cache)] D <--> B click D href "https://github.com/emberjs/data/tree/main/packages/store" "Go to @ember-data/store" _blank click E href "https://github.com/emberjs/data/tree/main/packages/json-api" "Go to @ember-data/json-api" _blank style D color:#58a6ff; style E color:#58a6ff; ``` To see code examples of how to use `RequestManager` see the [basic usage guide](../examples/0-basic-usage.md). To see how to start migrating your application to use `RequestManager` see the [incremental adoption guide](../../cookbook/incremental-adoption-guide.md). *** * Previous ← Intro: [What Is a Request?](./0-intro.md) * Next → [?](./2-.md) * ⮐ [Requests Guide](../index.md) --- --- url: /guide/misc/3-requests/examples/0-basic-usage.md --- # Requests * Next → [Auth Handler](./1-auth.md) * ⮐ [Requests Guide](../index.md) ## Basic Usage Example > **Note** > This example uses [Ember](https://emberjs.com/) > for convenience. > > `@ember-data/request` works with raw javascript > or any framework of your choosing. Say you want to show a list of companies and their CEO. Your API returns a list of companies with the related employee records with a payload similar to the one shown below. ```jsonc { "data": [ { "id": "1", "type": "company", "attributes": { "name": "Auditboard" }, "relationships": { "ceo": { "data": { "id": "1", "type": "employee" } } } }, // ... and 49 more omitted for brevity ], "included": [ { "id": "1", "type": "employee", "attributes": { "name": "Scott Arnold", "profileImage": "https://www.auditboard.com/img/leadership/scott-arnold.jpg" } } // ... and 49 more omitted for brevity ], } ``` > **Note** > Curious about this format? This is [JSON:API](https://jsonapi.org/format/#document-top-level) using [Cursor Pagination Profiles](https://jsonapi.org/profiles/ethanresnick/cursor-pagination/) and [Sparse Fieldsets](https://jsonapi.org/format/#fetching-sparse-fieldsets) Because the list is large and our API supports pagination, we want to request just 50 items at a time. And because we only need the name of each company, and the name and profile image of its ceo, we want to ask for just that information to be returned. To get this payload we issue the following http request: ```HTTP GET /api/companies?fields[company]=name&fields[employee]=name,profileImage&included=ceo&page[size]=10 HTTP/2 Accept: application/vnd.api+json; profile="https://jsonapi.org/profiles/ethanresnick/cursor-pagination" ``` Lets see how we'd approach this request. ## Step 1: lets create a request manager for our app *app/fetch.ts* ```ts import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; const fetch = new RequestManager().use([Fetch]); export default fetch; ``` Our API is a simple HTTP api and all we really need is the ability to interact with it via `fetch`. While you might be tempted to just make a fetch request and move on, there's a few advantages to using a RequestManager here instead. First, the manager takes care of a few things for us right away even in this simple form. * [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) is wired in * The double await goes away (ie no `response = await fetch(); data = await response.json()` ) * Its simpler to mock for our tests and can even help us provide [advanced parallel and concurrent test mocking](https://github.com/emberjs/data/tree/main/packages/holodeck#readme) * It automatically adds test waiters we can use to guard against leaky tests! * It gives us a unified interface for managing requests everywhere in our app, not just for this request! It also sets up nicely in case we later decide to refactor our API, add authentication, adjust needed headers, or add caching. Second, the [Fetch Handler](https://api.emberjs.com/ember-data/release/classes/Fetch) is doing a lot of heavy lifting for us. * It normalizes network errors * It ensures API errors are thrown as errors * It parses JSON responses (content or errors) into JSON for us and attaches meaningful status information. Apps may have multiple request managers, but typically just one will do even for extremely large apps. ## Step 2: Configure some request defaults Since we're interacting with a JSON:API API we can use the request utilities provided by [@ember-data/json-api/request](https://github.com/emberjs/data/tree/main/packages/json-api#readme) to help us construct requests. Let's configure the utils to interface with this API and use the [Cursor Pagination Profile](https://jsonapi.org/profiles/ethanresnick/cursor-pagination/): ```ts import { setBuildURLConfig } from '@ember-data/json-api/request'; setBuildURLConfig({ host: 'https://cloud.example.com', namespace: 'api/v1', profiles: { pagination: "https://jsonapi.org/profiles/ethanresnick/cursor-pagination" } }); ``` ## Step 3: Lets make a request! As a reminder, this is the request we want to construct: ```HTTP GET /api/companies?fields[company]=name&fields[employee]=name,profileImage&included=ceo&page[size]=10 HTTP/2 Accept: application/vnd.api+json; profile="https://jsonapi.org/profiles/ethanresnick/cursor-pagination" ``` The `query` builder from `@ember-data/json-api/request` will do most of the heavy lifting for us, constructing the url, and making sure headers are attached appropriately. *app/page.ts* ```ts import { query } from '@ember-data/json-api/request'; import fetch from './fetch'; // ... execute a request const { content: collection } = await fetch.request(query('company', { include: ['ceo'], fields: { company: 'name', employee: ['name', 'profileImage'] }, page: { size: 10 } })); ``` Now, we can make use of the returned data. The has the following structure: ```ts type StructuredResponse = { request: Request; response: Response; content: T; } ``` The `json:api` document we got back is available as `content`, so the companies list is its `data`. ```ts const companies = collection.data; ``` At first this may feel a little verbose, but this structure ensures we have access to everything, so for instance if your API stores valuable information as `headers` then `result.response.headers` will give access to that information. ### Requesting via the Store Requests issued against the store differ in three ways from raw requests. 1. The store's `CacheHandler` will resolve from cache if the request is not stale 2. The store's `CacheHandler` will update the cache if a new request is made 3. The result's `content` will be a `StructuredDocument` whose data property is a list of records instead of raw data. ```ts import { query } from '@ember-data/json-api/request'; // ... execute a request const { content: collection } = await store.request(query('company', { include: ['ceo'], fields: { company: 'name', employee: ['name', 'profileImage'] }, page: { size: 10 } })); // accessing the data is the same, except now // this will be a list of records instead of raw objects const companies = collection.data; ``` ### Pagination The API response above likely contained a bit more information in the payload than just `data` and `included`. Since we were using the `cursor pagination` profile, the full response likely looked like this: ```jsonc { "data": [ // ... ], "included": [ //... ], "links": { "first": "/api/company?fields[company]=name&fields[employee]=name,profileImage&included=ceo&page[size]=10", "prev": null, "next": "/api/company?fields[company]=name&fields[employee]=name,profileImage&included=ceo&page[size]=10&page[after]=10", "last": "/api/company?fields[company]=name&fields[employee]=name,profileImage&included=ceo&page[size]=10&page[after]=5990", "self": "/api/company?fields[company]=name&fields[employee]=name,profileImage&included=ceo&page[size]=10" }, "meta": { "page": { "total": 6000, "maxSize": 100 } } } ``` This information is also available on the result, and can be used to quickly fetch additional pages in the same collection without needing to remember all the original parameters. ```ts const { content: nextPage } = await fetch.request({ url: result.content.links.next }); ``` If we were using the cache handler and store, this is built in! ```ts const nextPage = await collection.next(); ``` ## Step 4: Handling Errors Errors are handled via try/catch ```ts import { query } from '@ember-data/json-api/request'; import fetch from './fetch'; // ... execute a request try { const result = await fetch.request(query('company', { include: ['ceo'], fields: { company: 'name', employee: ['name', 'profileImage'] }, page: { size: 10 } })); } catch (error) { // errors will be normal Errors with some extra information error instanceof Error; // true // request and response are also available on errors const { request, response } = error; } ``` Errors thrown by the `Fetch` handler have some additional useful properties. * If the API returned an error with a JSON payload, it is parsed and available as `content`. * If the API returned an array of errors or an object with an `errors` property as an array, an `AggregateError` is thrown with those errors. * `status`, `statusText`, `name`, `code` are all available and normalized * `isRequestError` will be set to `true` *** * Next → [Auth Handler](./1-auth.md) * ⮐ [Requests Guide](../index.md) --- --- url: /api-examples.md --- # Runtime API Examples This page demonstrates usage of some of the runtime APIs provided by VitePress. The main `useData()` API can be used to access site, theme, and page data for the current page. It works in both `.md` and `.vue` files: ```md ## Results ### Theme Data

{{ theme }}
### Page Data
{{ page }}
### Page Frontmatter
{{ frontmatter }}
``` ## Results ### Theme Data ### Page Data ### Page Frontmatter ## More Check out the documentation for the [full list of runtime APIs](https://vitepress.dev/reference/runtime-api#usedata). --- --- url: /guide/contributing/setting-up-the-project.md --- # Setting Up The Project ## Setup Volta If you are not already using [⚡️ volta](https://volta.sh/) or have a version older than `1.1.1` you will want to begin by [installing it](https://docs.volta.sh/guide/getting-started). For package management, the project uses [PNPM](https://pnpm.io/). Volta will manage `node` and `pnpm` versions for you, but for [PNPM there is one more step](https://docs.volta.sh/advanced/pnpm): To your shell profile you will want to add the following. ```sh export VOLTA_FEATURE_PNPM=1; ``` > **Note** if you have previously installed pnpm globally via other means you should uninstall it from all other locations first. You may also need to uninstall nvm or other node version managers if they turn out to conflict. ## Install bun.sh If you don't already have [bun.sh](https://bun.sh/) For MacOS or Linux ```sh curl -fsSL https://bun.sh/install | bash ``` can be done using homebrew, npm or Docker (User choice) checkout installation [doc](https://bun.sh/docs/installation#macos-and-linux) For Windows ```sh # WARNING: No stability is guaranteed on the experimental Windows builds powershell -c "irm bun.sh/install.ps1|iex" ``` Installation [doc](https://bun.sh/docs/installation#windows) ## Install certificate packages Install mkcert using homebrew on MacOS or Linux ```sh brew install mkcert ``` can be done using Chocolatey, Scoop or MacPorts (User choice) checkout installation \[doc]\[https://github.com/FiloSottile/mkcert?tab=readme-ov-file#installation] For Firefox users, Mozilla NSS is also needed Using homebrew on MacOS ```sh brew install nss ``` Or apt on Linux ```sh sudo apt install libnss3-tools ``` but can also be done using other methods. ## Clone the repository ```sh git clone git@github.com:emberjs/data.git ``` ## Install the project dependencies ```sh cd data && pnpm install ``` Currently the install command is also what builds all of the individual packages in the monorepo and hardlinks them together, so if making changes to one package that need to be used by another you will need to rerun `pnpm install` for the changes to be picked up. ## Create certificates ```sh pnpm dlx @warp-drive/holodeck ensure-cert ``` ## Building the project The project's packages will build whenever `pnpm install` is run. They can be rebuilt by running `pnpm prepare`. Both `install` and `prepare` will ensure turbo cache is ignored so that pnpm will automatically update "hardlinks" for the build output files in the node\_modules directory of the various other packages and test apps that depend upon the package. However, this is pretty slow for development, so a fast albeit slightly manual approach is available for development by running the below commands in order: From the project root: * install: `pnpm install` - installs all dependencies and sets up initial hardlinks * start: `pnpm start` - starts the build for every public package in watch mode Then, from an individual test app: * `pnpm start` - starts the build for test assets in watch mode * `pnpm test:start` - launches a test server (and by opens a browser window for debugging them) Because the project uses hardlinks, even though the packages are rebuilding, the test apps won't be able to see the results of the change in many scenarios unless the hardlinks are regenerated. At anypoint, run `pnpm sync` from the root to regenerate the hardlinks. The test app server may pick up this change automatically, but if it does not saving any file (even without changing it) in the test app will trigger a rebuild. ## Run some commands Generally test and lint commands can be found in the `"scripts"` section of the root `package.json` manifest. Individual packages or test packages have additional commands in the `"scripts"` section of their own `package.json` manifest as well. Any command in script can be run using `pnpm` from the directory of that manifest. For instance, to run linting from the root: `pnpm lint` Github Actions workflows will generally use these same commands. --- --- url: /guide/1-configuration/2-setup/1-universal.md --- ::: tip EmberData/WarpDrive Packages Have Been [Simplified](https://rfcs.emberjs.com/id/1075-warp-drive-package-unification/) Looking for the [Old Package Setup Guide?](../4-old-package-setup/1-overview.md) ::: # Setup All frameworks should follow this configuration first. ## Configure the Build Plugin ***Warp*Drive** uses a [babel plugin](https://www.npmjs.com/package/@embroider/macros) to inject app-specific configuration allowing us to provide advanced dev-mode debugging features, deprecation management, and canary feature toggles. For Ember.js, this plugin comes built-in to the toolchain and all you need to do is provide it the desired configuration in `ember-cli-build`. For all other projects, the configuration is done inside of the app's babel configuration file. ::: code-group ```ts [Universal Apps] import { setConfig } from '@warp-drive/core/build-config'; setConfig(context, { // this should be the most recent . version for // which all deprecations have been fully resolved // and should be updated when that changes // for new apps it should be the version you installed // for universal apps this MUST be at least 5.6 compatWith: '5.6' }); ``` ```ts [New Ember Apps] 'use strict'; const EmberApp = require('ember-cli/lib/broccoli/ember-app'); const { compatBuild } = require('@embroider/compat'); module.exports = async function (defaults) { const { setConfig } = await import('@warp-drive/core/build-config'); // [!code focus] const { buildOnce } = await import('@embroider/vite'); const app = new EmberApp(defaults, {}); setConfig(app, __dirname, { // [!code focus:7] // this should be the most recent . version for // which all deprecations have been fully resolved // and should be updated when that changes // for new apps it should be the version you installed compatWith: '5.6' }); return compatBuild(app, buildOnce); }; ``` ```ts [Existing Ember Apps] 'use strict'; const EmberApp = require('ember-cli/lib/broccoli/ember-app'); const { compatBuild } = require('@embroider/compat'); module.exports = async function (defaults) { const { setConfig } = await import('@warp-drive/core/build-config'); // [!code focus] const { buildOnce } = await import('@embroider/vite'); const app = new EmberApp(defaults, {}); setConfig(app, __dirname, { // [!code focus:9] // this should be the most recent . version for // which all deprecations have been fully resolved // and should be updated when that changes compatWith: '4.12' deprecations: { // ... list individual deprecations that have been resolved here } }); return compatBuild(app, buildOnce); }; ``` ::: ## Configure the Store To get up and running we need to configure a `Store` to understand how we want to handle requests, what our data looks like, how to cache it, and what sort of reactive objects to create for that data. Here's an example final configuration. Below we'll show each bit in parts and discuss what each does. ::: tip 💡 Guide Looking for Legacy Adapter/Serializer Support? → After finishing this page read the guide for [Ember.js](./2-ember.md) ::: ::: code-group ```ts [Universal] import { Fetch, RequestManager, Store } from '@warp-drive/core'; import { instantiateRecord, registerDerivations, SchemaService, teardownRecord } from '@warp-drive/core/reactive'; import { CacheHandler, CachePolicy } from '@warp-drive/core/store'; import type { CacheCapabilitiesManager, ResourceKey } from '@warp-drive/core/types'; import { JSONAPICache } from '@warp-drive/json-api'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); lifetimes = new CachePolicy({ apiHardExpires: 15 * 60 * 1000, // 15 minutes apiSoftExpires: 1 * 30 * 1000, // 30 seconds constraints: { 'X-WarpDrive-Expires': true, 'Cache-Control': true, 'Expires': true, } }); createSchemaService() { const schema = new SchemaService(); registerDerivations(schema); return schema; } createCache(capabilities: CacheCapabilitiesManager) { return new JSONAPICache(capabilities); } instantiateRecord(identifier: ResourceKey, createArgs?: Record) { return instantiateRecord(this, identifier, createArgs); } teardownRecord(record: unknown): void { return teardownRecord(record); } } ``` ```ts [Model (Ember Only)] import Store, { CacheHandler } from '@ember-data/store'; import type { CacheCapabilitiesManager, ModelSchema, SchemaService } from '@ember-data/store/types'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import { CachePolicy } from '@ember-data/request-utils'; import JSONAPICache from '@ember-data/json-api'; import type { ResourceKey } from '@warp-drive/core-types'; import type { TypeFromInstance } from '@warp-drive/core-types/record'; import type Model from '@ember-data/model'; import { buildSchema, instantiateRecord, modelFor, teardownRecord } from '@ember-data/model'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); lifetimes = new CachePolicy({ apiHardExpires: 15 * 60 * 1000, // 15 minutes apiSoftExpires: 1 * 30 * 1000, // 30 seconds constraints: { 'X-WarpDrive-Expires': true, 'Cache-Control': true, 'Expires': true, } }); createSchemaService(): SchemaService { return buildSchema(this); } createCache(capabilities: CacheCapabilitiesManager) { return new JSONAPICache(capabilities); } instantiateRecord(identifier: ResourceKey, createRecordArgs: Record) { return instantiateRecord.call(this, identifier, createRecordArgs); } teardownRecord(record: unknown): void { return teardownRecord.call(this, record as Model); } modelFor(type: TypeFromInstance): ModelSchema; modelFor(type: string): ModelSchema; modelFor(type: string): ModelSchema { return (modelFor.call(this, type) as ModelSchema) || super.modelFor(type); } } ``` ```ts [Migration (Ember Only)] import Store, { CacheHandler, recordIdentifierFor } from '@ember-data/store'; import type { CacheCapabilitiesManager, ModelSchema } from '@ember-data/store/types'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import { CachePolicy } from '@ember-data/request-utils'; import JSONAPICache from '@ember-data/json-api'; import type { ResourceKey } from '@warp-drive/core-types'; import type { TypeFromInstance } from '@warp-drive/core-types/record'; import { DelegatingSchemaService } from '@ember-data/model/migration-support'; import type Model from '@ember-data/model'; import { instantiateRecord as instantiateModel, modelFor, teardownRecord as teardownModel } from '@ember-data/model'; import { instantiateRecord, registerDerivations, SchemaService, teardownRecord } from '@warp-drive/schema-record'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); lifetimes = new CachePolicy({ apiHardExpires: 15 * 60 * 1000, // 15 minutes apiSoftExpires: 1 * 30 * 1000, // 30 seconds constraints: { 'X-WarpDrive-Expires': true, 'Cache-Control': true, 'Expires': true, } }); createSchemaService() { const schema = new SchemaService(); registerDerivations(schema); return new DelegatingSchemaService(this, schema); } createCache(capabilities: CacheCapabilitiesManager) { return new JSONAPICache(capabilities); } instantiateRecord(identifier: ResourceKey, createArgs?: Record) { if (this.schema.isDelegated(identifier)) { return instantiateModel.call(this, identifier, createRecordArgs) } return instantiateRecord(this, identifier, createArgs); } teardownRecord(record: unknown): void { const identifier = recordIdentifierFor(record); if (this.schema.isDelegated(identifier)) { return teardownModel.call(this, record as Model); } return teardownRecord(record); } modelFor(type: TypeFromInstance): ModelSchema; modelFor(type: string): ModelSchema; modelFor(type: string): ModelSchema { return (modelFor.call(this, type) as ModelSchema) || super.modelFor(type); } } ``` ::: ### Start With A Store The store is the central piece of the ***Warp*Drive** experience. It functions as a coordinator, linking together requests for data with schemas, caching and reactivity. While it's easy to use ***just*** ***Warp*Drive**'s request management, most apps will find they require far more than basic fetch management. For this reason it's often best to start with a Store even when you aren't sure yet. ```ts import { Store } from '@warp-drive/core'; export default class AppStore extends Store {} ``` ### Add Basic Request Management `RequestManager` provides a chain-of-responsibility style pipeline for helping you handle centralized concerns around requesting and updating data from your backend. ::: tip 💡 Guide → Learn more about [Making Requests](../../2-requests.md) ::: ```ts import { Fetch, RequestManager, Store } from '@warp-drive/core'; // [!code focus] export default class AppStore extends Store { requestManager = new RequestManager() // [!code focus:2] .use([Fetch]); } ``` ### Add a Source for Schema for your Data ***Warp*Drive** uses simple JSON schemas to define the shape and features of reactive objects. Schemas may seem simple, but they come packed with features that will help you build incredible applications. ::: tip 💡 Guide → Learn more about [Resource Schemas](../../8-schemas.md) ::: ::: code-group ```ts [Unniversal] import { Fetch, RequestManager, Store } from '@warp-drive/core'; import { // [!code focus:4] registerDerivations, SchemaService, } from '@warp-drive/core/reactive'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]); createSchemaService() { // [!code focus:5] const schema = new SchemaService(); registerDerivations(schema); return schema; } } ``` ```ts [Model (Ember Only)] import Store from '@ember-data/store'; import type { ModelSchema, SchemaService } from '@ember-data/store/types'; // [!code focus] import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import type { TypeFromInstance } from '@warp-drive/core-types/record'; // [!code focus] import { // [!code focus:4] buildSchema, modelFor, } from '@warp-drive/schema-record'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]); createSchemaService(): SchemaService { // [!code focus:3] return buildSchema(this); } modelFor(type: TypeFromInstance): ModelSchema; // [!code focus:6] modelFor(type: string): ModelSchema; modelFor(type: string): ModelSchema { return (modelFor.call(this, type) as ModelSchema) || super.modelFor(type); } } ``` ```ts [Migration (Ember Only)] import Store from '@ember-data/store'; import type { ModelSchema } from '@ember-data/store/types'; // [!code focus] import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import type { TypeFromInstance } from '@warp-drive/core-types/record'; // [!code focus:2] import { DelegatingSchemaService } from '@ember-data/model/migration-support'; import { // [!code focus:3] modelFor, } from '@warp-drive/schema-record'; import { // [!code focus:4] registerDerivations, SchemaService, } from '@warp-drive/schema-record'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]); createSchemaService() { // [!code focus:5] const schema = new SchemaService(); registerDerivations(schema); return new DelegatingSchemaService(this, schema); } modelFor(type: TypeFromInstance): ModelSchema; // [!code focus:6] modelFor(type: string): ModelSchema; modelFor(type: string): ModelSchema { return (modelFor.call(this, type) as ModelSchema) || super.modelFor(type); } } ``` ::: ### Add a Cache Do you really need a cache? Are sunsets beautiful? Caching is what powers features like immutability, mutation management, and allows ***Warp*Drive** to understand your relational data. Some caches are simple request/response maps. ***Warp*Drive**'s is not. The Cache deeply understands the structure of your data, ensuring your data remains consistent both within and across requests. Out of the box, ***Warp*Drive** provides a Cache that expects the [{JSON:API}](https://jsonapi.org) format. This format excels at simiplifying common complex problems around cache consistency and information density. Most APIs can be quickly adapted to work with it, but if a cache built to understand another format would do better it just needs to follow the same interface. ```ts import { Fetch, RequestManager, Store } from '@warp-drive/core'; import { CacheHandler } from '@warp-drive/core/store'; // [!code focus:4] import type { CacheCapabilitiesManager } from '@warp-drive/core/types'; import { registerDerivations, SchemaService, } from '@warp-drive/core/reactive'; import { JSONAPICache } from '@warp-drive/json-api'; // [!code focus] export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); createSchemaService() { const schema = new SchemaService(); registerDerivations(schema); return schema; } createCache(capabilities: CacheCapabilitiesManager) { // [!code focus:2] return new JSONAPICache(capabilities); } } ``` ### Setup Your Data to be Reactive While it is possible to use ***Warp*Drive** to store and retrieve raw json, you'd be missing out on the best part. Reactive objects transform raw cached data into rich, reactive data. The resulting objects are immutable, always displaying the latest state in the cache while preventing accidental or unsafe mutation in your app. ::: code-group ```ts [SchemaRecord] import { Fetch, RequestManager, Store } from '@warp-drive/core'; import { CacheHandler } from '@warp-drive/core/store'; import type { CacheCapabilitiesManager, ResourceKey // [!code focus] } from '@warp-drive/core/types'; import { instantiateRecord, // [!code focus] registerDerivations, SchemaService, teardownRecord // [!code focus] } from '@warp-drive/core/reactive'; import { JSONAPICache } from '@warp-drive/json-api'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); createSchemaService() { const schema = new SchemaService(); registerDerivations(schema); return schema; } createCache(capabilities: CacheCapabilitiesManager) { return new JSONAPICache(capabilities); } instantiateRecord(identifier: ResourceKey, createArgs?: Record) { // [!code focus:3] return instantiateRecord(this, identifier, createArgs); } teardownRecord(record: unknown): void { // [!code focus:3] return teardownRecord(record); } } ``` ```ts [Model (Ember Only)] import Store, { CacheHandler } from '@ember-data/store'; import type { CacheCapabilitiesManager, ModelSchema, SchemaService } from '@ember-data/store/types'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import JSONAPICache from '@ember-data/json-api'; import type { ResourceKey } from '@warp-drive/core-types'; // [!code focus] import type { TypeFromInstance } from '@warp-drive/core-types/record'; import type Model from '@ember-data/model'; // [!code focus] import { buildSchema, instantiateRecord, // [!code focus] modelFor, teardownRecord // [!code focus] } from '@ember-data/model'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); createSchemaService(): SchemaService { return buildSchema(this); } createCache(capabilities: CacheCapabilitiesManager) { return new JSONAPICache(capabilities); } instantiateRecord(identifier: ResourceKey, createRecordArgs: Record) { // [!code focus:3] return instantiateRecord.call(this, identifier, createRecordArgs); } teardownRecord(record: unknown): void { // [!code focus:3] return teardownRecord.call(this, record as Model); } modelFor(type: TypeFromInstance): ModelSchema; modelFor(type: string): ModelSchema; modelFor(type: string): ModelSchema { return (modelFor.call(this, type) as ModelSchema) || super.modelFor(type); } } ``` ```ts [Migration (Ember Only)] import Store, { CacheHandler, recordIdentifierFor } from '@ember-data/store'; import type { CacheCapabilitiesManager, ModelSchema } from '@ember-data/store/types'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import JSONAPICache from '@ember-data/json-api'; import type { ResourceKey } from '@warp-drive/core-types'; // [!code focus] import type { TypeFromInstance } from '@warp-drive/core-types/record'; import { DelegatingSchemaService } from '@ember-data/model/migration-support'; import type Model from '@ember-data/model'; // [!code focus] import { instantiateRecord as instantiateModel, // [!code focus] modelFor, teardownRecord as teardownModel // [!code focus] } from '@ember-data/model'; import { instantiateRecord, // [!code focus] registerDerivations, SchemaService, teardownRecord // [!code focus] } from '@warp-drive/schema-record'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); createSchemaService() { const schema = new SchemaService(); registerDerivations(schema); return new DelegatingSchemaService(this, schema); } createCache(capabilities: CacheCapabilitiesManager) { return new JSONAPICache(capabilities); } instantiateRecord(identifier: ResourceKey, createArgs?: Record) { // [!code focus:6] if (this.schema.isDelegated(identifier)) { return instantiateModel.call(this, identifier, createRecordArgs) } return instantiateRecord(this, identifier, createArgs); } teardownRecord(record: unknown): void { // [!code focus:7] const identifier = recordIdentifierFor(record); if (this.schema.isDelegated(identifier)) { return teardownModel.call(this, record as Model); } return teardownRecord(record); } modelFor(type: TypeFromInstance): ModelSchema; modelFor(type: string): ModelSchema; modelFor(type: string): ModelSchema { return (modelFor.call(this, type) as ModelSchema) || super.modelFor(type); } } ``` ::: ### Decide How Long Requests are Valid for with a CachePolicy And of course, what's a great cache without an eviction policy? ***Warp*Drive** provides an interface for creating Cache Policies. Whenever a request is made, the policy is checked to determine if the current cached representation is still valid. Policies also have the ability to subscribe to cache updates and issue invalidation notifications. The `` component subscribes to these notifications and will trigger a reload if necessary if an invalidated request is in active use, letting you craft advanced policies that meet your product's needs. ***Warp*Drive** provides a basic CachePolicy with a number of great defaults that is a great starting point for most applications. We configure this basic policy below. The basic policy will invalidate requests based on caching and date headers available on request responses, falling back to a simple time based policy. ```ts import { Fetch, RequestManager, Store } from '@warp-drive/core'; import { instantiateRecord, registerDerivations, SchemaService, teardownRecord } from '@warp-drive/core/reactive'; import { CacheHandler, CachePolicy } from '@warp-drive/core/store'; // [!code focus] import type { CacheCapabilitiesManager, ResourceKey } from '@warp-drive/core/types'; import { JSONAPICache } from '@warp-drive/json-api'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); lifetimes = new CachePolicy({ // [!code focus:9] apiHardExpires: 15 * 60 * 1000, // 15 minutes apiSoftExpires: 1 * 30 * 1000, // 30 seconds constraints: { 'X-WarpDrive-Expires': true, 'Cache-Control': true, 'Expires': true, } }); createSchemaService() { const schema = new SchemaService(); registerDerivations(schema); return schema; } createCache(capabilities: CacheCapabilitiesManager) { return new JSONAPICache(capabilities); } instantiateRecord(identifier: ResourceKey, createArgs?: Record) { return instantiateRecord(this, identifier, createArgs); } teardownRecord(record: unknown): void { return teardownRecord(record); } } ``` ### Configure Your Framework The final setup step is to configure reactivity for your framework. See each framework's guide for this step. * [Ember.js](./2-ember.md) ## Configure ESLint 🚧 Under Construction --- --- url: /guide/1-configuration/4-old-package-setup/2-setup/1-universal.md --- ::: tip Boilerplate Sucks 👎🏽 We're re-aligning our packages into a new streamlined installation and setup experience. Below you'll find the current *boilerplate heavy* setup. Curious? Read the [RFC](https://rfcs.emberjs.com/id/1075-warp-drive-package-unification/) ::: # Setup All frameworks should follow this configuration first. ## Configure the Build Plugin ***Warp*Drive** uses a [babel plugin](https://www.npmjs.com/package/@embroider/macros) to inject app-specific configuration allowing us to provide advanced dev-mode debugging features, deprecation management, and canary feature toggles. For Ember.js, this plugin comes built-in to the toolchain and all you need to do is provide it the desired configuration in `ember-cli-build`. For all other projects, the configuration is done inside of the app's babel configuration file. ::: code-group ```ts [New Ember Apps] 'use strict'; const EmberApp = require('ember-cli/lib/broccoli/ember-app'); const { compatBuild } = require('@embroider/compat'); module.exports = async function (defaults) { const { setConfig } = await import('@warp-drive/build-config'); // [!code focus] const { buildOnce } = await import('@embroider/vite'); const app = new EmberApp(defaults, {}); setConfig(app, __dirname, { // [!code focus:7] // this should be the most recent . version for // which all deprecations have been fully resolved // and should be updated when that changes // for new apps it should be the version you installed compatWith: '5.5' }); return compatBuild(app, buildOnce); }; ``` ```ts [Existing Ember Apps] 'use strict'; const EmberApp = require('ember-cli/lib/broccoli/ember-app'); const { compatBuild } = require('@embroider/compat'); module.exports = async function (defaults) { const { setConfig } = await import('@warp-drive/build-config'); // [!code focus] const { buildOnce } = await import('@embroider/vite'); const app = new EmberApp(defaults, {}); setConfig(app, __dirname, { // [!code focus:9] // this should be the most recent . version for // which all deprecations have been fully resolved // and should be updated when that changes compatWith: '4.12' deprecations: { // ... list individual deprecations that have been resolved here } }); return compatBuild(app, buildOnce); }; ``` ```ts [Universal Apps] import { setConfig } from '@warp-drive/build-config'; setConfig(context, { // this should be the most recent . version for // which all deprecations have been fully resolved // and should be updated when that changes // for new apps it should be the version you installed // for universal apps this MUST be at least 5.5 compatWith: '5.5' }); ``` ::: ## Add TypeScript Types ::: code-group ```tsconfig.json [Universal] { compilerOptions: { types: [ "@ember-data/graph/unstable-preview-types", // [!code ++] "@ember-data/json-api/unstable-preview-types", // [!code ++] "@ember-data/request/unstable-preview-types", // [!code ++] "@ember-data/request-utils/unstable-preview-types", // [!code ++] "@ember-data/store/unstable-preview-types", // [!code ++] "@warp-drive/build-config/declarations", // [!code ++] "@warp-drive/core-types/unstable-preview-types", // [!code ++] "@warp-drive/schema-record/unstable-preview-types", // [!code ++] ] } } ``` ```tsconfig.json [Ember Polaris] { compilerOptions: { types: [ "@ember-data/debug/unstable-preview-types", // [!code ++] "@ember-data/graph/unstable-preview-types", // [!code ++] "@ember-data/json-api/unstable-preview-types", // [!code ++] "@ember-data/request/unstable-preview-types", // [!code ++] "@ember-data/request-utils/unstable-preview-types", // [!code ++] "@ember-data/store/unstable-preview-types", // [!code ++] "@warp-drive/build-config/declarations", // [!code ++] "@warp-drive/core-types/unstable-preview-types", // [!code ++] "@warp-drive/schema-record/unstable-preview-types", // [!code ++] ] } } ``` ```tsconfig.json [Ember Full Legacy] { compilerOptions: { types: [ "@ember-data/adapter/unstable-preview-types", // [!code ++] "@ember-data/debug/unstable-preview-types", // [!code ++] "@ember-data/graph/unstable-preview-types", // [!code ++] "@ember-data/json-api/unstable-preview-types", // [!code ++] "@ember-data/legacy-compat/unstable-preview-types", // [!code ++] "@ember-data/model/unstable-preview-types", // [!code ++] "@ember-data/request/unstable-preview-types", // [!code ++] "@ember-data/request-utils/unstable-preview-types", // [!code ++] "@ember-data/serializer/unstable-preview-types", // [!code ++] "@ember-data/store/unstable-preview-types", // [!code ++] "@warp-drive/build-config/declarations", // [!code ++] "@warp-drive/core-types/unstable-preview-types", // [!code ++] "@warp-drive/schema-record/unstable-preview-types", // [!code ++] ] } } ``` ## Configure the Store To get up and running we need to configure a `Store` to understand how we want to handle requests, what our data looks like, how to cache it, and what sort of reactive objects to create for that data. Here's an example final configuration. Below we'll show each bit in parts and discuss what each does. ::: tip 💡 Guide Looking for Legacy Adapter/Serializer Support? → After finishing this page read the guide for [Ember.js](./2-ember.md) ::: ::: code-group ```ts [SchemaRecord] import Store, { CacheHandler } from '@ember-data/store'; import type { CacheCapabilitiesManager } from '@ember-data/store/types'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import { CachePolicy } from '@ember-data/request-utils'; import JSONAPICache from '@ember-data/json-api'; import type { ResourceKey } from '@warp-drive/core-types'; import { instantiateRecord, registerDerivations, SchemaService, teardownRecord } from '@warp-drive/schema-record'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); lifetimes = new CachePolicy({ apiHardExpires: 15 * 60 * 1000, // 15 minutes apiSoftExpires: 1 * 30 * 1000, // 30 seconds constraints: { 'X-WarpDrive-Expires': true, 'Cache-Control': true, 'Expires': true, } }); createSchemaService() { const schema = new SchemaService(); registerDerivations(schema); return schema; } createCache(capabilities: CacheCapabilitiesManager) { return new JSONAPICache(capabilities); } instantiateRecord(identifier: ResourceKey, createArgs?: Record) { return instantiateRecord(this, identifier, createArgs); } teardownRecord(record: unknown): void { return teardownRecord(record); } } ``` ```ts [Model (Ember Only)] import Store, { CacheHandler } from '@ember-data/store'; import type { CacheCapabilitiesManager, ModelSchema, SchemaService } from '@ember-data/store/types'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import { CachePolicy } from '@ember-data/request-utils'; import JSONAPICache from '@ember-data/json-api'; import type { ResourceKey } from '@warp-drive/core-types'; import type { TypeFromInstance } from '@warp-drive/core-types/record'; import type Model from '@ember-data/model'; import { buildSchema, instantiateRecord, modelFor, teardownRecord } from '@ember-data/model'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); lifetimes = new CachePolicy({ apiHardExpires: 15 * 60 * 1000, // 15 minutes apiSoftExpires: 1 * 30 * 1000, // 30 seconds constraints: { 'X-WarpDrive-Expires': true, 'Cache-Control': true, 'Expires': true, } }); createSchemaService(): SchemaService { return buildSchema(this); } createCache(capabilities: CacheCapabilitiesManager) { return new JSONAPICache(capabilities); } instantiateRecord(identifier: ResourceKey, createRecordArgs: Record) { return instantiateRecord.call(this, identifier, createRecordArgs); } teardownRecord(record: unknown): void { return teardownRecord.call(this, record as Model); } modelFor(type: TypeFromInstance): ModelSchema; modelFor(type: string): ModelSchema; modelFor(type: string): ModelSchema { return (modelFor.call(this, type) as ModelSchema) || super.modelFor(type); } } ``` ```ts [Migration (Ember Only)] import Store, { CacheHandler, recordIdentifierFor } from '@ember-data/store'; import type { CacheCapabilitiesManager, ModelSchema } from '@ember-data/store/types'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import { CachePolicy } from '@ember-data/request-utils'; import JSONAPICache from '@ember-data/json-api'; import type { ResourceKey } from '@warp-drive/core-types'; import type { TypeFromInstance } from '@warp-drive/core-types/record'; import { DelegatingSchemaService } from '@ember-data/model/migration-support'; import type Model from '@ember-data/model'; import { instantiateRecord as instantiateModel, modelFor, teardownRecord as teardownModel } from '@ember-data/model'; import { instantiateRecord, registerDerivations, SchemaService, teardownRecord } from '@warp-drive/schema-record'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); lifetimes = new CachePolicy({ apiHardExpires: 15 * 60 * 1000, // 15 minutes apiSoftExpires: 1 * 30 * 1000, // 30 seconds constraints: { 'X-WarpDrive-Expires': true, 'Cache-Control': true, 'Expires': true, } }); createSchemaService() { const schema = new SchemaService(); registerDerivations(schema); return new DelegatingSchemaService(this, schema); } createCache(capabilities: CacheCapabilitiesManager) { return new JSONAPICache(capabilities); } instantiateRecord(identifier: ResourceKey, createArgs?: Record) { if (this.schema.isDelegated(identifier)) { return instantiateModel.call(this, identifier, createRecordArgs) } return instantiateRecord(this, identifier, createArgs); } teardownRecord(record: unknown): void { const identifier = recordIdentifierFor(record); if (this.schema.isDelegated(identifier)) { return teardownModel.call(this, record as Model); } return teardownRecord(record); } modelFor(type: TypeFromInstance): ModelSchema; modelFor(type: string): ModelSchema; modelFor(type: string): ModelSchema { return (modelFor.call(this, type) as ModelSchema) || super.modelFor(type); } } ``` ::: ### Start With A Store The store is the central piece of the ***Warp*Drive** experience. It functions as a coordinator, linking together requests for data with schemas, caching and reactivity. While it's easy to use ***just*** ***Warp*Drive**'s request management, most apps will find they require far more than basic fetch management. For this reason it's often best to start with a Store even when you aren't sure yet. ```ts import Store from '@ember-data/store'; export default class AppStore extends Store {} ``` ### Add Basic Request Management `RequestManager` provides a chain-of-responsibility style pipeline for helping you handle centralized concerns around requesting and updating data from your backend. ::: tip 💡 Guide → Learn more about [Making Requests](../../2-requests.md) ::: ```ts import Store from '@ember-data/store'; import RequestManager from '@ember-data/request'; // [!code focus:2] import Fetch from '@ember-data/request/fetch'; export default class AppStore extends Store { requestManager = new RequestManager() // [!code focus:2] .use([Fetch]); } ``` ### Add a Source for Schema for your Data ***Warp*Drive** uses simple JSON schemas to define the shape and features of reactive objects. Schemas may seem simple, but they come packed with features that will help you build incredible applications. ::: tip 💡 Guide → Learn more about [Resource Schemas](../../8-schemas.md) ::: ::: code-group ```ts [SchemaRecord] import Store from '@ember-data/store'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import { // [!code focus:4] registerDerivations, SchemaService, } from '@warp-drive/schema-record'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]); createSchemaService() { // [!code focus:5] const schema = new SchemaService(); registerDerivations(schema); return schema; } } ``` ```ts [Model (Ember Only)] import Store from '@ember-data/store'; import type { ModelSchema, SchemaService } from '@ember-data/store/types'; // [!code focus] import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import type { TypeFromInstance } from '@warp-drive/core-types/record'; // [!code focus] import { // [!code focus:4] buildSchema, modelFor, } from '@warp-drive/schema-record'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]); createSchemaService(): SchemaService { // [!code focus:3] return buildSchema(this); } modelFor(type: TypeFromInstance): ModelSchema; // [!code focus:6] modelFor(type: string): ModelSchema; modelFor(type: string): ModelSchema { return (modelFor.call(this, type) as ModelSchema) || super.modelFor(type); } } ``` ```ts [Migration (Ember Only)] import Store from '@ember-data/store'; import type { ModelSchema } from '@ember-data/store/types'; // [!code focus] import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import type { TypeFromInstance } from '@warp-drive/core-types/record'; // [!code focus:2] import { DelegatingSchemaService } from '@ember-data/model/migration-support'; import { // [!code focus:3] modelFor, } from '@warp-drive/schema-record'; import { // [!code focus:4] registerDerivations, SchemaService, } from '@warp-drive/schema-record'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]); createSchemaService() { // [!code focus:5] const schema = new SchemaService(); registerDerivations(schema); return new DelegatingSchemaService(this, schema); } modelFor(type: TypeFromInstance): ModelSchema; // [!code focus:6] modelFor(type: string): ModelSchema; modelFor(type: string): ModelSchema { return (modelFor.call(this, type) as ModelSchema) || super.modelFor(type); } } ``` ::: ### Add a Cache Do you really need a cache? Are sunsets beautiful? Caching is what powers features like immutability, mutation management, and allows ***Warp*Drive** to understand your relational data. Some caches are simple request/response maps. ***Warp*Drive**'s is not. The Cache deeply understands the structure of your data, ensuring your data remains consistent both within and across requests. Out of the box, ***Warp*Drive** provides a Cache that expects the [{JSON:API}](https://jsonapi.org) format. This format excels at simiplifying common complex problems around cache consistency and information density. Most APIs can be quickly adapted to work with it, but if a cache built to understand another format would do better it just needs to follow the same interface. ```ts import Store, { CacheHandler } from '@ember-data/store'; // [!code focus:2] import type { CacheCapabilitiesManager } from '@ember-data/store/types'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import JSONAPICache from '@ember-data/json-api'; // [!code focus] import { registerDerivations, SchemaService, } from '@warp-drive/schema-record'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); createSchemaService() { const schema = new SchemaService(); registerDerivations(schema); return schema; } createCache(capabilities: CacheCapabilitiesManager) { // [!code focus:2] return new JSONAPICache(capabilities); } } ``` ### Setup Your Data to be Reactive While it is possible to use ***Warp*Drive** to store and retrieve raw json, you'd be missing out on the best part. Reactive objects transform raw cached data into rich, reactive data. The resulting objects are immutable, always displaying the latest state in the cache while preventing accidental or unsafe mutation in your app. ::: code-group ```ts [SchemaRecord] import Store, { CacheHandler } from '@ember-data/store'; import type { CacheCapabilitiesManager } from '@ember-data/store/types'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import JSONAPICache from '@ember-data/json-api'; import type { ResourceKey } from '@warp-drive/core-types'; // [!code focus] import { instantiateRecord, // [!code focus] registerDerivations, SchemaService, teardownRecord // [!code focus] } from '@warp-drive/schema-record'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); createSchemaService() { const schema = new SchemaService(); registerDerivations(schema); return schema; } createCache(capabilities: CacheCapabilitiesManager) { return new JSONAPICache(capabilities); } instantiateRecord(identifier: ResourceKey, createArgs?: Record) { // [!code focus:3] return instantiateRecord(this, identifier, createArgs); } teardownRecord(record: unknown): void { // [!code focus:3] return teardownRecord(record); } } ``` ```ts [Model (Ember Only)] import Store, { CacheHandler } from '@ember-data/store'; import type { CacheCapabilitiesManager, ModelSchema, SchemaService } from '@ember-data/store/types'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import JSONAPICache from '@ember-data/json-api'; import type { ResourceKey } from '@warp-drive/core-types'; // [!code focus] import type { TypeFromInstance } from '@warp-drive/core-types/record'; import type Model from '@ember-data/model'; // [!code focus] import { buildSchema, instantiateRecord, // [!code focus] modelFor, teardownRecord // [!code focus] } from '@ember-data/model'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); createSchemaService(): SchemaService { return buildSchema(this); } createCache(capabilities: CacheCapabilitiesManager) { return new JSONAPICache(capabilities); } instantiateRecord(identifier: ResourceKey, createRecordArgs: Record) { // [!code focus:3] return instantiateRecord.call(this, identifier, createRecordArgs); } teardownRecord(record: unknown): void { // [!code focus:3] return teardownRecord.call(this, record as Model); } modelFor(type: TypeFromInstance): ModelSchema; modelFor(type: string): ModelSchema; modelFor(type: string): ModelSchema { return (modelFor.call(this, type) as ModelSchema) || super.modelFor(type); } } ``` ```ts [Migration (Ember Only)] import Store, { CacheHandler, recordIdentifierFor } from '@ember-data/store'; import type { CacheCapabilitiesManager, ModelSchema } from '@ember-data/store/types'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import JSONAPICache from '@ember-data/json-api'; import type { ResourceKey } from '@warp-drive/core-types'; // [!code focus] import type { TypeFromInstance } from '@warp-drive/core-types/record'; import { DelegatingSchemaService } from '@ember-data/model/migration-support'; import type Model from '@ember-data/model'; // [!code focus] import { instantiateRecord as instantiateModel, // [!code focus] modelFor, teardownRecord as teardownModel // [!code focus] } from '@ember-data/model'; import { instantiateRecord, // [!code focus] registerDerivations, SchemaService, teardownRecord // [!code focus] } from '@warp-drive/schema-record'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); createSchemaService() { const schema = new SchemaService(); registerDerivations(schema); return new DelegatingSchemaService(this, schema); } createCache(capabilities: CacheCapabilitiesManager) { return new JSONAPICache(capabilities); } instantiateRecord(identifier: ResourceKey, createArgs?: Record) { // [!code focus:6] if (this.schema.isDelegated(identifier)) { return instantiateModel.call(this, identifier, createRecordArgs) } return instantiateRecord(this, identifier, createArgs); } teardownRecord(record: unknown): void { // [!code focus:7] const identifier = recordIdentifierFor(record); if (this.schema.isDelegated(identifier)) { return teardownModel.call(this, record as Model); } return teardownRecord(record); } modelFor(type: TypeFromInstance): ModelSchema; modelFor(type: string): ModelSchema; modelFor(type: string): ModelSchema { return (modelFor.call(this, type) as ModelSchema) || super.modelFor(type); } } ``` ::: ### Decide How Long Requests are Valid for with a CachePolicy And of course, what's a great cache without an eviction policy? ***Warp*Drive** provides an interface for creating Cache Policies. Whenever a request is made, the policy is checked to determine if the current cached representation is still valid. Policies also have the ability to subscribe to cache updates and issue invalidation notifications. The `` component subscribes to these notifications and will trigger a reload if necessary if an invalidated request is in active use, letting you craft advanced policies that meet your product's needs. ***Warp*Drive** provides a basic CachePolicy with a number of great defaults that is a great starting point for most applications. We configure this basic policy below. The basic policy will invalidate requests based on caching and date headers available on request responses, falling back to a simple time based policy. ```ts import Store, { CacheHandler } from '@ember-data/store'; import type { CacheCapabilitiesManager } from '@ember-data/store/types'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import { CachePolicy } from '@ember-data/request-utils'; // [!code focus] import JSONAPICache from '@ember-data/json-api'; import type { ResourceKey } from '@warp-drive/core-types'; import { instantiateRecord, registerDerivations, SchemaService, teardownRecord } from '@warp-drive/schema-record'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); lifetimes = new CachePolicy({ // [!code focus:9] apiHardExpires: 15 * 60 * 1000, // 15 minutes apiSoftExpires: 1 * 30 * 1000, // 30 seconds constraints: { 'X-WarpDrive-Expires': true, 'Cache-Control': true, 'Expires': true, } }); createSchemaService() { const schema = new SchemaService(); registerDerivations(schema); return schema; } createCache(capabilities: CacheCapabilitiesManager) { return new JSONAPICache(capabilities); } instantiateRecord(identifier: ResourceKey, createArgs?: Record) { return instantiateRecord(this, identifier, createArgs); } teardownRecord(record: unknown): void { return teardownRecord(record); } } ``` ### Configure Your Framework The final setup step is to configure reactivity for your framework. See each framework's guide for this step. * [Ember.js](./2-ember.md) ## Configure ESLint 🚧 Under Construction --- --- url: /guide/contributing/submitting-prs.md --- # Submitting Work Before implementing a feature or a fix, it is usually best to discuss the proposed changes with [team members](https://emberjs.com/team/). Some fixes might require new public API or changes to existing public APIs. If this is the case, it is even more important to discuss the issue's problem space and the proposed changes before diving too deep into the implementation. ## Making a PR Submissions should be made as PRs against the `main` branch. If a bugfix for an existing release is needed, that work should be cherry-picked to secondary PRs targeting the appropriate release branches after being accepted to the main branch. ### Writing Tests All PRs should have accompanying tests. For bug-fixes, this should include tests that demonstrate the issue being fixed and test that the solution works. * We do write tests for our deprecations and assertion messages, using the `assert.expectAssertion()` and `assert.expectDeprecation()` helpers. * Because we run tests in both development and `production` environments, assertions, deprecations and warnings may be stripped out. To avoid tests of debug behaviors failing for your PR in production environments, use the `testInDebug` function instead of `qunit` `test` to skip them in production when appropriate. * alternatively wrap specific assertions in `if (DEBUG)` or `if (PRODUCTION)` * Update the documentation, examples, and guides when affected by your contribution ### Running Tests * PRs will automatically run an extensive set of test scenarios for your work. In some cases a contributor may need to approve the workflow run if this is your first contribution. * `WarpDrive` is a collection of packages and comes with multiple test apps scoped to specific situations or parts of the codebase we want to test. These test applications can be found in `/tests`. These should look like familiar ember app/addon tests, and to run them from within a specific test app use `pnpm test` or `pnpm test --serve`. For additional test commands see the list of commands in the respective `package.json` files. ### Pull Request Titles PRs should be meaningfully titled to give context into the change for the changelog. ### Pull Request Labeling All PRs should be labeled. PR labeling for changelog and backporting is enforced in CI, but labels may only be applied by project maintainers. PRs from non-maintainers will be labeled by maintainers prior to a PR being accepted and merged. #### Changelog Labels Labels used for the changelog include any labels listed in the changelog config in the [root package.json](https://github.com/emberjs/data/blob/main/package.json). These labels are prefixed with `changelog:` and currently the options are: * `:label: breaking` which should be used to signify a breaking change * `:label: feat` which should be used to signify an addition of a new public feature or behavior * `:label: bug` which should be used to signify a fix for a reported issue * `:label: perf` which should be used to signify that the commit will improve performance characteristics in a meaningful way * `:label: cleanup` which should be used to signify removal of deprecated features or that a deprecation has become an assertion. * `:label: deprecation` which should be used to signify addition of a new deprecation * `:label: doc` which should be used to signify a fix or improvement to documentation generated for api.emberjs.com * `:label: test` which should be used to signify addition of new tests or refactoring of existing tests * `:label: chore` which should be used to signify refactoring of internal code that should not have an affect on public APIs or behaviors but which we may want to call out for potentially unintended consequences. * `:label: dependencies` which should be used when bumping dependencies on `main`. Bumps on other branches should use other labels as this implies a more substantive change. #### Backporting Labels We use one set of labels to indicate that a PR needs to be backported and where it needs to be backported to, and a second set of labels to indicate that a PR **is** the backport PR. To indicate that a PR should be backported, the following labels, all prefixed with `target:` are available: * `:dart: canary` indicates that a PR will not require backporting. * `:dart: beta` indicates the PR requires being backported to the current beta release. * `:dart: release` indicates the PR requires being backported to the current active release. * `:dart: lts` indicates that a PR requires being backported to the most current LTS release. * `:dart: lts-prev` indicates that a PR requires being backported to the second-most recent LTS release. Note: a PR should add the individual label for *every* backport target required. We use this while releasing to search for any commits still requiring backport to include, and will eventually automate opening backport PRs via a bot when these labels are present. We remove the `target:` label from merged PRs only once the backport PR has been opened. To indicate that a PR **is** the backport PR, the following labels, all prefixed with `backport-` are available: * `backport-beta` for PRs to the beta branch * `backport-release` for PRs to the current active release branch * `backport-old-release` for PRs to previous release branches that are not LTS branches * `backport-lts` for PRs targetting the current active LTS branch * `backport-lts-prev` for PRs targetting the second most current LTS branch Note, we automatically add this label to any PR opened to a beta/release/lts branch, but for non-current non-lts backports it will need to be added manually. #### Project Labels Labels used for tracking work in [various projects](https://github.com/emberjs/data/projects) are not enforced, but PRs and issues should be labeled for any applicable projects and added to those projects when reviewed. --- --- url: /guide/contributing/terminology.md --- # Terminology * [Builder](#builder) * [Cache](#cache) * [Collections](#collections) * [Derivations](#derivations) * [Document](#document) * [Fields](#fields) * [Handler](#handler) * [Identifier](#identifier) * [Presentation](#presentation) * [Record](#record) * [Relationships](#relationships) * [Request](#request) * [Resource](#resource) * [Schema](#schema) * [Store](#store) **Legacy Glossery** * [Adapter](#adapter) * [Model](#model) * [Serializer](#serializer) ## Definitions These are presented in "mental model" order as opposed to alphabetical order. ### Request ### Builder ### Handler ### Document ### Resource ### Identifier ### Fields ### Collections ### Relationships ### Derivations ### Cache ### Presentation ### Schema ### Store ### Record ## Legacy Terminology ### Model ### Adapter ### Serializer --- --- url: /guide/misc/9-terminology.md --- # Terminology * ⮐ [Main Guide](./index.md) **Sections** * [Data](#data) * [Resource](#resource) * [Collection](#collection) * [Identifier](#identifier) * [Document](#document) * [RelationshipDocument](#relationshipdocument) * [Relationships](#relationships) * [Inverse](#inverse) * [Self Referential](#self-referential) * [Reflexive](#reflexive) * [Circular](#circular) * [Polymorphic](#polymorphic) *** ## Data EmberData treats data "opaquely" meaning that any data format will work so long as you are able to describe to the library how that data fits into various concepts (usually this is done by implementing a [Cache](https://api.emberjs.com/ember-data/release/classes/%3CInterface%3E%20Cache)). Below, we describe the semantic meaning of these more opaque concepts. ### Resource A resource is a unit of discretely identifiable data. Usually resources map to things like rows in a database with their "type" being derived from the table name. Discretely identifiable means that given some data, your app would consistently be able to identify the source of that data and meaningfully distinguish it from other data. For instance, in the following JSON we have two distinct resources: ```jsonc { "users": [ { "id": 1, "name": "Chris" }, // => resource 1 { "id": 2, "name": "Rey" } // => resource 2 ] } ``` #### Resource Types Every resource has a string "type". All resources with the same type are assumed to have the same [schema](#schema). Types can represent polymorphic traits. For instance, imagine your API has the notion of an `automobile` resource. Automobiles have an id, a number of wheels, and a name. ```jsonc { "automobiles": [ { "id": 1, "wheels": 4, "name": "Rivian R1T" } ] } ``` However, every specific automobile belongs to a more specialized type. For instance "pickup" which has the additional [fields](#field) of `length` and `4wd` and "racecar" which has the additional field of `topspeed`. ```jsonc { "pickups": [ { "id": 1, "wheels": 4, "name": "Rivian R1T", "length": "12ft", "4wd": true } ], "racecars": [ { "id": 2, "wheels": 4, "name": "Mazda 787B", "topspeed": { "value": 258, "unit": "mph" } } ] } ``` In this case, we can refer to both type `pickup` and type `racecar` as satisfying type `automobile`. We refer to `pickup` and `racecar` as "concrete types" and to `automobile` as an `abstract type`. For more, read about [polymorphism in depth](./relationships/features/polymorphism.md). ### Field ### Schema ### Collection ### Identifier ### Document ### RelationshipDocument *** ## Relationships ### Inverse The "inverse" of a relationship is the compound key generated by considering both the [type](#resource-types) and the `name` of the matching [field](#field) on the related [resource](#resource) . E.g. if Users have Pets and Pets have Owners, then the inverse of the field `user.pets` is `pet.owners`, and the inverse of `pet.owners` is similarly `user.pets`. > **Note** `to-none` relationships have no inverse. We often refer to this as a `null inverse`. ### Self Referential Self referential relationships are relationships that point back at the same resource type. E.g. if a Person has parents and children, the link between `person.parents` and `person.children` is self-referential because both sides belong to the `person` resource type. ### Reflexive Reflexive relationships are self-referential relationships that point back at the same property in addition to the same type. For instance, if a User has friends, where `user.friends` is its own inverse. ### Circular A circular relationship is a self-referential or reflexive relationship for which the *value* is the same on both sides. For instance, if Ego is his own best friend, then `ego.bestFriend === ego` ### Polymorphic Polymorphic relationships can be satisfied by multiple resource types. For instance, a user may have many vehicles, and each vehicle might be of type `car` or `boat` or `airplane` etc. --- --- url: /guide/misc/2-typescript/7-typing-includes.md --- # Typing Includes Many APIs offer the concept of "sideloading" or "including related resources". For instance, when loading a `user` you might also want to load the information for the company where they work, the company's CEO, and a list of the user's friends. Historically this was managed through the `includes` param. For instance, in the example above, the includes array would usually look like this: ```ts { include: ['company', 'company.ceo', 'friends'] } ``` Though some users author this requirement as a string instead: ```ts { include: 'company,company.ceo,friends' } ``` > \[!TIP] > We recommend authoring includes as an array instead of as a string. It will > generally scale better if the list is long, and provides better autocomplete support. > Within WarpDrive/EmberData provided builders and adapters there should be no functional > difference between using an array or using a string. Typing relationship paths like includes is valuable for increased confidence, as small typos in these strings could result in significant application bugs. And, where possible, autocomplete support while typing these strings can help a developer better learn and explore the graph of data available to be loaded. WarpDrive offers several type utilities to assist with strictly typing strings that represent relationship paths: `Includes` and `StringSatisfiesIncludes` ## The `Includes` Type Util The `Includes` type util will return a union of all valid relationship paths discoverable from the input type, within a few constraints. * Cyclical paths are eliminated, so if a user has friends that are users you should never see `user.friends.friends` or `user.friends.company` as options. * There is a configurable MAX\_DEPTH which defaults to `3` to help encourage reduced complexity and better typescript performance * There is an absolute MAX-DEPTH for paths of `5`. If you wish to support longer paths than `5` please reach out to discuss. This limit is in place for performance reasons due to the size of union that gets generated. * If your type/model has non-relationship properties that compute to typed record instances (or arrays of typed record instances) you may encounter false positives for paths. > \[!TIP] > In general, we discourage the usage of `getters` (aka `computed` or `derived` fields) that compute their value from related records. ```ts Includes< T extends TypedRecordInstance, MAX_DEPTH extends _DEPTHCOUNT = DEFAULT_MAX_DEPTH > ``` ### Basic Usage ```ts import type { Includes } from '@warp-drive/core-types/record'; function builderThatAcceptsIncludes(req: { includes: Includes[] // ... other props }); builderThatAcceptsIncludes({ includes: ['friends'] }) ``` ## The `StringSatisfiesIncludes` Type Util Due to limitations in TypeScript and the underlying (poor) algorithmic performance that would result from many approaches, comma-separated-string based include arguments (e.g. `'company,company.ceo,friends'`) aren't typed by-default. However, if you wish to support validating these strings with types, we offer a stand-alone utility with reasonably good performance characteristics and minimal runtime overhead. We mention runtime overhead as it requires creating a function to have it work with reasonable DX. This approach has two main drawbacks: it currently does not autocomplete (though we believe there's a path to making it do so) and its up to the developer to use the validator at the callsite, its not automatic. ### Using the Runtime Function ```ts import { createIncludeValidator } from '@warp-drive/core-types/record'; const userIncludesValidator = createIncludeValidator; function builderThatAcceptsIncludes(req: { includes: string // ... other props }); builderThatAcceptsIncludes({ includes: userIncludesValidator('company,company.ceo,friends') }) ``` ### Using the Type Util Directly The type util that powers `createIncludeValidator` can be used directly; however, we only recommend doing so if writing a wrapper utility similar to `createIncludeValidator` as otherwise it results in needing to type out the string twice. ```ts import type { StringSatisfiesIncludes, Includes } from '@warp-drive/core-types/record'; function builderThatAcceptsIncludes(req: { includes: string // ... other props }); const includes: StringSatisfiedIncludes< 'company,company.ceo,friends', Includes > = 'company,company.ceo,friends'; builderThatAcceptsIncludes({ includes }) ``` --- --- url: /guide/misc/2-typescript/5-typing-models.md --- # Typing Models & Transforms ## Type Example: add the `Type` brand to the `user` model. ```ts import Model, { attr } from '@ember-data/model'; import { Type } from '@warp-drive/core-types/symbols'; export default class User extends Model { @attr declare name: string; [Type] = 'user' as const; } ``` The benefit of the above is that the value of Type is readable at runtime and thus easy to debug. However, you can also choose to do this via types only: ```ts import Model, { attr } from '@ember-data/model'; import type { Type } from '@warp-drive/core-types/symbols'; export default class User extends Model { @attr declare name: string; declare [Type]: 'user'; } ``` EmberData will never access Type as an actual value, these brands are *purely* for type inference. ## Transforms Transforms with a `Type` brand will have their type and options validated. Once we move to stage-3 decorators, the signature of the field would also be validated against the transform. Example: Typing a Transform ```ts import type { Type } from '@warp-drive/core-types/symbols'; export default class BigIntTransform { deserialize(serialized: string): BigInt | null { return !serialized || serialized === '' ? null : BigInt(serialized + 'n'); } serialize(deserialized: BigInt | null): string | null { return !deserialized ? null : String(deserialized); } declare [Type]: 'big-int'; static create() { return new this(); } } ``` Example: Using Transforms ```ts import Model, { attr } from '@ember-data/model'; import type { StringTransform } from '@ember-data/serializer/transforms'; import type { Type } from '@warp-drive/core-types/symbols'; export default class User extends Model { @attr('string') declare name: string; declare [Type]: 'user'; } ``` ## Sync BelongsTo `belongsTo` relationships will have their resource type and options config validated against the passed in type. Once we move to stage-3 decorators, explicitly setting the generic would not be required as it could be infered from the field's type. ```ts import Model, { belongsTo } from '@ember-data/model'; import type Address from './address'; import { Type } from '@warp-drive/core-types/symbols'; export default class User extends Model { @belongsTo
('address', { async: false, inverse: null }) declare address: Address; [Type] = 'user' as const; } ``` ## Async BelongsTo `belongsTo` relationships will have their resource type and options config validated against the passed in type. Once we move to stage-3 decorators, explicitly setting the generic would not be required as it could be infered from the field's type. ```ts import Model, { belongsTo, AsyncBelongsTo } from '@ember-data/model'; import type Address from './address'; import { Type } from '@warp-drive/core-types/symbols'; export default class User extends Model { @belongsTo
('address', { async: true, inverse: null }) declare address: AsyncBelongsTo
; [Type] = 'user' as const; } ``` ## Sync HasMany (data only) If you don't need access to meta or links on relationships, you can type the relationship as just an array. `hasMany` relationships will have their resource type and options config validated against the passed in type. Once we move to stage-3 decorators, explicitly setting the generic would not be required as it could be infered from the field's type. ```ts import Model, { hasMany } from '@ember-data/model'; import type Post from './post'; import { Type } from '@warp-drive/core-types/symbols'; export default class User extends Model { @hasMany('post', { async: false, inverse: 'author' }) declare posts: Post[]; [Type] = 'user' as const; } ``` ## Sync HasMany (with meta, links, etc) `hasMany` relationships will have their resource type and options config validated against the passed in type. Once we move to stage-3 decorators, explicitly setting the generic would not be required as it could be infered from the field's type. ```ts import Model, { hasMany, HasMany } from '@ember-data/model'; import type Post from './post'; import { Type } from '@warp-drive/core-types/symbols'; export default class User extends Model { @hasMany('post', { async: false, inverse: 'author' }) declare posts: HasMany; [Type] = 'user' as const; } ``` ## Async HasMany (restricted) If you don't need access to meta, links or template iterations on relationships, you can type the relationship as just a promise resolving to an array. Only use this if the value will always be awaited before iteration. `hasMany` relationships will have their resource type and options config validated against the passed in type. Once we move to stage-3 decorators, explicitly setting the generic would not be required as it could be infered from the field's type. ```ts import Model, { hasMany, AsyncHasMany } from '@ember-data/model'; import type Post from './post'; import { Type } from '@warp-drive/core-types/symbols'; export default class User extends Model { @hasMany('post', { async: true, inverse: 'author' }) declare posts: Promise; [Type] = 'user' as const; } ``` `Promise>` also works. ## Async HasMany (with links, meta, etc.) `hasMany` relationships will have their resource type and options config validated against the passed in type. Once we move to stage-3 decorators, explicitly setting the generic would not be required as it could be infered from the field's type. ```ts import Model, { hasMany, AsyncHasMany } from '@ember-data/model'; import type Post from './post'; import { Type } from '@warp-drive/core-types/symbols'; export default class User extends Model { @hasMany('post', { async: true, inverse: 'author' }) declare posts: AsyncHasMany; [Type] = 'user' as const; } ``` --- --- url: /guide/2-requests/3-typing-requests.md --- # Typing Requests ## How it works (but what not to do in the general case) `requestManager.request` and `store.request` each take a generic that can be used to set the return type of the content of the associated request. ```ts const { content } = await store.request({ ... }); // here content will be typed as a User ``` > \[!CAUTION] > Note that this puts the burden on you to ensure the return type accurately portrays the result! In all cases, the response will be a `StructuredDocument` where `T` is the content type provided. This approach allows for a lot of flexibility in designing great sugar overtop of the request infrastructure, but again, limits the amount of safety provided and should be used with great caution. A better approach is to use builders and set the generic via inference. ## Setting Content's Type from a Builder The signature for `request` will infer the generic for the content type from a special brand on the options passed to it. ```ts import type { RequestSignature } from '@warp-drive/core-types/symbols'; import type { User } from '../types/data/user'; type MyRequest { // ... [RequestSignature]: CollectionRecordArray } function buildMyRequest(...): MyRequest { /* ... */ } const { content } = await store.request( buildMyRequest(...) ); // here content will be set to `CollectionRecordArray` ``` ## Advanced Builders Because builders are just functions that produce a request options object, and because this object can be branded with the type signature of the response, we can use this to create advanced more-strongly-typed systems. For instance, imagine you had a query builder that validated and linted the query against a backing schema, such as you might get with GraphQL ```ts const { content } = await store.request( gql`query withoutVariable { continents { code name countries { name capital } } }` ); ``` --- --- url: /api/@ember-data/active-record/functions/createRecord.md --- [Documentation](../../../index.md) / [@ember-data/active-record](../index.md) / createRecord ## Call Signature ```ts function createRecord(record, options?): CreateRequestOptions; ``` Defined in: save-record.d.ts:94 Builds request options to create new record for resources, configured for the url, method and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { createRecord } from '@warp-drive/utilities/active-record'; const person = store.createRecord('person', { name: 'Ted' }); const data = await store.request(createRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { createRecord } from '@warp-drive/utilities/active-record'; const person = store.createRecord('person', { name: 'Ted' }); const options = createRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### record `T` #### options? [`ConstrainedRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`CreateRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/CreateRequestOptions.md)<`T`> ## Call Signature ```ts function createRecord(record, options?): CreateRequestOptions; ``` Defined in: save-record.d.ts:95 Builds request options to create new record for resources, configured for the url, method and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { createRecord } from '@warp-drive/utilities/active-record'; const person = store.createRecord('person', { name: 'Ted' }); const data = await store.request(createRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { createRecord } from '@warp-drive/utilities/active-record'; const person = store.createRecord('person', { name: 'Ted' }); const options = createRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Parameters #### record `unknown` #### options? [`ConstrainedRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`CreateRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/CreateRequestOptions.md) --- --- url: /api/@ember-data/active-record/functions/deleteRecord.md --- [Documentation](../../../index.md) / [@ember-data/active-record](../index.md) / deleteRecord ## Call Signature ```ts function deleteRecord(record, options?): DeleteRequestOptions; ``` Defined in: save-record.d.ts:53 Builds request options to delete record for resources, configured for the url, method and header expectations of ActiveRecord APIs. **Basic Usage** ```ts import { deleteRecord } from '@warp-drive/utilities/active-record'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const data = await store.request(deleteRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { deleteRecord } from '@warp-drive/utilities/active-record'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const options = deleteRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### record `T` #### options? [`ConstrainedRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`DeleteRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/DeleteRequestOptions.md)<`T`> ## Call Signature ```ts function deleteRecord(record, options?): DeleteRequestOptions; ``` Defined in: save-record.d.ts:54 Builds request options to delete record for resources, configured for the url, method and header expectations of ActiveRecord APIs. **Basic Usage** ```ts import { deleteRecord } from '@warp-drive/utilities/active-record'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const data = await store.request(deleteRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { deleteRecord } from '@warp-drive/utilities/active-record'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const options = deleteRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Parameters #### record `unknown` #### options? [`ConstrainedRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`DeleteRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/DeleteRequestOptions.md) --- --- url: /api/@ember-data/active-record/functions/findRecord.md --- [Documentation](../../../index.md) / [@ember-data/active-record](../index.md) / findRecord ## Call Signature ```ts function findRecord(identifier, options?): FindRecordRequestOptions, T>; ``` Defined in: find-record.d.ts:62 Builds request options to fetch a single resource by a known id or identifier configured for the url and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const data = await store.request(findRecord('person', '1')); ``` **With Options** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord('person', '1', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **With an Identifier** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### identifier [`RemotelyAccessibleIdentifier`](../../../@warp-drive/core-types/request/type-aliases/RemotelyAccessibleIdentifier.md)<[`TypeFromInstance`](../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`>> #### options? [`FindRecordOptions`](../../../@warp-drive/core-types/request/type-aliases/FindRecordOptions.md)<`T`> ### Returns [`FindRecordRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/FindRecordRequestOptions.md)<`FindRecordResultDocument`<`T`>, `T`> ## Call Signature ```ts function findRecord(identifier, options?): FindRecordRequestOptions; ``` Defined in: find-record.d.ts:63 Builds request options to fetch a single resource by a known id or identifier configured for the url and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const data = await store.request(findRecord('person', '1')); ``` **With Options** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord('person', '1', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **With an Identifier** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' }); const data = await store.request(options); ``` ### Parameters #### identifier [`RemotelyAccessibleIdentifier`](../../../@warp-drive/core-types/request/type-aliases/RemotelyAccessibleIdentifier.md) #### options? [`FindRecordOptions`](../../../@warp-drive/core-types/request/type-aliases/FindRecordOptions.md) ### Returns [`FindRecordRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/FindRecordRequestOptions.md) ## Call Signature ```ts function findRecord( type, id, options?): FindRecordRequestOptions, T>; ``` Defined in: find-record.d.ts:64 Builds request options to fetch a single resource by a known id or identifier configured for the url and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const data = await store.request(findRecord('person', '1')); ``` **With Options** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord('person', '1', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **With an Identifier** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### type [`TypeFromInstance`](../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> #### id `string` #### options? [`FindRecordOptions`](../../../@warp-drive/core-types/request/type-aliases/FindRecordOptions.md)<`T`> ### Returns [`FindRecordRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/FindRecordRequestOptions.md)<`FindRecordResultDocument`<`T`>, `T`> ## Call Signature ```ts function findRecord( type, id, options?): FindRecordRequestOptions; ``` Defined in: find-record.d.ts:65 Builds request options to fetch a single resource by a known id or identifier configured for the url and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const data = await store.request(findRecord('person', '1')); ``` **With Options** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord('person', '1', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **With an Identifier** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' }); const data = await store.request(options); ``` ### Parameters #### type `string` #### id `string` #### options? [`FindRecordOptions`](../../../@warp-drive/core-types/request/type-aliases/FindRecordOptions.md) ### Returns [`FindRecordRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/FindRecordRequestOptions.md) --- --- url: /api/@ember-data/active-record/functions/query.md --- [Documentation](../../../index.md) / [@ember-data/active-record](../index.md) / query ## Call Signature ```ts function query( type, query?, options?): QueryRequestOptions, T>; ``` Defined in: query.d.ts:52 Builds request options to query for resources, usually by a primary type, configured for the url and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { query } from '@warp-drive/utilities/active-record'; const data = await store.request(query('person')); ``` **With Query Params** ```ts import { query } from '@warp-drive/utilities/active-record'; const options = query('person', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { query } from '@warp-drive/utilities/active-record'; const options = query('person', { include: ['pets', 'friends'] }, { reload: true }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### type [`TypeFromInstance`](../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> #### query? [`QueryParamsSource`](../../../@warp-drive/core-types/params/type-aliases/QueryParamsSource.md) #### options? [`ConstrainedRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`QueryRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/QueryRequestOptions.md)<[`CollectionResourceDataDocument`](../../../@warp-drive/core-types/spec/document/interfaces/CollectionResourceDataDocument.md)<`T`>, `T`> ## Call Signature ```ts function query( type, query?, options?): QueryRequestOptions; ``` Defined in: query.d.ts:53 Builds request options to query for resources, usually by a primary type, configured for the url and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { query } from '@warp-drive/utilities/active-record'; const data = await store.request(query('person')); ``` **With Query Params** ```ts import { query } from '@warp-drive/utilities/active-record'; const options = query('person', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { query } from '@warp-drive/utilities/active-record'; const options = query('person', { include: ['pets', 'friends'] }, { reload: true }); const data = await store.request(options); ``` ### Parameters #### type `string` #### query? [`QueryParamsSource`](../../../@warp-drive/core-types/params/type-aliases/QueryParamsSource.md) #### options? [`ConstrainedRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`QueryRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/QueryRequestOptions.md) --- --- url: /api/@ember-data/active-record/functions/updateRecord.md --- [Documentation](../../../index.md) / [@ember-data/active-record](../index.md) / updateRecord ## Call Signature ```ts function updateRecord(record, options?): UpdateRequestOptions>, T>; ``` Defined in: save-record.d.ts:138 Builds request options to update existing record for resources, configured for the url, method and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { updateRecord } from '@warp-drive/utilities/active-record'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const data = await store.request(updateRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`. * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { updateRecord } from '@warp-drive/utilities/active-record'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const options = updateRecord(person, { patch: true }); const data = await store.request(options); ``` ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../../../@warp-drive/core-types/record/interfaces/TypedRecordInstance.md) #### RT `RT` *extends* [`TypedRecordInstance`](../../../@warp-drive/core-types/record/interfaces/TypedRecordInstance.md) = `T` ### Parameters #### record `T` #### options? [`ConstrainedRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) & `object` ### Returns [`UpdateRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/UpdateRequestOptions.md)<[`SingleResourceDataDocument`](../../../@warp-drive/core-types/spec/document/interfaces/SingleResourceDataDocument.md)<`RT`, `StableExistingRecordIdentifier`<`string`>>, `T`> ## Call Signature ```ts function updateRecord(record, options?): UpdateRequestOptions; ``` Defined in: save-record.d.ts:141 Builds request options to update existing record for resources, configured for the url, method and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { updateRecord } from '@warp-drive/utilities/active-record'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const data = await store.request(updateRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`. * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { updateRecord } from '@warp-drive/utilities/active-record'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const options = updateRecord(person, { patch: true }); const data = await store.request(options); ``` ### Parameters #### record `unknown` #### options? [`ConstrainedRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) & `object` ### Returns [`UpdateRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/UpdateRequestOptions.md) --- --- url: /api/@ember-data/active-record.md --- [Documentation](../../index.md) / @ember-data/active-record This package provides utilities for working with [ActiveRecord](https://guides.rubyonrails.org/active_record_basics.html#convention-over-configuration-in-active-record) APIs. ## Installation Install using your javascript package manager of choice. For instance with [pnpm](https://pnpm.io/) ::: code-group ```sh [pnpm] pnpm add -E @ember-data/active-record ``` ```sh [npm] npm add -E @ember-data/active-record ``` ```sh [yarn] yarn add -E @ember-data/active-record ``` ```sh [bun] bun add --exact @ember-data/active-record ``` ::: ## Usage Request builders are functions that produce [Fetch Options](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). They take a few contextual inputs about the request you want to make, abstracting away the gnarlier details. For instance, to construct a request that would fetch a resource from your API: ```ts import { findRecord } from '@ember-data/active-record/request'; const options = findRecord('ember-developer', '1', { include: ['pets', 'friends'] }); ``` This would produce the following request object: ```js { url: 'https://api.example.com/v1/ember_developers/1?include=friends,pets', method: 'GET', headers: , // 'Accept': 'application/json;charset=utf-8' op: 'findRecord'; records: [{ type: 'ember-developer', id: '1' }] } ``` Request builder output may be used with either `requestManager.request` or `store.request`. ```ts const data = await store.request(options); ``` URLs are stable. The same query will produce the same URL every time, even if the order of keys in the query or values in an array changes. URLs follow the most common ActiveRecord format (underscored pluralized resource types). ## Functions * [createRecord](functions/createRecord.md) * [deleteRecord](functions/deleteRecord.md) * [findRecord](functions/findRecord.md) * [query](functions/query.md) * [updateRecord](functions/updateRecord.md) --- --- url: /api/@ember-data/adapter/error/classes/ConflictError.md --- [Documentation](../../../../index.md) / [@ember-data/adapter](../../index.md) / [error](../index.md) / ConflictError Defined in: warp-drive-packages/legacy/declarations/adapter/error.d.ts:26 ## Properties ### code ```ts code: string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/error.d.ts:28 --- --- url: /api/@ember-data/adapter/error/classes/AbortError.md --- [Documentation](../../../../index.md) / [@ember-data/adapter](../../index.md) / [error](../index.md) / AbortError Defined in: warp-drive-packages/legacy/declarations/adapter/error.d.ts:10 ## Properties ### code ```ts code: string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/error.d.ts:12 --- --- url: /api/@ember-data/adapter/error/classes/ForbiddenError.md --- [Documentation](../../../../index.md) / [@ember-data/adapter](../../index.md) / [error](../index.md) / ForbiddenError Defined in: warp-drive-packages/legacy/declarations/adapter/error.d.ts:18 ## Properties ### code ```ts code: string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/error.d.ts:20 --- --- url: /api/@ember-data/adapter/error/classes/InvalidError.md --- [Documentation](../../../../index.md) / [@ember-data/adapter](../../index.md) / [error](../index.md) / InvalidError Defined in: warp-drive-packages/legacy/declarations/adapter/error.d.ts:2 ## Properties ### code ```ts code: string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/error.d.ts:4 --- --- url: /api/@ember-data/adapter/error/classes/NotFoundError.md --- [Documentation](../../../../index.md) / [@ember-data/adapter](../../index.md) / [error](../index.md) / NotFoundError Defined in: warp-drive-packages/legacy/declarations/adapter/error.d.ts:22 ## Properties ### code ```ts code: string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/error.d.ts:24 --- --- url: /api/@ember-data/adapter/error/classes/ServerError.md --- [Documentation](../../../../index.md) / [@ember-data/adapter](../../index.md) / [error](../index.md) / ServerError Defined in: warp-drive-packages/legacy/declarations/adapter/error.d.ts:30 ## Properties ### code ```ts code: string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/error.d.ts:32 --- --- url: /api/@ember-data/adapter/error/classes/TimeoutError.md --- [Documentation](../../../../index.md) / [@ember-data/adapter](../../index.md) / [error](../index.md) / TimeoutError Defined in: warp-drive-packages/legacy/declarations/adapter/error.d.ts:6 ## Properties ### code ```ts code: string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/error.d.ts:8 --- --- url: /api/@ember-data/adapter/error/classes/UnauthorizedError.md --- [Documentation](../../../../index.md) / [@ember-data/adapter](../../index.md) / [error](../index.md) / UnauthorizedError Defined in: warp-drive-packages/legacy/declarations/adapter/error.d.ts:14 ## Properties ### code ```ts code: string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/error.d.ts:16 --- --- url: /api/@ember-data/adapter/error.md --- [Documentation](../../../index.md) / [@ember-data/adapter](../index.md) / error ## Classes * [AbortError](classes/AbortError.md) * [ConflictError](classes/ConflictError.md) * [ForbiddenError](classes/ForbiddenError.md) * [InvalidError](classes/InvalidError.md) * [NotFoundError](classes/NotFoundError.md) * [ServerError](classes/ServerError.md) * [TimeoutError](classes/TimeoutError.md) * [UnauthorizedError](classes/UnauthorizedError.md) ## Variables * [default](variables/default.md) --- --- url: /api/@ember-data/adapter/error/variables/default.md --- [Documentation](../../../../index.md) / [@ember-data/adapter](../../index.md) / [error](../index.md) / default ```ts const default: typeof _AdapterError; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/error.d.ts:1 --- --- url: /api/@ember-data/adapter.md --- [Documentation](../../index.md) / @ember-data/adapter ## Modules * [error](error/index.md) * [index](index/index.md) * [json-api](json-api/index.md) * [rest](rest/index.md) --- --- url: /api/@ember-data/adapter/index/classes/default.md --- [Documentation](../../../../index.md) / [@ember-data/adapter](../../index.md) / [index](../index.md) / default Defined in: warp-drive-packages/legacy/declarations/adapter.d.ts:249 An adapter is an object that receives requests from a store and translates them into the appropriate action to take against your persistence layer. The persistence layer is usually an HTTP API but may be anything, such as the browser's local storage. Typically the adapter is not invoked directly instead its functionality is accessed through the `store`. > ⚠️ CAUTION you likely want the docs for [MinimumAdapterInterface](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md) > as extending this abstract class is unnecessary. ### Creating an Adapter Create a new subclass of `Adapter` in the `app/adapters` folder: ```js [app/adapters/application.js] import { Adapter } from '@warp-drive/legacy/adapter'; export default class extends Adapter { // ...your code here } ``` Model-specific adapters can be created by putting your adapter class in an `app/adapters/` + `model-name` + `.js` file of the application. ```js [app/adapters/post.js] import { Adapter } from '@warp-drive/legacy/adapter'; export default class extends Adapter { // ...Post-specific adapter code goes here } ``` `Adapter` is an abstract base class that you should override in your application to customize it for your backend. The minimum set of methods that you should implement is: * `findRecord()` * `createRecord()` * `updateRecord()` * `deleteRecord()` * `findAll()` * `query()` To improve the network performance of your application, you can optimize your adapter by overriding these lower-level methods: * `findMany()` For an example of the implementation, see `RESTAdapter`, the included REST adapter. Adapter ## Extends * `unknown` ## Implements * [`MinimumAdapterInterface`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md) ## Constructors ### Constructor ```ts new default(): Adapter; ``` #### Returns `Adapter` #### Inherited from ```ts EmberObject.constructor ``` ## Properties ### \_coalesceFindRequests ```ts _coalesceFindRequests: boolean; ``` Defined in: warp-drive-packages/legacy/declarations/adapter.d.ts:251 *** ### store ```ts store: default; ``` Defined in: warp-drive-packages/legacy/declarations/adapter.d.ts:250 ## Accessors ### coalesceFindRequests #### Get Signature ```ts get coalesceFindRequests(): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/adapter.d.ts:580 By default the store will try to coalesce all `findRecord` calls within the same runloop into as few requests as possible by calling groupRecordsForFindMany and passing it into a findMany call. You can opt out of this behaviour by either not implementing the findMany hook or by setting coalesceFindRequests to false. ##### Returns `boolean` #### Set Signature ```ts set coalesceFindRequests(value): void; ``` Defined in: warp-drive-packages/legacy/declarations/adapter.d.ts:581 **`Optional`** If your adapter implements `findMany`, setting this to `true` will cause `findRecord` requests triggered within the same `runloop` to be coalesced into one or more calls to `adapter.findMany`. The number of calls made and the records contained in each call can be tuned by your adapter's `groupRecordsForHasMany` method. Implementing coalescing using this flag and the associated methods does not always offer the right level of correctness, timing control or granularity. If your application would be better suited coalescing across multiple types, coalescing for longer than a single runloop, or with a more custom request structure, coalescing within your application adapter may prove more effective. ##### Parameters ###### value `boolean` ##### Returns `void` **`Optional`** If your adapter implements `findMany`, setting this to `true` will cause `findRecord` requests triggered within the same `runloop` to be coalesced into one or more calls to `adapter.findMany`. The number of calls made and the records contained in each call can be tuned by your adapter's `groupRecordsForHasMany` method. Implementing coalescing using this flag and the associated methods does not always offer the right level of correctness, timing control or granularity. If your application would be better suited coalescing across multiple types, coalescing for longer than a single runloop, or with a more custom request structure, coalescing within your application adapter may prove more effective. #### Implementation of [`MinimumAdapterInterface`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md).[`coalesceFindRequests`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md#coalescefindrequests) ## Methods ### createRecord() ```ts createRecord( store, type, snapshot): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter.d.ts:477 Implement this method in a subclass to handle the creation of new records. Serializes the record and sends it to the server. Example ```js [app/adapters/application.js] import { Adapter } from '@warp-drive/legacy/adapter'; import RSVP from 'RSVP'; import $ from 'jquery'; export default class ApplicationAdapter extends Adapter { createRecord(store, type, snapshot) { let data = this.serialize(snapshot, { includeId: true }); return new RSVP.Promise(function (resolve, reject) { $.ajax({ type: 'POST', url: `/${type.modelName}`, dataType: 'json', data: data }).then(function (data) { resolve(data); }, function (jqXHR) { jqXHR.then = null; // tame jQuery's ill mannered promises reject(jqXHR); }); }); } } ``` #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### type [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) the Model class of the record ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise #### Implementation of [`MinimumAdapterInterface`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md).[`createRecord`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md#createrecord) *** ### deleteRecord() ```ts deleteRecord( store, type, snapshot): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter.d.ts:569 Implement this method in a subclass to handle the deletion of a record. Sends a delete request for the record to the server. Example ```js [app/adapters/application.js] import { Adapter } from '@warp-drive/legacy/adapter'; import RSVP from 'RSVP'; import $ from 'jquery'; export default class ApplicationAdapter extends Adapter { deleteRecord(store, type, snapshot) { let data = this.serialize(snapshot, { includeId: true }); let id = snapshot.id; return new RSVP.Promise(function(resolve, reject) { $.ajax({ type: 'DELETE', url: `/${type.modelName}/${id}`, dataType: 'json', data: data }).then(function(data) { resolve(data) }, function(jqXHR) { jqXHR.then = null; // tame jQuery's ill mannered promises reject(jqXHR); }); }); } } ``` #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### type [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) the Model class of the record ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise #### Implementation of [`MinimumAdapterInterface`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md).[`deleteRecord`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md#deleterecord) *** ### findAll() ```ts findAll( store, type, neverSet, snapshotRecordArray): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter.d.ts:317 The `findAll()` method is used to retrieve all records for a given type. Example ```js [app/adapters/application.js] import { Adapter } from '@warp-drive/legacy/adapter'; import RSVP from 'RSVP'; import $ from 'jquery'; export default class ApplicationAdapter extends Adapter { findAll(store, type) { return new RSVP.Promise(function(resolve, reject) { $.getJSON(`/${type.modelName}`).then(function(data) { resolve(data); }, function(jqXHR) { reject(jqXHR); }); }); } } ``` #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### type [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### neverSet `null` a value is never provided to this argument ##### snapshotRecordArray `SnapshotRecordArray` #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise #### Implementation of [`MinimumAdapterInterface`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md).[`findAll`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md#findall) *** ### findRecord() ```ts findRecord( store, type, id, snapshot): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter.d.ts:286 The `findRecord()` method is invoked when the store is asked for a record that has not previously been loaded. In response to `findRecord()` being called, you should query your persistence layer for a record with the given ID. The `findRecord` method should return a promise that will resolve to a JavaScript object that will be normalized by the serializer. Here is an example of the `findRecord` implementation: ```js [app/adapters/application.js] import { Adapter } from '@warp-drive/legacy/adapter'; import RSVP from 'RSVP'; import $ from 'jquery'; export default class ApplicationAdapter extends Adapter { findRecord(store, type, id, snapshot) { return new RSVP.Promise(function(resolve, reject) { $.getJSON(`/${type.modelName}/${id}`).then(function(data) { resolve(data); }, function(jqXHR) { reject(jqXHR); }); }); } } ``` #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### type [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### id `string` ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise #### Implementation of [`MinimumAdapterInterface`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md).[`findRecord`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md#findrecord) *** ### groupRecordsForFindMany() ```ts groupRecordsForFindMany(store, snapshots): Snapshot[][]; ``` Defined in: warp-drive-packages/legacy/declarations/adapter.d.ts:633 Organize records into groups, each of which is to be passed to separate calls to `findMany`. For example, if your API has nested URLs that depend on the parent, you will want to group records by their parent. The default implementation returns the records as a single group. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### snapshots `Snapshot`<`unknown`>\[] #### Returns `Snapshot`<`unknown`>\[]\[] an array of arrays of records, each of which is to be loaded separately by `findMany`. #### Implementation of [`MinimumAdapterInterface`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md).[`groupRecordsForFindMany`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md#grouprecordsforfindmany) *** ### query() ```ts query( store, type, query): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter.d.ts:349 This method is called when you call `query` on the store. Example ```js [app/adapters/application.js] import { Adapter } from '@warp-drive/legacy/adapter'; import RSVP from 'RSVP'; import $ from 'jquery'; export default class ApplicationAdapter extends Adapter { query(store, type, query) { return new RSVP.Promise(function(resolve, reject) { $.getJSON(`/${type.modelName}`, query).then(function(data) { resolve(data); }, function(jqXHR) { reject(jqXHR); }); }); } } ``` #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### type [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### query `any` #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise #### Implementation of [`MinimumAdapterInterface`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md).[`query`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md#query) *** ### queryRecord() ```ts queryRecord( store, type, query, adapterOptions): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter.d.ts:380 The `queryRecord()` method is invoked when the store is asked for a single record through a query object. In response to `queryRecord()` being called, you should always fetch fresh data. Once found, you can asynchronously call the store's `push()` method to push the record into the store. Here is an example `queryRecord` implementation: Example ```js [app/adapters/application.js] import { Adapter, BuildURLMixin } from '@warp-drive/legacy/adapter'; export default class ApplicationAdapter extends Adapter.extend(BuildURLMixin) { queryRecord(store, type, query) { return fetch(`/${type.modelName}`, { body: JSON.stringify(query) }) .then((response) => response.json()); } } ``` #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### type [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### query `any` ##### adapterOptions `any` #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise #### Implementation of [`MinimumAdapterInterface`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md).[`queryRecord`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md#queryrecord) *** ### serialize() ```ts serialize(snapshot, options): Record; ``` Defined in: warp-drive-packages/legacy/declarations/adapter.d.ts:436 Proxies to the serializer's `serialize` method. Example ```js [app/adapters/application.js] import { Adapter } from '@warp-drive/legacy/adapter'; export default class ApplicationAdapter extends Adapter { createRecord(store, type, snapshot) { let data = this.serialize(snapshot, { includeId: true }); let url = `/${type.modelName}`; // ... } } ``` #### Parameters ##### snapshot `Snapshot` ##### options [`SerializerOptions`](../../../legacy-compat/index/type-aliases/SerializerOptions.md) #### Returns `Record`<`string`, `unknown`> serialized snapshot *** ### shouldBackgroundReloadAll() ```ts shouldBackgroundReloadAll(store, snapshotRecordArray): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/adapter.d.ts:798 This method is used by the store to determine if the store should reload a record array after the `store.findAll` method resolves with a cached record array. This method is *only* checked by the store when the store is returning a cached record array. If this method returns `true` the store will re-fetch all records from the adapter. For example, if you do not want to fetch complex data over a mobile connection, or if the network is down, you can implement `shouldBackgroundReloadAll` as follows: ```javascript shouldBackgroundReloadAll(store, snapshotArray) { let { downlink, effectiveType } = navigator.connection; return downlink > 0 && effectiveType === '4g'; } ``` By default this method returns `true`, indicating that a background reload should always be triggered. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### snapshotRecordArray `SnapshotRecordArray` #### Returns `boolean` #### Since 1.13.0 #### Implementation of [`MinimumAdapterInterface`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md).[`shouldBackgroundReloadAll`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md#shouldbackgroundreloadall) *** ### shouldBackgroundReloadRecord() ```ts shouldBackgroundReloadRecord(store, snapshot): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/adapter.d.ts:765 This method is used by the store to determine if the store should reload a record after the `store.findRecord` method resolves a cached record. This method is *only* checked by the store when the store is returning a cached record. If this method returns `true` the store will re-fetch a record from the adapter. For example, if you do not want to fetch complex data over a mobile connection, or if the network is down, you can implement `shouldBackgroundReloadRecord` as follows: ```javascript shouldBackgroundReloadRecord(store, snapshot) { let { downlink, effectiveType } = navigator.connection; return downlink > 0 && effectiveType === '4g'; } ``` By default, this hook returns `true` so the data for the record is updated in the background. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### snapshot `Snapshot` #### Returns `boolean` #### Since 1.13.0 #### Implementation of [`MinimumAdapterInterface`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md).[`shouldBackgroundReloadRecord`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md#shouldbackgroundreloadrecord) *** ### shouldReloadAll() ```ts shouldReloadAll(store, snapshotRecordArray): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/adapter.d.ts:732 This method is used by the store to determine if the store should reload all records from the adapter when records are requested by `store.findAll`. If this method returns `true`, the store will re-fetch all records from the adapter. If this method returns `false`, the store will resolve immediately using the cached records. For example, if you are building an events ticketing system, in which users can only reserve tickets for 20 minutes at a time, and want to ensure that in each route you have data that is no more than 20 minutes old you could write: ```javascript shouldReloadAll(store, snapshotArray) { let snapshots = snapshotArray.snapshots(); return snapshots.any((ticketSnapshot) => { let lastAccessedAt = ticketSnapshot.attr('lastAccessedAt'); let timeDiff = moment().diff(lastAccessedAt, 'minutes'); if (timeDiff > 20) { return true; } else { return false; } }); } ``` This method would ensure that whenever you do `store.findAll('ticket')` you will always get a list of tickets that are no more than 20 minutes old. In case a cached version is more than 20 minutes old, `findAll` will not resolve until you fetched the latest versions. By default, this method returns `true` if the passed `snapshotRecordArray` is empty (meaning that there are no records locally available yet), otherwise, it returns `false`. Note that, with default settings, `shouldBackgroundReloadAll` will always re-fetch all the records in the background even if `shouldReloadAll` returns `false`. You can override `shouldBackgroundReloadAll` if this does not suit your use case. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### snapshotRecordArray `SnapshotRecordArray` #### Returns `boolean` #### Since 1.13.0 #### Implementation of [`MinimumAdapterInterface`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md).[`shouldReloadAll`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md#shouldreloadall) *** ### shouldReloadRecord() ```ts shouldReloadRecord(store, snapshot): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/adapter.d.ts:680 This method is used by the store to determine if the store should reload a record from the adapter when a record is requested by `store.findRecord`. If this method returns `true`, the store will re-fetch a record from the adapter. If this method returns `false`, the store will resolve immediately using the cached record. For example, if you are building an events ticketing system, in which users can only reserve tickets for 20 minutes at a time, and want to ensure that in each route you have data that is no more than 20 minutes old you could write: ```javascript shouldReloadRecord(store, ticketSnapshot) { let lastAccessedAt = ticketSnapshot.attr('lastAccessedAt'); let timeDiff = moment().diff(lastAccessedAt, 'minutes'); if (timeDiff > 20) { return true; } else { return false; } } ``` This method would ensure that whenever you do `store.findRecord('ticket', id)` you will always get a ticket that is no more than 20 minutes old. In case the cached version is more than 20 minutes old, `findRecord` will not resolve until you fetched the latest version. By default this hook returns `false`, as most UIs should not block user interactions while waiting on data update. Note that, with default settings, `shouldBackgroundReloadRecord` will always re-fetch the records in the background even if `shouldReloadRecord` returns `false`. You can override `shouldBackgroundReloadRecord` if this does not suit your use case. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### snapshot `Snapshot` #### Returns `boolean` #### Since 1.13.0 #### Implementation of [`MinimumAdapterInterface`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md).[`shouldReloadRecord`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md#shouldreloadrecord) *** ### updateRecord() ```ts updateRecord( store, type, snapshot): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter.d.ts:527 Implement this method in a subclass to handle the updating of a record. Serializes the record update and sends it to the server. The updateRecord method is expected to return a promise that will resolve with the serialized record. This allows the backend to inform the Ember Data store the current state of this record after the update. If it is not possible to return a serialized record the updateRecord promise can also resolve with `undefined` and the Ember Data store will assume all of the updates were successfully applied on the backend. Example ```js [app/adapters/application.js] import { Adapter } from '@warp-drive/legacy/adapter'; import RSVP from 'RSVP'; import $ from 'jquery'; export default class ApplicationAdapter extends Adapter { updateRecord(store, type, snapshot) { let data = this.serialize(snapshot, { includeId: true }); let id = snapshot.id; return new RSVP.Promise(function(resolve, reject) { $.ajax({ type: 'PUT', url: `/${type.modelName}/${id}`, dataType: 'json', data: data }).then(function(data) { resolve(data); }, function(jqXHR) { jqXHR.then = null; // tame jQuery's ill mannered promises reject(jqXHR); }); }); } } ``` #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### type [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) the Model class of the record ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise #### Implementation of [`MinimumAdapterInterface`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md).[`updateRecord`](../../../legacy-compat/index/interfaces/MinimumAdapterInterface.md#updaterecord) --- --- url: /api/@ember-data/adapter/index.md --- [Documentation](../../../index.md) / [@ember-data/adapter](../index.md) / index ## Classes * [default](classes/default.md) ## Interfaces * [BuildURLMixin](interfaces/BuildURLMixin.md) ## Variables * [BuildURLMixin](variables/BuildURLMixin.md) --- --- url: /api/@ember-data/adapter/index/interfaces/BuildURLMixin.md --- [Documentation](../../../../index.md) / [@ember-data/adapter](../../index.md) / [index](../index.md) / BuildURLMixin Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:3 ## Methods ### \_buildURL() ```ts _buildURL( this, modelName, id?): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:15 #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `undefined` | `null` | `string` ##### id? `null` | `string` #### Returns `string` *** ### buildURL() #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:4 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"findRecord"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:5 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` ###### snapshot `SnapshotRecordArray` ###### requestType `"findAll"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType, query): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:6 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` ###### snapshot `null` ###### requestType `"query"` ###### query `Record`<`string`, `unknown`> ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType, query): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:7 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` ###### snapshot `null` ###### requestType `"queryRecord"` ###### query `Record`<`string`, `unknown`> ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:8 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string`\[] ###### snapshot `Snapshot`<`unknown`>\[] ###### requestType `"findMany"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:9 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"findHasMany"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:10 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"findBelongsTo"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:11 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` | `string` ###### snapshot `Snapshot` ###### requestType `"createRecord"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:12 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"updateRecord"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:13 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"deleteRecord"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:14 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ##### Returns `string` *** ### pathForType() ```ts pathForType(this, modelName): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:27 #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `string` #### Returns `string` *** ### urlForCreateRecord() ```ts urlForCreateRecord( this, modelName, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:23 #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` *** ### urlForDeleteRecord() ```ts urlForDeleteRecord( this, id, modelName, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:25 #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` *** ### urlForFindAll() ```ts urlForFindAll( this, modelName, snapshots): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:17 #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `string` ##### snapshots `SnapshotRecordArray` #### Returns `string` *** ### urlForFindBelongsTo() ```ts urlForFindBelongsTo( this, id, modelName, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:22 #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` *** ### urlForFindHasMany() ```ts urlForFindHasMany( this, id, modelName, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:21 #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` *** ### urlForFindMany() ```ts urlForFindMany( this, ids, modelName, snapshots): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:20 #### Parameters ##### this `MixtBuildURLMixin` ##### ids `string`\[] ##### modelName `string` ##### snapshots `Snapshot`<`unknown`>\[] #### Returns `string` *** ### urlForFindRecord() ```ts urlForFindRecord( this, id, modelName, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:16 #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` *** ### urlForQuery() ```ts urlForQuery( this, query, modelName): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:19 #### Parameters ##### this `MixtBuildURLMixin` ##### query `Record`<`string`, `unknown`> ##### modelName `string` #### Returns `string` *** ### urlForQueryRecord() ```ts urlForQueryRecord( this, query, modelName): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:18 #### Parameters ##### this `MixtBuildURLMixin` ##### query `Record`<`string`, `unknown`> ##### modelName `string` #### Returns `string` *** ### urlForUpdateRecord() ```ts urlForUpdateRecord( this, id, modelName, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:24 #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` *** ### urlPrefix() ```ts urlPrefix( this, path?, parentURL?): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:26 #### Parameters ##### this `MixtBuildURLMixin` ##### path? `null` | `string` ##### parentURL? `string` #### Returns `string` --- --- url: /api/@ember-data/adapter/index/variables/BuildURLMixin.md --- [Documentation](../../../../index.md) / [@ember-data/adapter](../../index.md) / [index](../index.md) / BuildURLMixin ```ts BuildURLMixin: Mixin; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:3 --- --- url: /api/@ember-data/adapter/json-api/classes/default.md --- [Documentation](../../../../index.md) / [@ember-data/adapter](../../index.md) / [json-api](../index.md) / default Defined in: warp-drive-packages/legacy/declarations/adapter/json-api.d.ts:151 ## Overview The `JSONAPIAdapter` is an adapter whichtransforms the store's requests into HTTP requests that follow the [JSON API format](http://jsonapi.org/format/). ## JSON API Conventions The JSONAPIAdapter uses JSON API conventions for building the URL for a record and selecting the HTTP verb to use with a request. The actions you can take on a record map onto the following URLs in the JSON API adapter: ## Success and failure The JSONAPIAdapter will consider a success any response with a status code of the 2xx family ("Success"), as well as 304 ("Not Modified"). Any other status code will be considered a failure. On success, the request promise will be resolved with the full response payload. Failed responses with status code 422 ("Unprocessable Entity") will be considered "invalid". The response will be discarded, except for the `errors` key. The request promise will be rejected with a `InvalidError`. This error object will encapsulate the saved `errors` value. Any other status codes will be treated as an adapter error. The request promise will be rejected, similarly to the invalid case, but with an instance of `AdapterError` instead. ### Endpoint path customization Endpoint paths can be prefixed with a `namespace` by setting the namespace property on the adapter: ```js [app/adapters/application.js] import JSONAPIAdapter from '@ember-data/adapter/json-api'; export default class ApplicationAdapter extends JSONAPIAdapter { namespace = 'api/1'; } ``` Requests for the `person` model would now target `/api/1/people/1`. ### Host customization An adapter can target other hosts by setting the `host` property. ```js [app/adapters/application.js] import JSONAPIAdapter from '@ember-data/adapter/json-api'; export default class ApplicationAdapter extends JSONAPIAdapter { host = 'https://api.example.com'; } ``` Requests for the `person` model would now target `https://api.example.com/people/1`. ## Since 1.13.0 JSONAPIAdapter ## Extends * [`default`](../../rest/classes/default.md) ## Constructors ### Constructor ```ts new default(): JSONAPIAdapter; ``` #### Returns `JSONAPIAdapter` #### Inherited from [`default`](../../rest/classes/default.md).[`constructor`](../../rest/classes/default.md#constructor) ## Properties ### \_coalesceFindRequests ```ts _coalesceFindRequests: boolean; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:260 #### Inherited from [`default`](../../rest/classes/default.md).[`_coalesceFindRequests`](../../rest/classes/default.md#_coalescefindrequests) *** ### \_defaultContentType ```ts _defaultContentType: string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/json-api.d.ts:152 #### Overrides [`default`](../../rest/classes/default.md).[`_defaultContentType`](../../rest/classes/default.md#_defaultcontenttype) *** ### \_fastboot ```ts _fastboot: FastBoot; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:259 #### Inherited from [`default`](../../rest/classes/default.md).[`_fastboot`](../../rest/classes/default.md#_fastboot) *** ### headers ```ts headers: undefined | Record; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:427 Some APIs require HTTP headers, e.g. to provide an API key. Arbitrary headers can be set as key/value pairs on the `RESTAdapter`'s `headers` object and Ember Data will send them along with each ajax request. For dynamic headers see [headers customization](/ember-data/release/classes/RESTAdapter). ```js [app/adapters/application.js] import { RESTAdapter } from '@warp-drive/legacy/adapter/rest'; export default class ApplicationAdapter extends RESTAdapter { get headers() { return { 'API_KEY': 'secret key', 'ANOTHER_HEADER': 'Some header value' }; } } ``` #### Inherited from [`default`](../../rest/classes/default.md).[`headers`](../../rest/classes/default.md#headers) *** ### host ```ts host: null | string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:261 #### Inherited from [`default`](../../rest/classes/default.md).[`host`](../../rest/classes/default.md#host) *** ### maxURLLength ```ts maxURLLength: number; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:656 #### Inherited from [`default`](../../rest/classes/default.md).[`maxURLLength`](../../rest/classes/default.md#maxurllength) *** ### namespace ```ts namespace: null | string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:262 #### Inherited from [`default`](../../rest/classes/default.md).[`namespace`](../../rest/classes/default.md#namespace) *** ### useFetch ```ts useFetch: boolean; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:271 This property allows ajax to still be used instead when `false`. #### Default ```ts true @public ``` #### Inherited from [`default`](../../rest/classes/default.md).[`useFetch`](../../rest/classes/default.md#usefetch) ## Accessors ### coalesceFindRequests #### Get Signature ```ts get coalesceFindRequests(): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/json-api.d.ts:217 By default the JSONAPIAdapter will send each find request coming from a `store.find` or from accessing a relationship separately to the server. If your server supports passing ids as a query string, you can set coalesceFindRequests to true to coalesce all find requests within a single runloop. For example, if you have an initial payload of: ```javascript { data: { id: 1, type: 'post', relationship: { comments: { data: [ { id: 1, type: 'comment' }, { id: 2, type: 'comment' } ] } } } } ``` By default calling `post.comments` will trigger the following requests(assuming the comments haven't been loaded before): ``` GET /comments/1 GET /comments/2 ``` If you set coalesceFindRequests to `true` it will instead trigger the following request: ``` GET /comments?filter[id]=1,2 ``` Setting coalesceFindRequests to `true` also works for `store.find` requests and `belongsTo` relationships accessed within the same runloop. If you set `coalesceFindRequests: true` ```javascript store.findRecord('comment', 1); store.findRecord('comment', 2); ``` will also send a request to: `GET /comments?filter[id]=1,2` Note: Requests coalescing rely on URL building strategy. So if you override `buildURL` in your app `groupRecordsForFindMany` more likely should be overridden as well in order for coalescing to work. ##### Returns `boolean` #### Set Signature ```ts set coalesceFindRequests(value): void; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/json-api.d.ts:218 By default the RESTAdapter will send each find request coming from a `store.find` or from accessing a relationship separately to the server. If your server supports passing ids as a query string, you can set coalesceFindRequests to true to coalesce all find requests within a single runloop. For example, if you have an initial payload of: ```javascript { post: { id: 1, comments: [1, 2] } } ``` By default calling `post.comments` will trigger the following requests(assuming the comments haven't been loaded before): ``` GET /comments/1 GET /comments/2 ``` If you set coalesceFindRequests to `true` it will instead trigger the following request: ``` GET /comments?ids[]=1&ids[]=2 ``` Setting coalesceFindRequests to `true` also works for `store.find` requests and `belongsTo` relationships accessed within the same runloop. If you set `coalesceFindRequests: true` ```javascript store.findRecord('comment', 1); store.findRecord('comment', 2); ``` will also send a request to: `GET /comments?ids[]=1&ids[]=2` Note: Requests coalescing rely on URL building strategy. So if you override `buildURL` in your app `groupRecordsForFindMany` more likely should be overridden as well in order for coalescing to work. ##### Parameters ###### value `boolean` ##### Returns `void` #### Overrides [`default`](../../rest/classes/default.md).[`coalesceFindRequests`](../../rest/classes/default.md#coalescefindrequests) *** ### fastboot #### Get Signature ```ts get fastboot(): FastBoot; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:273 ##### Returns `FastBoot` #### Set Signature ```ts set fastboot(value): void; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:274 ##### Parameters ###### value `FastBoot` ##### Returns `void` #### Inherited from [`default`](../../rest/classes/default.md).[`fastboot`](../../rest/classes/default.md#fastboot) ## Methods ### \_ajax() ```ts _ajax(options): void; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:764 #### Parameters ##### options [`JQueryRequestInit`](../../rest/interfaces/JQueryRequestInit.md) | [`FetchRequestInit`](../../rest/interfaces/FetchRequestInit.md) #### Returns `void` #### Inherited from [`default`](../../rest/classes/default.md).[`_ajax`](../../rest/classes/default.md#_ajax) *** ### \_ajaxURL() ```ts _ajaxURL(url): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:773 #### Parameters ##### url `string` #### Returns `string` #### Inherited from [`default`](../../rest/classes/default.md).[`_ajaxURL`](../../rest/classes/default.md#_ajaxurl) *** ### \_buildURL() ```ts _buildURL( this, modelName, id?): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:15 #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `undefined` | `null` | `string` ##### id? `null` | `string` #### Returns `string` #### Inherited from [`default`](../../rest/classes/default.md).[`_buildURL`](../../rest/classes/default.md#_buildurl) *** ### \_fetchRequest() ```ts _fetchRequest(options): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:763 #### Parameters ##### options [`FetchRequestInit`](../../rest/interfaces/FetchRequestInit.md) #### Returns `Promise`<`Response`> #### Inherited from [`default`](../../rest/classes/default.md).[`_fetchRequest`](../../rest/classes/default.md#_fetchrequest) *** ### \_stripIDFromURL() ```ts _stripIDFromURL(store, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:655 #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### snapshot `Snapshot` #### Returns `string` #### Inherited from [`default`](../../rest/classes/default.md).[`_stripIDFromURL`](../../rest/classes/default.md#_stripidfromurl) *** ### buildQuery() ```ts buildQuery(snapshot): QueryState; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/json-api.d.ts:231 Used by `findAll` and `findRecord` to build the query's `data` hash supplied to the ajax method. #### Parameters ##### snapshot `Snapshot`<`unknown`> | `SnapshotRecordArray` #### Returns [`QueryState`](../../rest/type-aliases/QueryState.md) #### Since 2.5.0 #### Overrides [`default`](../../rest/classes/default.md).[`buildQuery`](../../rest/classes/default.md#buildquery) *** ### buildURL() #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:4 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"findRecord"` ##### Returns `string` ##### Inherited from [`default`](../../rest/classes/default.md).[`buildURL`](../../rest/classes/default.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:5 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` ###### snapshot `SnapshotRecordArray` ###### requestType `"findAll"` ##### Returns `string` ##### Inherited from [`default`](../../rest/classes/default.md).[`buildURL`](../../rest/classes/default.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType, query): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:6 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` ###### snapshot `null` ###### requestType `"query"` ###### query `Record`<`string`, `unknown`> ##### Returns `string` ##### Inherited from [`default`](../../rest/classes/default.md).[`buildURL`](../../rest/classes/default.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType, query): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:7 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` ###### snapshot `null` ###### requestType `"queryRecord"` ###### query `Record`<`string`, `unknown`> ##### Returns `string` ##### Inherited from [`default`](../../rest/classes/default.md).[`buildURL`](../../rest/classes/default.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:8 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string`\[] ###### snapshot `Snapshot`<`unknown`>\[] ###### requestType `"findMany"` ##### Returns `string` ##### Inherited from [`default`](../../rest/classes/default.md).[`buildURL`](../../rest/classes/default.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:9 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"findHasMany"` ##### Returns `string` ##### Inherited from [`default`](../../rest/classes/default.md).[`buildURL`](../../rest/classes/default.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:10 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"findBelongsTo"` ##### Returns `string` ##### Inherited from [`default`](../../rest/classes/default.md).[`buildURL`](../../rest/classes/default.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:11 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` | `string` ###### snapshot `Snapshot` ###### requestType `"createRecord"` ##### Returns `string` ##### Inherited from [`default`](../../rest/classes/default.md).[`buildURL`](../../rest/classes/default.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:12 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"updateRecord"` ##### Returns `string` ##### Inherited from [`default`](../../rest/classes/default.md).[`buildURL`](../../rest/classes/default.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:13 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"deleteRecord"` ##### Returns `string` ##### Inherited from [`default`](../../rest/classes/default.md).[`buildURL`](../../rest/classes/default.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:14 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ##### Returns `string` ##### Inherited from [`default`](../../rest/classes/default.md).[`buildURL`](../../rest/classes/default.md#buildurl) *** ### createRecord() ```ts createRecord( store, type, snapshot): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:625 Called by the store when a newly created record is saved via the `save` method on a model record instance. The `createRecord` method serializes the record and makes an Ajax (HTTP POST) request to a URL computed by `buildURL`. See `serialize` for information on how to customize the serialized form of a record. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### type [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise #### Inherited from [`default`](../../rest/classes/default.md).[`createRecord`](../../rest/classes/default.md#createrecord) *** ### deleteRecord() ```ts deleteRecord( store, schema, snapshot): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:654 Called by the store when a record is deleted. The `deleteRecord` method makes an Ajax (HTTP DELETE) request to a URL computed by `buildURL`. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### schema [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise #### Inherited from [`default`](../../rest/classes/default.md).[`deleteRecord`](../../rest/classes/default.md#deleterecord) *** ### findAll() ```ts findAll( store, type, sinceToken, snapshotRecordArray): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:460 Called by the store in order to fetch a JSON array for all of the records for a given type. The `findAll` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a promise for the resulting payload. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### type [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### sinceToken `null` ##### snapshotRecordArray `SnapshotRecordArray` #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise #### Inherited from [`default`](../../rest/classes/default.md).[`findAll`](../../rest/classes/default.md#findall) *** ### findBelongsTo() ```ts findBelongsTo( store, snapshot, url, relationship): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:608 Called by the store in order to fetch the JSON for the unloaded record in a belongs-to relationship that was originally specified as a URL (inside of `links`). For example, if your original payload looks like this: ```js { "person": { "id": 1, "name": "Tom Dale", "links": { "group": "/people/1/group" } } } ``` This method will be called with the parent record and `/people/1/group`. The `findBelongsTo` method will make an Ajax (HTTP GET) request to the originally specified URL. The format of your `links` value will influence the final request URL via the `urlPrefix` method: * Links beginning with `//`, `http://`, `https://`, will be used as is, with no further manipulation. * Links beginning with a single `/` will have the current adapter's `host` value prepended to it. * Links with no beginning `/` will have a parentURL prepended to it, via the current adapter's `buildURL`. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### snapshot `Snapshot` ##### url `string` ##### relationship `any` meta object describing the relationship #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise #### Inherited from [`default`](../../rest/classes/default.md).[`findBelongsTo`](../../rest/classes/default.md#findbelongsto) *** ### findHasMany() ```ts findHasMany( store, snapshot, url, relationship): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:571 Called by the store in order to fetch a JSON array for the unloaded records in a has-many relationship that were originally specified as a URL (inside of `links`). For example, if your original payload looks like this: ```js { "post": { "id": 1, "title": "Rails is omakase", "links": { "comments": "/posts/1/comments" } } } ``` This method will be called with the parent record and `/posts/1/comments`. The `findHasMany` method will make an Ajax (HTTP GET) request to the originally specified URL. The format of your `links` value will influence the final request URL via the `urlPrefix` method: * Links beginning with `//`, `http://`, `https://`, will be used as is, with no further manipulation. * Links beginning with a single `/` will have the current adapter's `host` value prepended to it. * Links with no beginning `/` will have a parentURL prepended to it, via the current adapter's `buildURL`. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### snapshot `Snapshot` ##### url `string` ##### relationship `Record`<`string`, `unknown`> meta object describing the relationship #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise #### Inherited from [`default`](../../rest/classes/default.md).[`findHasMany`](../../rest/classes/default.md#findhasmany) *** ### findMany() ```ts findMany( store, type, ids, snapshots): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/json-api.d.ts:219 Called by the store in order to fetch several records together if `coalesceFindRequests` is true For example, if the original payload looks like: ```js { "id": 1, "title": "Rails is omakase", "comments": [ 1, 2, 3 ] } ``` The IDs will be passed as a URL-encoded Array of IDs, in this form: ``` ids[]=1&ids[]=2&ids[]=3 ``` Many servers, such as Rails and PHP, will automatically convert this URL-encoded array into an Array for you on the server-side. If you want to encode the IDs, differently, just override this (one-line) method. The `findMany` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a promise for the resulting payload. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### type [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### ids `string`\[] ##### snapshots `Snapshot`<`unknown`>\[] #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise #### Overrides [`default`](../../rest/classes/default.md).[`findMany`](../../rest/classes/default.md#findmany) *** ### findRecord() ```ts findRecord( store, type, id, snapshot): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:445 Called by the store in order to fetch the JSON for a given type and ID. The `findRecord` method makes an Ajax request to a URL computed by `buildURL`, and returns a promise for the resulting payload. This method performs an HTTP `GET` request with the id provided as part of the query string. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### type [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### id `string` ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise #### Since 1.13.0 #### Inherited from [`default`](../../rest/classes/default.md).[`findRecord`](../../rest/classes/default.md#findrecord) *** ### groupRecordsForFindMany() ```ts groupRecordsForFindMany(store, snapshots): Snapshot[][]; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:679 Organize records into groups, each of which is to be passed to separate calls to `findMany`. This implementation groups together records that have the same base URL but differing ids. For example `/comments/1` and `/comments/2` will be grouped together because we know findMany can coalesce them together as `/comments?ids[]=1&ids[]=2` It also supports urls where ids are passed as a query param, such as `/comments?id=1` but not those where there is more than 1 query param such as `/comments?id=2&name=David` Currently only the query param of `id` is supported. If you need to support others, please override this or the `_stripIDFromURL` method. It does not group records that have differing base urls, such as for example: `/posts/1/comments/2` and `/posts/2/comments/3` #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### snapshots `Snapshot`<`unknown`>\[] #### Returns `Snapshot`<`unknown`>\[]\[] an array of arrays of records, each of which is to be loaded separately by `findMany`. #### Inherited from [`default`](../../rest/classes/default.md).[`groupRecordsForFindMany`](../../rest/classes/default.md#grouprecordsforfindmany) *** ### handleResponse() ```ts handleResponse( status, headers, payload, requestData): typeof _AdapterError | Payload; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:709 Takes an ajax response, and returns the json payload or an error. By default this hook just returns the json payload passed to it. You might want to override it in two cases: 1. Your API might return useful results in the response headers. Response headers are passed in as the second argument. 2. Your API might return errors as successful responses with status code 200 and an Errors text or object. You can return a `InvalidError` or a `AdapterError` (or a sub class) from this hook and it will automatically reject the promise and put your record into the invalid or error state. Returning a `InvalidError` from this method will cause the record to transition into the `invalid` state and make the `errors` object available on the record. When returning an `InvalidError` the store will attempt to normalize the error data returned from the server using the serializer's `extractErrors` method. #### Parameters ##### status `number` ##### headers `Record`<`string`, `string`> ##### payload `Payload` ##### requestData [`RequestData`](../../rest/type-aliases/RequestData.md) the original request information #### Returns *typeof* `_AdapterError` | `Payload` response #### Since 1.13.0 #### Inherited from [`default`](../../rest/classes/default.md).[`handleResponse`](../../rest/classes/default.md#handleresponse) *** ### isInvalid() ```ts isInvalid( status, _headers, _payload): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:733 Default `handleResponse` implementation uses this hook to decide if the response is an invalid error. #### Parameters ##### status `number` ##### \_headers `Record`<`string`, `unknown`> ##### \_payload `Payload` #### Returns `boolean` #### Since 1.13.0 #### Inherited from [`default`](../../rest/classes/default.md).[`isInvalid`](../../rest/classes/default.md#isinvalid) *** ### isSuccess() ```ts isSuccess( status, _headers, _payload): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:721 Default `handleResponse` implementation uses this hook to decide if the response is a success. #### Parameters ##### status `number` ##### \_headers `Record`<`string`, `unknown`> ##### \_payload `Payload` #### Returns `boolean` #### Since 1.13.0 #### Inherited from [`default`](../../rest/classes/default.md).[`isSuccess`](../../rest/classes/default.md#issuccess) *** ### pathForType() ```ts pathForType(modelName): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/json-api.d.ts:220 #### Parameters ##### modelName `string` #### Returns `string` #### Overrides [`default`](../../rest/classes/default.md).[`pathForType`](../../rest/classes/default.md#pathfortype) *** ### query() ```ts query( store, type, query): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:480 Called by the store in order to fetch a JSON array for the records that match a particular query. The `query` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a promise for the resulting payload. The `query` argument is a simple JavaScript object that will be passed directly to the server as parameters. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### type [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### query `Record`<`string`, `unknown`> #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise #### Inherited from [`default`](../../rest/classes/default.md).[`query`](../../rest/classes/default.md#query) *** ### queryRecord() ```ts queryRecord( store, type, query, adapterOptions): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:500 Called by the store in order to fetch a JSON object for the record that matches a particular query. The `queryRecord` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a promise for the resulting payload. The `query` argument is a simple JavaScript object that will be passed directly to the server as parameters. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### type [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### query `Record`<`string`, `unknown`> ##### adapterOptions `Record`<`string`, `unknown`> #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise #### Since 1.13.0 #### Inherited from [`default`](../../rest/classes/default.md).[`queryRecord`](../../rest/classes/default.md#queryrecord) *** ### sortQueryParams() ```ts sortQueryParams(obj): Record; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:317 By default, the RESTAdapter will send the query params sorted alphabetically to the server. For example: ```js store.query('posts', { sort: 'price', category: 'pets' }); ``` will generate a requests like this `/posts?category=pets&sort=price`, even if the parameters were specified in a different order. That way the generated URL will be deterministic and that simplifies caching mechanisms in the backend. Setting `sortQueryParams` to a falsey value will respect the original order. In case you want to sort the query parameters with a different criteria, set `sortQueryParams` to your custom sort function. ```js [app/adapters/application.js] import { RESTAdapter } from '@warp-drive/legacy/adapter/rest'; export default class ApplicationAdapter extends RESTAdapter { sortQueryParams(params) { let sortedKeys = Object.keys(params).sort().reverse(); let len = sortedKeys.length, newParams = {}; for (let i = 0; i < len; i++) { newParams[sortedKeys[i]] = params[sortedKeys[i]]; } return newParams; } } ``` #### Parameters ##### obj `Record`<`string`, `unknown`> #### Returns `Record`<`string`, `unknown`> #### Inherited from [`default`](../../rest/classes/default.md).[`sortQueryParams`](../../rest/classes/default.md#sortqueryparams) *** ### updateRecord() ```ts updateRecord( store, schema, snapshot): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/json-api.d.ts:221 Called by the store when an existing record is saved via the `save` method on a model record instance. The `updateRecord` method serializes the record and makes an Ajax (HTTP PUT) request to a URL computed by `buildURL`. See `serialize` for information on how to customize the serialized form of a record. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### schema [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise #### Overrides [`default`](../../rest/classes/default.md).[`updateRecord`](../../rest/classes/default.md#updaterecord) *** ### urlForCreateRecord() ```ts urlForCreateRecord( this, modelName, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:23 #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` #### Inherited from [`default`](../../rest/classes/default.md).[`urlForCreateRecord`](../../rest/classes/default.md#urlforcreaterecord) *** ### urlForDeleteRecord() ```ts urlForDeleteRecord( this, id, modelName, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:25 #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` #### Inherited from [`default`](../../rest/classes/default.md).[`urlForDeleteRecord`](../../rest/classes/default.md#urlfordeleterecord) *** ### urlForFindAll() ```ts urlForFindAll( this, modelName, snapshots): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:17 #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `string` ##### snapshots `SnapshotRecordArray` #### Returns `string` #### Inherited from [`default`](../../rest/classes/default.md).[`urlForFindAll`](../../rest/classes/default.md#urlforfindall) *** ### urlForFindBelongsTo() ```ts urlForFindBelongsTo( this, id, modelName, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:22 #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` #### Inherited from [`default`](../../rest/classes/default.md).[`urlForFindBelongsTo`](../../rest/classes/default.md#urlforfindbelongsto) *** ### urlForFindHasMany() ```ts urlForFindHasMany( this, id, modelName, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:21 #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` #### Inherited from [`default`](../../rest/classes/default.md).[`urlForFindHasMany`](../../rest/classes/default.md#urlforfindhasmany) *** ### urlForFindMany() ```ts urlForFindMany( this, ids, modelName, snapshots): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:20 #### Parameters ##### this `MixtBuildURLMixin` ##### ids `string`\[] ##### modelName `string` ##### snapshots `Snapshot`<`unknown`>\[] #### Returns `string` #### Inherited from [`default`](../../rest/classes/default.md).[`urlForFindMany`](../../rest/classes/default.md#urlforfindmany) *** ### urlForFindRecord() ```ts urlForFindRecord( this, id, modelName, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:16 #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` #### Inherited from [`default`](../../rest/classes/default.md).[`urlForFindRecord`](../../rest/classes/default.md#urlforfindrecord) *** ### urlForQuery() ```ts urlForQuery( this, query, modelName): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:19 #### Parameters ##### this `MixtBuildURLMixin` ##### query `Record`<`string`, `unknown`> ##### modelName `string` #### Returns `string` #### Inherited from [`default`](../../rest/classes/default.md).[`urlForQuery`](../../rest/classes/default.md#urlforquery) *** ### urlForQueryRecord() ```ts urlForQueryRecord( this, query, modelName): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:18 #### Parameters ##### this `MixtBuildURLMixin` ##### query `Record`<`string`, `unknown`> ##### modelName `string` #### Returns `string` #### Inherited from [`default`](../../rest/classes/default.md).[`urlForQueryRecord`](../../rest/classes/default.md#urlforqueryrecord) *** ### urlForUpdateRecord() ```ts urlForUpdateRecord( this, id, modelName, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:24 #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` #### Inherited from [`default`](../../rest/classes/default.md).[`urlForUpdateRecord`](../../rest/classes/default.md#urlforupdaterecord) *** ### urlPrefix() ```ts urlPrefix( this, path?, parentURL?): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:26 #### Parameters ##### this `MixtBuildURLMixin` ##### path? `null` | `string` ##### parentURL? `string` #### Returns `string` #### Inherited from [`default`](../../rest/classes/default.md).[`urlPrefix`](../../rest/classes/default.md#urlprefix) --- --- url: /api/@ember-data/adapter/json-api.md --- [Documentation](../../../index.md) / [@ember-data/adapter](../index.md) / json-api ## Classes * [default](classes/default.md) --- --- url: /api/@ember-data/adapter/rest.md --- [Documentation](../../../index.md) / [@ember-data/adapter](../index.md) / rest ## Classes * [default](classes/default.md) ## Interfaces * [FetchRequestInit](interfaces/FetchRequestInit.md) * [JQueryRequestInit](interfaces/JQueryRequestInit.md) ## Type Aliases * [QueryState](type-aliases/QueryState.md) * [RequestData](type-aliases/RequestData.md) --- --- url: /api/@ember-data/adapter/rest/classes/default.md --- [Documentation](../../../../index.md) / [@ember-data/adapter](../../index.md) / [rest](../index.md) / default Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:258 The REST adapter allows your store to communicate with an HTTP server by transmitting JSON via XHR. This adapter is designed around the idea that the JSON exchanged with the server should be conventional. It builds URLs in a manner that follows the structure of most common REST-style web services. ## Success and failure The REST adapter will consider a success any response with a status code of the 2xx family ("Success"), as well as 304 ("Not Modified"). Any other status code will be considered a failure. On success, the request promise will be resolved with the full response payload. Failed responses with status code 422 ("Unprocessable Entity") will be considered "invalid". The response will be discarded, except for the `errors` key. The request promise will be rejected with a `InvalidError`. This error object will encapsulate the saved `errors` value. Any other status codes will be treated as an "adapter error". The request promise will be rejected, similarly to the "invalid" case, but with an instance of `AdapterError` instead. ## JSON Structure The REST adapter expects the JSON returned from your server to follow these conventions. ### Object Root The JSON payload should be an object that contains the record inside a root property. For example, in response to a `GET` request for `/posts/1`, the JSON should look like this: ```js { "posts": { "id": 1, "title": "I'm Running to Reform the W3C", "author": "Yehuda Katz" } } ``` Similarly, in response to a `GET` request for `/posts`, the JSON should look like this: ```js { "posts": [ { "id": 1, "title": "I'm Running to Reform the W3C", "author": "Yehuda Katz" }, { "id": 2, "title": "Rails is omakase", "author": "D2H" } ] } ``` Note that the object root can be pluralized for both a single-object response and an array response: the REST adapter is not strict on this. Further, if the HTTP server responds to a `GET` request to `/posts/1` (e.g. the response to a `findRecord` query) with more than one object in the array, Ember Data will only display the object with the matching ID. ### Conventional Names Attribute names in your JSON payload should be the camelCased versions of the attributes in your Ember.js models. For example, if you have a `Person` model: ```js [app/models/person.js] import { Model, attr } from '@warp-drive/legacy/model'; export default Model.extend({ firstName: attr('string'), lastName: attr('string'), occupation: attr('string') }); ``` The JSON returned should look like this: ```js { "people": { "id": 5, "firstName": "Zaphod", "lastName": "Beeblebrox", "occupation": "President" } } ``` #### Relationships Relationships are usually represented by ids to the record in the relationship. The related records can then be sideloaded in the response under a key for the type. ```js { "posts": { "id": 5, "title": "I'm Running to Reform the W3C", "author": "Yehuda Katz", "comments": [1, 2] }, "comments": [{ "id": 1, "author": "User 1", "message": "First!", }, { "id": 2, "author": "User 2", "message": "Good Luck!", }] } ``` If the records in the relationship are not known when the response is serialized it's also possible to represent the relationship as a URL using the `links` key in the response. Ember Data will fetch this URL to resolve the relationship when it is accessed for the first time. ```js { "posts": { "id": 5, "title": "I'm Running to Reform the W3C", "author": "Yehuda Katz", "links": { "comments": "/posts/5/comments" } } } ``` ### Errors If a response is considered a failure, the JSON payload is expected to include a top-level key `errors`, detailing any specific issues. For example: ```js { "errors": { "msg": "Something went wrong" } } ``` This adapter does not make any assumptions as to the format of the `errors` object. It will simply be passed along as is, wrapped in an instance of `InvalidError` or `AdapterError`. The serializer can interpret it afterwards. ## Customization ### Endpoint path customization Endpoint paths can be prefixed with a `namespace` by setting the namespace property on the adapter: ```js [app/adapters/application.js] import { RESTAdapter } from '@warp-drive/legacy/adapter/rest'; export default class ApplicationAdapter extends RESTAdapter { namespace = 'api/1'; } ``` Requests for the `Person` model would now target `/api/1/people/1`. ### Host customization An adapter can target other hosts by setting the `host` property. ```js [app/adapters/application.js] import { RESTAdapter } from '@warp-drive/legacy/adapter/rest'; export default class ApplicationAdapter extends RESTAdapter { host = 'https://api.example.com'; } ``` ### Headers customization Some APIs require HTTP headers, e.g. to provide an API key. Arbitrary headers can be set as key/value pairs on the `RESTAdapter`'s `headers` object and WarpDrive will send them along with each ajax request. ```js [app/adapters/application.js] import { RESTAdapter } from '@warp-drive/legacy/adapter/rest'; export default class ApplicationAdapter extends RESTAdapter { get headers() { return { 'API_KEY': 'secret key', 'ANOTHER_HEADER': 'Some header value' }; } } ``` RESTAdapter ## Uses BuildURLMixin ## Extends * `RESTAdapter_base`.`MixtBuildURLMixin` ## Extended by * [`default`](../../json-api/classes/default.md) ## Constructors ### Constructor ```ts new default(): RESTAdapter; ``` #### Returns `RESTAdapter` #### Inherited from ```ts RESTAdapter_base.constructor ``` ## Properties ### \_coalesceFindRequests ```ts _coalesceFindRequests: boolean; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:260 *** ### \_defaultContentType ```ts _defaultContentType: string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:272 *** ### \_fastboot ```ts _fastboot: FastBoot; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:259 *** ### headers ```ts headers: undefined | Record; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:427 Some APIs require HTTP headers, e.g. to provide an API key. Arbitrary headers can be set as key/value pairs on the `RESTAdapter`'s `headers` object and Ember Data will send them along with each ajax request. For dynamic headers see [headers customization](/ember-data/release/classes/RESTAdapter). ```js [app/adapters/application.js] import { RESTAdapter } from '@warp-drive/legacy/adapter/rest'; export default class ApplicationAdapter extends RESTAdapter { get headers() { return { 'API_KEY': 'secret key', 'ANOTHER_HEADER': 'Some header value' }; } } ``` *** ### host ```ts host: null | string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:261 #### Overrides ```ts RESTAdapter_base.host ``` *** ### maxURLLength ```ts maxURLLength: number; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:656 *** ### namespace ```ts namespace: null | string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:262 #### Overrides ```ts RESTAdapter_base.namespace ``` *** ### useFetch ```ts useFetch: boolean; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:271 This property allows ajax to still be used instead when `false`. #### Default ```ts true @public ``` ## Accessors ### coalesceFindRequests #### Get Signature ```ts get coalesceFindRequests(): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:366 By default the RESTAdapter will send each find request coming from a `store.find` or from accessing a relationship separately to the server. If your server supports passing ids as a query string, you can set coalesceFindRequests to true to coalesce all find requests within a single runloop. For example, if you have an initial payload of: ```javascript { post: { id: 1, comments: [1, 2] } } ``` By default calling `post.comments` will trigger the following requests(assuming the comments haven't been loaded before): ``` GET /comments/1 GET /comments/2 ``` If you set coalesceFindRequests to `true` it will instead trigger the following request: ``` GET /comments?ids[]=1&ids[]=2 ``` Setting coalesceFindRequests to `true` also works for `store.find` requests and `belongsTo` relationships accessed within the same runloop. If you set `coalesceFindRequests: true` ```javascript store.findRecord('comment', 1); store.findRecord('comment', 2); ``` will also send a request to: `GET /comments?ids[]=1&ids[]=2` Note: Requests coalescing rely on URL building strategy. So if you override `buildURL` in your app `groupRecordsForFindMany` more likely should be overridden as well in order for coalescing to work. ##### Returns `boolean` #### Set Signature ```ts set coalesceFindRequests(value): void; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:367 ##### Parameters ###### value `boolean` ##### Returns `void` *** ### fastboot #### Get Signature ```ts get fastboot(): FastBoot; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:273 ##### Returns `FastBoot` #### Set Signature ```ts set fastboot(value): void; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:274 ##### Parameters ###### value `FastBoot` ##### Returns `void` ## Methods ### \_ajax() ```ts _ajax(options): void; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:764 #### Parameters ##### options [`JQueryRequestInit`](../interfaces/JQueryRequestInit.md) | [`FetchRequestInit`](../interfaces/FetchRequestInit.md) #### Returns `void` *** ### \_ajaxURL() ```ts _ajaxURL(url): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:773 #### Parameters ##### url `string` #### Returns `string` *** ### \_buildURL() ```ts _buildURL( this, modelName, id?): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:15 #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `undefined` | `null` | `string` ##### id? `null` | `string` #### Returns `string` #### Inherited from ```ts RESTAdapter_base._buildURL ``` *** ### \_fetchRequest() ```ts _fetchRequest(options): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:763 #### Parameters ##### options [`FetchRequestInit`](../interfaces/FetchRequestInit.md) #### Returns `Promise`<`Response`> *** ### \_stripIDFromURL() ```ts _stripIDFromURL(store, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:655 #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### snapshot `Snapshot` #### Returns `string` *** ### buildQuery() ```ts buildQuery(snapshot): QueryState; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:809 Used by `findAll` and `findRecord` to build the query's `data` hash supplied to the ajax method. #### Parameters ##### snapshot `Snapshot`<`unknown`> | `SnapshotRecordArray` #### Returns [`QueryState`](../type-aliases/QueryState.md) #### Since 2.5.0 *** ### buildURL() #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:4 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"findRecord"` ##### Returns `string` ##### Inherited from ```ts RESTAdapter_base.buildURL ``` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:5 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` ###### snapshot `SnapshotRecordArray` ###### requestType `"findAll"` ##### Returns `string` ##### Inherited from ```ts RESTAdapter_base.buildURL ``` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType, query): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:6 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` ###### snapshot `null` ###### requestType `"query"` ###### query `Record`<`string`, `unknown`> ##### Returns `string` ##### Inherited from ```ts RESTAdapter_base.buildURL ``` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType, query): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:7 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` ###### snapshot `null` ###### requestType `"queryRecord"` ###### query `Record`<`string`, `unknown`> ##### Returns `string` ##### Inherited from ```ts RESTAdapter_base.buildURL ``` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:8 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string`\[] ###### snapshot `Snapshot`<`unknown`>\[] ###### requestType `"findMany"` ##### Returns `string` ##### Inherited from ```ts RESTAdapter_base.buildURL ``` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:9 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"findHasMany"` ##### Returns `string` ##### Inherited from ```ts RESTAdapter_base.buildURL ``` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:10 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"findBelongsTo"` ##### Returns `string` ##### Inherited from ```ts RESTAdapter_base.buildURL ``` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:11 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` | `string` ###### snapshot `Snapshot` ###### requestType `"createRecord"` ##### Returns `string` ##### Inherited from ```ts RESTAdapter_base.buildURL ``` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:12 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"updateRecord"` ##### Returns `string` ##### Inherited from ```ts RESTAdapter_base.buildURL ``` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:13 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"deleteRecord"` ##### Returns `string` ##### Inherited from ```ts RESTAdapter_base.buildURL ``` #### Call Signature ```ts buildURL( this, modelName, id, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:14 ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ##### Returns `string` ##### Inherited from ```ts RESTAdapter_base.buildURL ``` *** ### createRecord() ```ts createRecord( store, type, snapshot): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:625 Called by the store when a newly created record is saved via the `save` method on a model record instance. The `createRecord` method serializes the record and makes an Ajax (HTTP POST) request to a URL computed by `buildURL`. See `serialize` for information on how to customize the serialized form of a record. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### type [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise *** ### deleteRecord() ```ts deleteRecord( store, schema, snapshot): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:654 Called by the store when a record is deleted. The `deleteRecord` method makes an Ajax (HTTP DELETE) request to a URL computed by `buildURL`. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### schema [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise *** ### findAll() ```ts findAll( store, type, sinceToken, snapshotRecordArray): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:460 Called by the store in order to fetch a JSON array for all of the records for a given type. The `findAll` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a promise for the resulting payload. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### type [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### sinceToken `null` ##### snapshotRecordArray `SnapshotRecordArray` #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise *** ### findBelongsTo() ```ts findBelongsTo( store, snapshot, url, relationship): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:608 Called by the store in order to fetch the JSON for the unloaded record in a belongs-to relationship that was originally specified as a URL (inside of `links`). For example, if your original payload looks like this: ```js { "person": { "id": 1, "name": "Tom Dale", "links": { "group": "/people/1/group" } } } ``` This method will be called with the parent record and `/people/1/group`. The `findBelongsTo` method will make an Ajax (HTTP GET) request to the originally specified URL. The format of your `links` value will influence the final request URL via the `urlPrefix` method: * Links beginning with `//`, `http://`, `https://`, will be used as is, with no further manipulation. * Links beginning with a single `/` will have the current adapter's `host` value prepended to it. * Links with no beginning `/` will have a parentURL prepended to it, via the current adapter's `buildURL`. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### snapshot `Snapshot` ##### url `string` ##### relationship `any` meta object describing the relationship #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise *** ### findHasMany() ```ts findHasMany( store, snapshot, url, relationship): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:571 Called by the store in order to fetch a JSON array for the unloaded records in a has-many relationship that were originally specified as a URL (inside of `links`). For example, if your original payload looks like this: ```js { "post": { "id": 1, "title": "Rails is omakase", "links": { "comments": "/posts/1/comments" } } } ``` This method will be called with the parent record and `/posts/1/comments`. The `findHasMany` method will make an Ajax (HTTP GET) request to the originally specified URL. The format of your `links` value will influence the final request URL via the `urlPrefix` method: * Links beginning with `//`, `http://`, `https://`, will be used as is, with no further manipulation. * Links beginning with a single `/` will have the current adapter's `host` value prepended to it. * Links with no beginning `/` will have a parentURL prepended to it, via the current adapter's `buildURL`. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### snapshot `Snapshot` ##### url `string` ##### relationship `Record`<`string`, `unknown`> meta object describing the relationship #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise *** ### findMany() ```ts findMany( store, type, ids, snapshots): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:534 Called by the store in order to fetch several records together if `coalesceFindRequests` is true For example, if the original payload looks like: ```js { "id": 1, "title": "Rails is omakase", "comments": [ 1, 2, 3 ] } ``` The IDs will be passed as a URL-encoded Array of IDs, in this form: ``` ids[]=1&ids[]=2&ids[]=3 ``` Many servers, such as Rails and PHP, will automatically convert this URL-encoded array into an Array for you on the server-side. If you want to encode the IDs, differently, just override this (one-line) method. The `findMany` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a promise for the resulting payload. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### type [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### ids `string`\[] ##### snapshots `Snapshot`<`unknown`>\[] #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise *** ### findRecord() ```ts findRecord( store, type, id, snapshot): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:445 Called by the store in order to fetch the JSON for a given type and ID. The `findRecord` method makes an Ajax request to a URL computed by `buildURL`, and returns a promise for the resulting payload. This method performs an HTTP `GET` request with the id provided as part of the query string. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### type [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### id `string` ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise #### Since 1.13.0 *** ### groupRecordsForFindMany() ```ts groupRecordsForFindMany(store, snapshots): Snapshot[][]; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:679 Organize records into groups, each of which is to be passed to separate calls to `findMany`. This implementation groups together records that have the same base URL but differing ids. For example `/comments/1` and `/comments/2` will be grouped together because we know findMany can coalesce them together as `/comments?ids[]=1&ids[]=2` It also supports urls where ids are passed as a query param, such as `/comments?id=1` but not those where there is more than 1 query param such as `/comments?id=2&name=David` Currently only the query param of `id` is supported. If you need to support others, please override this or the `_stripIDFromURL` method. It does not group records that have differing base urls, such as for example: `/posts/1/comments/2` and `/posts/2/comments/3` #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### snapshots `Snapshot`<`unknown`>\[] #### Returns `Snapshot`<`unknown`>\[]\[] an array of arrays of records, each of which is to be loaded separately by `findMany`. *** ### handleResponse() ```ts handleResponse( status, headers, payload, requestData): typeof _AdapterError | Payload; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:709 Takes an ajax response, and returns the json payload or an error. By default this hook just returns the json payload passed to it. You might want to override it in two cases: 1. Your API might return useful results in the response headers. Response headers are passed in as the second argument. 2. Your API might return errors as successful responses with status code 200 and an Errors text or object. You can return a `InvalidError` or a `AdapterError` (or a sub class) from this hook and it will automatically reject the promise and put your record into the invalid or error state. Returning a `InvalidError` from this method will cause the record to transition into the `invalid` state and make the `errors` object available on the record. When returning an `InvalidError` the store will attempt to normalize the error data returned from the server using the serializer's `extractErrors` method. #### Parameters ##### status `number` ##### headers `Record`<`string`, `string`> ##### payload `Payload` ##### requestData [`RequestData`](../type-aliases/RequestData.md) the original request information #### Returns *typeof* `_AdapterError` | `Payload` response #### Since 1.13.0 *** ### isInvalid() ```ts isInvalid( status, _headers, _payload): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:733 Default `handleResponse` implementation uses this hook to decide if the response is an invalid error. #### Parameters ##### status `number` ##### \_headers `Record`<`string`, `unknown`> ##### \_payload `Payload` #### Returns `boolean` #### Since 1.13.0 *** ### isSuccess() ```ts isSuccess( status, _headers, _payload): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:721 Default `handleResponse` implementation uses this hook to decide if the response is a success. #### Parameters ##### status `number` ##### \_headers `Record`<`string`, `unknown`> ##### \_payload `Payload` #### Returns `boolean` #### Since 1.13.0 *** ### pathForType() ```ts pathForType(this, modelName): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:27 #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `string` #### Returns `string` #### Inherited from ```ts RESTAdapter_base.pathForType ``` *** ### query() ```ts query( store, type, query): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:480 Called by the store in order to fetch a JSON array for the records that match a particular query. The `query` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a promise for the resulting payload. The `query` argument is a simple JavaScript object that will be passed directly to the server as parameters. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### type [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### query `Record`<`string`, `unknown`> #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise *** ### queryRecord() ```ts queryRecord( store, type, query, adapterOptions): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:500 Called by the store in order to fetch a JSON object for the record that matches a particular query. The `queryRecord` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a promise for the resulting payload. The `query` argument is a simple JavaScript object that will be passed directly to the server as parameters. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### type [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### query `Record`<`string`, `unknown`> ##### adapterOptions `Record`<`string`, `unknown`> #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise #### Since 1.13.0 *** ### sortQueryParams() ```ts sortQueryParams(obj): Record; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:317 By default, the RESTAdapter will send the query params sorted alphabetically to the server. For example: ```js store.query('posts', { sort: 'price', category: 'pets' }); ``` will generate a requests like this `/posts?category=pets&sort=price`, even if the parameters were specified in a different order. That way the generated URL will be deterministic and that simplifies caching mechanisms in the backend. Setting `sortQueryParams` to a falsey value will respect the original order. In case you want to sort the query parameters with a different criteria, set `sortQueryParams` to your custom sort function. ```js [app/adapters/application.js] import { RESTAdapter } from '@warp-drive/legacy/adapter/rest'; export default class ApplicationAdapter extends RESTAdapter { sortQueryParams(params) { let sortedKeys = Object.keys(params).sort().reverse(); let len = sortedKeys.length, newParams = {}; for (let i = 0; i < len; i++) { newParams[sortedKeys[i]] = params[sortedKeys[i]]; } return newParams; } } ``` #### Parameters ##### obj `Record`<`string`, `unknown`> #### Returns `Record`<`string`, `unknown`> *** ### updateRecord() ```ts updateRecord( store, schema, snapshot): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:642 Called by the store when an existing record is saved via the `save` method on a model record instance. The `updateRecord` method serializes the record and makes an Ajax (HTTP PUT) request to a URL computed by `buildURL`. See `serialize` for information on how to customize the serialized form of a record. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### schema [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../legacy-compat/index/type-aliases/AdapterPayload.md)> promise *** ### urlForCreateRecord() ```ts urlForCreateRecord( this, modelName, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:23 #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` #### Inherited from ```ts RESTAdapter_base.urlForCreateRecord ``` *** ### urlForDeleteRecord() ```ts urlForDeleteRecord( this, id, modelName, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:25 #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` #### Inherited from ```ts RESTAdapter_base.urlForDeleteRecord ``` *** ### urlForFindAll() ```ts urlForFindAll( this, modelName, snapshots): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:17 #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `string` ##### snapshots `SnapshotRecordArray` #### Returns `string` #### Inherited from ```ts RESTAdapter_base.urlForFindAll ``` *** ### urlForFindBelongsTo() ```ts urlForFindBelongsTo( this, id, modelName, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:22 #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` #### Inherited from ```ts RESTAdapter_base.urlForFindBelongsTo ``` *** ### urlForFindHasMany() ```ts urlForFindHasMany( this, id, modelName, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:21 #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` #### Inherited from ```ts RESTAdapter_base.urlForFindHasMany ``` *** ### urlForFindMany() ```ts urlForFindMany( this, ids, modelName, snapshots): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:20 #### Parameters ##### this `MixtBuildURLMixin` ##### ids `string`\[] ##### modelName `string` ##### snapshots `Snapshot`<`unknown`>\[] #### Returns `string` #### Inherited from ```ts RESTAdapter_base.urlForFindMany ``` *** ### urlForFindRecord() ```ts urlForFindRecord( this, id, modelName, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:16 #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` #### Inherited from ```ts RESTAdapter_base.urlForFindRecord ``` *** ### urlForQuery() ```ts urlForQuery( this, query, modelName): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:19 #### Parameters ##### this `MixtBuildURLMixin` ##### query `Record`<`string`, `unknown`> ##### modelName `string` #### Returns `string` #### Inherited from ```ts RESTAdapter_base.urlForQuery ``` *** ### urlForQueryRecord() ```ts urlForQueryRecord( this, query, modelName): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:18 #### Parameters ##### this `MixtBuildURLMixin` ##### query `Record`<`string`, `unknown`> ##### modelName `string` #### Returns `string` #### Inherited from ```ts RESTAdapter_base.urlForQueryRecord ``` *** ### urlForUpdateRecord() ```ts urlForUpdateRecord( this, id, modelName, snapshot): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:24 #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` #### Inherited from ```ts RESTAdapter_base.urlForUpdateRecord ``` *** ### urlPrefix() ```ts urlPrefix( this, path?, parentURL?): string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/-private/build-url-mixin.d.ts:26 #### Parameters ##### this `MixtBuildURLMixin` ##### path? `null` | `string` ##### parentURL? `string` #### Returns `string` #### Inherited from ```ts RESTAdapter_base.urlPrefix ``` --- --- url: /api/@ember-data/adapter/rest/interfaces/FetchRequestInit.md --- [Documentation](../../../../index.md) / [@ember-data/adapter](../../index.md) / [rest](../index.md) / FetchRequestInit Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:15 ## Extends * `RequestInit` ## Properties ### body? ```ts optional body: null | BodyInit; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1922 A BodyInit object or null to set request's body. #### Inherited from ```ts RequestInit.body ``` *** ### cache? ```ts optional cache: RequestCache; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1924 A string indicating how the request will interact with the browser's cache to set request's cache. #### Inherited from ```ts RequestInit.cache ``` *** ### credentials? ```ts optional credentials: RequestCredentials; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1926 A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials. #### Inherited from ```ts RequestInit.credentials ``` *** ### headers? ```ts optional headers: HeadersInit; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1928 A Headers object, an object literal, or an array of two-item arrays to set request's headers. #### Inherited from ```ts RequestInit.headers ``` *** ### integrity? ```ts optional integrity: string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1930 A cryptographic hash of the resource to be fetched by request. Sets request's integrity. #### Inherited from ```ts RequestInit.integrity ``` *** ### keepalive? ```ts optional keepalive: boolean; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1932 A boolean to set request's keepalive. #### Inherited from ```ts RequestInit.keepalive ``` *** ### method ```ts method: HTTPMethod; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:17 A string to set request's method. #### Overrides ```ts RequestInit.method ``` *** ### mode? ```ts optional mode: RequestMode; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1936 A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode. #### Inherited from ```ts RequestInit.mode ``` *** ### priority? ```ts optional priority: RequestPriority; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1937 #### Inherited from ```ts RequestInit.priority ``` *** ### redirect? ```ts optional redirect: RequestRedirect; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1939 A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. #### Inherited from ```ts RequestInit.redirect ``` *** ### referrer? ```ts optional referrer: string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1941 A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer. #### Inherited from ```ts RequestInit.referrer ``` *** ### referrerPolicy? ```ts optional referrerPolicy: ReferrerPolicy; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1943 A referrer policy to set request's referrerPolicy. #### Inherited from ```ts RequestInit.referrerPolicy ``` *** ### signal? ```ts optional signal: null | AbortSignal; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1945 An AbortSignal to set request's signal. #### Inherited from ```ts RequestInit.signal ``` *** ### type ```ts type: HTTPMethod; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:18 *** ### url ```ts url: string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:16 *** ### window? ```ts optional window: null; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1947 Can only be null. Used to disassociate request from any Window. #### Inherited from ```ts RequestInit.window ``` --- --- url: /api/@ember-data/adapter/rest/interfaces/JQueryRequestInit.md --- [Documentation](../../../../index.md) / [@ember-data/adapter](../../index.md) / [rest](../index.md) / JQueryRequestInit Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:20 ## Extends * `JQueryAjaxSettings` ## Properties ### method ```ts method: HTTPMethod; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:22 *** ### type ```ts type: HTTPMethod; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:23 *** ### url ```ts url: string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:21 --- --- url: /api/@ember-data/adapter/rest/type-aliases/RequestData.md --- [Documentation](../../../../index.md) / [@ember-data/adapter](../../index.md) / [rest](../index.md) / RequestData ```ts type RequestData = object; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:25 ## Indexable ```ts [key: string]: unknown ``` ## Properties ### method ```ts method: HTTPMethod; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:27 *** ### url ```ts url: string; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:26 --- --- url: /api/@ember-data/adapter/rest/type-aliases/QueryState.md --- [Documentation](../../../../index.md) / [@ember-data/adapter](../../index.md) / [rest](../index.md) / QueryState ```ts type QueryState = object; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:11 ## Properties ### include? ```ts optional include: unknown; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:12 *** ### since? ```ts optional since: unknown; ``` Defined in: warp-drive-packages/legacy/declarations/adapter/rest.d.ts:13 --- --- url: /api/@ember-data/graph.md --- [Documentation](../../index.md) / @ember-data/graph --- --- url: /api/@ember-data/json-api.md --- [Documentation](../../index.md) / @ember-data/json-api ## Modules * [index](index/index.md) * [request](request/index.md) --- --- url: /api/@ember-data/json-api/index/classes/default.md --- [Documentation](../../../../index.md) / [@ember-data/json-api](../../index.md) / [index](../index.md) / default Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:55 A JSON:API Cache implementation. What cache the store uses is configurable. Using a different implementation can be achieved by implementing the store's createCache hook. This is the cache implementation used by `ember-data`. ```js import Cache from '@ember-data/json-api'; import Store from '@ember-data/store'; export default class extends Store { createCache(wrapper) { return new Cache(wrapper); } } ``` Cache ## Implements * [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md) ## Constructors ### Constructor ```ts new default(capabilities): JSONAPICache; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:74 #### Parameters ##### capabilities [`CacheCapabilitiesManager`](../../../../@warp-drive/core-types/index/type-aliases/CacheCapabilitiesManager.md) #### Returns `JSONAPICache` ## Properties ### version ```ts version: "2"; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:63 The Cache Version that this implementation implements. #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`version`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#version) ## Methods ### changedAttrs() ```ts changedAttrs(identifier): ChangedAttributesHash; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:354 Query the cache for the changed attributes of a resource. #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `ChangedAttributesHash` `{ : [, ] }` #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`changedAttrs`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#changedattrs) *** ### changedRelationships() ```ts changedRelationships(identifier): Map; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:399 Query the cache for the changes to relationships of a resource. Returns a map of relationship names to RelationshipDiff objects. ```ts type RelationshipDiff = | { kind: 'collection'; remoteState: StableRecordIdentifier[]; additions: Set; removals: Set; localState: StableRecordIdentifier[]; reordered: boolean; } | { kind: 'resource'; remoteState: StableRecordIdentifier | null; localState: StableRecordIdentifier | null; }; ``` #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `Map`<`string`, [`RelationshipDiff`](../../../../@warp-drive/core-types/cache/type-aliases/RelationshipDiff.md)> #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`changedRelationships`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#changedrelationships) *** ### clientDidCreate() ```ts clientDidCreate(identifier, options?): Record; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:289 \[LIFECYCLE] Signal to the cache that a new record has been instantiated on the client It returns properties from options that should be set on the record during the create process. This return value behavior is deprecated. #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### options? `Record`<`string`, [`Value`](../../../../@warp-drive/core-types/json/raw/type-aliases/Value.md)> #### Returns `Record`<`string`, `unknown`> #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`clientDidCreate`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#clientdidcreate) *** ### commitWasRejected() ```ts commitWasRejected(identifier, errors?): void; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:315 \[LIFECYCLE] Signals to the cache that a resource was update via a save transaction failed. #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### errors? [`ApiError`](../../../../@warp-drive/core-types/spec/error/interfaces/ApiError.md)\[] #### Returns `void` #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`commitWasRejected`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#commitwasrejected) *** ### didCommit() ```ts didCommit(committedIdentifier, result): SingleResourceDataDocument; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:306 \[LIFECYCLE] Signals to the cache that a resource was successfully updated as part of a save transaction. #### Parameters ##### committedIdentifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### result [`StructuredDataDocument`](../../../../@warp-drive/core-types/request/interfaces/StructuredDataDocument.md)<[`SingleResourceDocument`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md)> #### Returns [`SingleResourceDataDocument`](../../../../@warp-drive/core-types/spec/document/interfaces/SingleResourceDataDocument.md) #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`didCommit`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#didcommit) *** ### diff() ```ts diff(): Promise; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:252 Generate the list of changes applied to all record in the store. Each individual resource or document that has been mutated should be described as an individual `Change` entry in the returned array. A `Change` is described by an object containing up to three properties: (1) the `identifier` of the entity that changed; (2) the `op` code of that change being one of `upsert` or `remove`, and if the op is `upsert` a `patch` containing the data to merge into the cache for the given entity. This `patch` is opaque to the Store but should be understood by the Cache and may expect to be utilized by an Adapter when generating data during a `save` operation. It is generally recommended that the `patch` contain only the updated state, ignoring fields that are unchanged ```ts interface Change { identifier: StableRecordIdentifier | StableDocumentIdentifier; op: 'upsert' | 'remove'; patch?: unknown; } ``` #### Returns `Promise`<[`Change`](../../../../@warp-drive/core-types/cache/change/interfaces/Change.md)\[]> #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`diff`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#diff) *** ### dump() ```ts dump(): Promise>; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:261 Serialize the entire contents of the Cache into a Stream which may be fed back into a new instance of the same Cache via `cache.hydrate`. #### Returns `Promise`<`ReadableStream`<`unknown`>> #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`dump`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#dump) *** ### getAttr() ```ts getAttr(identifier, attr): | undefined | Value; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:334 Retrieve the data for an attribute from the cache #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### attr `string` | `string`\[] #### Returns | `undefined` | [`Value`](../../../../@warp-drive/core-types/json/raw/type-aliases/Value.md) #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`getAttr`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#getattr) *** ### getErrors() ```ts getErrors(identifier): ApiError[]; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:448 Query the cache for any validation errors applicable to the given resource. #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns [`ApiError`](../../../../@warp-drive/core-types/spec/error/interfaces/ApiError.md)\[] #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`getErrors`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#geterrors) *** ### getRelationship() ```ts getRelationship(identifier, field): | ResourceRelationship | CollectionRelationship; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:428 Query the cache for the current state of a relationship property #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### field `string` #### Returns | [`ResourceRelationship`](../../../../@warp-drive/core-types/cache/relationship/interfaces/ResourceRelationship.md)<[`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md)> | [`CollectionRelationship`](../../../../@warp-drive/core-types/cache/relationship/interfaces/CollectionRelationship.md)<[`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md)> resource relationship object #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`getRelationship`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#getrelationship) *** ### getRemoteAttr() ```ts getRemoteAttr(identifier, attr): | undefined | Value; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:335 Retrieve remote state without any local changes for a specific attribute #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### attr `string` | `string`\[] #### Returns | `undefined` | [`Value`](../../../../@warp-drive/core-types/json/raw/type-aliases/Value.md) #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`getRemoteAttr`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#getremoteattr) *** ### getRemoteRelationship() ```ts getRemoteRelationship(identifier, field): | ResourceRelationship | CollectionRelationship; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:429 Query the cache for the server state of a relationship property without any local changes #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### field `string` #### Returns | [`ResourceRelationship`](../../../../@warp-drive/core-types/cache/relationship/interfaces/ResourceRelationship.md)<[`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md)> | [`CollectionRelationship`](../../../../@warp-drive/core-types/cache/relationship/interfaces/CollectionRelationship.md)<[`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md)> resource relationship object #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`getRemoteRelationship`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#getremoterelationship) *** ### hasChangedAttrs() ```ts hasChangedAttrs(identifier): boolean; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:362 Query the cache for whether any mutated attributes exist #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`hasChangedAttrs`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#haschangedattrs) *** ### hasChangedRelationships() ```ts hasChangedRelationships(identifier): boolean; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:407 Query the cache for whether any mutated relationships exist #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`hasChangedRelationships`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#haschangedrelationships) *** ### hydrate() ```ts hydrate(stream): Promise; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:278 hydrate a Cache from a Stream with content previously serialized from another instance of the same Cache, resolving when hydration is complete. This method should expect to be called both in the context of restoring the Cache during application rehydration after SSR **AND** at unknown times during the lifetime of an already booted application when it is desired to bulk-load additional information into the cache. This latter behavior supports optimizing pre/fetching of data for route transitions via data-only SSR modes. #### Parameters ##### stream `ReadableStream`<`unknown`> #### Returns `Promise`<`void`> #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`hydrate`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#hydrate) *** ### isDeleted() ```ts isDeleted(identifier): boolean; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:474 Query the cache for whether a given resource is marked as deleted (but not necessarily persisted yet). #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`isDeleted`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#isdeleted) *** ### isDeletionCommitted() ```ts isDeletionCommitted(identifier): boolean; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:483 Query the cache for whether a given resource has been deleted and that deletion has also been persisted. #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`isDeletionCommitted`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#isdeletioncommitted) *** ### isEmpty() ```ts isEmpty(identifier): boolean; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:456 Query the cache for whether a given resource has any available data #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`isEmpty`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#isempty) *** ### isNew() ```ts isNew(identifier): boolean; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:465 Query the cache for whether a given resource was created locally and not yet persisted. #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`isNew`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#isnew) *** ### merge() ```ts merge(cache): Promise; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:219 Merge a fork back into a parent Cache. Applications should typically not call this method themselves, preferring instead to merge at the Store level, which will utilize this method to merge the caches. #### Parameters ##### cache [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md) #### Returns `Promise`<`void`> #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`merge`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#merge) *** ### mutate() ```ts mutate(mutation): void; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:138 Update the "local" or "current" (unpersisted) state of the Cache #### Parameters ##### mutation [`LocalRelationshipOperation`](../../../../@warp-drive/core-types/graph/type-aliases/LocalRelationshipOperation.md) #### Returns `void` #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`mutate`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#mutate) *** ### patch() ```ts patch(op): void; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:130 Update the "remote" or "canonical" (persisted) state of the Cache by merging new information into the existing state. #### Parameters ##### op the operation or list of operations to perform [`Operation`](../../../../@warp-drive/core-types/cache/operations/type-aliases/Operation.md) | [`Operation`](../../../../@warp-drive/core-types/cache/operations/type-aliases/Operation.md)\[] #### Returns `void` #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`patch`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#patch) *** ### peek() #### Call Signature ```ts peek(identifier): | null | ResourceObject; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:170 Peek resource data from the Cache. In development, if the return value is JSON the return value will be deep-cloned and deep-frozen to prevent mutation thereby enforcing cache Immutability. This form of peek is useful for implementations that want to feed raw-data from cache to the UI or which want to interact with a blob of data directly from the presentation cache. An implementation might want to do this because de-referencing records which read from their own blob is generally safer because the record does not require retainining connections to the Store and Cache to present data on a per-field basis. This generally takes the place of `getAttr` as an API and may even take the place of `getRelationship` depending on implementation specifics, though this latter usage is less recommended due to the advantages of the Graph handling necessary entanglements and notifications for relational data. ##### Parameters ###### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### Returns | `null` | [`ResourceObject`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/ResourceObject.md) the known resource data ##### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`peek`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#peek) #### Call Signature ```ts peek(identifier): | null | ResourceDocument; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:171 Peek resource data from the Cache. In development, if the return value is JSON the return value will be deep-cloned and deep-frozen to prevent mutation thereby enforcing cache Immutability. This form of peek is useful for implementations that want to feed raw-data from cache to the UI or which want to interact with a blob of data directly from the presentation cache. An implementation might want to do this because de-referencing records which read from their own blob is generally safer because the record does not require retainining connections to the Store and Cache to present data on a per-field basis. This generally takes the place of `getAttr` as an API and may even take the place of `getRelationship` depending on implementation specifics, though this latter usage is less recommended due to the advantages of the Graph handling necessary entanglements and notifications for relational data. ##### Parameters ###### identifier [`StableDocumentIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md) ##### Returns | `null` | [`ResourceDocument`](../../../../@warp-drive/core-types/spec/document/type-aliases/ResourceDocument.md) the known resource data ##### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`peek`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#peek) *** ### peekRemoteState() #### Call Signature ```ts peekRemoteState(identifier): | null | ResourceObject; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:172 Peek remote resource data from the Cache. This will give the data provided from the server without any local changes. In development, if the return value is JSON the return value will be deep-cloned and deep-frozen to prevent mutation thereby enforcing cache Immutability. This form of peek is useful for implementations that want to feed raw-data from cache to the UI or which want to interact with a blob of data directly from the presentation cache. An implementation might want to do this because de-referencing records which read from their own blob is generally safer because the record does not require retainining connections to the Store and Cache to present data on a per-field basis. This generally takes the place of `getAttr` as an API and may even take the place of `getRelationship` depending on implementation specifics, though this latter usage is less recommended due to the advantages of the Graph handling necessary entanglements and notifications for relational data. ##### Parameters ###### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### Returns | `null` | [`ResourceObject`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/ResourceObject.md) the known resource data ##### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`peekRemoteState`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#peekremotestate) #### Call Signature ```ts peekRemoteState(identifier): | null | ResourceDocument; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:173 ##### Parameters ###### identifier [`StableDocumentIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md) ##### Returns | `null` | [`ResourceDocument`](../../../../@warp-drive/core-types/spec/document/type-aliases/ResourceDocument.md) ##### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`peekRemoteState`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#peekremotestate) *** ### peekRequest() ```ts peekRequest(identifier): | null | StructuredDocument; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:186 Peek the Cache for the existing request data associated with a cacheable request. This is effectively the reverse of `put` for a request in that it will return the the request, response, and content whereas `peek` will return just the `content`. #### Parameters ##### identifier [`StableDocumentIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md) #### Returns | `null` | [`StructuredDocument`](../../../../@warp-drive/core-types/request/type-aliases/StructuredDocument.md)<[`ResourceDocument`](../../../../@warp-drive/core-types/spec/document/type-aliases/ResourceDocument.md)> #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`peekRequest`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#peekrequest) *** ### put() #### Call Signature ```ts put(doc): SingleResourceDataDocument; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:113 Cache the response to a request Implements `Cache.put`. Expects a StructuredDocument whose `content` member is a JsonApiDocument. ```js cache.put({ request: { url: 'https://api.example.com/v1/user/1' }, content: { data: { type: 'user', id: '1', attributes: { name: 'Chris' } } } }) ``` > **Note** > The nested `content` and `data` members are not a mistake. This is because > there are two separate concepts involved here, the `StructuredDocument` which contains > the context of a given Request that has been issued with the returned contents as its > `content` property, and a `JSON:API Document` which is the json contents returned by > this endpoint and which uses its `data` property to signify which resources are the > primary resources associated with the request. StructuredDocument's with urls will be cached as full documents with associated resource membership order and contents preserved but linked into the cache. ##### Type Parameters ###### T `T` *extends* [`SingleResourceDocument`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md) ##### Parameters ###### doc [`StructuredDataDocument`](../../../../@warp-drive/core-types/request/interfaces/StructuredDataDocument.md)<`T`> ##### Returns [`SingleResourceDataDocument`](../../../../@warp-drive/core-types/spec/document/interfaces/SingleResourceDataDocument.md) ##### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`put`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#put) #### Call Signature ```ts put(doc): CollectionResourceDataDocument; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:114 Cache the response to a request Implements `Cache.put`. Expects a StructuredDocument whose `content` member is a JsonApiDocument. ```js cache.put({ request: { url: 'https://api.example.com/v1/user/1' }, content: { data: { type: 'user', id: '1', attributes: { name: 'Chris' } } } }) ``` > **Note** > The nested `content` and `data` members are not a mistake. This is because > there are two separate concepts involved here, the `StructuredDocument` which contains > the context of a given Request that has been issued with the returned contents as its > `content` property, and a `JSON:API Document` which is the json contents returned by > this endpoint and which uses its `data` property to signify which resources are the > primary resources associated with the request. StructuredDocument's with urls will be cached as full documents with associated resource membership order and contents preserved but linked into the cache. ##### Type Parameters ###### T `T` *extends* [`CollectionResourceDocument`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/CollectionResourceDocument.md) ##### Parameters ###### doc [`StructuredDataDocument`](../../../../@warp-drive/core-types/request/interfaces/StructuredDataDocument.md)<`T`> ##### Returns [`CollectionResourceDataDocument`](../../../../@warp-drive/core-types/spec/document/interfaces/CollectionResourceDataDocument.md) ##### Implementation of ```ts Cache.put ``` #### Call Signature ```ts put(doc): ResourceErrorDocument; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:115 Cache the response to a request Implements `Cache.put`. Expects a StructuredDocument whose `content` member is a JsonApiDocument. ```js cache.put({ request: { url: 'https://api.example.com/v1/user/1' }, content: { data: { type: 'user', id: '1', attributes: { name: 'Chris' } } } }) ``` > **Note** > The nested `content` and `data` members are not a mistake. This is because > there are two separate concepts involved here, the `StructuredDocument` which contains > the context of a given Request that has been issued with the returned contents as its > `content` property, and a `JSON:API Document` which is the json contents returned by > this endpoint and which uses its `data` property to signify which resources are the > primary resources associated with the request. StructuredDocument's with urls will be cached as full documents with associated resource membership order and contents preserved but linked into the cache. ##### Type Parameters ###### T `T` *extends* [`ResourceErrorDocument`](../../../../@warp-drive/core-types/spec/document/interfaces/ResourceErrorDocument.md) ##### Parameters ###### doc [`StructuredErrorDocument`](../../../../@warp-drive/core-types/request/interfaces/StructuredErrorDocument.md)<`T`> ##### Returns [`ResourceErrorDocument`](../../../../@warp-drive/core-types/spec/document/interfaces/ResourceErrorDocument.md) ##### Implementation of ```ts Cache.put ``` #### Call Signature ```ts put(doc): ResourceMetaDocument; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:116 Cache the response to a request Implements `Cache.put`. Expects a StructuredDocument whose `content` member is a JsonApiDocument. ```js cache.put({ request: { url: 'https://api.example.com/v1/user/1' }, content: { data: { type: 'user', id: '1', attributes: { name: 'Chris' } } } }) ``` > **Note** > The nested `content` and `data` members are not a mistake. This is because > there are two separate concepts involved here, the `StructuredDocument` which contains > the context of a given Request that has been issued with the returned contents as its > `content` property, and a `JSON:API Document` which is the json contents returned by > this endpoint and which uses its `data` property to signify which resources are the > primary resources associated with the request. StructuredDocument's with urls will be cached as full documents with associated resource membership order and contents preserved but linked into the cache. ##### Type Parameters ###### T `T` *extends* [`ResourceMetaDocument`](../../../../@warp-drive/core-types/spec/document/interfaces/ResourceMetaDocument.md) ##### Parameters ###### doc [`StructuredDataDocument`](../../../../@warp-drive/core-types/request/interfaces/StructuredDataDocument.md)<`T`> ##### Returns [`ResourceMetaDocument`](../../../../@warp-drive/core-types/spec/document/interfaces/ResourceMetaDocument.md) ##### Implementation of ```ts Cache.put ``` *** ### rollbackAttrs() ```ts rollbackAttrs(identifier): string[]; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:372 Tell the cache to discard any uncommitted mutations to attributes This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `string`\[] the names of fields that were restored #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`rollbackAttrs`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#rollbackattrs) *** ### rollbackRelationships() ```ts rollbackRelationships(identifier): string[]; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:419 Tell the cache to discard any uncommitted mutations to relationships. This will also discard the change on any appropriate inverses. This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `string`\[] the names of relationships that were restored #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`rollbackRelationships`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#rollbackrelationships) *** ### setAttr() ```ts setAttr( identifier, attr, value): void; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:346 Mutate the data for an attribute in the cache This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### attr `string` | `string`\[] ##### value [`Value`](../../../../@warp-drive/core-types/json/raw/type-aliases/Value.md) #### Returns `void` #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`setAttr`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#setattr) *** ### setIsDeleted() ```ts setIsDeleted(identifier, isDeleted): void; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:440 Update the cache state for the given resource to be marked as locally deleted, or remove such a mark. This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### isDeleted `boolean` #### Returns `void` #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`setIsDeleted`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#setisdeleted) *** ### unloadRecord() ```ts unloadRecord(identifier): void; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:325 \[LIFECYCLE] Signals to the cache that all data for a resource should be cleared. This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `void` #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`unloadRecord`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#unloadrecord) *** ### upsert() ```ts upsert( identifier, data, calculateChanges?): void | string[]; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:196 Push resource data from a remote source into the cache for this identifier #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### data `ExistingResourceObject` ##### calculateChanges? `boolean` #### Returns `void` | `string`\[] if `hasRecord` is true then calculated key changes should be returned #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`upsert`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#upsert) *** ### willCommit() ```ts willCommit(identifier): void; ``` Defined in: warp-drive-packages/json-api/declarations/-private/cache.d.ts:297 \[LIFECYCLE] Signals to the cache that a resource will be part of a save transaction. #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `void` #### Implementation of [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md).[`willCommit`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md#willcommit) --- --- url: /api/@ember-data/json-api/index.md --- [Documentation](../../../index.md) / [@ember-data/json-api](../index.md) / index ## Classes * [default](classes/default.md) --- --- url: /api/@ember-data/json-api/request/functions/createRecord.md --- [Documentation](../../../../index.md) / [@ember-data/json-api](../../index.md) / [request](../index.md) / createRecord ## Call Signature ```ts function createRecord(record, options?): CreateRequestOptions; ``` Defined in: warp-drive-packages/utilities/declarations/-private/json-api/save-record.d.ts:94 Builds request options to create new record for resources, configured for the url, method and header expectations of most JSON:API APIs. **Basic Usage** ```ts import { createRecord } from '@warp-drive/utilities/json-api'; const person = store.createRecord('person', { name: 'Ted' }); const data = await store.request(createRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { createRecord } from '@warp-drive/utilities/json-api'; const person = store.createRecord('person', { name: 'Ted' }); const options = createRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### record `T` #### options? [`ConstrainedRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`CreateRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/CreateRequestOptions.md)<`T`> ## Call Signature ```ts function createRecord(record, options?): CreateRequestOptions; ``` Defined in: warp-drive-packages/utilities/declarations/-private/json-api/save-record.d.ts:95 Builds request options to create new record for resources, configured for the url, method and header expectations of most JSON:API APIs. **Basic Usage** ```ts import { createRecord } from '@warp-drive/utilities/json-api'; const person = store.createRecord('person', { name: 'Ted' }); const data = await store.request(createRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { createRecord } from '@warp-drive/utilities/json-api'; const person = store.createRecord('person', { name: 'Ted' }); const options = createRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Parameters #### record `unknown` #### options? [`ConstrainedRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`CreateRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/CreateRequestOptions.md) --- --- url: /api/@ember-data/json-api/request/functions/findRecord.md --- [Documentation](../../../../index.md) / [@ember-data/json-api](../../index.md) / [request](../index.md) / findRecord ## Call Signature ```ts function findRecord(identifier, options?): FindRecordRequestOptions, T>; ``` Defined in: warp-drive-packages/utilities/declarations/-private/json-api/find-record.d.ts:62 ### Type Parameters #### T `T` ### Parameters #### identifier [`RemotelyAccessibleIdentifier`](../../../../@warp-drive/core-types/request/type-aliases/RemotelyAccessibleIdentifier.md)<[`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`>> #### options? [`FindRecordOptions`](../../../../@warp-drive/core-types/request/type-aliases/FindRecordOptions.md)<`T`> ### Returns [`FindRecordRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/FindRecordRequestOptions.md)<`FindRecordResultDocument`<`T`>, `T`> ## Call Signature ```ts function findRecord(identifier, options?): FindRecordRequestOptions; ``` Defined in: warp-drive-packages/utilities/declarations/-private/json-api/find-record.d.ts:63 ### Parameters #### identifier [`RemotelyAccessibleIdentifier`](../../../../@warp-drive/core-types/request/type-aliases/RemotelyAccessibleIdentifier.md) #### options? [`FindRecordOptions`](../../../../@warp-drive/core-types/request/type-aliases/FindRecordOptions.md) ### Returns [`FindRecordRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/FindRecordRequestOptions.md) ## Call Signature ```ts function findRecord( type, id, options?): FindRecordRequestOptions, T>; ``` Defined in: warp-drive-packages/utilities/declarations/-private/json-api/find-record.d.ts:64 ### Type Parameters #### T `T` ### Parameters #### type [`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> #### id `string` #### options? [`FindRecordOptions`](../../../../@warp-drive/core-types/request/type-aliases/FindRecordOptions.md)<`T`> ### Returns [`FindRecordRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/FindRecordRequestOptions.md)<`FindRecordResultDocument`<`T`>, `T`> ## Call Signature ```ts function findRecord( type, id, options?): FindRecordRequestOptions; ``` Defined in: warp-drive-packages/utilities/declarations/-private/json-api/find-record.d.ts:65 ### Parameters #### type `string` #### id `string` #### options? [`FindRecordOptions`](../../../../@warp-drive/core-types/request/type-aliases/FindRecordOptions.md) ### Returns [`FindRecordRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/FindRecordRequestOptions.md) --- --- url: /api/@ember-data/json-api/request/functions/deleteRecord.md --- [Documentation](../../../../index.md) / [@ember-data/json-api](../../index.md) / [request](../index.md) / deleteRecord ## Call Signature ```ts function deleteRecord(record, options?): DeleteRequestOptions; ``` Defined in: warp-drive-packages/utilities/declarations/-private/json-api/save-record.d.ts:53 Builds request options to delete record for resources, configured for the url, method and header expectations of most JSON:API APIs. **Basic Usage** ```ts import { deleteRecord } from '@warp-drive/utilities/json-api'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const data = await store.request(deleteRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { deleteRecord } from '@warp-drive/utilities/json-api'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const options = deleteRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### record `T` #### options? [`ConstrainedRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`DeleteRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/DeleteRequestOptions.md)<`T`> ## Call Signature ```ts function deleteRecord(record, options?): DeleteRequestOptions; ``` Defined in: warp-drive-packages/utilities/declarations/-private/json-api/save-record.d.ts:54 Builds request options to delete record for resources, configured for the url, method and header expectations of most JSON:API APIs. **Basic Usage** ```ts import { deleteRecord } from '@warp-drive/utilities/json-api'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const data = await store.request(deleteRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { deleteRecord } from '@warp-drive/utilities/json-api'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const options = deleteRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Parameters #### record `unknown` #### options? [`ConstrainedRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`DeleteRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/DeleteRequestOptions.md) --- --- url: /api/@ember-data/json-api/request/functions/postQuery.md --- [Documentation](../../../../index.md) / [@ember-data/json-api](../../index.md) / [request](../index.md) / postQuery ## Call Signature ```ts function postQuery( type, query?, options?): PostQueryRequestOptions, T>; ``` Defined in: warp-drive-packages/utilities/declarations/-private/json-api/query.d.ts:102 Builds request options to query for resources, usually by a primary type, configured for the url and header expectations of most JSON:API APIs. The key difference between this and `query` is that this method will send the query as the JSON body of a "POST" request instead of as query params in the url of a "GET" request. A CacheKey is generated from the url and query params, and used to cache the response in the store. ```ts import { postQuery } from '@warp-drive/utilities/json-api'; const options = postQuery('person', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { postQuery } from '@warp-drive/utilities/json-api'; const options = postQuery('person', { include: ['pets', 'friends'] }, { reload: true }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### type [`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> #### query? [`QueryParamsSource`](../../../../@warp-drive/core-types/params/type-aliases/QueryParamsSource.md) #### options? [`ConstrainedRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`PostQueryRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/PostQueryRequestOptions.md)<[`CollectionResourceDataDocument`](../../../../@warp-drive/core-types/spec/document/interfaces/CollectionResourceDataDocument.md)<`T`>, `T`> ## Call Signature ```ts function postQuery( type, query?, options?): PostQueryRequestOptions; ``` Defined in: warp-drive-packages/utilities/declarations/-private/json-api/query.d.ts:103 Builds request options to query for resources, usually by a primary type, configured for the url and header expectations of most JSON:API APIs. The key difference between this and `query` is that this method will send the query as the JSON body of a "POST" request instead of as query params in the url of a "GET" request. A CacheKey is generated from the url and query params, and used to cache the response in the store. ```ts import { postQuery } from '@warp-drive/utilities/json-api'; const options = postQuery('person', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { postQuery } from '@warp-drive/utilities/json-api'; const options = postQuery('person', { include: ['pets', 'friends'] }, { reload: true }); const data = await store.request(options); ``` ### Parameters #### type `string` #### query? [`QueryParamsSource`](../../../../@warp-drive/core-types/params/type-aliases/QueryParamsSource.md) #### options? [`ConstrainedRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`PostQueryRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/PostQueryRequestOptions.md) --- --- url: /api/@ember-data/json-api/request/functions/query.md --- [Documentation](../../../../index.md) / [@ember-data/json-api](../../index.md) / [request](../index.md) / query ## Call Signature ```ts function query( type, query?, options?): QueryRequestOptions, T>; ``` Defined in: warp-drive-packages/utilities/declarations/-private/json-api/query.d.ts:56 Builds request options to query for resources, usually by a primary type, configured for the url and header expectations of most JSON:API APIs. The key difference between this and `postQuery` is that this method will send the query as query params in the url of a "GET" request instead of as the JSON body of a "POST" request. **Basic Usage** ```ts import { query } from '@warp-drive/utilities/json-api'; const data = await store.request(query('person')); ``` **With Query Params** ```ts import { query } from '@warp-drive/utilities/json-api'; const options = query('person', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { query } from '@warp-drive/utilities/json-api'; const options = query('person', { include: ['pets', 'friends'] }, { reload: true }); const data = await store.request(options); ``` ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../../../../@warp-drive/core-types/record/interfaces/TypedRecordInstance.md) ### Parameters #### type [`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> #### query? [`QueryParamsSource`](../../../../@warp-drive/core-types/params/type-aliases/QueryParamsSource.md)<`T`> #### options? [`ConstrainedRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`QueryRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/QueryRequestOptions.md)<[`CollectionResourceDataDocument`](../../../../@warp-drive/core-types/spec/document/interfaces/CollectionResourceDataDocument.md)<`T`>, `T`> ## Call Signature ```ts function query( type, query?, options?): QueryRequestOptions; ``` Defined in: warp-drive-packages/utilities/declarations/-private/json-api/query.d.ts:57 Builds request options to query for resources, usually by a primary type, configured for the url and header expectations of most JSON:API APIs. The key difference between this and `postQuery` is that this method will send the query as query params in the url of a "GET" request instead of as the JSON body of a "POST" request. **Basic Usage** ```ts import { query } from '@warp-drive/utilities/json-api'; const data = await store.request(query('person')); ``` **With Query Params** ```ts import { query } from '@warp-drive/utilities/json-api'; const options = query('person', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { query } from '@warp-drive/utilities/json-api'; const options = query('person', { include: ['pets', 'friends'] }, { reload: true }); const data = await store.request(options); ``` ### Parameters #### type `string` #### query? [`QueryParamsSource`](../../../../@warp-drive/core-types/params/type-aliases/QueryParamsSource.md) #### options? [`ConstrainedRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`QueryRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/QueryRequestOptions.md) --- --- url: /api/@ember-data/json-api/request/functions/serializePatch.md --- [Documentation](../../../../index.md) / [@ember-data/json-api](../../index.md) / [request](../index.md) / serializePatch ```ts function serializePatch(cache, identifier): object; ``` Defined in: warp-drive-packages/utilities/declarations/-private/json-api/serialize.d.ts:53 Serializes changes to a resource for use with PATCH requests. Only attributes which are changed are serialized. Only relationships which are changed are serialized. Collection relationships serialize the collection as a whole. If you would like to serialize updates to a collection more granularly (for instance, as operations) request the diff from the store and serialize as desired: ```ts const relationshipDiffMap = cache.changedRelationships(identifier); ``` ## Parameters ### cache [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md) ### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ## Returns `object` An object with a `data` property containing the serialized resource patch ### data ```ts data: JsonApiResourcePatch; ``` --- --- url: /api/@ember-data/json-api/request/functions/serializeResources.md --- [Documentation](../../../../index.md) / [@ember-data/json-api](../../index.md) / [request](../index.md) / serializeResources ## Call Signature ```ts function serializeResources(cache, identifiers): object; ``` Defined in: warp-drive-packages/utilities/declarations/-private/json-api/serialize.d.ts:26 Serializes the current state of a resource or array of resources for use with POST or PUT requests. ### Parameters #### cache [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md) #### identifiers [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ### Returns `object` An object with a `data` property containing the serialized resource patch #### data ```ts data: ResourceObject; ``` ## Call Signature ```ts function serializeResources(cache, identifiers): object; ``` Defined in: warp-drive-packages/utilities/declarations/-private/json-api/serialize.d.ts:29 Serializes the current state of a resource or array of resources for use with POST or PUT requests. ### Parameters #### cache [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md) #### identifiers [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md)\[] ### Returns `object` An object with a `data` property containing the serialized resource patch #### data ```ts data: ResourceObject[]; ``` --- --- url: /api/@ember-data/json-api/request/functions/setBuildURLConfig.md --- [Documentation](../../../../index.md) / [@ember-data/json-api](../../index.md) / [request](../index.md) / setBuildURLConfig ```ts function setBuildURLConfig(config): void; ``` Defined in: warp-drive-packages/utilities/declarations/-private/json-api/-utils.d.ts:54 Allows setting extensions and profiles to be used in the `Accept` header. Extensions and profiles are keyed by their namespace with the value being their URI. Example: ```ts setBuildURLConfig({ extensions: { atomic: 'https://jsonapi.org/ext/atomic' }, profiles: { pagination: 'https://jsonapi.org/profiles/ethanresnick/cursor-pagination' } }); ``` This also sets the global configuration for `buildBaseURL` for host and namespace values for the global coniguration done via `import { setBuildURLConfig } from '@warp-drive/utilities';` These values may still be overridden by passing them to buildBaseURL directly. This method may be called as many times as needed ```ts type BuildURLConfig = { host: string; namespace: string' } ``` ## Parameters ### config `JSONAPIConfig` ## Returns `void` --- --- url: /api/@ember-data/json-api/request/functions/updateRecord.md --- [Documentation](../../../../index.md) / [@ember-data/json-api](../../index.md) / [request](../index.md) / updateRecord ## Call Signature ```ts function updateRecord(record, options?): UpdateRequestOptions>, T>; ``` Defined in: warp-drive-packages/utilities/declarations/-private/json-api/save-record.d.ts:138 Builds request options to update existing record for resources, configured for the url, method and header expectations of most JSON:API APIs. **Basic Usage** ```ts import { updateRecord } from '@warp-drive/utilities/json-api'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const data = await store.request(updateRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`. * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { updateRecord } from '@warp-drive/utilities/json-api'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const options = updateRecord(person, { patch: true }); const data = await store.request(options); ``` ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../../../../@warp-drive/core-types/record/interfaces/TypedRecordInstance.md) #### RT `RT` *extends* [`TypedRecordInstance`](../../../../@warp-drive/core-types/record/interfaces/TypedRecordInstance.md) = `T` ### Parameters #### record `T` #### options? [`ConstrainedRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) & `object` ### Returns [`UpdateRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/UpdateRequestOptions.md)<[`SingleResourceDataDocument`](../../../../@warp-drive/core-types/spec/document/interfaces/SingleResourceDataDocument.md)<`RT`, `StableExistingRecordIdentifier`<`string`>>, `T`> ## Call Signature ```ts function updateRecord(record, options?): UpdateRequestOptions; ``` Defined in: warp-drive-packages/utilities/declarations/-private/json-api/save-record.d.ts:141 Builds request options to update existing record for resources, configured for the url, method and header expectations of most JSON:API APIs. **Basic Usage** ```ts import { updateRecord } from '@warp-drive/utilities/json-api'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const data = await store.request(updateRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`. * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { updateRecord } from '@warp-drive/utilities/json-api'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const options = updateRecord(person, { patch: true }); const data = await store.request(options); ``` ### Parameters #### record `unknown` #### options? [`ConstrainedRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) & `object` ### Returns [`UpdateRequestOptions`](../../../../@warp-drive/core-types/request/type-aliases/UpdateRequestOptions.md) --- --- url: /api/@ember-data/json-api/request.md --- [Documentation](../../../index.md) / [@ember-data/json-api](../index.md) / request This package provides utilities for working with [JSON:API](https://json-api.org) APIs with [*Ember***Data**](https://github.com/emberjs/data/). ## Installation Install using your javascript package manager of choice. For instance with [pnpm](https://pnpm.io/) ```no-highlight pnpm add @ember-data/json-api ``` ## Usage Request builders are functions that produce [Fetch Options](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). They take a few contextual inputs about the request you want to make, abstracting away the gnarlier details. For instance, to fetch a resource from your API ```ts import { findRecord } from '@ember-data/json-api/request'; const options = findRecord('ember-developer', '1', { include: ['pets', 'friends'] }); /* { url: 'https://api.example.com/v1/ember-developers/1?include=friends,pets', method: 'GET', headers: , // => 'Accept': 'application/vnd.api+json' // => 'Content-Type': 'application/vnd.api+json' op: 'findRecord'; records: [{ type: 'ember-developer', id: '1' }] } \ ``` Request builder output may be used with either `requestManager.request` or `store.request`. URLs are stable. The same query will produce the same URL every time, even if the order of keys in the query or values in an array changes. URLs follow the most common JSON:API format (dasherized pluralized resource types). ## Functions * [createRecord](functions/createRecord.md) * [deleteRecord](functions/deleteRecord.md) * [findRecord](functions/findRecord.md) * [postQuery](functions/postQuery.md) * [query](functions/query.md) * [serializePatch](functions/serializePatch.md) * [serializeResources](functions/serializeResources.md) * [setBuildURLConfig](functions/setBuildURLConfig.md) * [updateRecord](functions/updateRecord.md) --- --- url: /api/@ember-data/legacy-compat/builders/functions/findAll.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [builders](../index.md) / findAll ## Call Signature ```ts function findAll(type, options?): FindAllRequestInput, T[]>; ``` Defined in: warp-drive-packages/legacy/declarations/compat/builders/find-all.d.ts:30 This function builds a request config to perform a `findAll` request for the given type. When passed to `store.request`, this config will result in the same behavior as a `store.findAll` request. Additionally, it takes the same options as `store.findAll`. All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../../../../@warp-drive/core-types/record/interfaces/TypedRecordInstance.md) ### Parameters #### type [`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> the name of the resource #### options? `FindAllBuilderOptions`<`T`> optional, may include `adapterOptions` hash which will be passed to adapter.findAll ### Returns `FindAllRequestInput`<[`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`>, `T`\[]> request config ### Deprecated ## Call Signature ```ts function findAll(type, options?): FindAllRequestInput; ``` Defined in: warp-drive-packages/legacy/declarations/compat/builders/find-all.d.ts:31 This function builds a request config to perform a `findAll` request for the given type. When passed to `store.request`, this config will result in the same behavior as a `store.findAll` request. Additionally, it takes the same options as `store.findAll`. All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Parameters #### type `string` the name of the resource #### options? `FindAllBuilderOptions`<`unknown`> optional, may include `adapterOptions` hash which will be passed to adapter.findAll ### Returns `FindAllRequestInput` request config ### Deprecated --- --- url: /api/@ember-data/legacy-compat/builders/functions/query.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [builders](../index.md) / query ## Call Signature ```ts function query( type, query, options?): QueryRequestInput, T[]>; ``` Defined in: warp-drive-packages/legacy/declarations/compat/builders/query.d.ts:31 This function builds a request config for a given type and query object. When passed to `store.request`, this config will result in the same behavior as a `store.query` request. Additionally, it takes the same options as `store.query`. All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../../../../@warp-drive/core-types/record/interfaces/TypedRecordInstance.md) ### Parameters #### type [`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> the name of the resource #### query [`LegacyResourceQuery`](../../../../@warp-drive/core-types/index/type-aliases/LegacyResourceQuery.md)<`T`> a query to be used by the adapter #### options? [`QueryOptions`](../../../../@warp-drive/core-types/index/type-aliases/QueryOptions.md) optional, may include `adapterOptions` hash which will be passed to adapter.query ### Returns `QueryRequestInput`<[`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`>, `T`\[]> request config ### Deprecated ## Call Signature ```ts function query( type, query, options?): QueryRequestInput; ``` Defined in: warp-drive-packages/legacy/declarations/compat/builders/query.d.ts:32 This function builds a request config for a given type and query object. When passed to `store.request`, this config will result in the same behavior as a `store.query` request. Additionally, it takes the same options as `store.query`. All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Parameters #### type `string` the name of the resource #### query [`LegacyResourceQuery`](../../../../@warp-drive/core-types/index/type-aliases/LegacyResourceQuery.md) a query to be used by the adapter #### options? [`QueryOptions`](../../../../@warp-drive/core-types/index/type-aliases/QueryOptions.md) optional, may include `adapterOptions` hash which will be passed to adapter.query ### Returns `QueryRequestInput` request config ### Deprecated --- --- url: /api/@ember-data/legacy-compat/builders/functions/queryRecord.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [builders](../index.md) / queryRecord ## Call Signature ```ts function queryRecord( type, query, options?): QueryRecordRequestInput, null | T>; ``` Defined in: warp-drive-packages/legacy/declarations/compat/builders/query.d.ts:58 This function builds a request config for a given type and query object. When passed to `store.request`, this config will result in the same behavior as a `store.queryRecord` request. Additionally, it takes the same options as `store.queryRecord`. All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../../../../@warp-drive/core-types/record/interfaces/TypedRecordInstance.md) ### Parameters #### type [`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> the name of the resource #### query [`LegacyResourceQuery`](../../../../@warp-drive/core-types/index/type-aliases/LegacyResourceQuery.md)<`T`> a query to be used by the adapter #### options? [`QueryOptions`](../../../../@warp-drive/core-types/index/type-aliases/QueryOptions.md) optional, may include `adapterOptions` hash which will be passed to adapter.query ### Returns `QueryRecordRequestInput`<[`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`>, `null` | `T`> request config ### Deprecated ## Call Signature ```ts function queryRecord( type, query, options?): QueryRecordRequestInput; ``` Defined in: warp-drive-packages/legacy/declarations/compat/builders/query.d.ts:59 This function builds a request config for a given type and query object. When passed to `store.request`, this config will result in the same behavior as a `store.queryRecord` request. Additionally, it takes the same options as `store.queryRecord`. All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Parameters #### type `string` the name of the resource #### query [`LegacyResourceQuery`](../../../../@warp-drive/core-types/index/type-aliases/LegacyResourceQuery.md) a query to be used by the adapter #### options? [`QueryOptions`](../../../../@warp-drive/core-types/index/type-aliases/QueryOptions.md) optional, may include `adapterOptions` hash which will be passed to adapter.query ### Returns `QueryRecordRequestInput` request config ### Deprecated --- --- url: /api/@ember-data/legacy-compat/builders/functions/findRecord.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [builders](../index.md) / findRecord ## Call Signature ```ts function findRecord( type, id, options?): FindRecordRequestInput, T>; ``` Defined in: warp-drive-packages/legacy/declarations/compat/builders/find-record.d.ts:49 This function builds a request config to find the record for a given identifier or type and id combination. When passed to `store.request`, this config will result in the same behavior as a `store.findRecord` request. Additionally, it takes the same options as `store.findRecord`, with the exception of `preload` (which is unsupported). **Example 1** ```ts import { findRecord } from '@ember-data/legacy-compat/builders'; const { content: post } = await store.request(findRecord('post', '1')); ``` **Example 2** `findRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) ```ts import { findRecord } from '@ember-data/legacy-compat/builders'; const { content: post } = await store.request(findRecord({ type: 'post', id })); ``` All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../../../../@warp-drive/core-types/record/interfaces/TypedRecordInstance.md) ### Parameters #### type [`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> #### id `string` optional object with options for the request only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved #### options? `FindRecordBuilderOptions` if the first param is a string this will be the optional options for the request. See examples for available options. ### Returns `FindRecordRequestInput`<[`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`>, `T`> request config ### Deprecated ## Call Signature ```ts function findRecord( type, id, options?): FindRecordRequestInput; ``` Defined in: warp-drive-packages/legacy/declarations/compat/builders/find-record.d.ts:50 This function builds a request config to find the record for a given identifier or type and id combination. When passed to `store.request`, this config will result in the same behavior as a `store.findRecord` request. Additionally, it takes the same options as `store.findRecord`, with the exception of `preload` (which is unsupported). **Example 1** ```ts import { findRecord } from '@ember-data/legacy-compat/builders'; const { content: post } = await store.request(findRecord('post', '1')); ``` **Example 2** `findRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) ```ts import { findRecord } from '@ember-data/legacy-compat/builders'; const { content: post } = await store.request(findRecord({ type: 'post', id })); ``` All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Parameters #### type `string` #### id `string` optional object with options for the request only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved #### options? `FindRecordBuilderOptions` if the first param is a string this will be the optional options for the request. See examples for available options. ### Returns `FindRecordRequestInput` request config ### Deprecated ## Call Signature ```ts function findRecord(resource, options?): FindRecordRequestInput, T>; ``` Defined in: warp-drive-packages/legacy/declarations/compat/builders/find-record.d.ts:51 This function builds a request config to find the record for a given identifier or type and id combination. When passed to `store.request`, this config will result in the same behavior as a `store.findRecord` request. Additionally, it takes the same options as `store.findRecord`, with the exception of `preload` (which is unsupported). **Example 1** ```ts import { findRecord } from '@ember-data/legacy-compat/builders'; const { content: post } = await store.request(findRecord('post', '1')); ``` **Example 2** `findRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) ```ts import { findRecord } from '@ember-data/legacy-compat/builders'; const { content: post } = await store.request(findRecord({ type: 'post', id })); ``` All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../../../../@warp-drive/core-types/record/interfaces/TypedRecordInstance.md) ### Parameters #### resource [`ResourceIdentifierObject`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/ResourceIdentifierObject.md)<[`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`>> either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record #### options? `FindRecordBuilderOptions` if the first param is a string this will be the optional options for the request. See examples for available options. ### Returns `FindRecordRequestInput`<[`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`>, `T`> request config ### Deprecated ## Call Signature ```ts function findRecord(resource, options?): FindRecordRequestInput; ``` Defined in: warp-drive-packages/legacy/declarations/compat/builders/find-record.d.ts:52 This function builds a request config to find the record for a given identifier or type and id combination. When passed to `store.request`, this config will result in the same behavior as a `store.findRecord` request. Additionally, it takes the same options as `store.findRecord`, with the exception of `preload` (which is unsupported). **Example 1** ```ts import { findRecord } from '@ember-data/legacy-compat/builders'; const { content: post } = await store.request(findRecord('post', '1')); ``` **Example 2** `findRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) ```ts import { findRecord } from '@ember-data/legacy-compat/builders'; const { content: post } = await store.request(findRecord({ type: 'post', id })); ``` All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Parameters #### resource [`ResourceIdentifierObject`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/ResourceIdentifierObject.md) either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record #### options? `FindRecordBuilderOptions` if the first param is a string this will be the optional options for the request. See examples for available options. ### Returns `FindRecordRequestInput` request config ### Deprecated --- --- url: /api/@ember-data/legacy-compat/builders/functions/saveRecord.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [builders](../index.md) / saveRecord ```ts function saveRecord(record, options?): SaveRecordRequestInput, T>; ``` Defined in: warp-drive-packages/legacy/declarations/compat/builders/save-record.d.ts:30 This function builds a request config for saving the given record (e.g. creating, updating, or deleting the record). When passed to `store.request`, this config will result in the same behavior as a legacy `store.saveRecord` request. Additionally, it takes the same options as `store.saveRecord`. All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ## Type Parameters ### T `T` *extends* [`TypedRecordInstance`](../../../../@warp-drive/core-types/record/interfaces/TypedRecordInstance.md) ## Parameters ### record `T` a record to save ### options? `Record`<`string`, `unknown`> optional, may include `adapterOptions` hash which will be passed to adapter.saveRecord ## Returns `SaveRecordRequestInput`<[`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`>, `T`> request config ## Deprecated --- --- url: /api/@ember-data/legacy-compat/builders.md --- [Documentation](../../../index.md) / [@ember-data/legacy-compat](../index.md) / builders Builders for migrating from `store` methods to `store.request`. These builders enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ## Deprecated ## Functions * [~~findAll~~](functions/findAll.md) * [~~findRecord~~](functions/findRecord.md) * [~~query~~](functions/query.md) * [~~queryRecord~~](functions/queryRecord.md) * [~~saveRecord~~](functions/saveRecord.md) --- --- url: /api/@ember-data/legacy-compat.md --- [Documentation](../../index.md) / @ember-data/legacy-compat ## Modules * [~~builders~~](builders/index.md) * [index](index/index.md) * [~~utils~~](utils/index.md) --- --- url: /api/@ember-data/legacy-compat/index/functions/adapterFor.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [index](../index.md) / adapterFor ## Call Signature ```ts function adapterFor(this, modelName): MinimumAdapterInterface; ``` Defined in: warp-drive-packages/legacy/declarations/compat.d.ts:37 Returns an instance of the adapter for a given type. For example, `adapterFor('person')` will return an instance of the adapter located at `app/adapters/person.js` If no `person` adapter is found, this method will look for an `application` adapter (the default adapter for your entire application). ### Parameters #### this [`default`](../../../store/index/classes/default.md) #### modelName `string` ### Returns [`MinimumAdapterInterface`](../interfaces/MinimumAdapterInterface.md) ## Call Signature ```ts function adapterFor( this, modelName, _allowMissing): | undefined | MinimumAdapterInterface; ``` Defined in: warp-drive-packages/legacy/declarations/compat.d.ts:38 Returns an instance of the adapter for a given type. For example, `adapterFor('person')` will return an instance of the adapter located at `app/adapters/person.js` If no `person` adapter is found, this method will look for an `application` adapter (the default adapter for your entire application). ### Parameters #### this [`default`](../../../store/index/classes/default.md) #### modelName `string` #### \_allowMissing `true` ### Returns | `undefined` | [`MinimumAdapterInterface`](../interfaces/MinimumAdapterInterface.md) --- --- url: /api/@ember-data/legacy-compat/index/functions/cleanup.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [index](../index.md) / cleanup ```ts function cleanup(this): void; ``` Defined in: warp-drive-packages/legacy/declarations/compat.d.ts:133 ## Parameters ### this [`default`](../../../store/index/classes/default.md) ## Returns `void` --- --- url: /api/@ember-data/legacy-compat/index/functions/normalize.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [index](../index.md) / normalize ```ts function normalize( this, modelName, payload): SingleResourceDocument; ``` Defined in: warp-drive-packages/legacy/declarations/compat.d.ts:75 `normalize` converts a json payload into the normalized form that [push](../methods/push?anchor=push) expects. Example ```js socket.on('message', function(message) { let modelName = message.model; let data = message.data; store.push(store.normalize(modelName, data)); }); ``` ## Parameters ### this [`default`](../../../store/index/classes/default.md) ### modelName `string` The name of the model type for this payload ### payload [`ObjectValue`](../../../../@warp-drive/core-types/json/raw/interfaces/ObjectValue.md) ## Returns [`SingleResourceDocument`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md)<`string`> The normalized payload --- --- url: /api/@ember-data/legacy-compat/index/functions/pushPayload.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [index](../index.md) / pushPayload ```ts function pushPayload( this, modelName, inputPayload): void; ``` Defined in: warp-drive-packages/legacy/declarations/compat.d.ts:131 Push some raw data into the store. This method can be used both to push in brand new records, as well as to update existing records. You can push in more than one type of object at once. All objects should be in the format expected by the serializer. ```js [app/serializers/application.js] import RESTSerializer from '@ember-data/serializer/rest'; export default class ApplicationSerializer extends RESTSerializer; ``` ```js let pushData = { posts: [ { id: 1, postTitle: "Great post", commentIds: [2] } ], comments: [ { id: 2, commentBody: "Insightful comment" } ] } store.pushPayload(pushData); ``` By default, the data will be deserialized using a default serializer (the application serializer if it exists). Alternatively, `pushPayload` will accept a model type which will determine which serializer will process the payload. ```js [app/serializers/application.js] import RESTSerializer from '@ember-data/serializer/rest'; export default class ApplicationSerializer extends RESTSerializer; ``` ```js [app/serializers/post.js] import JSONSerializer from '@ember-data/serializer/json'; export default JSONSerializer; ``` ```js store.pushPayload(pushData); // Will use the application serializer store.pushPayload('post', pushData); // Will use the post serializer ``` ## Parameters ### this [`default`](../../../store/index/classes/default.md) ### modelName `string` Optionally, a model type used to determine which serializer will be used ### inputPayload [`ObjectValue`](../../../../@warp-drive/core-types/json/raw/interfaces/ObjectValue.md) ## Returns `void` --- --- url: /api/@ember-data/legacy-compat/index/functions/serializeRecord.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [index](../index.md) / serializeRecord ```ts function serializeRecord( this, record, options?): unknown; ``` Defined in: warp-drive-packages/legacy/declarations/compat.d.ts:132 ## Parameters ### this [`default`](../../../store/index/classes/default.md) ### record `unknown` ### options? [`SerializerOptions`](../type-aliases/SerializerOptions.md) ## Returns `unknown` --- --- url: /api/@ember-data/legacy-compat/index/functions/serializerFor.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [index](../index.md) / serializerFor ```ts function serializerFor(this, modelName): | null | MinimumSerializerInterface; ``` Defined in: warp-drive-packages/legacy/declarations/compat.d.ts:55 Returns an instance of the serializer for a given type. For example, `serializerFor('person')` will return an instance of `App.PersonSerializer`. If no `App.PersonSerializer` is found, this method will look for an `App.ApplicationSerializer` (the default serializer for your entire application). If a serializer cannot be found on the adapter, it will fall back to an instance of `JSONSerializer`. ## Parameters ### this [`default`](../../../store/index/classes/default.md) ### modelName `string` the record to serialize ## Returns | `null` | [`MinimumSerializerInterface`](../interfaces/MinimumSerializerInterface.md) --- --- url: /api/@ember-data/legacy-compat/index.md --- [Documentation](../../../index.md) / [@ember-data/legacy-compat](../index.md) / index ## Interfaces * [MinimumAdapterInterface](interfaces/MinimumAdapterInterface.md) * [MinimumSerializerInterface](interfaces/MinimumSerializerInterface.md) ## Type Aliases * [AdapterPayload](type-aliases/AdapterPayload.md) * [CompatStore](type-aliases/CompatStore.md) * [LegacyStoreCompat](type-aliases/LegacyStoreCompat.md) * [SerializerOptions](type-aliases/SerializerOptions.md) ## Variables * [LegacyNetworkHandler](variables/LegacyNetworkHandler.md) ## Functions * [adapterFor](functions/adapterFor.md) * [cleanup](functions/cleanup.md) * [normalize](functions/normalize.md) * [pushPayload](functions/pushPayload.md) * [serializeRecord](functions/serializeRecord.md) * [serializerFor](functions/serializerFor.md) --- --- url: /api/@ember-data/legacy-compat/index/interfaces/MinimumAdapterInterface.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [index](../index.md) / MinimumAdapterInterface Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:27 The following documentation describes the methods an adapter should implement with descriptions around when an application might expect these methods to be called. Methods that are not required are marked as **optional**. (Interface) Adapter ## Properties ### coalesceFindRequests? ```ts optional coalesceFindRequests: boolean; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:396 **`Optional`** If your adapter implements `findMany`, setting this to `true` will cause `findRecord` requests triggered within the same `runloop` to be coalesced into one or more calls to `adapter.findMany`. The number of calls made and the records contained in each call can be tuned by your adapter's `groupRecordsForHasMany` method. Implementing coalescing using this flag and the associated methods does not always offer the right level of correctness, timing control or granularity. If your application would be better suited coalescing across multiple types, coalescing for longer than a single runloop, or with a more custom request structure, coalescing within your application adapter may prove more effective. ## Methods ### createRecord() ```ts createRecord( store, schema, snapshot): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:193 `adapter.createRecord` takes a request to create a resource of a given `type` and should return a `Promise` which fulfills with data for the newly created resource. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `createRecord`, which should return a `JSON:API` document. The final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing data for the record. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. If the adapter rejects or throws an error the record will enter an error state and the attributes that had attempted to be saved will still be considered dirty. ### InvalidErrors When rejecting a `createRecord` request due to validation issues during save (typically a 422 status code), you may throw an `InvalidError`. Throwing an `InvalidError` makes per-attribute errors available for records to use in the UI as needed. Records can also use this information to mark themselves as being in an `invalid` state. For more reading [see the RecordData Errors RFC](https://emberjs.github.io/rfcs/0465-record-data-errors.html) ```js let error = new Error(errorMessage); // these two properties combined // alert EmberData to this error being for // invalid properties on the record during // the request error.isAdapterError = true; error.code = 'InvalidError'; // A JSON:API formatted array of errors // See https://jsonapi.org/format/#errors error.errors = []; throw error; ``` #### Parameters ##### store [`default`](../../../store/index/classes/default.md) The store service that initiated the request being normalized ##### schema [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> a promise resolving with resource data to feed to the associated serializer *** ### deleteRecord() ```ts deleteRecord( store, schema, snapshot): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:269 `adapter.deleteRecord` takes a request to delete a resource of a given `type` and should return a `Promise` which resolves when that deletion is complete. Usually the response will be empty, but you may include additional updates in the response. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `deleteRecord`, which should return a `JSON:API` document. The final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing data. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. If the adapter rejects or errors the record will need to be saved again once the reason for the error is addressed in order to persist the deleted state. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) The store service that initiated the request being normalized ##### schema [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### snapshot `Snapshot` A Snapshot containing the record's current data #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> *** ### destroy()? ```ts optional destroy(): void; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:524 **`Optional`** In some situations the adapter may need to perform cleanup when destroyed, that cleanup can be done in `destroy`. If not implemented, the store does not inform the adapter of destruction. #### Returns `void` *** ### findAll() ```ts findAll( store, schema, sinceToken, snapshotRecordArray): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:84 `adapter.findAll` takes a request for resources of a given `type` and should return a `Promise` which fulfills with a collection of resource data matching that `type`. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `findAll`, which should return a `JSON:API` document. The final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing records for `type`. Existing records for the `type` will not be removed. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. `adapter.findAll` is called whenever `store.findAll` is asked to reload or backgroundReload. The records in the response are merged with the contents of the store. Existing records for the `type` will not be removed. See also `shouldReloadAll` and `shouldBackgroundReloadAll` #### Parameters ##### store [`default`](../../../store/index/classes/default.md) The store service that initiated the request being normalized ##### schema [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### sinceToken `null` This parameter is no longer used and will always be null. ##### snapshotRecordArray `SnapshotRecordArray` an object containing any passed in options, adapterOptions, and the ability to access a snapshot for each existing record of the type. #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> a promise resolving with resource data to feed to the associated serializer *** ### findBelongsTo()? ```ts optional findBelongsTo( store, snapshot, relatedLink, relationship): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:299 **`Optional`** `adapter.findBelongsTo` takes a request to fetch a related resource located at a `relatedLink` and should return a `Promise` which fulfills with data for a single resource. ⚠️ This method is only called if the store previously received relationship information for a resource containing a [related link](https://jsonapi.org/format/#document-resource-object-related-resource-links). If the cache does not have a `link` for the relationship then `findRecord` will be used if a `type` and `id` for the related resource is known. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `findBelongsTo`, which should return a `JSON:API` document. The final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing data. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) The store service that initiated the request being normalized ##### snapshot `Snapshot` A Snapshot containing the parent record's current data ##### relatedLink `string` The link at which the associated resource might be found ##### relationship [`LegacyRelationshipField`](../../../../@warp-drive/core-types/schema/fields/type-aliases/LegacyRelationshipField.md) #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> a promise resolving with resource data to feed to the associated serializer *** ### findHasMany()? ```ts optional findHasMany( store, snapshot, relatedLink, relationship): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:330 **`Optional`** `adapter.findHasMany` takes a request to fetch a related resource collection located at a `relatedLink` and should return a `Promise` which fulfills with data for that collection. ⚠️ This method is only called if the store previously received relationship information for a resource containing a [related link](https://jsonapi.org/format/#document-resource-object-related-resource-links). If the cache does not have a `link` for the relationship but the `type` and `id` of related resources are known then `findRecord` will be used for each individual related resource. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `findHasMany`, which should return a `JSON:API` document. The final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing data. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) The store service that initiated the request being normalized ##### snapshot `Snapshot` A Snapshot containing the parent record's current data ##### relatedLink `string` The link at which the associated resource collection might be found ##### relationship [`LegacyRelationshipField`](../../../../@warp-drive/core-types/schema/fields/type-aliases/LegacyRelationshipField.md) #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> a promise resolving with resource data to feed to the associated serializer *** ### findMany()? ```ts optional findMany( store, schema, ids, snapshots): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:359 **`Optional`** ⚠️ This Method is only called if `coalesceFindRequests` is `true`. The array passed to it is determined by the adapter's `groupRecordsForFindMany` method, and will be called once per group returned. `adapter.findMany` takes a request to fetch a collection of resources and should return a `Promise` which fulfills with data for that collection. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `findMany`, which should return a `JSON:API` document. The final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing data. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. See also `groupRecordsForFindMany` and `coalesceFindRequests` #### Parameters ##### store [`default`](../../../store/index/classes/default.md) The store service that initiated the request being normalized ##### schema [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### ids `string`\[] An array of the ids of the resources to fetch ##### snapshots `Snapshot`<`unknown`>\[] An array of snapshots of the available data for the resources to fetch #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> a promise resolving with resource data to feed to the associated serializer *** ### findRecord() ```ts findRecord( store, schema, id, snapshot): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:54 `adapter.findRecord` takes a request for a resource of a given `type` and `id` combination and should return a `Promise` which fulfills with data for a single resource matching that `type` and `id`. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `findRecord`, which should return a `JSON:API` document. The final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing data for the record. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. `adapter.findRecord` is called whenever the `store` needs to load, reload, or backgroundReload the resource data for a given `type` and `id`. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) The store service that initiated the request being normalized ##### schema [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### id `string` ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> a promise resolving with resource data to feed to the associated serializer *** ### generateIdForRecord()? ```ts optional generateIdForRecord( store, type, properties): string; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:378 **`Optional`** This method provides the ability to generate an ID to assign to a new record whenever `store.createRecord` is called if no `id` was provided. Alternatively you can pass an id into the call to `store.createRecord` directly. ```js let id = generateNewId(type); let newRecord = store.createRecord(type, { id }); ``` #### Parameters ##### store [`default`](../../../store/index/classes/default.md) The store service that initiated the request being normalized ##### type `string` The type (or modelName) of record being created ##### properties `unknown` the properties passed as the second arg to `store.createRecord` #### Returns `string` a string ID that should be unique (no other models of `type` in the cache should have this `id`) *** ### groupRecordsForFindMany()? ```ts optional groupRecordsForFindMany(store, snapshots): Group[]; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:418 **`Optional`** ⚠️ This Method is only called if `coalesceFindRequests` is `true`. This method allows for you to split pending requests for records into multiple `findMany` requests. It receives an array of snapshots where each snapshot represents a unique record requested via `store.findRecord` during the most recent `runloop` that was not found in the cache or needs to be reloaded. It should return an array of groups. A group is an array of snapshots meant to be fetched together by a single `findMany` request. By default if this method is not implemented EmberData will call `findMany` once with all requested records as a single group when `coalesceFindRequests` is `true`. See also `findMany` and `coalesceFindRequests` #### Parameters ##### store [`default`](../../../store/index/classes/default.md) The store service that initiated the request being normalized ##### snapshots `Snapshot`<`unknown`>\[] An array of snapshots #### Returns `Group`\[] An array of Snapshot arrays *** ### query() ```ts query( store, schema, query, recordArray, options): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:115 `adapter.query` takes a request for resources of a given `type` and should return a `Promise` which fulfills with a collection of resource data matching that `type`. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `query`, which should return a `JSON:API` document. As with `findAll`, the final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing records for `type`. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. `adapter.query` is called whenever `store.query` is called or a previous query result is asked to reload. Existing records for the `type` will not be removed. The key difference is in the result returned by the `store`. For `findAll` the result is all known records of the `type`, while for `query` it will only be the records returned from `adapter.query`. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) The store service that initiated the request being normalized ##### schema [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### query `Record`<`string`, `unknown`> ##### recordArray `Collection` ##### options ###### adapterOptions? `unknown` #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> a promise resolving with resource data to feed to the associated serializer *** ### queryRecord() ```ts queryRecord( store, schema, query, options): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:140 `adapter.queryRecord` takes a request for resource of a given `type` and should return a `Promise` which fulfills with data for a single resource matching that `type`. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `queryRecord`, which should return a `JSON:API` document. The final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing data for the returned record. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) The store service that initiated the request being normalized ##### schema [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### query `Record`<`string`, `unknown`> ##### options ###### adapterOptions? `unknown` #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> a promise resolving with resource data to feed to the associated serializer *** ### shouldBackgroundReloadAll()? ```ts optional shouldBackgroundReloadAll(store, snapshotArray): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:514 **`Optional`** When `store.findAll()` is called and a `reload` is not initiated, the adapter is presented the opportunity to trigger a new non-blocking (background) request for records of that type Users may explicitly declare that this background request should/should not occur by passing `backgroundReload: true` or `backgroundReload: false` as an option to the request respectively. ```js store.findAll('user', { backgroundReload: false }) ``` The default behavior if this method is not implemented and the option is not specified is to perform a reload, the same as a return of `true`. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) The store service that initiated the request being normalized ##### snapshotArray `SnapshotRecordArray` #### Returns `boolean` true if the a new request for all records of the type in SnapshotRecordArray should be made in the background, false otherwise *** ### shouldBackgroundReloadRecord()? ```ts optional shouldBackgroundReloadRecord(store, snapshot): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:492 **`Optional`** When a record is already available in the store and is requested again via `store.findRecord`, and the record does not need to be reloaded prior to return, this method provides the ability to specify whether a refresh of the data for the reload should be scheduled to occur in the background. Users may explicitly declare a record should/should not be background reloaded by passing `backgroundReload: true` or `backgroundReload: false` as an option to the request respectively. ```js store.findRecord('user', '1', { backgroundReload: false }) ``` If the `backgroundReload` option is not present, this method will be called to determine whether a backgroundReload should be performed. The default behavior if this method is not implemented and the option was not specified is to background reload, the same as a return of `true`. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) The store service that initiated the request being normalized ##### snapshot `Snapshot` A Snapshot containing the record's current data #### Returns `boolean` true if the record should be reloaded in the background, false otherwise *** ### shouldReloadAll()? ```ts optional shouldReloadAll(store, snapshotArray): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:467 **`Optional`** When `store.findAll()` is called without a `reload` option, the adapter is presented the opportunity to trigger a new request for records of that type. If `reload` is specified as an option in the request (`true` or `false`) this method will not be called. ```js store.findAll('user', { reload: false }) ``` The default behavior if this method is not implemented and the option is not specified is to not reload, the same as a return of `false`. Note: the Promise returned by `store.findAll` resolves to the same LiveArray instance returned by `store.peekAll` for that type, and will include all records in the store for the given type, including any previously existing records not returned by the reload request. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) The store service that initiated the request being normalized ##### snapshotArray `SnapshotRecordArray` #### Returns `boolean` true if the a new request for all records of the type in SnapshotRecordArray should be made immediately, false otherwise *** ### shouldReloadRecord()? ```ts optional shouldReloadRecord(store, snapshot): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:442 **`Optional`** When a record is already available in the store and is requested again via `store.findRecord`, and `reload` is not specified as an option in the request, this method is called to determine whether the record should be reloaded prior to returning the result. If `reload` is specified as an option in the request (`true` or `false`) this method will not be called. ```js store.findRecord('user', '1', { reload: false }) ``` The default behavior if this method is not implemented and the option is not specified is to not reload, the same as a return of `false`. See also the documentation for `shouldBackgroundReloadRecord` which defaults to `true`. #### Parameters ##### store [`default`](../../../store/index/classes/default.md) The store service that initiated the request being normalized ##### snapshot `Snapshot` A Snapshot containing the record's current data #### Returns `boolean` true if the record should be reloaded immediately, false otherwise *** ### updateRecord() ```ts updateRecord( store, schema, snapshot): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:243 `adapter.updateRecord` takes a request to update a resource of a given `type` and should return a `Promise` which fulfills with the updated data for the resource. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `updateRecord`, which should return a `JSON:API` document. The final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing data for the record. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. If the adapter rejects or throws an error the record will enter an error state and the attributes that had attempted to be saved will still be considered dirty. ### InvalidErrors When rejecting a `createRecord` request due to validation issues during save (typically a 422 status code), you may throw an `InvalidError`. Throwing an `InvalidError` makes per-attribute errors available for records to use in the UI as needed. Records can also use this information to mark themselves as being in an `invalid` state. For more reading [see the RecordData Errors RFC](https://emberjs.github.io/rfcs/0465-record-data-errors.html) ```js let error = new Error(errorMessage); // these two properties combined // alert EmberData to this error being for // invalid properties on the record during // the request error.isAdapterError = true; error.code = 'InvalidError'; // A JSON:API formatted array of errors // See https://jsonapi.org/format/#errors error.errors = []; throw error; ``` #### Parameters ##### store [`default`](../../../store/index/classes/default.md) The store service that initiated the request being normalized ##### schema [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> --- --- url: /api/@ember-data/legacy-compat/index/interfaces/MinimumSerializerInterface.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [index](../index.md) / MinimumSerializerInterface Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts:29 The following documentation describes the methods an application serializer should implement with descriptions around when an application might expect these methods to be called. Methods that are not required are marked as **optional**. (Interface) Serializer ## Methods ### destroy()? ```ts optional destroy(): void; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts:222 **`Optional`** In some situations the serializer may need to perform cleanup when destroyed, that cleanup can be done in `destroy`. If not implemented, the store does not inform the serializer of destruction. #### Returns `void` *** ### normalize()? ```ts optional normalize( schema, rawPayload, prop?): SingleResourceDocument; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts:130 **`Optional`** This method is intended to normalize data into a [JSON:API Document](https://jsonapi.org/format/#document-structure) with a data member containing a single [Resource](https://jsonapi.org/format/#document-resource-objects). * `type` should be formatted in the singular, dasherized and lowercase form * `members` (the property names of attributes and relationships) should be formatted to match their definition in the corresponding `Model` definition. Typically this will be `camelCase`. * [`lid`](https://github.com/emberjs/rfcs/blob/main/text/0403-ember-data-identifiers.md) is a valid optional sibling to `id` and `type` in both [Resources](https://jsonapi.org/format/#document-resource-objects) and [Resource Identifier Objects](https://jsonapi.org/format/#document-resource-identifier-objects) This method is called by the `Store` when `store.normalize(modelName, payload)` is called. It is recommended to use `store.serializerFor(modelName).normalizeResponse` over `store.normalize`. This method may be called when also using the `RESTSerializer` when `serializer.pushPayload` is called by `store.pushPayload`. However, it is recommended to use `store.push` over `store.pushPayload` after normalizing the payload directly. Example: ```js function pushPayload(store, modelName, rawPayload) { const ModelClass = store.modelFor(modelName); const serializer = store.serializerFor(modelName); const jsonApiPayload = serializer.normalizeResponse(store, ModelClass, rawPayload, null, 'query'); return store.push(jsonApiPayload); } ``` This method may be called when also using the `JSONAPISerializer` when normalizing included records. If mixing serializer usage in this way we recommend implementing this method, but caution that it may lead to unexpected mixing of formats. This method may also be called when normalizing embedded relationships when using the `EmbeddedRecordsMixin`. If using this mixin in a serializer in your application we recommend implementing this method, but caution that it may lead to unexpected mixing of formats. #### Parameters ##### schema [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### rawPayload [`ObjectValue`](../../../../@warp-drive/core-types/json/raw/interfaces/ObjectValue.md) Some raw JSON data to be normalized into a JSON:API Resource. ##### prop? `string` When called by the EmbeddedRecordsMixin this param will be the property at which the object provided as rawPayload was found. #### Returns [`SingleResourceDocument`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md) A JSON:API Document containing a single JSON:API Resource as its primary data. *** ### normalizeResponse() ```ts normalizeResponse( store, schema, rawPayload, id, requestType): JsonApiDocument; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts:59 This method is responsible for normalizing the value resolved from the promise returned by an Adapter request into the format expected by the `Store`. The output should be a [JSON:API Document](https://jsonapi.org/format/#document-structure) with the following additional restrictions: * `type` should be formatted in the `singular` `dasherized` `lowercase` form * `members` (the property names of attributes and relationships) should be formatted to match their definition in the corresponding `Model` definition. Typically this will be `camelCase`. * [`lid`](https://github.com/emberjs/rfcs/blob/main/text/0403-ember-data-identifiers.md) is a valid optional sibling to `id` and `type` in both [Resources](https://jsonapi.org/format/#document-resource-objects) and [Resource Identifier Objects](https://jsonapi.org/format/#document-resource-identifier-objects) #### Parameters ##### store [`default`](../../../store/index/classes/default.md) The store service that initiated the request being normalized ##### schema [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### rawPayload [`AdapterPayload`](../type-aliases/AdapterPayload.md) The raw JSON response data returned from an API request. This correlates to the value the promise returned by the adapter method that performed the request resolved to. ##### id For a findRecord request, this is the id initially provided in the call to store.findRecord. Else this value is null. `null` | `string` ##### requestType The type of request the Adapter had been asked to perform. `"findRecord"` | `"queryRecord"` | `"findAll"` | `"findBelongsTo"` | `"findHasMany"` | `"findMany"` | `"query"` | `"createRecord"` | `"deleteRecord"` | `"updateRecord"` #### Returns `JsonApiDocument` a document following the structure of a JSON:API Document. *** ### pushPayload()? ```ts optional pushPayload(store, rawPayload): void; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts:212 **`Optional`** This method allows for normalization of data when `store.pushPayload` is called and should be implemented if you want to use that method. The method is responsible for pushing new data to the store using `store.push` once any necessary normalization has occurred, and no data in the store will be updated unless it does so. The normalized form pushed to the store should be a [JSON:API Document](https://jsonapi.org/format/#document-structure) with the following additional restrictions: * `type` should be formatted in the singular, dasherized and lowercase form * `members` (the property names of attributes and relationships) should be formatted to match their definition in the corresponding `Model` definition. Typically this will be `camelCase`. * [`lid`](https://github.com/emberjs/rfcs/blob/main/text/0403-ember-data-identifiers.md) is a valid optional sibling to `id` and `type` in both [Resources](https://jsonapi.org/format/#document-resource-objects) and [Resource Identifier Objects](https://jsonapi.org/format/#document-resource-identifier-objects) If you need better control over normalization or want access to the records being added or updated in the store, we recommended using `store.push` over `store.pushPayload` after normalizing the payload directly. This can even take advantage of an existing serializer for the format the data is in, for example: ```js function pushPayload(store, modelName, rawPayload) { const ModelClass = store.modelFor(modelName); const serializer = store.serializerFor(modelName); const jsonApiPayload = serializer.normalizeResponse(store, ModelClass, rawPayload, null, 'query'); return store.push(jsonApiPayload); } ``` #### Parameters ##### store [`default`](../../../store/index/classes/default.md) The store service that initiated the request being normalized ##### rawPayload [`ObjectValue`](../../../../@warp-drive/core-types/json/raw/interfaces/ObjectValue.md) The raw JSON response data returned from an API request. This JSON should be in the API format expected by the serializer. #### Returns `void` *** ### serialize() ```ts serialize(snapshot, options?): ObjectValue; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts:76 This method is responsible for serializing an individual record via a [Snapshot](Snapshot) into the format expected by the API. This method is called by `snapshot.serialize()`. When using `Model`, this method is called by `record.serialize()`. When using `JSONAPIAdapter` or `RESTAdapter` this method is called by `updateRecord` and `createRecord` if `Serializer.serializeIntoHash` is not implemented. #### Parameters ##### snapshot `Snapshot` A Snapshot for the record to serialize ##### options? [`SerializerOptions`](../type-aliases/SerializerOptions.md) #### Returns [`ObjectValue`](../../../../@warp-drive/core-types/json/raw/interfaces/ObjectValue.md) *** ### serializeIntoHash()? ```ts optional serializeIntoHash( hash, schema, snapshot, options?): void; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts:170 **`Optional`** When using `JSONAPIAdapter` or `RESTAdapter` this method is called by `adapter.updateRecord` and `adapter.createRecord` if `serializer.serializeIntoHash` is implemented. If this method is not implemented, `serializer.serialize` will be called in this case. You can use this method to customize the root keys serialized into the payload. The hash property should be modified by reference. For instance, your API may expect resources to be keyed by underscored type in the payload: ```js { _user: { type: 'user', id: '1' } } ``` Which when using these adapters can be achieved by implementing this method similar to the following: ```js serializeIntoHash(hash, ModelClass, snapshot, options) { hash[`_${snapshot.modelName}`] = this.serialize(snapshot, options).data; } ``` #### Parameters ##### hash `object` A top most object of the request payload onto which to append the serialized record ##### schema [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### snapshot `Snapshot` A Snapshot for the record to serialize ##### options? [`SerializerOptions`](../type-aliases/SerializerOptions.md) #### Returns `void` --- --- url: /api/@ember-data/legacy-compat/index/type-aliases/AdapterPayload.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [index](../index.md) / AdapterPayload ```ts type AdapterPayload = Record | unknown[]; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts:8 --- --- url: /api/@ember-data/legacy-compat/index/type-aliases/CompatStore.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [index](../index.md) / CompatStore ```ts type CompatStore = default & LegacyStoreCompat; ``` Defined in: warp-drive-packages/legacy/declarations/compat.d.ts:23 --- --- url: /api/@ember-data/legacy-compat/index/type-aliases/LegacyStoreCompat.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [index](../index.md) / LegacyStoreCompat ```ts type LegacyStoreCompat = object; ``` Defined in: warp-drive-packages/legacy/declarations/compat.d.ts:8 ## Properties ### \_adapterCache ```ts _adapterCache: Record; ``` Defined in: warp-drive-packages/legacy/declarations/compat.d.ts:16 *** ### \_fetchManager ```ts _fetchManager: FetchManager; ``` Defined in: warp-drive-packages/legacy/declarations/compat.d.ts:9 *** ### \_serializerCache ```ts _serializerCache: Record; ``` Defined in: warp-drive-packages/legacy/declarations/compat.d.ts:19 ## Methods ### adapterFor() #### Call Signature ```ts adapterFor(this, modelName): MinimumAdapterInterface; ``` Defined in: warp-drive-packages/legacy/declarations/compat.d.ts:10 ##### Parameters ###### this [`default`](../../../store/index/classes/default.md) ###### modelName `string` ##### Returns [`MinimumAdapterInterface`](../interfaces/MinimumAdapterInterface.md) #### Call Signature ```ts adapterFor( this, modelName, _allowMissing): | undefined | MinimumAdapterInterface; ``` Defined in: warp-drive-packages/legacy/declarations/compat.d.ts:11 ##### Parameters ###### this [`default`](../../../store/index/classes/default.md) ###### modelName `string` ###### \_allowMissing `true` ##### Returns | `undefined` | [`MinimumAdapterInterface`](../interfaces/MinimumAdapterInterface.md) *** ### normalize() ```ts normalize(modelName, payload): ObjectValue; ``` Defined in: warp-drive-packages/legacy/declarations/compat.d.ts:13 #### Parameters ##### modelName `string` ##### payload [`ObjectValue`](../../../../@warp-drive/core-types/json/raw/interfaces/ObjectValue.md) #### Returns [`ObjectValue`](../../../../@warp-drive/core-types/json/raw/interfaces/ObjectValue.md) *** ### pushPayload() ```ts pushPayload(modelName, payload): void; ``` Defined in: warp-drive-packages/legacy/declarations/compat.d.ts:14 #### Parameters ##### modelName `string` ##### payload [`ObjectValue`](../../../../@warp-drive/core-types/json/raw/interfaces/ObjectValue.md) #### Returns `void` *** ### serializeRecord() ```ts serializeRecord(record, options?): unknown; ``` Defined in: warp-drive-packages/legacy/declarations/compat.d.ts:15 #### Parameters ##### record `unknown` ##### options? [`SerializerOptions`](SerializerOptions.md) #### Returns `unknown` *** ### serializerFor() ```ts serializerFor(modelName, _allowMissing?): | null | MinimumSerializerInterface; ``` Defined in: warp-drive-packages/legacy/declarations/compat.d.ts:12 #### Type Parameters ##### K `K` *extends* `string` #### Parameters ##### modelName `K` ##### \_allowMissing? `boolean` #### Returns | `null` | [`MinimumSerializerInterface`](../interfaces/MinimumSerializerInterface.md) --- --- url: /api/@ember-data/legacy-compat/index/variables/LegacyNetworkHandler.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [index](../index.md) / LegacyNetworkHandler ```ts const LegacyNetworkHandler: Handler; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts:2 --- --- url: /api/@ember-data/legacy-compat/index/type-aliases/SerializerOptions.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [index](../index.md) / SerializerOptions ```ts type SerializerOptions = object; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts:7 ## Properties ### includeId? ```ts optional includeId: boolean; ``` Defined in: warp-drive-packages/legacy/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts:8 --- --- url: /api/@ember-data/legacy-compat/utils/functions/configureAssertFn.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [utils](../index.md) / configureAssertFn ```ts function configureAssertFn(fn): void; ``` Defined in: warp-drive-packages/legacy/declarations/compat/utils.d.ts:19 Configure a function to be called when an id or type fails validation. This is useful for instrumenting to discover places where usage in the app is not consistent. ## Parameters ### fn (`message`, `condition`) => `void` ## Returns `void` --- --- url: /api/@ember-data/legacy-compat/utils/functions/configureMismatchReporter.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [utils](../index.md) / configureMismatchReporter ```ts function configureMismatchReporter(fn): void; ``` Defined in: warp-drive-packages/legacy/declarations/compat/utils.d.ts:10 Configure a function to be called when an id or type changes during normalization. This is useful for instrumenting to discover places where usage in the app is not consistent. ## Parameters ### fn `Reporter` ## Returns `void` --- --- url: /api/@ember-data/legacy-compat/utils/functions/configureTypeNormalization.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [utils](../index.md) / configureTypeNormalization ```ts function configureTypeNormalization(fn): void; ``` Defined in: warp-drive-packages/legacy/declarations/compat/utils.d.ts:33 Configure a function to be called to normalize a resource type string. Used by both formattedType and isEquivType to ensure consistent normalization during comparison. If validation fails or the type turns out be unnormalized the configured mismatch reporter and assert functions will be called. ## Parameters ### fn (`type`) => `string` ## Returns `void` --- --- url: /api/@ember-data/legacy-compat/utils/functions/formattedId.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [utils](../index.md) / formattedId ## Call Signature ```ts function formattedId(id): string; ``` Defined in: warp-drive-packages/legacy/declarations/compat/utils.d.ts:84 Format an id to the format expected by the EmberData Cache. Currently this means that id should be `string | null`. Asserts invalid IDs (undefined, '', 0, '0') in dev. **Usage** ````js import formattedId from 'client/utils/formatted-id'; formattedId('1'); // => '1' formattedId(1); // => '1' formattedId(null); // => null ``` ### Parameters #### id the potentially un-normalized id `string` | `number` ### Returns `string` the normalized id ## Call Signature ```ts function formattedId(id): null; ```` Defined in: warp-drive-packages/legacy/declarations/compat/utils.d.ts:85 Format an id to the format expected by the EmberData Cache. Currently this means that id should be `string | null`. Asserts invalid IDs (undefined, '', 0, '0') in dev. **Usage** ````js import formattedId from 'client/utils/formatted-id'; formattedId('1'); // => '1' formattedId(1); // => '1' formattedId(null); // => null ``` ### Parameters #### id `null` the potentially un-normalized id ### Returns `null` the normalized id ## Call Signature ```ts function formattedId(id): null | string; ```` Defined in: warp-drive-packages/legacy/declarations/compat/utils.d.ts:86 Format an id to the format expected by the EmberData Cache. Currently this means that id should be `string | null`. Asserts invalid IDs (undefined, '', 0, '0') in dev. **Usage** ````js import formattedId from 'client/utils/formatted-id'; formattedId('1'); // => '1' formattedId(1); // => '1' formattedId(null); // => null ``` ### Parameters #### id the potentially un-normalized id `null` | `string` | `number` ### Returns `null` \| `string` the normalized id ```` --- --- url: /api/@ember-data/legacy-compat/utils/functions/expectId.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [utils](../index.md) / expectId ## Call Signature ```ts function expectId(id): string; ``` Defined in: warp-drive-packages/legacy/declarations/compat/utils.d.ts:87 ### Parameters #### id `string` | `number` ### Returns `string` ## Call Signature ```ts function expectId(id): never; ``` Defined in: warp-drive-packages/legacy/declarations/compat/utils.d.ts:88 ### Parameters #### id `null` ### Returns `never` --- --- url: /api/@ember-data/legacy-compat/utils/functions/formattedType.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [utils](../index.md) / formattedType ```ts function formattedType(type): T; ``` Defined in: warp-drive-packages/legacy/declarations/compat/utils.d.ts:63 Converts a potentially unnormalized type into the format expected by our EmberData Cache. Currently this is singular-dasherized. you should not rely on this function to give you an exact format for display purposes. Formatting for display should be handled differently if the exact format matters. Asserts invalid types (undefined, null, '') in dev. **Usage** ```js import formattedType from 'soxhub-client/helpers/formatted-type'; formattedType('post'); // => 'post' formattedType('posts'); // => 'post' formattedType('Posts'); // => 'post' formattedType('post-comment'); // => 'post-comment' formattedType('post-comments'); // => 'post-comment' formattedType('post_comment'); // => 'post-comment' formattedType('postComment'); // => 'post-comment' formattedType('PostComment'); // => 'post-comment' ``` ## Type Parameters ### T `T` *extends* `string` ## Parameters ### type the potentially un-normalized type `string` | `T` ## Returns `T` the normalized type --- --- url: /api/@ember-data/legacy-compat/utils/functions/isEquivId.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [utils](../index.md) / isEquivId ```ts function isEquivId(expected, actual): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/compat/utils.d.ts:136 Compares two IDs for strict equality, converting them to the format expected by the EmberData Cache to ensure differences in format are accounted for in the comparison. Asserts when expected or actual are invalid IDs in dev. Expected may never be null. ```js isEquivId('1', 1); // true isEquivId('2', '2'); // true isEquivId(3, '3'); // true isEquivId(4, '3'); // false isEquivId(1, null); // false ``` ## Parameters ### expected a potentially un-normalized id to match against `string` | `number` ### actual a potentially un-normalized id to match against `null` | `string` | `number` ## Returns `boolean` true if the ids are equivalent --- --- url: /api/@ember-data/legacy-compat/utils/functions/isEquivType.md --- [Documentation](../../../../index.md) / [@ember-data/legacy-compat](../../index.md) / [utils](../index.md) / isEquivType ```ts function isEquivType(expected, actual): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/compat/utils.d.ts:114 Compares two types for strict equality, converting them to the format expected by the EmberData Cache to ensure differences in format are accounted for in the comparison. Asserts when expected or actual are invalid types in dev. Expected may never be null. ```js isEquivType('posts', 'post'); // true isEquivType('post', 'post'); // true isEquivType('posts', 'posts'); // true isEquivType('post-comment', 'postComment'); // true isEquivType('post-comment', 'PostComment'); // true isEquivType('post-comment', 'post_comment'); // true isEquivType('post-comment', 'post-comment'); // true isEquivType('post-comment', 'post'); // false isEquivType('posts', null); // false ``` ## Parameters ### expected `string` a potentially unnormalized type to match against ### actual `string` a potentially unnormalized type to match against ## Returns `boolean` true if the types are equivalent --- --- url: /api/@ember-data/legacy-compat/utils.md --- [Documentation](../../../index.md) / [@ember-data/legacy-compat](../index.md) / utils Utilities for helping to migrate to stricter and more consistent use of IDs and types. ## Deprecated ## Functions * [~~configureAssertFn~~](functions/configureAssertFn.md) * [~~configureMismatchReporter~~](functions/configureMismatchReporter.md) * [~~configureTypeNormalization~~](functions/configureTypeNormalization.md) * [~~expectId~~](functions/expectId.md) * [~~formattedId~~](functions/formattedId.md) * [~~formattedType~~](functions/formattedType.md) * [~~isEquivId~~](functions/isEquivId.md) * [~~isEquivType~~](functions/isEquivType.md) --- --- url: /api/@ember-data/model/hooks.md --- [Documentation](../../../index.md) / [@ember-data/model](../index.md) / hooks ## References ### buildSchema Re-exports [buildSchema](../index/functions/buildSchema.md) *** ### instantiateRecord Re-exports [instantiateRecord](../index/functions/instantiateRecord.md) *** ### modelFor Re-exports [modelFor](../index/functions/modelFor.md) *** ### teardownRecord Re-exports [teardownRecord](../index/functions/teardownRecord.md) --- --- url: /api/@ember-data/model.md --- [Documentation](../../index.md) / @ember-data/model ## Modules * [hooks](hooks/index.md) * [index](index/index.md) * [migration-support](migration-support/index.md) --- --- url: /api/@ember-data/model/index/classes/AsyncHasMany.md --- [Documentation](../../../../index.md) / [@ember-data/model](../../index.md) / [index](../index.md) / AsyncHasMany Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:24 This class is returned as the result of accessing an async hasMany relationship on an instance of a Model extending from `@ember-data/model`. A PromiseManyArray is an iterable proxy that allows templates to consume related ManyArrays and update once their contents are no longer pending. In your JS code you should resolve the promise first. ```js const comments = await post.comments; ``` PromiseManyArray ## Type Parameters ### T `T` = `unknown` ## Constructors ### Constructor ```ts new AsyncHasMany(promise, content?): PromiseManyArray; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:28 #### Parameters ##### promise `Promise`<[`ManyArray`](ManyArray.md)<`T`>> ##### content? [`ManyArray`](ManyArray.md)<`T`> #### Returns `PromiseManyArray`<`T`> ## Properties ### \[LegacyPromiseProxy] ```ts [LegacyPromiseProxy]: true; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:124 *** ### content ```ts content: null | ManyArray; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:27 *** ### isDestroyed ```ts isDestroyed: boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:26 *** ### isFulfilled ```ts isFulfilled: boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:76 Whether the loading promise succeeded *** ### isPending ```ts isPending: boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:60 Whether the loading promise is still pending *** ### isRejected ```ts isRejected: boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:68 Whether the loading promise rejected *** ### isSettled ```ts isSettled: boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:84 Whether the loading promise completed (resolved or rejected) *** ### promise ```ts promise: null | Promise>; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:25 ## Accessors ### \[] #### Get Signature ```ts get : undefined | 0 | ManyArray; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:35 ##### Returns `undefined` | `0` | [`ManyArray`](ManyArray.md)<`T`> *** ### length #### Get Signature ```ts get length(): number; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:34 Retrieve the length of the content ##### Returns `number` *** ### links #### Get Signature ```ts get links(): | undefined | null | Links; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:115 Retrieve the links for this relationship ##### Returns | `undefined` | `null` | [`Links`](../../../../@warp-drive/core-types/spec/json-api-raw/interfaces/Links.md) *** ### meta #### Get Signature ```ts get meta(): undefined | null | Record; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:121 Retrieve the meta for this relationship ##### Returns `undefined` | `null` | `Record`<`string`, `unknown`> ## Methods ### \_update() ```ts _update(promise, content?): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:122 #### Parameters ##### promise `Promise`<[`ManyArray`](ManyArray.md)<`T`>> ##### content? [`ManyArray`](ManyArray.md)<`T`> #### Returns `void` *** ### catch() ```ts catch(cb): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:100 catch errors thrown by this promise #### Parameters ##### cb `undefined` | `null` | (`reason`) => `unknown` #### Returns `Promise`<`unknown`> *** ### destroy() ```ts destroy(): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:109 #### Returns `void` *** ### finally() ```ts finally(cb): Promise>; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:108 run cleanup after this promise completes #### Parameters ##### cb `undefined` | `null` | () => `void` #### Returns `Promise`<[`ManyArray`](ManyArray.md)<`T`>> *** ### reload() ```ts reload(options): this; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:52 Reload the relationship #### Parameters ##### options `Omit`<[`BaseFinderOptions`](../../../../@warp-drive/core-types/index/interfaces/BaseFinderOptions.md)<`unknown`>, `""`> #### Returns `this` *** ### then() ```ts then(s, f?): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:93 chain this promise #### Parameters ##### s `undefined` | `null` | (`value`) => `unknown` ##### f? `null` | (`reason`) => `unknown` #### Returns `Promise`<`unknown`> *** ### create() ```ts static create(__namedParameters): PromiseManyArray; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/promise-many-array.d.ts:123 #### Type Parameters ##### T `T` #### Parameters ##### \_\_namedParameters `HasManyProxyCreateArgs`<`T`> #### Returns `PromiseManyArray`<`T`> --- --- url: /api/@ember-data/model/index/classes/ManyArray.md --- [Documentation](../../../../index.md) / [@ember-data/model](../../index.md) / [index](../index.md) / ManyArray Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:69 A `ManyArray` is a `MutableArray` that represents the contents of a has-many relationship. The `ManyArray` is instantiated lazily the first time the relationship is requested. This class is not intended to be directly instantiated by consuming applications. ### Inverses Often, the relationships in Ember Data applications will have an inverse. For example, imagine the following models are defined: ```js [app/models/post.js] import Model, { hasMany } from '@ember-data/model'; export default class PostModel extends Model { @hasMany('comment') comments; } ``` ```js [app/models/comment.js] import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class CommentModel extends Model { @belongsTo('post') post; } ``` If you created a new instance of `Post` and added a `Comment` record to its `comments` has-many relationship, you would expect the comment's `post` property to be set to the post that contained the has-many. We call the record to which a relationship belongs-to the relationship's *owner*. ManyArray ## Extends * `IdentifierArray`<`T`> ## Type Parameters ### T `T` = `unknown` ## Indexable ```ts [key: number]: T ``` ## Constructors ### Constructor ```ts new ManyArray(options): RelatedCollection; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:142 #### Parameters ##### options `ManyArrayCreateArgs`<`T`> #### Returns `RelatedCollection`<`T`> #### Overrides ```ts IdentifierArray.constructor ``` ## Properties ### \_\_\_(unique) Symbol(#\[]) ```ts ___(unique) Symbol(#[]): WarpDriveSignal; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:73 #### Inherited from ```ts IdentifierArray.___(unique) Symbol(#[]) ``` *** ### \_\_\_(unique) Symbol(#source) ```ts ___(unique) Symbol(#source): StableRecordIdentifier[]; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:74 #### Inherited from ```ts IdentifierArray.___(unique) Symbol(#source) ``` *** ### \_\_\_(unique) Symbol(IS\_COLLECTION) ```ts ___(unique) Symbol(IS_COLLECTION): boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:72 #### Inherited from ```ts IdentifierArray.___(unique) Symbol(IS_COLLECTION) ``` *** ### \_inverseIsAsync ```ts _inverseIsAsync: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:87 *** ### \_manager ```ts _manager: MinimumManager; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:137 #### Overrides ```ts IdentifierArray._manager ``` *** ### \_updatingPromise ```ts _updatingPromise: null | Promise>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:70 #### Inherited from ```ts IdentifierArray._updatingPromise ``` *** ### \[unscopables] ```ts readonly [unscopables]: object; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:97 Is an object whose properties have the value 'true' when they will be absent when used in a 'with' statement. #### Index Signature ```ts [key: number]: undefined | boolean ``` #### \[iterator]? ```ts optional [iterator]: boolean; ``` #### \[unscopables]? ```ts readonly optional [unscopables]: boolean; ``` Is an object whose properties have the value 'true' when they will be absent when used in a 'with' statement. #### at? ```ts optional at: boolean; ``` #### concat? ```ts optional concat: boolean; ``` #### copyWithin? ```ts optional copyWithin: boolean; ``` #### entries? ```ts optional entries: boolean; ``` #### every? ```ts optional every: boolean; ``` #### fill? ```ts optional fill: boolean; ``` #### filter? ```ts optional filter: boolean; ``` #### find? ```ts optional find: boolean; ``` #### findIndex? ```ts optional findIndex: boolean; ``` #### findLast? ```ts optional findLast: boolean; ``` #### findLastIndex? ```ts optional findLastIndex: boolean; ``` #### flat? ```ts optional flat: boolean; ``` #### flatMap? ```ts optional flatMap: boolean; ``` #### forEach? ```ts optional forEach: boolean; ``` #### includes? ```ts optional includes: boolean; ``` #### indexOf? ```ts optional indexOf: boolean; ``` #### join? ```ts optional join: boolean; ``` #### keys? ```ts optional keys: boolean; ``` #### lastIndexOf? ```ts optional lastIndexOf: boolean; ``` #### length? ```ts optional length: boolean; ``` Gets or sets the length of the array. This is a number one higher than the highest index in the array. #### map? ```ts optional map: boolean; ``` #### pop? ```ts optional pop: boolean; ``` #### push? ```ts optional push: boolean; ``` #### reduce? ```ts optional reduce: boolean; ``` #### reduceRight? ```ts optional reduceRight: boolean; ``` #### reverse? ```ts optional reverse: boolean; ``` #### shift? ```ts optional shift: boolean; ``` #### slice? ```ts optional slice: boolean; ``` #### some? ```ts optional some: boolean; ``` #### sort? ```ts optional sort: boolean; ``` #### splice? ```ts optional splice: boolean; ``` #### toLocaleString? ```ts optional toLocaleString: boolean; ``` #### toReversed? ```ts optional toReversed: boolean; ``` #### toSorted? ```ts optional toSorted: boolean; ``` #### toSpliced? ```ts optional toSpliced: boolean; ``` #### toString? ```ts optional toString: boolean; ``` #### unshift? ```ts optional unshift: boolean; ``` #### values? ```ts optional values: boolean; ``` #### with? ```ts optional with: boolean; ``` #### Inherited from ```ts IdentifierArray.[unscopables] ``` *** ### cache ```ts cache: Cache; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:136 *** ### DEPRECATED\_CLASS\_NAME ```ts DEPRECATED_CLASS_NAME: string; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:52 #### Inherited from ```ts IdentifierArray.DEPRECATED_CLASS_NAME ``` *** ### identifier ```ts identifier: StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:135 #### Overrides ```ts IdentifierArray.identifier ``` *** ### isAsync ```ts isAsync: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:70 *** ### isDestroyed ```ts isDestroyed: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:69 #### Inherited from ```ts IdentifierArray.isDestroyed ``` *** ### isDestroying ```ts isDestroying: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:68 #### Inherited from ```ts IdentifierArray.isDestroying ``` *** ### isLoaded ```ts isLoaded: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:78 The loading state of this array #### Overrides ```ts IdentifierArray.isLoaded ``` *** ### isUpdating ```ts isUpdating: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:66 The flag to signal a `RecordArray` is currently loading data. Example ```javascript let people = store.peekAll('person'); people.isUpdating; // false people.update(); people.isUpdating; // true ``` #### Inherited from ```ts IdentifierArray.isUpdating ``` *** ### key ```ts key: string; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:139 *** ### length ```ts length: number; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1326 Gets or sets the length of the array. This is a number one higher than the highest index in the array. #### Inherited from ```ts IdentifierArray.length ``` *** ### links ```ts links: | null | Links | PaginationLinks; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:134 Retrieve the links for this relationship #### Overrides ```ts IdentifierArray.links ``` *** ### meta ```ts meta: null | Record; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:126 Metadata associated with the request for async hasMany relationships. Example Given that the server returns the following JSON payload when fetching a hasMany relationship: ```js { "comments": [{ "id": 1, "comment": "This is the first comment", }, { // ... }], "meta": { "page": 1, "total": 5 } } ``` You can then access the meta data via the `meta` property: ```js let comments = await post.comments; let meta = comments.meta; // meta.page => 1 // meta.total => 5 ``` #### Overrides ```ts IdentifierArray.meta ``` *** ### modelName ```ts modelName: T extends TypedRecordInstance ? TypeFromInstance> : string; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:141 #### Overrides ```ts IdentifierArray.modelName ``` *** ### save() ```ts save: () => Promise>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:195 Saves all of the records in the `ManyArray`. Note: this API can only be used in legacy mode with a configured Adapter. Example ```javascript const { content: { data: inbox } } = await store.request(findRecord({ type: 'inbox', id: '1' })); let messages = await inbox.messages; messages.forEach((message) => { message.isRead = true; }); messages.save(); ``` #### Returns `Promise`<`IdentifierArray`<`T`>> promise #### Overrides ```ts IdentifierArray.save ``` *** ### type ```ts type: ModelSchema; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:140 ## Methods ### \_\_\_(unique) Symbol(#update)() ```ts ___(unique) Symbol(#update)( target, receiver, prop, args, _SIGNAL): unknown; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:143 #### Parameters ##### target [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md)\[] ##### receiver *typeof* `NativeProxy` ##### prop `string` ##### args `unknown`\[] ##### \_SIGNAL `WarpDriveSignal` #### Returns `unknown` #### Overrides ```ts IdentifierArray.___(unique) Symbol(#update) ``` *** ### \_update() ```ts _update(): Promise>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:109 #### Returns `Promise`<`IdentifierArray`<`T`>> #### Inherited from ```ts IdentifierArray._update ``` *** ### \[iterator]\() ```ts iterator: ArrayIterator; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.iterable.d.ts:78 Iterator #### Returns `ArrayIterator`<`T`> #### Inherited from ```ts IdentifierArray.[iterator] ``` *** ### at() ```ts at(index): undefined | T; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2022.array.d.ts:24 Returns the item located at the specified index. #### Parameters ##### index `number` The zero-based index of the desired code unit. A negative index will count back from the last item. #### Returns `undefined` | `T` #### Inherited from ```ts IdentifierArray.at ``` *** ### concat() #### Call Signature ```ts concat(...items): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1350 Combines two or more arrays. This method returns a new array without modifying any existing arrays. ##### Parameters ###### items ...`ConcatArray`<`T`>\[] Additional arrays and/or items to add to the end of the array. ##### Returns `T`\[] ##### Inherited from ```ts IdentifierArray.concat ``` #### Call Signature ```ts concat(...items): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1356 Combines two or more arrays. This method returns a new array without modifying any existing arrays. ##### Parameters ###### items ...(`T` | `ConcatArray`<`T`>)\[] Additional arrays and/or items to add to the end of the array. ##### Returns `T`\[] ##### Inherited from ```ts IdentifierArray.concat ``` *** ### copyWithin() ```ts copyWithin( target, start, end?): this; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.core.d.ts:62 Returns the this object after copying a section of the array identified by start and end to the same array starting at position target #### Parameters ##### target `number` If target is negative, it is treated as length+target where length is the length of the array. ##### start `number` If start is negative, it is treated as length+start. If end is negative, it is treated as length+end. ##### end? `number` If not specified, length of the this object is used as its default value. #### Returns `this` #### Inherited from ```ts IdentifierArray.copyWithin ``` *** ### createRecord() ```ts createRecord(hash): T; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:174 Create a child record within the owner #### Parameters ##### hash `CreateRecordProperties`<`T`> #### Returns `T` record *** ### entries() ```ts entries(): ArrayIterator<[number, T]>; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.iterable.d.ts:83 Returns an iterable of key, value pairs for every entry in the array #### Returns `ArrayIterator`<\[`number`, `T`]> #### Inherited from ```ts IdentifierArray.entries ``` *** ### every() #### Call Signature ```ts every(predicate, thisArg?): this is S[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1433 Determines whether all the members of an array satisfy the specified test. ##### Type Parameters ###### S `S` ##### Parameters ###### predicate (`value`, `index`, `array`) => `value is S` A function that accepts up to three arguments. The every method calls the predicate function for each element in the array until the predicate returns a value which is coercible to the Boolean value false, or until the end of the array. ###### thisArg? `any` An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. ##### Returns `this is S[]` ##### Inherited from ```ts IdentifierArray.every ``` #### Call Signature ```ts every(predicate, thisArg?): boolean; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1442 Determines whether all the members of an array satisfy the specified test. ##### Parameters ###### predicate (`value`, `index`, `array`) => `unknown` A function that accepts up to three arguments. The every method calls the predicate function for each element in the array until the predicate returns a value which is coercible to the Boolean value false, or until the end of the array. ###### thisArg? `any` An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. ##### Returns `boolean` ##### Inherited from ```ts IdentifierArray.every ``` *** ### fill() ```ts fill( value, start?, end?): this; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.core.d.ts:51 Changes all array elements from `start` to `end` index to a static `value` and returns the modified array #### Parameters ##### value `T` value to fill array section with ##### start? `number` index to start filling the array at. If start is negative, it is treated as length+start where length is the length of the array. ##### end? `number` index to stop filling the array at. If end is negative, it is treated as length+end. #### Returns `this` #### Inherited from ```ts IdentifierArray.fill ``` *** ### filter() #### Call Signature ```ts filter(predicate, thisArg?): S[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1469 Returns the elements of an array that meet the condition specified in a callback function. ##### Type Parameters ###### S `S` ##### Parameters ###### predicate (`value`, `index`, `array`) => `value is S` A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. ###### thisArg? `any` An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. ##### Returns `S`\[] ##### Inherited from ```ts IdentifierArray.filter ``` #### Call Signature ```ts filter(predicate, thisArg?): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1475 Returns the elements of an array that meet the condition specified in a callback function. ##### Parameters ###### predicate (`value`, `index`, `array`) => `unknown` A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. ###### thisArg? `any` An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. ##### Returns `T`\[] ##### Inherited from ```ts IdentifierArray.filter ``` *** ### find() #### Call Signature ```ts find(predicate, thisArg?): undefined | S; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.core.d.ts:29 Returns the value of the first element in the array where predicate is true, and undefined otherwise. ##### Type Parameters ###### S `S` ##### Parameters ###### predicate (`value`, `index`, `obj`) => `value is S` find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns that element value. Otherwise, find returns undefined. ###### thisArg? `any` If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead. ##### Returns `undefined` | `S` ##### Inherited from ```ts IdentifierArray.find ``` #### Call Signature ```ts find(predicate, thisArg?): undefined | T; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.core.d.ts:30 ##### Parameters ###### predicate (`value`, `index`, `obj`) => `unknown` ###### thisArg? `any` ##### Returns `undefined` | `T` ##### Inherited from ```ts IdentifierArray.find ``` *** ### findIndex() ```ts findIndex(predicate, thisArg?): number; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.core.d.ts:41 Returns the index of the first element in the array where predicate is true, and -1 otherwise. #### Parameters ##### predicate (`value`, `index`, `obj`) => `unknown` find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, findIndex immediately returns that element index. Otherwise, findIndex returns -1. ##### thisArg? `any` If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead. #### Returns `number` #### Inherited from ```ts IdentifierArray.findIndex ``` *** ### findLast() #### Call Signature ```ts findLast(predicate, thisArg?): undefined | S; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2023.array.d.ts:29 Returns the value of the last element in the array where predicate is true, and undefined otherwise. ##### Type Parameters ###### S `S` ##### Parameters ###### predicate (`value`, `index`, `array`) => `value is S` findLast calls predicate once for each element of the array, in descending order, until it finds one where predicate returns true. If such an element is found, findLast immediately returns that element value. Otherwise, findLast returns undefined. ###### thisArg? `any` If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead. ##### Returns `undefined` | `S` ##### Inherited from ```ts IdentifierArray.findLast ``` #### Call Signature ```ts findLast(predicate, thisArg?): undefined | T; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2023.array.d.ts:30 ##### Parameters ###### predicate (`value`, `index`, `array`) => `unknown` ###### thisArg? `any` ##### Returns `undefined` | `T` ##### Inherited from ```ts IdentifierArray.findLast ``` *** ### findLastIndex() ```ts findLastIndex(predicate, thisArg?): number; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2023.array.d.ts:41 Returns the index of the last element in the array where predicate is true, and -1 otherwise. #### Parameters ##### predicate (`value`, `index`, `array`) => `unknown` findLastIndex calls predicate once for each element of the array, in descending order, until it finds one where predicate returns true. If such an element is found, findLastIndex immediately returns that element index. Otherwise, findLastIndex returns -1. ##### thisArg? `any` If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead. #### Returns `number` #### Inherited from ```ts IdentifierArray.findLastIndex ``` *** ### flat() ```ts flat(this, depth?): FlatArray[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2019.array.d.ts:75 Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth. #### Type Parameters ##### A `A` ##### D `D` *extends* `number` = `1` #### Parameters ##### this `A` ##### depth? `D` The maximum recursion depth #### Returns `FlatArray`<`A`, `D`>\[] #### Inherited from ```ts IdentifierArray.flat ``` *** ### flatMap() ```ts flatMap(callback, thisArg?): U[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2019.array.d.ts:64 Calls a defined callback function on each element of an array. Then, flattens the result into a new array. This is identical to a map followed by flat with depth 1. #### Type Parameters ##### U `U` ##### This `This` = `undefined` #### Parameters ##### callback (`this`, `value`, `index`, `array`) => `U` | readonly `U`\[] A function that accepts up to three arguments. The flatMap method calls the callback function one time for each element in the array. ##### thisArg? `This` An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used as the this value. #### Returns `U`\[] #### Inherited from ```ts IdentifierArray.flatMap ``` *** ### forEach() ```ts forEach(callbackfn, thisArg?): void; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1457 Performs the specified action for each element in an array. #### Parameters ##### callbackfn (`value`, `index`, `array`) => `void` A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. ##### thisArg? `any` An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. #### Returns `void` #### Inherited from ```ts IdentifierArray.forEach ``` *** ### includes() ```ts includes(searchElement, fromIndex?): boolean; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2016.array.include.d.ts:25 Determines whether an array includes a certain element, returning true or false as appropriate. #### Parameters ##### searchElement `T` The element to search for. ##### fromIndex? `number` The position in this array at which to begin searching for searchElement. #### Returns `boolean` #### Inherited from ```ts IdentifierArray.includes ``` *** ### indexOf() ```ts indexOf(searchElement, fromIndex?): number; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1418 Returns the index of the first occurrence of a value in an array, or -1 if it is not present. #### Parameters ##### searchElement `T` The value to locate in the array. ##### fromIndex? `number` The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. #### Returns `number` #### Inherited from ```ts IdentifierArray.indexOf ``` *** ### join() ```ts join(separator?): string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1361 Adds all the elements of an array into a string, separated by the specified separator string. #### Parameters ##### separator? `string` A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma. #### Returns `string` #### Inherited from ```ts IdentifierArray.join ``` *** ### keys() ```ts keys(): ArrayIterator; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.iterable.d.ts:88 Returns an iterable of keys in the array #### Returns `ArrayIterator`<`number`> #### Inherited from ```ts IdentifierArray.keys ``` *** ### lastIndexOf() ```ts lastIndexOf(searchElement, fromIndex?): number; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1424 Returns the index of the last occurrence of a specified value in an array, or -1 if it is not present. #### Parameters ##### searchElement `T` The value to locate in the array. ##### fromIndex? `number` The array index at which to begin searching backward. If fromIndex is omitted, the search starts at the last index in the array. #### Returns `number` #### Inherited from ```ts IdentifierArray.lastIndexOf ``` *** ### map() ```ts map(callbackfn, thisArg?): U[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1463 Calls a defined callback function on each element of an array, and returns an array that contains the results. #### Type Parameters ##### U `U` #### Parameters ##### callbackfn (`value`, `index`, `array`) => `U` A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. ##### thisArg? `any` An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. #### Returns `U`\[] #### Inherited from ```ts IdentifierArray.map ``` *** ### notify() ```ts notify(): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:144 #### Returns `void` *** ### pop() ```ts pop(): undefined | T; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1339 Removes the last element from an array and returns it. If the array is empty, undefined is returned and the array is not modified. #### Returns `undefined` | `T` #### Inherited from ```ts IdentifierArray.pop ``` *** ### push() ```ts push(...items): number; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1344 Appends new elements to the end of an array, and returns the new length of the array. #### Parameters ##### items ...`T`\[] New elements to add to the array. #### Returns `number` #### Inherited from ```ts IdentifierArray.push ``` *** ### reduce() #### Call Signature ```ts reduce(callbackfn): T; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1481 Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. ##### Parameters ###### callbackfn (`previousValue`, `currentValue`, `currentIndex`, `array`) => `T` A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. ##### Returns `T` ##### Inherited from ```ts IdentifierArray.reduce ``` #### Call Signature ```ts reduce(callbackfn, initialValue): T; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1482 ##### Parameters ###### callbackfn (`previousValue`, `currentValue`, `currentIndex`, `array`) => `T` ###### initialValue `T` ##### Returns `T` ##### Inherited from ```ts IdentifierArray.reduce ``` #### Call Signature ```ts reduce(callbackfn, initialValue): U; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1488 Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. ##### Type Parameters ###### U `U` ##### Parameters ###### callbackfn (`previousValue`, `currentValue`, `currentIndex`, `array`) => `U` A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. ###### initialValue `U` If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. ##### Returns `U` ##### Inherited from ```ts IdentifierArray.reduce ``` *** ### reduceRight() #### Call Signature ```ts reduceRight(callbackfn): T; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1494 Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. ##### Parameters ###### callbackfn (`previousValue`, `currentValue`, `currentIndex`, `array`) => `T` A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. ##### Returns `T` ##### Inherited from ```ts IdentifierArray.reduceRight ``` #### Call Signature ```ts reduceRight(callbackfn, initialValue): T; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1495 ##### Parameters ###### callbackfn (`previousValue`, `currentValue`, `currentIndex`, `array`) => `T` ###### initialValue `T` ##### Returns `T` ##### Inherited from ```ts IdentifierArray.reduceRight ``` #### Call Signature ```ts reduceRight(callbackfn, initialValue): U; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1501 Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. ##### Type Parameters ###### U `U` ##### Parameters ###### callbackfn (`previousValue`, `currentValue`, `currentIndex`, `array`) => `U` A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. ###### initialValue `U` If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. ##### Returns `U` ##### Inherited from ```ts IdentifierArray.reduceRight ``` *** ### reload() ```ts reload(options?): Promise>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:166 Reloads all of the records in the manyArray. If the manyArray holds a relationship that was originally fetched using a links url WarpDrive will revisit the original links url to repopulate the relationship. If the ManyArray holds the result of a `store.query()` reload will re-run the original query. Example ```javascript let user = store.peekRecord('user', '1') await login(user); let permissions = await user.permissions; await permissions.reload(); ``` #### Parameters ##### options? [`BaseFinderOptions`](../../../../@warp-drive/core-types/index/interfaces/BaseFinderOptions.md)<`unknown`> #### Returns `Promise`<`RelatedCollection`<`T`>> *** ### reverse() ```ts reverse(): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1366 Reverses the elements in an array in place. This method mutates the array and returns a reference to the same array. #### Returns `T`\[] #### Inherited from ```ts IdentifierArray.reverse ``` *** ### shift() ```ts shift(): undefined | T; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1371 Removes the first element from an array and returns it. If the array is empty, undefined is returned and the array is not modified. #### Returns `undefined` | `T` #### Inherited from ```ts IdentifierArray.shift ``` *** ### slice() ```ts slice(start?, end?): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1381 Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array. #### Parameters ##### start? `number` The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0. ##### end? `number` The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array. #### Returns `T`\[] #### Inherited from ```ts IdentifierArray.slice ``` *** ### some() ```ts some(predicate, thisArg?): boolean; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1451 Determines whether the specified callback function returns true for any element of an array. #### Parameters ##### predicate (`value`, `index`, `array`) => `unknown` A function that accepts up to three arguments. The some method calls the predicate function for each element in the array until the predicate returns a value which is coercible to the Boolean value true, or until the end of the array. ##### thisArg? `any` An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. #### Returns `boolean` #### Inherited from ```ts IdentifierArray.some ``` *** ### sort() ```ts sort(compareFn?): this; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1392 Sorts an array in place. This method mutates the array and returns a reference to the same array. #### Parameters ##### compareFn? (`a`, `b`) => `number` Function used to determine the order of the elements. It is expected to return a negative value if the first argument is less than the second argument, zero if they're equal, and a positive value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order. ```ts [11,2,22,1].sort((a, b) => a - b) ``` #### Returns `this` #### Inherited from ```ts IdentifierArray.sort ``` *** ### splice() #### Call Signature ```ts splice(start, deleteCount?): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1399 Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. ##### Parameters ###### start `number` The zero-based location in the array from which to start removing elements. ###### deleteCount? `number` The number of elements to remove. ##### Returns `T`\[] An array containing the elements that were deleted. ##### Inherited from ```ts IdentifierArray.splice ``` #### Call Signature ```ts splice( start, deleteCount, ... items): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1407 Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. ##### Parameters ###### start `number` The zero-based location in the array from which to start removing elements. ###### deleteCount `number` The number of elements to remove. ###### items ...`T`\[] Elements to insert into the array in place of the deleted elements. ##### Returns `T`\[] An array containing the elements that were deleted. ##### Inherited from ```ts IdentifierArray.splice ``` *** ### toLocaleString() #### Call Signature ```ts toLocaleString(): string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1334 Returns a string representation of an array. The elements are converted to string using their toLocaleString methods. ##### Returns `string` ##### Inherited from ```ts IdentifierArray.toLocaleString ``` #### Call Signature ```ts toLocaleString(locales, options?): string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.core.d.ts:64 ##### Parameters ###### locales `string` | `string`\[] ###### options? `NumberFormatOptions` & `DateTimeFormatOptions` ##### Returns `string` ##### Inherited from ```ts IdentifierArray.toLocaleString ``` *** ### toReversed() ```ts toReversed(): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2023.array.d.ts:46 Returns a copy of an array with its elements reversed. #### Returns `T`\[] #### Inherited from ```ts IdentifierArray.toReversed ``` *** ### toSorted() ```ts toSorted(compareFn?): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2023.array.d.ts:57 Returns a copy of an array with its elements sorted. #### Parameters ##### compareFn? (`a`, `b`) => `number` Function used to determine the order of the elements. It is expected to return a negative value if the first argument is less than the second argument, zero if they're equal, and a positive value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order. ```ts [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22] ``` #### Returns `T`\[] #### Inherited from ```ts IdentifierArray.toSorted ``` *** ### toSpliced() #### Call Signature ```ts toSpliced( start, deleteCount, ... items): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2023.array.d.ts:66 Copies an array and removes elements and, if necessary, inserts new elements in their place. Returns the copied array. ##### Parameters ###### start `number` The zero-based location in the array from which to start removing elements. ###### deleteCount `number` The number of elements to remove. ###### items ...`T`\[] Elements to insert into the copied array in place of the deleted elements. ##### Returns `T`\[] The copied array. ##### Inherited from ```ts IdentifierArray.toSpliced ``` #### Call Signature ```ts toSpliced(start, deleteCount?): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2023.array.d.ts:74 Copies an array and removes elements while returning the remaining elements. ##### Parameters ###### start `number` The zero-based location in the array from which to start removing elements. ###### deleteCount? `number` The number of elements to remove. ##### Returns `T`\[] A copy of the original array with the remaining elements. ##### Inherited from ```ts IdentifierArray.toSpliced ``` *** ### toString() ```ts toString(): string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1330 Returns a string representation of an array. #### Returns `string` #### Inherited from ```ts IdentifierArray.toString ``` *** ### unshift() ```ts unshift(...items): number; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1412 Inserts new elements at the start of an array, and returns the new length of the array. #### Parameters ##### items ...`T`\[] Elements to insert at the start of the array. #### Returns `number` #### Inherited from ```ts IdentifierArray.unshift ``` *** ### update() ```ts update(): Promise>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:108 Used to get the latest version of all of the records in this array from the adapter. Example ```javascript let people = store.peekAll('person'); people.isUpdating; // false people.update().then(function() { people.isUpdating; // false }); people.isUpdating; // true ``` #### Returns `Promise`<`IdentifierArray`<`T`>> #### Inherited from ```ts IdentifierArray.update ``` *** ### values() ```ts values(): ArrayIterator; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.iterable.d.ts:93 Returns an iterable of values in the array #### Returns `ArrayIterator`<`T`> #### Inherited from ```ts IdentifierArray.values ``` *** ### with() ```ts with(index, value): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2023.array.d.ts:85 Copies an array, then overwrites the value at the provided index with the given value. If the index is negative, then it replaces from the end of the array. #### Parameters ##### index `number` The index of the value to overwrite. If the index is negative, then it replaces from the end of the array. ##### value `T` The value to write into the copied array. #### Returns `T`\[] The copied array with the updated value. #### Inherited from ```ts IdentifierArray.with ``` --- --- url: /api/@ember-data/model/index/classes/default.md --- [Documentation](../../../../index.md) / [@ember-data/model](../../index.md) / [index](../index.md) / default Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:36 Base class from which Models can be defined. ::: code-group ```js [app/models/user.js] import { Model, attr, belongsTo, hasMany } from '@warp-drive/legacy/model'; export default class User extends Model { @attr name; @attr('number') age; @hasMany('post', { async: true, inverse: null }) posts; @belongsTo('group', { async: false, inverse: 'users' }) group; } ``` ```ts [app/models/user.ts] import { Model, attr, belongsTo, hasMany, type AsyncHasMany } from '@warp-drive/legacy/model'; import type { NumberTransform } from '@ember-data/serializer/transform'; import type Group from './group'; import type Post from './post'; export default class User extends Model { @attr declare name: string; @attr('number') declare age: number; @hasMany('post', { async: true, inverse: null }) declare posts: AsyncHasMany; @belongsTo('group', { async: false, inverse: 'users' }) declare group: Group | null; } ``` ::: Models both define the schema for a resource type and provide the class to use as the reactive object for data of resource of that type. ## Extends * `unknown` ## Implements * `MinimalLegacyRecord` ## Constructors ### Constructor ```ts new default(): Model; ``` #### Returns `Model` ## Properties ### isReloading ```ts readonly isReloading: boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:648 If `true` the store is attempting to reload the record from the adapter. Example ```javascript record.isReloading; // false record.reload(); record.isReloading; // true ``` *** ### store ```ts store: default; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:415 The store service instance which created this record instance *** ### modelName ```ts readonly static modelName: string; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:835 Represents the model's class name as a string. This can be used to look up the model's class name through `Store`'s modelFor method. `modelName` is generated for you by EmberData. It will be a lowercased, dasherized string. For example: ```javascript store.modelFor('post').modelName; // 'post' store.modelFor('blog-post').modelName; // 'blog-post' ``` The most common place you'll want to access `modelName` is in your serializer's `payloadKeyFromModelName` method. For example, to change payload keys to underscore (instead of dasherized), you might use the following code: ```javascript import RESTSerializer from '@ember-data/serializer/rest'; import { underscore } from '/utils/string-utils'; export default const PostSerializer = RESTSerializer.extend({ payloadKeyFromModelName(modelName) { return underscore(modelName); } }); ``` ## Accessors ### adapterError #### Get Signature ```ts get adapterError(): unknown; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:741 This property holds the `AdapterError` object with which last adapter operation was rejected. ##### Returns `unknown` #### Set Signature ```ts set adapterError(v): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:742 ##### Parameters ###### v `unknown` ##### Returns `void` *** ### currentState #### Set Signature ```ts set currentState(_v): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:675 ##### Parameters ###### \_v `RecordState` ##### Returns `void` *** ### dirtyType #### Get Signature ```ts get dirtyType(): "" | "created" | "updated" | "deleted"; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:611 If the record is in the dirty state this property will report what kind of change has caused it to move into the dirty state. Possible values are: * `created` The record has been created by the client and not yet saved to the adapter. * `updated` The record has been updated by the client and not yet saved to the adapter. * `deleted` The record has been deleted by the client and not yet saved to the adapter. Example ```javascript let record = store.createRecord('model'); record.dirtyType; // 'created' ``` ##### Returns `""` | `"created"` | `"updated"` | `"deleted"` *** ### errors #### Get Signature ```ts get errors(): Errors; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:733 When the record is in the `invalid` state this object will contain any errors returned by the adapter. When present the errors hash contains keys corresponding to the invalid property names and values which are arrays of Javascript objects with two keys: * `message` A string containing the error message from the backend * `attribute` The name of the property associated with this error message ```javascript record.errors.length; // 0 record.set('foo', 'invalid value'); record.save().catch(function() { record.errors.foo; // [{message: 'foo should be a number.', attribute: 'foo'}] }); ``` The `errors` property is useful for displaying error messages to the user. ```handlebars {{#each @model.errors.username as |error|}}
{{error.message}}
{{/each}} {{#each @model.errors.email as |error|}}
{{error.message}}
{{/each}} ``` You can also access the special `messages` property on the error object to get an array of all the error strings. ```handlebars {{#each @model.errors.messages as |message|}}
{{message}}
{{/each}} ``` ##### Returns `Errors` *** ### hasDirtyAttributes #### Get Signature ```ts get hasDirtyAttributes(): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:496 If this property is `true` the record is in the `dirty` state. The record has local changes that have not yet been saved by the adapter. This includes records that have been created (but not yet saved) or deleted. Example ```javascript let record = store.createRecord('model'); record.hasDirtyAttributes; // true const { content: { data: model } } = await store.request(findRecord({ type: 'model', id: '1' })); model.hasDirtyAttributes; // false model.foo = 'some value'; model.hasDirtyAttributes; // true ``` ##### Since 1.13.0 ##### Returns `boolean` *** ### id #### Get Signature ```ts get id(): null | string; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:667 All ember models have an id property. This is an identifier managed by an external source. These are always coerced to be strings before being used internally. Note when declaring the attributes for a model it is an error to declare an id attribute. ```javascript let record = store.createRecord('model'); record.id; // null const { content: { data: model } } = await store.request(findRecord({ type: 'model', id: '1' })); model.id; // '1' ``` ##### Returns `null` | `string` #### Set Signature ```ts set id(id): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:668 ##### Parameters ###### id `null` | `string` ##### Returns `void` *** ### isDeleted #### Get Signature ```ts get isDeleted(): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:557 If this property is `true` the record is in the `deleted` state and has been marked for deletion. When `isDeleted` is true and `hasDirtyAttributes` is true, the record is deleted locally but the deletion was not yet persisted. When `isSaving` is true, the change is in-flight. When both `hasDirtyAttributes` and `isSaving` are false, the change has persisted. Example ```javascript let record = store.createRecord('model'); record.isDeleted; // false record.deleteRecord(); // Locally deleted record.isDeleted; // true record.hasDirtyAttributes; // true record.isSaving; // false // Persisting the deletion let promise = record.save(); record.isDeleted; // true record.isSaving; // true // Deletion Persisted promise.then(function() { record.isDeleted; // true record.isSaving; // false record.hasDirtyAttributes; // false }); ``` ##### Returns `boolean` *** ### isEmpty #### Get Signature ```ts get isEmpty(): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:439 If this property is `true` the record is in the `empty` state. Empty is the first state all records enter after they have been created. Most records created by the store will quickly transition to the `loading` state if data needs to be fetched from the server or the `created` state if the record is created on the client. A record can also enter the empty state if the adapter is unable to locate the record. ##### Returns `boolean` *** ### isError #### Get Signature ```ts get isError(): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:631 If `true` the adapter reported that it was unable to save local changes to the backend for any reason other than a server-side validation error. Example ```javascript record.isError; // false record.set('foo', 'valid value'); record.save().then(null, function() { record.isError; // true }); ``` ##### Returns `boolean` *** ### isLoaded #### Get Signature ```ts get isLoaded(): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:471 If this property is `true` the record is in the `loaded` state. A record enters this state when its data is populated. Most of a record's lifecycle is spent inside substates of the `loaded` state. Example ```javascript let record = store.createRecord('model'); record.isLoaded; // true const { content: { data: model } } = await store.request(findRecord({ type: 'model', id: '1' })); model.isLoaded; ``` ##### Returns `boolean` *** ### isLoading #### Get Signature ```ts get isLoading(): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:450 If this property is `true` the record is in the `loading` state. A record enters this state when the store asks the adapter for its data. It remains in this state until the adapter provides the requested data. ##### Returns `boolean` *** ### isNew #### Get Signature ```ts get isNew(): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:579 If this property is `true` the record is in the `new` state. A record will be in the `new` state when it has been created on the client and the adapter has not yet report that it was successfully saved. Example ```javascript let record = store.createRecord('model'); record.isNew; // true record.save().then(function(model) { model.isNew; // false }); ``` ##### Returns `boolean` *** ### isSaving #### Get Signature ```ts get isSaving(): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:519 If this property is `true` the record is in the `saving` state. A record enters the saving state when `save` is called, but the adapter has not yet acknowledged that the changes have been persisted to the backend. Example ```javascript let record = store.createRecord('model'); record.isSaving; // false let promise = record.save(); record.isSaving; // true promise.then(function() { record.isSaving; // false }); ``` ##### Returns `boolean` *** ### isValid #### Get Signature ```ts get isValid(): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:590 If this property is `true` the record is in the `valid` state. A record will be in the `valid` state when the adapter did not report any server-side validation failures. ##### Returns `boolean` *** ### attributes #### Get Signature ```ts get static attributes(): Map; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:1137 A map whose keys are the attributes of the model (properties described by attr) and whose values are the meta object for the property. Example ```js [app/models/person.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PersonModel extends Model { @attr('string') firstName; @attr('string') lastName; @attr('date') birthday; } ``` ```javascript import Person from 'app/models/person' let attributes = Person.attributes attributes.forEach(function(meta, name) { // do thing }); // prints: // firstName {type: "string", kind: 'attribute', options: Object, parentType: function, name: "firstName"} // lastName {type: "string", kind: 'attribute', options: Object, parentType: function, name: "lastName"} // birthday {type: "date", kind: 'attribute', options: Object, parentType: function, name: "birthday"} ``` ##### Returns `Map`<`string`, [`LegacyAttributeField`](../../../../@warp-drive/core-types/schema/fields/interfaces/LegacyAttributeField.md)> *** ### fields #### Get Signature ```ts get static fields(): Map; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:1073 A map whose keys are the fields of the model and whose values are strings describing the kind of the field. A model's fields are the union of all of its attributes and relationships. For example: ```js [app/models/blog.js] import { Model, attr, belongsTo, hasMany } from '@warp-drive/legacy/model'; export default class BlogModel extends Model { @hasMany('user') users; @belongsTo('user') owner; @hasMany('post') posts; @attr('string') title; } ``` ```js import Blog from 'app/models/blog' let fields = Blog.fields; fields.forEach(function(kind, field) { // do thing }); // prints: // users, hasMany // owner, belongsTo // posts, hasMany // title, attribute ``` ##### Returns `Map`<`string`, `"belongsTo"` | `"hasMany"` | `"attribute"`> *** ### inverseMap #### Get Signature ```ts get static inverseMap(): Record; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:857 ##### Returns `Record`<`string`, | `null` | [`LegacyRelationshipField`](../../../../@warp-drive/core-types/schema/fields/type-aliases/LegacyRelationshipField.md)> *** ### relatedTypes #### Get Signature ```ts get static relatedTypes(): string[]; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:997 An array of types directly related to a model. Each type will be included once, regardless of the number of relationships it has with the model. For example, given a model with this definition: ```js [app/models/blog.js] import { Model, belongsTo, hasMany } from '@warp-drive/legacy/model'; export default class BlogModel extends Model { @hasMany('user') users; @belongsTo('user') owner; @hasMany('post') posts; } ``` This property would contain the following: ```javascript import Blog from 'app/models/blog'; let relatedTypes = Blog.relatedTypes'); //=> ['user', 'post'] ``` ##### Returns `string`\[] *** ### relationshipNames #### Get Signature ```ts get static relationshipNames(): object; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:962 A hash containing lists of the model's relationships, grouped by the relationship kind. For example, given a model with this definition: ```js [app/models/blog.js] import { Model, belongsTo, hasMany } from '@warp-drive/legacy/model'; export default class BlogModel extends Model { @hasMany('user') users; @belongsTo('user') owner; @hasMany('post') posts; } ``` This property would contain the following: ```javascript import Blog from 'app/models/blog'; let relationshipNames = Blog.relationshipNames; relationshipNames.hasMany; //=> ['users', 'posts'] relationshipNames.belongsTo; //=> ['owner'] ``` ##### Returns `object` ###### belongsTo ```ts belongsTo: string[]; ``` ###### hasMany ```ts hasMany: string[]; ``` *** ### relationships #### Get Signature ```ts get static relationships(): Map; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:929 The model's relationships as a map, keyed on the type of the relationship. The value of each entry is an array containing a descriptor for each relationship with that type, describing the name of the relationship as well as the type. For example, given the following model definition: ```js [app/models/blog.js] import { Model, belongsTo, hasMany } from '@warp-drive/legacy/model'; export default class BlogModel extends Model { @hasMany('user') users; @belongsTo('user') owner; @hasMany('post') posts; } ``` This computed property would return a map describing these relationships, like this: ```javascript import Blog from 'app/models/blog'; import User from 'app/models/user'; import Post from 'app/models/post'; let relationships = Blog.relationships; relationships.user; //=> [ { name: 'users', kind: 'hasMany' }, // { name: 'owner', kind: 'belongsTo' } ] relationships.post; //=> [ { name: 'posts', kind: 'hasMany' } ] ``` ##### Returns `Map`<`string`, [`LegacyRelationshipField`](../../../../@warp-drive/core-types/schema/fields/type-aliases/LegacyRelationshipField.md)\[]> *** ### relationshipsByName #### Get Signature ```ts get static relationshipsByName(): Map; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:1032 A map whose keys are the relationships of a model and whose values are relationship descriptors. For example, given a model with this definition: ```js [app/models/blog.js] import { Model, belongsTo, hasMany } from '@warp-drive/legacy/model'; export default class BlogModel extends Model { @hasMany('user') users; @belongsTo('user') owner; @hasMany('post') posts; } ``` This property would contain the following: ```javascript import Blog from 'app/models/blog'; let relationshipsByName = Blog.relationshipsByName; relationshipsByName.users; //=> { name: 'users', kind: 'hasMany', type: 'user', options: Object } relationshipsByName.owner; //=> { name: 'owner', kind: 'belongsTo', type: 'user', options: Object } ``` ##### Returns `Map`<`string`, [`LegacyRelationshipField`](../../../../@warp-drive/core-types/schema/fields/type-aliases/LegacyRelationshipField.md)> *** ### relationshipsObject #### Get Signature ```ts get static relationshipsObject(): Record; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:1033 ##### Returns `Record`<`string`, [`LegacyRelationshipField`](../../../../@warp-drive/core-types/schema/fields/type-aliases/LegacyRelationshipField.md)> *** ### transformedAttributes #### Get Signature ```ts get static transformedAttributes(): Map; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:1174 A map whose keys are the attributes of the model (properties described by attr) and whose values are type of transformation applied to each attribute. This map does not include any attributes that do not have an transformation type. Example ```js [app/models/person.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PersonModel extends Model { @attr firstName; @attr('string') lastName; @attr('date') birthday; } ``` ```javascript import Person from 'app/models/person'; let transformedAttributes = Person.transformedAttributes transformedAttributes.forEach(function(field, type) { // do thing }); // prints: // lastName string // birthday date ``` ##### Returns `Map`<`string`, `string`> ## Methods ### belongsTo() ```ts belongsTo(this, prop): BelongsToReference; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:286 Get the reference for the specified belongsTo relationship. For instance, given the following model ```js [app/models/blog-post.js] import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class BlogPost extends Model { @belongsTo('user', { async: true, inverse: null }) author; } ``` Then the reference for the author relationship would be retrieved from a record instance like so: ```js blogPost.belongsTo('author'); ``` A `BelongsToReference` is a low-level API that allows access and manipulation of a belongsTo relationship. It is especially useful when you're dealing with `async` relationships as it allows synchronous access to the relationship data if loaded, as well as APIs for loading, reloading the data or accessing available information without triggering a load. It may also be useful when using `sync` relationships that need to be loaded/reloaded with more precise timing than marking the relationship as `async` and relying on autofetch would have allowed. However,keep in mind that marking a relationship as `async: false` will introduce bugs into your application if the data is not always guaranteed to be available by the time the relationship is accessed. Ergo, it is recommended when using this approach to utilize `links` for unloaded relationship state instead of identifiers. Reference APIs are entangled with the relationship's underlying state, thus any getters or cached properties that utilize these will properly invalidate if the relationship state changes. References are "stable", meaning that multiple calls to retrieve the reference for a given relationship will always return the same HasManyReference. #### Type Parameters ##### T `T` *extends* `Model` ##### K `K` *extends* `string` #### Parameters ##### this `T` ##### prop `K` & `K` *extends* `_MaybeBelongsToFields`<`T`> ? `K`<`K`> : `never` #### Returns `BelongsToReference`<`T`, `K`> reference for this relationship #### Since 2.5.0 *** ### changedAttributes() ```ts changedAttributes(this): ChangedAttributesHash; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:147 Returns an object, whose keys are changed properties, and value is an \[oldProp, newProp] array. The array represents the diff of the canonical state with the local state of the model. Note: if the model is created locally, the canonical state is empty since the adapter hasn't acknowledged the attributes yet: Example ```js [app/models/mascot.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class MascotModel extends Model { @attr('string') name; @attr('boolean', { defaultValue: false }) isAdmin; } ``` ```javascript let mascot = store.createRecord('mascot'); mascot.changedAttributes(); // {} mascot.set('name', 'Tomster'); mascot.changedAttributes(); // { name: [undefined, 'Tomster'] } mascot.set('isAdmin', true); mascot.changedAttributes(); // { isAdmin: [undefined, true], name: [undefined, 'Tomster'] } mascot.save().then(function() { mascot.changedAttributes(); // {} mascot.set('isAdmin', false); mascot.changedAttributes(); // { isAdmin: [true, false] } }); ``` #### Type Parameters ##### T `T` *extends* `MinimalLegacyRecord` #### Parameters ##### this `T` #### Returns `ChangedAttributesHash` an object, whose keys are changed properties, and value is an \[oldProp, newProp] array. *** ### deleteRecord() ```ts deleteRecord(this): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:365 Marks the record as deleted but does not save it. You must call `save` afterwards if you want to persist it. You might use this method if you want to allow the user to still `rollbackAttributes()` after a delete was made. Example ```js import Component from '@glimmer/component'; export default class extends Component { softDelete = () => { this.args.model.deleteRecord(); } confirm = () => { this.args.model.save(); } undo = () => { this.args.model.rollbackAttributes(); } } ``` #### Type Parameters ##### T `T` *extends* `MinimalLegacyRecord` #### Parameters ##### this `T` #### Returns `void` *** ### destroyRecord() ```ts destroyRecord(this, options?): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:94 Same as `deleteRecord`, but saves the record immediately. Example ```js import Component from '@glimmer/component'; export default class extends Component { delete = () => { this.args.model.destroyRecord().then(function() { this.transitionToRoute('model.index'); }); } } ``` If you pass an object on the `adapterOptions` property of the options argument it will be passed to your adapter via the snapshot ```js record.destroyRecord({ adapterOptions: { subscribe: false } }); ``` ```js [app/adapters/post.js] import MyCustomAdapter from './custom-adapter'; export default class PostAdapter extends MyCustomAdapter { deleteRecord(store, type, snapshot) { if (snapshot.adapterOptions.subscribe) { // ... } // ... } } ``` #### Type Parameters ##### T `T` *extends* `MinimalLegacyRecord` #### Parameters ##### this `T` ##### options? `Record`<`string`, `unknown`> #### Returns `Promise`<`Model`> a promise that will be resolved when the adapter returns successfully or rejected if the adapter returns with an error. *** ### eachAttribute() ```ts eachAttribute(callback, binding?): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:801 #### Type Parameters ##### T `T` #### Parameters ##### callback (`this`, `key`, `meta`) => `void` ##### binding? `T` #### Returns `void` *** ### eachRelationship() ```ts eachRelationship(callback, binding?): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:798 Given a callback, iterates over each of the relationships in the model, invoking the callback with the name of each relationship and its relationship descriptor. The callback method you provide should have the following signature (all parameters are optional): ```javascript function(name, descriptor); ``` * `name` the name of the current property in the iteration * `descriptor` the meta object that describes this relationship The relationship descriptor argument is an object with the following properties. * **name** String the name of this relationship on the Model * **kind** String "hasMany" or "belongsTo" * **options** Object the original options hash passed when the relationship was declared * **parentType** Model the type of the Model that owns this relationship * **type** String the type name of the related Model Note that in addition to a callback, you can also pass an optional target object that will be set as `this` on the context. Example ```js [app/serializers/application.js] import JSONSerializer from '@ember-data/serializer/json'; export default class ApplicationSerializer extends JSONSerializer { serialize(record, options) { let json = {}; record.eachRelationship(function(name, descriptor) { if (descriptor.kind === 'hasMany') { let serializedHasManyName = name.toUpperCase() + '_IDS'; json[serializedHasManyName] = record.get(name).map(r => r.id); } }); return json; } } ``` #### Type Parameters ##### T `T` #### Parameters ##### callback (`this`, `key`, `meta`) => `void` the callback to invoke ##### binding? `T` the value to which the callback's `this` should be bound #### Returns `void` *** ### hasMany() ```ts hasMany(this, prop): HasManyReference; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:336 Get the reference for the specified hasMany relationship. For instance, given the following model ```js [app/models/blog-post.js] import { Model, hasMany } from '@warp-drive/legacy/model'; export default class BlogPost extends Model { @hasMany('comment', { async: true, inverse: null }) comments; } ``` Then the reference for the comments relationship would be retrieved from a record instance like so: ```js blogPost.hasMany('comments'); ``` A `HasManyReference` is a low-level API that allows access and manipulation of a hasMany relationship. It is especially useful when you are dealing with `async` relationships as it allows synchronous access to the relationship data if loaded, as well as APIs for loading, reloading the data or accessing available information without triggering a load. It may also be useful when using `sync` relationships with `@ember-data/model` that need to be loaded/reloaded with more precise timing than marking the relationship as `async` and relying on autofetch would have allowed. However,keep in mind that marking a relationship as `async: false` will introduce bugs into your application if the data is not always guaranteed to be available by the time the relationship is accessed. Ergo, it is recommended when using this approach to utilize `links` for unloaded relationship state instead of identifiers. Reference APIs are entangled with the relationship's underlying state, thus any getters or cached properties that utilize these will properly invalidate if the relationship state changes. References are "stable", meaning that multiple calls to retrieve the reference for a given relationship will always return the same HasManyReference. #### Type Parameters ##### T `T` *extends* `MinimalLegacyRecord` ##### K `K` *extends* `string` #### Parameters ##### this `T` ##### prop `K` #### Returns `HasManyReference`<`T`, `K`> reference for this relationship #### Since 2.5.0 *** ### inverseFor() ```ts inverseFor(name): | null | LegacyRelationshipField; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:800 #### Parameters ##### name `string` #### Returns | `null` | [`LegacyRelationshipField`](../../../../@warp-drive/core-types/schema/fields/type-aliases/LegacyRelationshipField.md) *** ### notifyPropertyChange() ```ts notifyPropertyChange(prop): this; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:743 #### Parameters ##### prop `string` #### Returns `this` *** ### relationshipFor() ```ts relationshipFor(name): | undefined | LegacyRelationshipField; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:799 #### Parameters ##### name `string` #### Returns | `undefined` | [`LegacyRelationshipField`](../../../../@warp-drive/core-types/schema/fields/type-aliases/LegacyRelationshipField.md) *** ### reload() ```ts reload(this, options?): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:236 Reload the record from the adapter. This will only work if the record has already finished loading. Example ```js import Component from '@glimmer/component'; export default class extends Component { async reload = () => { await this.args.model.reload(); // do something with the reloaded model } } ``` #### Type Parameters ##### T `T` *extends* `MinimalLegacyRecord` #### Parameters ##### this `T` ##### options? `Record`<`string`, `unknown`> optional, may include `adapterOptions` hash which will be passed to adapter request #### Returns `Promise`<`T`> a promise that will be resolved with the record when the adapter returns successfully or rejected if the adapter returns with an error. *** ### rollbackAttributes() ```ts rollbackAttributes(this): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:165 If the model `hasDirtyAttributes` this function will discard any unsaved changes. If the model `isNew` it will be removed from the store. Example ```javascript record.name; // 'Untitled Document' record.set('name', 'Doc 1'); record.name; // 'Doc 1' record.rollbackAttributes(); record.name; // 'Untitled Document' ``` #### Type Parameters ##### T `T` *extends* `MinimalLegacyRecord` #### Parameters ##### this `T` #### Returns `void` #### Since 1.13.0 *** ### save() ```ts save(this, options?): Promise; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:210 Save the record and persist any changes to the record to an external source via the adapter. Example ```javascript record.set('name', 'Tomster'); record.save().then(function() { // Success callback }, function() { // Error callback }); ``` If you pass an object using the `adapterOptions` property of the options argument it will be passed to your adapter via the snapshot. ```js record.save({ adapterOptions: { subscribe: false } }); ``` ```js [app/adapters/post.js] import MyCustomAdapter from './custom-adapter'; export default class PostAdapter extends MyCustomAdapter { updateRecord(store, type, snapshot) { if (snapshot.adapterOptions.subscribe) { // ... } // ... } } ``` #### Type Parameters ##### T `T` *extends* `MinimalLegacyRecord` #### Parameters ##### this `T` ##### options? `Record`<`string`, `unknown`> #### Returns `Promise`<`Model`> a promise that will be resolved when the adapter returns successfully or rejected if the adapter returns with an error. *** ### serialize() ```ts serialize(this, options?): unknown; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:51 Create a JSON representation of the record, using the serialization strategy of the store's adapter. `serialize` takes an optional hash as a parameter, currently supported options are: * `includeId`: `true` if the record's ID should be included in the JSON representation. #### Type Parameters ##### T `T` *extends* `MinimalLegacyRecord` #### Parameters ##### this `T` ##### options? `Record`<`string`, `unknown`> #### Returns `unknown` an object whose values are primitive JSON values only *** ### toString() ```ts toString(): string; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:669 Returns a string representation of an object. #### Returns `string` *** ### unloadRecord() ```ts unloadRecord(this): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:101 Unloads the record from the store. This will not send a delete request to your server, it just unloads the record from memory. #### Type Parameters ##### T `T` *extends* `MinimalLegacyRecord` #### Parameters ##### this `T` #### Returns `void` *** ### \_findInverseFor() ```ts static _findInverseFor(name, store): | null | LegacyRelationshipField; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:890 #### Parameters ##### name `string` ##### store [`default`](../../../store/index/classes/default.md) #### Returns | `null` | [`LegacyRelationshipField`](../../../../@warp-drive/core-types/schema/fields/type-aliases/LegacyRelationshipField.md) *** ### eachAttribute() ```ts static eachAttribute(callback, binding?): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:1217 Iterates through the attributes of the model, calling the passed function on each attribute. The callback method you provide should have the following signature (all parameters are optional): ```javascript function(name, meta); ``` * `name` the name of the current property in the iteration * `meta` the meta object for the attribute property in the iteration Note that in addition to a callback, you can also pass an optional target object that will be set as `this` on the context. Example ```javascript import { Model, attr } from '@warp-drive/legacy/model'; class PersonModel extends Model { @attr('string') firstName; @attr('string') lastName; @attr('date') birthday; } PersonModel.eachAttribute(function(name, meta) { // do thing }); // prints: // firstName {type: "string", kind: 'attribute', options: Object, parentType: function, name: "firstName"} // lastName {type: "string", kind: 'attribute', options: Object, parentType: function, name: "lastName"} // birthday {type: "date", kind: 'attribute', options: Object, parentType: function, name: "birthday"} ``` #### Type Parameters ##### T `T` ##### Schema `Schema` *extends* `Model` #### Parameters ##### callback (`this`, `key`, `attribute`) => `void` The callback to execute ##### binding? `T` the value to which the callback's `this` should be bound #### Returns `void` *** ### eachRelatedType() ```ts static eachRelatedType(callback, binding?): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:1094 Given a callback, iterates over each of the types related to a model, invoking the callback with the related type's class. Each type will be returned just once, regardless of how many different relationships it has with a model. #### Type Parameters ##### T `T` #### Parameters ##### callback (`this`, `type`) => `void` the callback to invoke ##### binding? `T` the value to which the callback's `this` should be bound #### Returns `void` *** ### eachRelationship() ```ts static eachRelationship(callback, binding?): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:1083 Given a callback, iterates over each of the relationships in the model, invoking the callback with the name of each relationship and its relationship descriptor. #### Type Parameters ##### T `T` ##### Schema `Schema` *extends* `Model` #### Parameters ##### callback (`this`, `key`, `relationship`) => `void` the callback to invoke ##### binding? `T` the value to which the callback's `this` should be bound #### Returns `void` *** ### eachTransformedAttribute() ```ts static eachTransformedAttribute(callback, binding?): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:1261 Iterates through the transformedAttributes of the model, calling the passed function on each attribute. Note the callback will not be called for any attributes that do not have an transformation type. The callback method you provide should have the following signature (all parameters are optional): ```javascript function(name, type); ``` * `name` the name of the current property in the iteration * `type` a string containing the name of the type of transformed applied to the attribute Note that in addition to a callback, you can also pass an optional target object that will be set as `this` on the context. Example ```javascript import { Model, attr } from '@warp-drive/legacy/model'; let Person = Model.extend({ firstName: attr(), lastName: attr('string'), birthday: attr('date') }); Person.eachTransformedAttribute(function(name, type) { // do thing }); // prints: // lastName string // birthday date ``` #### Type Parameters ##### T `T` ##### Schema `Schema` *extends* `Model` #### Parameters ##### callback (`this`, `key`, `type`) => `void` The callback to execute ##### binding? `T` the value to which the callback's `this` should be bound #### Returns `void` *** ### inverseFor() ```ts static inverseFor(name, store): | null | LegacyRelationshipField; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:889 Find the relationship which is the inverse of the one asked for. For example, if you define models like this: ```js [app/models/post.js] import { Model, hasMany } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @hasMany('message') comments; } ``` ```js [app/models/message.js] import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class MessageModel extends Model { @belongsTo('post') owner; } ``` ```js store.modelFor('post').inverseFor('comments', store) // { type: 'message', name: 'owner', kind: 'belongsTo' } store.modelFor('message').inverseFor('owner', store) // { type: 'post', name: 'comments', kind: 'hasMany' } ``` #### Parameters ##### name `string` the name of the relationship ##### store [`default`](../../../store/index/classes/default.md) #### Returns | `null` | [`LegacyRelationshipField`](../../../../@warp-drive/core-types/schema/fields/type-aliases/LegacyRelationshipField.md) the inverse relationship, or null *** ### toString() ```ts static toString(): string; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:1267 Returns the name of the model class. #### Returns `string` *** ### typeForRelationship() ```ts static typeForRelationship(name, store): | undefined | ModelSchema; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/model.d.ts:856 For a given relationship name, returns the model type of the relationship. For example, if you define a model like this: ```js [app/models/post.js] import { Model, hasMany } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @hasMany('comment') comments; } ``` Calling `store.modelFor('post').typeForRelationship('comments', store)` will return `Comment`. #### Parameters ##### name `string` the name of the relationship ##### store [`default`](../../../store/index/classes/default.md) an instance of Store #### Returns | `undefined` | [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md)<`unknown`> the type of the relationship, or undefined --- --- url: /api/@ember-data/model/index/functions/attr.md --- [Documentation](../../../../index.md) / [@ember-data/model](../../index.md) / [index](../index.md) / attr ## Call Signature ```ts function attr(): DataDecorator; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/attr.d.ts:157 `attr` defines an attribute on a [Model](/ember-data/release/classes/Model). By default, attributes are passed through as-is, however you can specify an optional type to have the value automatically transformed. EmberData ships with four basic transform types: `string`, `number`, `boolean` and `date`. You can define your own transforms by subclassing [Transform](/ember-data/release/classes/Transform). Note that you cannot use `attr` to define an attribute of `id`. `attr` takes an optional hash as a second parameter, currently supported options are: * `defaultValue`: Pass a string or a function to be called to set the attribute to a default value if and only if the key is absent from the payload response. Example ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr('boolean', { defaultValue: false }) verified; } ``` Default value can also be a function. This is useful it you want to return a new object for each attribute. ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr({ defaultValue() { return {}; } }) settings; } ``` The `options` hash is passed as second argument to a transforms' `serialize` and `deserialize` method. This allows to configure a transformation and adapt the corresponding value, based on the config: ```js [app/models/post.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @attr('text', { uppercase: true }) text; } ``` ```js [app/transforms/text.js] export default class TextTransform { serialize(value, options) { if (options.uppercase) { return value.toUpperCase(); } return value; } deserialize(value) { return value; } static create() { return new this(); } } ``` ### Returns `DataDecorator` ## Call Signature ```ts function attr(type): DataDecorator; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/attr.d.ts:158 `attr` defines an attribute on a [Model](/ember-data/release/classes/Model). By default, attributes are passed through as-is, however you can specify an optional type to have the value automatically transformed. EmberData ships with four basic transform types: `string`, `number`, `boolean` and `date`. You can define your own transforms by subclassing [Transform](/ember-data/release/classes/Transform). Note that you cannot use `attr` to define an attribute of `id`. `attr` takes an optional hash as a second parameter, currently supported options are: * `defaultValue`: Pass a string or a function to be called to set the attribute to a default value if and only if the key is absent from the payload response. Example ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr('boolean', { defaultValue: false }) verified; } ``` Default value can also be a function. This is useful it you want to return a new object for each attribute. ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr({ defaultValue() { return {}; } }) settings; } ``` The `options` hash is passed as second argument to a transforms' `serialize` and `deserialize` method. This allows to configure a transformation and adapt the corresponding value, based on the config: ```js [app/models/post.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @attr('text', { uppercase: true }) text; } ``` ```js [app/transforms/text.js] export default class TextTransform { serialize(value, options) { if (options.uppercase) { return value.toUpperCase(); } return value; } deserialize(value) { return value; } static create() { return new this(); } } ``` ### Type Parameters #### T `T` ### Parameters #### type `TypeFromInstance`<`T`> the attribute type ### Returns `DataDecorator` ## Call Signature ```ts function attr(type): DataDecorator; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/attr.d.ts:159 `attr` defines an attribute on a [Model](/ember-data/release/classes/Model). By default, attributes are passed through as-is, however you can specify an optional type to have the value automatically transformed. EmberData ships with four basic transform types: `string`, `number`, `boolean` and `date`. You can define your own transforms by subclassing [Transform](/ember-data/release/classes/Transform). Note that you cannot use `attr` to define an attribute of `id`. `attr` takes an optional hash as a second parameter, currently supported options are: * `defaultValue`: Pass a string or a function to be called to set the attribute to a default value if and only if the key is absent from the payload response. Example ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr('boolean', { defaultValue: false }) verified; } ``` Default value can also be a function. This is useful it you want to return a new object for each attribute. ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr({ defaultValue() { return {}; } }) settings; } ``` The `options` hash is passed as second argument to a transforms' `serialize` and `deserialize` method. This allows to configure a transformation and adapt the corresponding value, based on the config: ```js [app/models/post.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @attr('text', { uppercase: true }) text; } ``` ```js [app/transforms/text.js] export default class TextTransform { serialize(value, options) { if (options.uppercase) { return value.toUpperCase(); } return value; } deserialize(value) { return value; } static create() { return new this(); } } ``` ### Parameters #### type `string` the attribute type ### Returns `DataDecorator` ## Call Signature ```ts function attr(options): DataDecorator; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/attr.d.ts:160 `attr` defines an attribute on a [Model](/ember-data/release/classes/Model). By default, attributes are passed through as-is, however you can specify an optional type to have the value automatically transformed. EmberData ships with four basic transform types: `string`, `number`, `boolean` and `date`. You can define your own transforms by subclassing [Transform](/ember-data/release/classes/Transform). Note that you cannot use `attr` to define an attribute of `id`. `attr` takes an optional hash as a second parameter, currently supported options are: * `defaultValue`: Pass a string or a function to be called to set the attribute to a default value if and only if the key is absent from the payload response. Example ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr('boolean', { defaultValue: false }) verified; } ``` Default value can also be a function. This is useful it you want to return a new object for each attribute. ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr({ defaultValue() { return {}; } }) settings; } ``` The `options` hash is passed as second argument to a transforms' `serialize` and `deserialize` method. This allows to configure a transformation and adapt the corresponding value, based on the config: ```js [app/models/post.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @attr('text', { uppercase: true }) text; } ``` ```js [app/transforms/text.js] export default class TextTransform { serialize(value, options) { if (options.uppercase) { return value.toUpperCase(); } return value; } deserialize(value) { return value; } static create() { return new this(); } } ``` ### Parameters #### options `AttrOptions` a hash of options ### Returns `DataDecorator` ## Call Signature ```ts function attr(type, options?): DataDecorator; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/attr.d.ts:161 `attr` defines an attribute on a [Model](/ember-data/release/classes/Model). By default, attributes are passed through as-is, however you can specify an optional type to have the value automatically transformed. EmberData ships with four basic transform types: `string`, `number`, `boolean` and `date`. You can define your own transforms by subclassing [Transform](/ember-data/release/classes/Transform). Note that you cannot use `attr` to define an attribute of `id`. `attr` takes an optional hash as a second parameter, currently supported options are: * `defaultValue`: Pass a string or a function to be called to set the attribute to a default value if and only if the key is absent from the payload response. Example ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr('boolean', { defaultValue: false }) verified; } ``` Default value can also be a function. This is useful it you want to return a new object for each attribute. ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr({ defaultValue() { return {}; } }) settings; } ``` The `options` hash is passed as second argument to a transforms' `serialize` and `deserialize` method. This allows to configure a transformation and adapt the corresponding value, based on the config: ```js [app/models/post.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @attr('text', { uppercase: true }) text; } ``` ```js [app/transforms/text.js] export default class TextTransform { serialize(value, options) { if (options.uppercase) { return value.toUpperCase(); } return value; } deserialize(value) { return value; } static create() { return new this(); } } ``` ### Type Parameters #### T `T` ### Parameters #### type `TypeFromInstance`<`T`> the attribute type #### options? `OptionsFromInstance`<`T`> a hash of options ### Returns `DataDecorator` ## Call Signature ```ts function attr(type, options?): DataDecorator; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/attr.d.ts:162 `attr` defines an attribute on a [Model](/ember-data/release/classes/Model). By default, attributes are passed through as-is, however you can specify an optional type to have the value automatically transformed. EmberData ships with four basic transform types: `string`, `number`, `boolean` and `date`. You can define your own transforms by subclassing [Transform](/ember-data/release/classes/Transform). Note that you cannot use `attr` to define an attribute of `id`. `attr` takes an optional hash as a second parameter, currently supported options are: * `defaultValue`: Pass a string or a function to be called to set the attribute to a default value if and only if the key is absent from the payload response. Example ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr('boolean', { defaultValue: false }) verified; } ``` Default value can also be a function. This is useful it you want to return a new object for each attribute. ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr({ defaultValue() { return {}; } }) settings; } ``` The `options` hash is passed as second argument to a transforms' `serialize` and `deserialize` method. This allows to configure a transformation and adapt the corresponding value, based on the config: ```js [app/models/post.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @attr('text', { uppercase: true }) text; } ``` ```js [app/transforms/text.js] export default class TextTransform { serialize(value, options) { if (options.uppercase) { return value.toUpperCase(); } return value; } deserialize(value) { return value; } static create() { return new this(); } } ``` ### Parameters #### type `string` the attribute type #### options? `AttrOptions`< | `object` | [`PrimitiveValue`](../../../../@warp-drive/core-types/json/raw/type-aliases/PrimitiveValue.md) | `unknown`\[]> & `object` a hash of options ### Returns `DataDecorator` ## Call Signature ```ts function attr( target, key, desc?): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/attr.d.ts:163 `attr` defines an attribute on a [Model](/ember-data/release/classes/Model). By default, attributes are passed through as-is, however you can specify an optional type to have the value automatically transformed. EmberData ships with four basic transform types: `string`, `number`, `boolean` and `date`. You can define your own transforms by subclassing [Transform](/ember-data/release/classes/Transform). Note that you cannot use `attr` to define an attribute of `id`. `attr` takes an optional hash as a second parameter, currently supported options are: * `defaultValue`: Pass a string or a function to be called to set the attribute to a default value if and only if the key is absent from the payload response. Example ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr('boolean', { defaultValue: false }) verified; } ``` Default value can also be a function. This is useful it you want to return a new object for each attribute. ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr({ defaultValue() { return {}; } }) settings; } ``` The `options` hash is passed as second argument to a transforms' `serialize` and `deserialize` method. This allows to configure a transformation and adapt the corresponding value, based on the config: ```js [app/models/post.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @attr('text', { uppercase: true }) text; } ``` ```js [app/transforms/text.js] export default class TextTransform { serialize(value, options) { if (options.uppercase) { return value.toUpperCase(); } return value; } deserialize(value) { return value; } static create() { return new this(); } } ``` ### Parameters #### target `object` #### key `string` | `symbol` #### desc? `PropertyDescriptor` ### Returns `void` --- --- url: /api/@ember-data/model/index/functions/buildSchema.md --- [Documentation](../../../../index.md) / [@ember-data/model](../../index.md) / [index](../index.md) / buildSchema ```ts function buildSchema(store): SchemaService; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/schema-provider.d.ts:60 ## Parameters ### store [`default`](../../../store/index/classes/default.md) ## Returns [`SchemaService`](../../../../@warp-drive/core-types/index/interfaces/SchemaService.md) --- --- url: /api/@ember-data/model/index/functions/belongsTo.md --- [Documentation](../../../../index.md) / [@ember-data/model](../../index.md) / [index](../index.md) / belongsTo ## Call Signature ```ts function belongsTo(): never; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/belongs-to.d.ts:169 `belongsTo` is used to define One-To-One and One-To-Many, and One-To-None relationships on a [Model](/ember-data/release/classes/Model). `belongsTo` takes a configuration hash as a second parameter, currently supported options are: * `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship. * `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`. * `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic * `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism. ### Examples To declare a **one-to-many** (or many-to-many) relationship, use `belongsTo` in combination with `hasMany`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('post', { async: false, inverse: 'comments' }) post; } // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'post' }) comments; } ``` To declare a **one-to-one** relationship with managed inverses, use `belongsTo` for both sides: ```js // app/models/author.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Author extends Model { @belongsTo('address', { async: true, inverse: 'owner' }) address; } // app/models/address.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Address extends Model { @belongsTo('author', { async: true, inverse: 'address' }) owner; } ``` To declare a **one-to-one** relationship without managed inverses, use `belongsTo` for both sides with `null` as the inverse: ```js // app/models/author.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Author extends Model { @belongsTo('address', { async: true, inverse: null }) address; } // app/models/address.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Address extends Model { @belongsTo('author', { async: true, inverse: null }) owner; } ``` To declare a one-to-none relationship between two models, use `belongsTo` with inverse set to `null` on just one side:: ```js // app/models/person.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Person extends Model { @belongsTo('person', { async: false, inverse: null }) bestFriend; } ``` #### Sync vs Async Relationships EmberData fulfills relationships using resource data available in the cache. Sync relationships point directly to the known related resources. When a relationship is declared as async, if any of the known related resources have not been loaded, they will be fetched. The property on the record when accessed provides a promise that resolves once all resources are loaded. Async relationships may take advantage of links. On access, if the related link has not been loaded, or if any known resources are not available in the cache, the fresh state will be fetched using the link. In contrast to async relationship, accessing a sync relationship will error on access when any of the known related resources have not been loaded. If you are using `links` with sync relationships, you have to use the BelongsTo reference API to fetch or refresh related resources that aren't loaded. For instance, for a `bestFriend` relationship: ```js person.belongsTo('bestFriend').reload(); ``` #### Polymorphic Relationships To declare a polymorphic relationship, use `hasMany` with the `polymorphic` option set to `true`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent; } ``` `'commentable'` here is referred to as the "abstract type" for the polymorphic relationship. Polymorphic relationships with `inverse: null` will accept any type of record as their content. Polymorphic relationships with `inverse` set to a string will only accept records with a matching inverse relationships declaring itself as satisfying the abstract type. Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable' for this relationship. ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments; } ``` Note: every Model that declares an inverse to a polymorphic relationship must declare itself exactly the same. This is because polymorphism is based on structural traits. Polymorphic to polymorphic relationships are supported. Both sides of the relationship must be declared as polymorphic, and the `as` option must be used to declare the abstract type each record satisfies on both sides. ### Returns `never` relationship ## Call Signature ```ts function belongsTo(type): never; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/belongs-to.d.ts:170 `belongsTo` is used to define One-To-One and One-To-Many, and One-To-None relationships on a [Model](/ember-data/release/classes/Model). `belongsTo` takes a configuration hash as a second parameter, currently supported options are: * `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship. * `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`. * `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic * `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism. ### Examples To declare a **one-to-many** (or many-to-many) relationship, use `belongsTo` in combination with `hasMany`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('post', { async: false, inverse: 'comments' }) post; } // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'post' }) comments; } ``` To declare a **one-to-one** relationship with managed inverses, use `belongsTo` for both sides: ```js // app/models/author.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Author extends Model { @belongsTo('address', { async: true, inverse: 'owner' }) address; } // app/models/address.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Address extends Model { @belongsTo('author', { async: true, inverse: 'address' }) owner; } ``` To declare a **one-to-one** relationship without managed inverses, use `belongsTo` for both sides with `null` as the inverse: ```js // app/models/author.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Author extends Model { @belongsTo('address', { async: true, inverse: null }) address; } // app/models/address.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Address extends Model { @belongsTo('author', { async: true, inverse: null }) owner; } ``` To declare a one-to-none relationship between two models, use `belongsTo` with inverse set to `null` on just one side:: ```js // app/models/person.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Person extends Model { @belongsTo('person', { async: false, inverse: null }) bestFriend; } ``` #### Sync vs Async Relationships EmberData fulfills relationships using resource data available in the cache. Sync relationships point directly to the known related resources. When a relationship is declared as async, if any of the known related resources have not been loaded, they will be fetched. The property on the record when accessed provides a promise that resolves once all resources are loaded. Async relationships may take advantage of links. On access, if the related link has not been loaded, or if any known resources are not available in the cache, the fresh state will be fetched using the link. In contrast to async relationship, accessing a sync relationship will error on access when any of the known related resources have not been loaded. If you are using `links` with sync relationships, you have to use the BelongsTo reference API to fetch or refresh related resources that aren't loaded. For instance, for a `bestFriend` relationship: ```js person.belongsTo('bestFriend').reload(); ``` #### Polymorphic Relationships To declare a polymorphic relationship, use `hasMany` with the `polymorphic` option set to `true`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent; } ``` `'commentable'` here is referred to as the "abstract type" for the polymorphic relationship. Polymorphic relationships with `inverse: null` will accept any type of record as their content. Polymorphic relationships with `inverse` set to a string will only accept records with a matching inverse relationships declaring itself as satisfying the abstract type. Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable' for this relationship. ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments; } ``` Note: every Model that declares an inverse to a polymorphic relationship must declare itself exactly the same. This is because polymorphism is based on structural traits. Polymorphic to polymorphic relationships are supported. Both sides of the relationship must be declared as polymorphic, and the `as` option must be used to declare the abstract type each record satisfies on both sides. ### Parameters #### type `string` (optional) the name of the related resource ### Returns `never` relationship ## Call Signature ```ts function belongsTo(type, options): RelationshipDecorator; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/belongs-to.d.ts:171 `belongsTo` is used to define One-To-One and One-To-Many, and One-To-None relationships on a [Model](/ember-data/release/classes/Model). `belongsTo` takes a configuration hash as a second parameter, currently supported options are: * `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship. * `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`. * `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic * `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism. ### Examples To declare a **one-to-many** (or many-to-many) relationship, use `belongsTo` in combination with `hasMany`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('post', { async: false, inverse: 'comments' }) post; } // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'post' }) comments; } ``` To declare a **one-to-one** relationship with managed inverses, use `belongsTo` for both sides: ```js // app/models/author.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Author extends Model { @belongsTo('address', { async: true, inverse: 'owner' }) address; } // app/models/address.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Address extends Model { @belongsTo('author', { async: true, inverse: 'address' }) owner; } ``` To declare a **one-to-one** relationship without managed inverses, use `belongsTo` for both sides with `null` as the inverse: ```js // app/models/author.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Author extends Model { @belongsTo('address', { async: true, inverse: null }) address; } // app/models/address.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Address extends Model { @belongsTo('author', { async: true, inverse: null }) owner; } ``` To declare a one-to-none relationship between two models, use `belongsTo` with inverse set to `null` on just one side:: ```js // app/models/person.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Person extends Model { @belongsTo('person', { async: false, inverse: null }) bestFriend; } ``` #### Sync vs Async Relationships EmberData fulfills relationships using resource data available in the cache. Sync relationships point directly to the known related resources. When a relationship is declared as async, if any of the known related resources have not been loaded, they will be fetched. The property on the record when accessed provides a promise that resolves once all resources are loaded. Async relationships may take advantage of links. On access, if the related link has not been loaded, or if any known resources are not available in the cache, the fresh state will be fetched using the link. In contrast to async relationship, accessing a sync relationship will error on access when any of the known related resources have not been loaded. If you are using `links` with sync relationships, you have to use the BelongsTo reference API to fetch or refresh related resources that aren't loaded. For instance, for a `bestFriend` relationship: ```js person.belongsTo('bestFriend').reload(); ``` #### Polymorphic Relationships To declare a polymorphic relationship, use `hasMany` with the `polymorphic` option set to `true`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent; } ``` `'commentable'` here is referred to as the "abstract type" for the polymorphic relationship. Polymorphic relationships with `inverse: null` will accept any type of record as their content. Polymorphic relationships with `inverse` set to a string will only accept records with a matching inverse relationships declaring itself as satisfying the abstract type. Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable' for this relationship. ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments; } ``` Note: every Model that declares an inverse to a polymorphic relationship must declare itself exactly the same. This is because polymorphism is based on structural traits. Polymorphic to polymorphic relationships are supported. Both sides of the relationship must be declared as polymorphic, and the `as` option must be used to declare the abstract type each record satisfies on both sides. ### Type Parameters #### T `T` ### Parameters #### type [`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`Exclude`<`T`, `null`>> (optional) the name of the related resource #### options `RelationshipOptions`<`T`, `boolean`> (optional) a hash of options ### Returns `RelationshipDecorator`<`T`> relationship ## Call Signature ```ts function belongsTo(type, options): RelationshipDecorator; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/belongs-to.d.ts:172 `belongsTo` is used to define One-To-One and One-To-Many, and One-To-None relationships on a [Model](/ember-data/release/classes/Model). `belongsTo` takes a configuration hash as a second parameter, currently supported options are: * `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship. * `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`. * `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic * `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism. ### Examples To declare a **one-to-many** (or many-to-many) relationship, use `belongsTo` in combination with `hasMany`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('post', { async: false, inverse: 'comments' }) post; } // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'post' }) comments; } ``` To declare a **one-to-one** relationship with managed inverses, use `belongsTo` for both sides: ```js // app/models/author.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Author extends Model { @belongsTo('address', { async: true, inverse: 'owner' }) address; } // app/models/address.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Address extends Model { @belongsTo('author', { async: true, inverse: 'address' }) owner; } ``` To declare a **one-to-one** relationship without managed inverses, use `belongsTo` for both sides with `null` as the inverse: ```js // app/models/author.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Author extends Model { @belongsTo('address', { async: true, inverse: null }) address; } // app/models/address.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Address extends Model { @belongsTo('author', { async: true, inverse: null }) owner; } ``` To declare a one-to-none relationship between two models, use `belongsTo` with inverse set to `null` on just one side:: ```js // app/models/person.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Person extends Model { @belongsTo('person', { async: false, inverse: null }) bestFriend; } ``` #### Sync vs Async Relationships EmberData fulfills relationships using resource data available in the cache. Sync relationships point directly to the known related resources. When a relationship is declared as async, if any of the known related resources have not been loaded, they will be fetched. The property on the record when accessed provides a promise that resolves once all resources are loaded. Async relationships may take advantage of links. On access, if the related link has not been loaded, or if any known resources are not available in the cache, the fresh state will be fetched using the link. In contrast to async relationship, accessing a sync relationship will error on access when any of the known related resources have not been loaded. If you are using `links` with sync relationships, you have to use the BelongsTo reference API to fetch or refresh related resources that aren't loaded. For instance, for a `bestFriend` relationship: ```js person.belongsTo('bestFriend').reload(); ``` #### Polymorphic Relationships To declare a polymorphic relationship, use `hasMany` with the `polymorphic` option set to `true`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent; } ``` `'commentable'` here is referred to as the "abstract type" for the polymorphic relationship. Polymorphic relationships with `inverse: null` will accept any type of record as their content. Polymorphic relationships with `inverse` set to a string will only accept records with a matching inverse relationships declaring itself as satisfying the abstract type. Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable' for this relationship. ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments; } ``` Note: every Model that declares an inverse to a polymorphic relationship must declare itself exactly the same. This is because polymorphism is based on structural traits. Polymorphic to polymorphic relationships are supported. Both sides of the relationship must be declared as polymorphic, and the `as` option must be used to declare the abstract type each record satisfies on both sides. ### Parameters #### type `string` (optional) the name of the related resource #### options `RelationshipOptions`<`unknown`, `boolean`> (optional) a hash of options ### Returns `RelationshipDecorator`<`unknown`> relationship --- --- url: /api/@ember-data/model/index/functions/hasMany.md --- [Documentation](../../../../index.md) / [@ember-data/model](../../index.md) / [index](../index.md) / hasMany ## Call Signature ```ts function hasMany(): never; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/has-many.d.ts:160 `hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None relationships on a [Model](/ember-data/release/classes/Model). `hasMany` takes a configuration hash as a second parameter, currently supported options are: * `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship. * `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`. * `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic * `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism. ### Examples To declare a **many-to-one** (or one-to-many) relationship, use `belongsTo` in combination with `hasMany`: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'post' }) comments; } // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('post', { async: false, inverse: 'comments' }) post; } ``` To declare a **many-to-many** relationship with managed inverses, use `hasMany` for both sides: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('tag', { async: true, inverse: 'posts' }) tags; } // app/models/tag.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Tag extends Model { @hasMany('post', { async: true, inverse: 'tags' }) posts; } ``` To declare a **many-to-many** relationship without managed inverses, use `hasMany` for both sides with `null` as the inverse: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('tag', { async: true, inverse: null }) tags; } // app/models/tag.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Tag extends Model { @hasMany('post', { async: true, inverse: null }) posts; } ``` To declare a many-to-none relationship between two models, use `hasMany` with inverse set to `null` on just one side:: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('category', { async: true, inverse: null }) categories; } ``` #### Sync vs Async Relationships EmberData fulfills relationships using resource data available in the cache. Sync relationships point directly to the known related resources. When a relationship is declared as async, if any of the known related resources have not been loaded, they will be fetched. The property on the record when accessed provides a promise that resolves once all resources are loaded. Async relationships may take advantage of links. On access, if the related link has not been loaded, or if any known resources are not available in the cache, the fresh state will be fetched using the link. In contrast to async relationship, accessing a sync relationship will error on access when any of the known related resources have not been loaded. If you are using `links` with sync relationships, you have to use the HasMany reference API to fetch or refresh related resources that aren't loaded. For instance, for a `comments` relationship: ```js post.hasMany('comments').reload(); ``` #### Polymorphic Relationships To declare a polymorphic relationship, use `hasMany` with the `polymorphic` option set to `true`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent; } ``` `'commentable'` here is referred to as the "abstract type" for the polymorphic relationship. Polymorphic relationships with `inverse: null` will accept any type of record as their content. Polymorphic relationships with `inverse` set to a string will only accept records with a matching inverse relationships declaring itself as satisfying the abstract type. Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable' for this relationship. ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments; } ``` Note: every Model that declares an inverse to a polymorphic relationship must declare itself exactly the same. This is because polymorphism is based on structural traits. Polymorphic to polymorphic relationships are supported. Both sides of the relationship must be declared as polymorphic, and the `as` option must be used to declare the abstract type each record satisfies on both sides. ### Returns `never` relationship ## Call Signature ```ts function hasMany(type): never; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/has-many.d.ts:161 `hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None relationships on a [Model](/ember-data/release/classes/Model). `hasMany` takes a configuration hash as a second parameter, currently supported options are: * `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship. * `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`. * `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic * `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism. ### Examples To declare a **many-to-one** (or one-to-many) relationship, use `belongsTo` in combination with `hasMany`: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'post' }) comments; } // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('post', { async: false, inverse: 'comments' }) post; } ``` To declare a **many-to-many** relationship with managed inverses, use `hasMany` for both sides: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('tag', { async: true, inverse: 'posts' }) tags; } // app/models/tag.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Tag extends Model { @hasMany('post', { async: true, inverse: 'tags' }) posts; } ``` To declare a **many-to-many** relationship without managed inverses, use `hasMany` for both sides with `null` as the inverse: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('tag', { async: true, inverse: null }) tags; } // app/models/tag.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Tag extends Model { @hasMany('post', { async: true, inverse: null }) posts; } ``` To declare a many-to-none relationship between two models, use `hasMany` with inverse set to `null` on just one side:: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('category', { async: true, inverse: null }) categories; } ``` #### Sync vs Async Relationships EmberData fulfills relationships using resource data available in the cache. Sync relationships point directly to the known related resources. When a relationship is declared as async, if any of the known related resources have not been loaded, they will be fetched. The property on the record when accessed provides a promise that resolves once all resources are loaded. Async relationships may take advantage of links. On access, if the related link has not been loaded, or if any known resources are not available in the cache, the fresh state will be fetched using the link. In contrast to async relationship, accessing a sync relationship will error on access when any of the known related resources have not been loaded. If you are using `links` with sync relationships, you have to use the HasMany reference API to fetch or refresh related resources that aren't loaded. For instance, for a `comments` relationship: ```js post.hasMany('comments').reload(); ``` #### Polymorphic Relationships To declare a polymorphic relationship, use `hasMany` with the `polymorphic` option set to `true`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent; } ``` `'commentable'` here is referred to as the "abstract type" for the polymorphic relationship. Polymorphic relationships with `inverse: null` will accept any type of record as their content. Polymorphic relationships with `inverse` set to a string will only accept records with a matching inverse relationships declaring itself as satisfying the abstract type. Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable' for this relationship. ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments; } ``` Note: every Model that declares an inverse to a polymorphic relationship must declare itself exactly the same. This is because polymorphism is based on structural traits. Polymorphic to polymorphic relationships are supported. Both sides of the relationship must be declared as polymorphic, and the `as` option must be used to declare the abstract type each record satisfies on both sides. ### Parameters #### type `string` (optional) the name of the related resource ### Returns `never` relationship ## Call Signature ```ts function hasMany(type, options): RelationshipDecorator; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/has-many.d.ts:162 `hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None relationships on a [Model](/ember-data/release/classes/Model). `hasMany` takes a configuration hash as a second parameter, currently supported options are: * `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship. * `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`. * `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic * `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism. ### Examples To declare a **many-to-one** (or one-to-many) relationship, use `belongsTo` in combination with `hasMany`: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'post' }) comments; } // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('post', { async: false, inverse: 'comments' }) post; } ``` To declare a **many-to-many** relationship with managed inverses, use `hasMany` for both sides: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('tag', { async: true, inverse: 'posts' }) tags; } // app/models/tag.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Tag extends Model { @hasMany('post', { async: true, inverse: 'tags' }) posts; } ``` To declare a **many-to-many** relationship without managed inverses, use `hasMany` for both sides with `null` as the inverse: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('tag', { async: true, inverse: null }) tags; } // app/models/tag.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Tag extends Model { @hasMany('post', { async: true, inverse: null }) posts; } ``` To declare a many-to-none relationship between two models, use `hasMany` with inverse set to `null` on just one side:: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('category', { async: true, inverse: null }) categories; } ``` #### Sync vs Async Relationships EmberData fulfills relationships using resource data available in the cache. Sync relationships point directly to the known related resources. When a relationship is declared as async, if any of the known related resources have not been loaded, they will be fetched. The property on the record when accessed provides a promise that resolves once all resources are loaded. Async relationships may take advantage of links. On access, if the related link has not been loaded, or if any known resources are not available in the cache, the fresh state will be fetched using the link. In contrast to async relationship, accessing a sync relationship will error on access when any of the known related resources have not been loaded. If you are using `links` with sync relationships, you have to use the HasMany reference API to fetch or refresh related resources that aren't loaded. For instance, for a `comments` relationship: ```js post.hasMany('comments').reload(); ``` #### Polymorphic Relationships To declare a polymorphic relationship, use `hasMany` with the `polymorphic` option set to `true`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent; } ``` `'commentable'` here is referred to as the "abstract type" for the polymorphic relationship. Polymorphic relationships with `inverse: null` will accept any type of record as their content. Polymorphic relationships with `inverse` set to a string will only accept records with a matching inverse relationships declaring itself as satisfying the abstract type. Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable' for this relationship. ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments; } ``` Note: every Model that declares an inverse to a polymorphic relationship must declare itself exactly the same. This is because polymorphism is based on structural traits. Polymorphic to polymorphic relationships are supported. Both sides of the relationship must be declared as polymorphic, and the `as` option must be used to declare the abstract type each record satisfies on both sides. ### Type Parameters #### T `T` ### Parameters #### type [`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`NoNull`<`T`>> (optional) the name of the related resource #### options `RelationshipOptions`<`T`, `boolean`> (optional) a hash of options ### Returns `RelationshipDecorator`<`T`> relationship ## Call Signature ```ts function hasMany(type, options): RelationshipDecorator; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/has-many.d.ts:163 `hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None relationships on a [Model](/ember-data/release/classes/Model). `hasMany` takes a configuration hash as a second parameter, currently supported options are: * `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship. * `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`. * `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic * `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism. ### Examples To declare a **many-to-one** (or one-to-many) relationship, use `belongsTo` in combination with `hasMany`: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'post' }) comments; } // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('post', { async: false, inverse: 'comments' }) post; } ``` To declare a **many-to-many** relationship with managed inverses, use `hasMany` for both sides: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('tag', { async: true, inverse: 'posts' }) tags; } // app/models/tag.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Tag extends Model { @hasMany('post', { async: true, inverse: 'tags' }) posts; } ``` To declare a **many-to-many** relationship without managed inverses, use `hasMany` for both sides with `null` as the inverse: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('tag', { async: true, inverse: null }) tags; } // app/models/tag.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Tag extends Model { @hasMany('post', { async: true, inverse: null }) posts; } ``` To declare a many-to-none relationship between two models, use `hasMany` with inverse set to `null` on just one side:: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('category', { async: true, inverse: null }) categories; } ``` #### Sync vs Async Relationships EmberData fulfills relationships using resource data available in the cache. Sync relationships point directly to the known related resources. When a relationship is declared as async, if any of the known related resources have not been loaded, they will be fetched. The property on the record when accessed provides a promise that resolves once all resources are loaded. Async relationships may take advantage of links. On access, if the related link has not been loaded, or if any known resources are not available in the cache, the fresh state will be fetched using the link. In contrast to async relationship, accessing a sync relationship will error on access when any of the known related resources have not been loaded. If you are using `links` with sync relationships, you have to use the HasMany reference API to fetch or refresh related resources that aren't loaded. For instance, for a `comments` relationship: ```js post.hasMany('comments').reload(); ``` #### Polymorphic Relationships To declare a polymorphic relationship, use `hasMany` with the `polymorphic` option set to `true`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent; } ``` `'commentable'` here is referred to as the "abstract type" for the polymorphic relationship. Polymorphic relationships with `inverse: null` will accept any type of record as their content. Polymorphic relationships with `inverse` set to a string will only accept records with a matching inverse relationships declaring itself as satisfying the abstract type. Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable' for this relationship. ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments; } ``` Note: every Model that declares an inverse to a polymorphic relationship must declare itself exactly the same. This is because polymorphism is based on structural traits. Polymorphic to polymorphic relationships are supported. Both sides of the relationship must be declared as polymorphic, and the `as` option must be used to declare the abstract type each record satisfies on both sides. ### Parameters #### type `string` (optional) the name of the related resource #### options `RelationshipOptions`<`unknown`, `boolean`> (optional) a hash of options ### Returns `RelationshipDecorator`<`unknown`> relationship --- --- url: /api/@ember-data/model/index/functions/instantiateRecord.md --- [Documentation](../../../../index.md) / [@ember-data/model](../../index.md) / [index](../index.md) / instantiateRecord ```ts function instantiateRecord( this, identifier, createRecordArgs): default; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/hooks.d.ts:5 ## Parameters ### this [`default`](../../../store/index/classes/default.md) ### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ### createRecordArgs ## Returns [`default`](../classes/default.md) --- --- url: /api/@ember-data/model/index/functions/modelFor.md --- [Documentation](../../../../index.md) / [@ember-data/model](../../index.md) / [index](../index.md) / modelFor ## Call Signature ```ts function modelFor(type): void | typeof default; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/hooks.d.ts:9 ### Type Parameters #### T `T` ### Parameters #### type [`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> ### Returns `void` | *typeof* [`default`](../classes/default.md) ## Call Signature ```ts function modelFor(type): void | typeof default; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/hooks.d.ts:10 ### Parameters #### type `string` ### Returns `void` | *typeof* [`default`](../classes/default.md) --- --- url: /api/@ember-data/model/index/functions/teardownRecord.md --- [Documentation](../../../../index.md) / [@ember-data/model](../../index.md) / [index](../index.md) / teardownRecord ```ts function teardownRecord(record): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/-private/hooks.d.ts:8 ## Parameters ### record [`default`](../classes/default.md) ## Returns `void` --- --- url: /api/@ember-data/model/migration-support/classes/DelegatingSchemaService.md --- [Documentation](../../../../index.md) / [@ember-data/model](../../index.md) / [migration-support](../index.md) / DelegatingSchemaService Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:217 The SchemaService provides the ability to query for information about the structure of any resource type. Applications can provide any implementation of the SchemaService they please so long as it conforms to this interface. The design of the service means that schema information could be lazily populated, derived-on-demand, or progressively enhanced during the course of an application's runtime. The primary requirement is merely that any information the service needs to correctly respond to an inquest is available by the time it is asked. The `@ember-data/model` package provides an implementation of this service which makes use of your model classes as the source of information to respond to queries about resource schema. While this is useful, this may not be ideal for your application. For instance, Schema information could be sideloaded or pre-flighted for API calls, resulting in no need to bundle and ship potentially large and expensive JSON or large Javascript based Models to pull information from. To register a custom schema implementation, implement the store's `createSchemaService` hook to return an instance of your service. ```ts import Store from '@ember-data/store'; import CustomSchemas from './custom-schemas'; export default class extends Store { createSchemaService() { return new CustomSchemas(); } } ``` At runtime, both the `Store` and the `CacheCapabilitiesManager` provide access to this service via the `schema` property. ```ts export default class extends Component { @service store; get fields() { return this.store .schema .fields(this.args.dataType); } } ``` (Interface) SchemaService ## Implements * [`SchemaService`](../../../../@warp-drive/core-types/index/interfaces/SchemaService.md) ## Constructors ### Constructor ```ts new DelegatingSchemaService(store, schema): DelegatingSchemaService; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:229 #### Parameters ##### store [`default`](../../../store/index/classes/default.md) ##### schema [`SchemaService`](../../../../@warp-drive/core-types/index/interfaces/SchemaService.md) #### Returns `DelegatingSchemaService` ## Properties ### \_preferred ```ts _preferred: SchemaService; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:227 *** ### \_secondary ```ts _secondary: SchemaService; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:228 ## Methods ### ~~attributesDefinitionFor()?~~ ```ts optional attributesDefinitionFor(resource): AttributesSchema; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:218 DEPRECATED - use `fields` instead Returns definitions for all properties of the specified resource that are considered "attributes". Generally these are properties that are not related to book-keeping state on the client and do not represent a linkage to another resource. The return value should be a dictionary of key:value pairs where the `key` is the attribute or property's name and `value` is an object with at least the property `name` which should also match `key`. Optionally, this object may also specify `type`, which should be a string reference to a `transform`, and `options` which should be dictionary in which any key:value pairs are permissable. For instance, when using `@ember-data/model`, the following attribute definition: ```ts class extends Model { @attr('string', { defaultValue: 'hello' }) greeting; @attr('date') birthday; @attr firstName; } ``` Would be returned as: ```js { greeting: { name: 'greeting', type: 'string', options: { defaultValue: 'hello' } }, birthday: { name: 'birthday', type: 'date' }, firstName: { name: 'firstName' } } ``` #### Parameters ##### resource [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) | { `type`: `string`; } #### Returns `AttributesSchema` #### Deprecated *** ### derivation() ```ts derivation(field): Derivation; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:250 Returns the derivation registered with the name provided by `field.type`. Validates that the field is a valid DerivedField. #### Parameters ##### field [`DerivedField`](../../../../@warp-drive/core-types/schema/fields/interfaces/DerivedField.md) | { `type`: `string`; } #### Returns [`Derivation`](../../../../@warp-drive/core-types/schema/concepts/type-aliases/Derivation.md) *** ### ~~doesTypeExist()?~~ ```ts optional doesTypeExist(type): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:224 DEPRECATED - use `hasResource` instead Queries whether the SchemaService recognizes `type` as a resource type #### Parameters ##### type `string` #### Returns `boolean` #### Deprecated *** ### fields() ```ts fields(resource): Map; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:241 Queries for the fields of a given resource type or resource identity. Should error if the resource type is not recognized. #### Parameters ##### resource [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) | { `type`: `string`; } #### Returns `Map`<`string`, [`FieldSchema`](../../../../@warp-drive/core-types/schema/fields/type-aliases/FieldSchema.md)> *** ### hashFn() ```ts hashFn(field): HashFn; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:247 Returns the hash function registered with the name provided by `field.type`. Validates that the field is a valid HashField. #### Parameters ##### field [`HashField`](../../../../@warp-drive/core-types/schema/fields/interfaces/HashField.md) | { `type`: `string`; } #### Returns [`HashFn`](../../../../@warp-drive/core-types/schema/concepts/type-aliases/HashFn.md) *** ### hasResource() ```ts hasResource(resource): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:234 Queries whether the SchemaService recognizes `type` as a resource type #### Parameters ##### resource [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) | { `type`: `string`; } #### Returns `boolean` *** ### hasTrait() ```ts hasTrait(type): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:237 Queries whether the SchemaService recognizes `type` as a resource trait #### Parameters ##### type `string` #### Returns `boolean` *** ### isDelegated() ```ts isDelegated(resource): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:230 #### Parameters ##### resource [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) | { `type`: `string`; } #### Returns `boolean` *** ### registerDerivation() ```ts registerDerivation(derivation): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:259 Enables registration of a derivation. The derivation can later be retrieved by the name attached to it's `[Type]` property. #### Type Parameters ##### R `R` ##### T `T` ##### FM `FM` *extends* | `null` | [`ObjectValue`](../../../../@warp-drive/core-types/json/raw/interfaces/ObjectValue.md) #### Parameters ##### derivation [`Derivation`](../../../../@warp-drive/core-types/schema/concepts/type-aliases/Derivation.md)<`R`, `T`, `FM`> #### Returns `void` *** ### registerHashFn() ```ts registerHashFn(hashFn): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:260 Enables registration of a hashing function The hashing function can later be retrieved by the name attached to it's `[Type]` property. #### Parameters ##### hashFn [`HashFn`](../../../../@warp-drive/core-types/schema/concepts/type-aliases/HashFn.md) #### Returns `void` *** ### registerResource() ```ts registerResource(schema): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:257 Enables registration of a single Schema representing either a resource in PolarisMode or LegacyMode or an ObjectSchema representing an embedded structure in other schemas. This can be useful for either pre-loading schema information or for registering schema information delivered by API calls or other sources just-in-time. #### Parameters ##### schema [`ResourceSchema`](../../../../@warp-drive/core-types/schema/fields/type-aliases/ResourceSchema.md) | [`ObjectSchema`](../../../../@warp-drive/core-types/schema/fields/interfaces/ObjectSchema.md) #### Returns `void` *** ### registerResources() ```ts registerResources(schemas): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:256 Enables registration of multiple Schemas at once. This can be useful for either pre-loading schema information or for registering schema information delivered by API calls or other sources just-in-time. #### Parameters ##### schemas ( | [`ResourceSchema`](../../../../@warp-drive/core-types/schema/fields/type-aliases/ResourceSchema.md) | [`ObjectSchema`](../../../../@warp-drive/core-types/schema/fields/interfaces/ObjectSchema.md))\[] #### Returns `void` *** ### registerTransformation() ```ts registerTransformation(transform): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:258 Enables registration of a transformation. The transformation can later be retrieved by the name attached to it's `[Type]` property. #### Parameters ##### transform [`Transformation`](../../../../@warp-drive/core-types/schema/concepts/type-aliases/Transformation.md) #### Returns `void` *** ### ~~relationshipsDefinitionFor()?~~ ```ts optional relationshipsDefinitionFor(resource): RelationshipsSchema; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:221 DEPRECATED - use `fields` instead Returns definitions for all properties of the specified resource that are considered "relationships". Generally these are properties that represent a linkage to another resource. The return value should be a dictionary of key:value pairs where the `key` is the relationship or property's name and `value` is an object with at least the following properties: * `name` which should also match the `key` used in the dictionary. * `kind` which should be either `belongsTo` or `hasMany` * `type` which should be the related resource's string "type" * `options` which should be a dictionary allowing any key but with at least the below keys present. * `options.async` a boolean representing whether data for this relationship is typically loaded on-demand. * `options.inverse` a string or null representing the field name / key of the corresponding relationship on the inverse resource. Additionally the following options properties are optional. See [Polymorphic Relationships](https://rfcs.emberjs.com/id/0793-polymporphic-relations-without-inheritance) * `options.polymorphic` a boolean representing whether multiple resource types can be used to satisfy this relationship. * `options.as` a string representing the abstract type that the concrete side of a relationship must specify when fulfilling a polymorphic inverse. For example, the following Model using @ember-data/model would generate this relationships definition by default: ```js class User extends Model { @belongsTo('user', { async: false, inverse: null }) bestFriend; @hasMany('user', { async: true, inverse: 'friends' }) friends; @hasMany('pet', { async: false, polymorphic: true, inverse: 'owner' }) pets; } ``` Which would be returned as ```js { bestFriend: { name: 'bestFriend', kind: 'belongsTo', type: 'user', options: { async: false, inverse: null } }, friends: { name: 'friends', kind: 'hasMany', type: 'user', options: { async: true, inverse: 'friends' } }, pets: { name: 'pets', kind: 'hasMany', type: 'pet', options: { async: false, polymorphic: true, inverse: 'owner' } }, } ``` #### Parameters ##### resource [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) | { `type`: `string`; } #### Returns `RelationshipsSchema` #### Deprecated *** ### resource() ```ts resource(resource): | ResourceSchema | ObjectSchema; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:253 Returns the schema for the provided resource type. #### Parameters ##### resource [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) | { `type`: `string`; } #### Returns | [`ResourceSchema`](../../../../@warp-drive/core-types/schema/fields/type-aliases/ResourceSchema.md) | [`ObjectSchema`](../../../../@warp-drive/core-types/schema/fields/interfaces/ObjectSchema.md) *** ### resourceHasTrait() ```ts resourceHasTrait(resource, trait): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:238 Queries whether the given resource has the given trait #### Parameters ##### resource [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) | { `type`: `string`; } ##### trait `string` #### Returns `boolean` *** ### resourceTypes() ```ts resourceTypes(): readonly string[]; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:233 Returns all known resource types #### Returns readonly `string`\[] *** ### transformation() ```ts transformation(field): Transformation; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:244 Returns the transformation registered with the name provided by `field.type`. Validates that the field is a valid transformable. #### Parameters ##### field [`GenericField`](../../../../@warp-drive/core-types/schema/fields/interfaces/GenericField.md) | [`ObjectField`](../../../../@warp-drive/core-types/schema/fields/interfaces/ObjectField.md) | [`ArrayField`](../../../../@warp-drive/core-types/schema/fields/interfaces/ArrayField.md) | { `type`: `string`; } #### Returns [`Transformation`](../../../../@warp-drive/core-types/schema/concepts/type-aliases/Transformation.md) --- --- url: /api/@ember-data/model/index.md --- [Documentation](../../../index.md) / [@ember-data/model](../index.md) / index This package provides a Presentation Model for resource data in an EmberData Cache. Models are defined as classes extending from `import Model from '@ember-data/model';` and the attributes and relationships on these classes are parsed at runtime to supply static "schema" to EmberData's SchemaService. Resource data for individual resources fetched from your API is presented to the UI via instances of the `Model`s you define. An instantiated `Model` is referred to as a `record`. When we refer to the `ModelClass` as opposed to a `Model` or `Record` we are referring specifically to the class definition and the static schema methods present on it. When we refer to a `record` we refer to a specific class instance presenting the resource data for a given `type` and `id`. ### Defining a Model ```js [app/models/person.js] import Model, { attr, belongsTo, hasMany } from '@ember-data/model'; export default class PersonModel extends Model { @attr name; @belongsTo('pet', { inverse: 'owners', async: false }) dog; @hasMany('person', { inverse: 'friends', async: true }) friends; } ``` ### modelName convention By convention, the name of a given model (its `type`) matches the name of the file in the `app/models` folder and should be lowercase, singular and dasherized. ## Classes * [AsyncHasMany](classes/AsyncHasMany.md) * [default](classes/default.md) * [ManyArray](classes/ManyArray.md) ## Functions * [attr](functions/attr.md) * [belongsTo](functions/belongsTo.md) * [buildSchema](functions/buildSchema.md) * [hasMany](functions/hasMany.md) * [instantiateRecord](functions/instantiateRecord.md) * [modelFor](functions/modelFor.md) * [teardownRecord](functions/teardownRecord.md) ## References ### HasMany Renames and re-exports [ManyArray](classes/ManyArray.md) --- --- url: /api/@ember-data/model/migration-support/functions/registerDerivations.md --- [Documentation](../../../../index.md) / [@ember-data/model](../../index.md) / [migration-support](../index.md) / registerDerivations ```ts function registerDerivations(schema): void; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:185 A function which registers the necessary derivations to support the LegacyMode features of @ember-data/model while migrating to WarpDrive. This must be called in order to use the fields added by: ```ts import { withDefaults } from '@ember-data/model/migration-support'; ``` ## Parameters ### schema [`SchemaService`](../../../../@warp-drive/core-types/index/interfaces/SchemaService.md) The schema service to register the derivations with. ## Returns `void` --- --- url: /api/@ember-data/model/migration-support/functions/withDefaults.md --- [Documentation](../../../../index.md) / [@ember-data/model](../../index.md) / [migration-support](../index.md) / withDefaults ```ts function withDefaults(schema): LegacyResourceSchema; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:170 A function which adds the necessary fields to a schema and marks it as being in LegacyMode. This is used to support the legacy features of @ember-data/model while migrating to WarpDrive. Example: ```ts import { withDefaults, WithLegacy } from '@ember-data/model/migration-support'; import { Type } from '@warp-drive/core-types/symbols'; import type { HasMany } from '@ember-data/model'; export const UserSchema = withDefaults({ type: 'user', fields: [ { name: 'firstName', kind: 'attribute' }, { name: 'lastName', kind: 'attribute' }, { name: 'age', kind: 'attribute' }, { name: 'friends', kind: 'hasMany', type: 'user', options: { inverse: 'friends', async: false } }, { name: 'bestFriend', kind: 'belongsTo', type: 'user', options: { inverse: null, async: false } }, ], }); export type User = WithLegacy<{ firstName: string; lastName: string; age: number; friends: HasMany; bestFriend: User | null; [Type]: 'user'; }> ``` Using this function require registering the derivations it requires with the schema service. ```ts import { registerDerivations } from '@ember-data/model/migration-support'; registerDerivations(schema); ``` ## Parameters ### schema [`WithPartial`](../../../../@warp-drive/core-types/utils/type-aliases/WithPartial.md)<[`LegacyResourceSchema`](../../../../@warp-drive/core-types/schema/fields/interfaces/LegacyResourceSchema.md), `"legacy"` | `"identity"`> The schema to add legacy support to. ## Returns [`LegacyResourceSchema`](../../../../@warp-drive/core-types/schema/fields/interfaces/LegacyResourceSchema.md) The schema with legacy support added. --- --- url: /api/@ember-data/model/migration-support.md --- [Documentation](../../../index.md) / [@ember-data/model](../index.md) / migration-support This module provides support for migrating away from @ember-data/model to @warp-drive/schema-record. It includes: * A `withDefaults` function to assist in creating a schema in LegacyMode * A `registerDerivations` function to register the derivations necessary to support LegacyMode * A `DelegatingSchemaService` that can be used to provide a schema service that works with both @ember-data/model and @warp-drive/schema-record simultaneously for migration purposes. * A `WithLegacy` type util that can be used to create a type that includes the legacy properties and methods of a record. Using LegacyMode features on a SchemaRecord *requires* the use of these derivations and schema additions. LegacyMode is not intended to be a long-term solution, but rather a stepping stone to assist in more rapidly adopting modern WarpDrive features. ## Classes * [DelegatingSchemaService](classes/DelegatingSchemaService.md) ## Type Aliases * [WithLegacy](type-aliases/WithLegacy.md) * [WithLegacyDerivations](type-aliases/WithLegacyDerivations.md) ## Functions * [registerDerivations](functions/registerDerivations.md) * [withDefaults](functions/withDefaults.md) --- --- url: /api/@ember-data/model/migration-support/type-aliases/WithLegacy.md --- [Documentation](../../../../index.md) / [@ember-data/model](../../index.md) / [migration-support](../index.md) / WithLegacy ```ts type WithLegacy = T & LegacyModeRecord; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:115 A Type utility that enables quickly adding type information for the fields defined by `import { withDefaults } from '@ember-data/model/migration-support'`. Example: ```ts import { withDefaults, WithLegacy } from '@ember-data/model/migration-support'; import { Type } from '@warp-drive/core-types/symbols'; import type { HasMany } from '@ember-data/model'; export const UserSchema = withDefaults({ type: 'user', fields: [ { name: 'firstName', kind: 'attribute' }, { name: 'lastName', kind: 'attribute' }, { name: 'age', kind: 'attribute' }, { name: 'friends', kind: 'hasMany', type: 'user', options: { inverse: 'friends', async: false } }, { name: 'bestFriend', kind: 'belongsTo', type: 'user', options: { inverse: null, async: false } }, ], }); export type User = WithLegacy<{ firstName: string; lastName: string; age: number; friends: HasMany; bestFriend: User | null; [Type]: 'user'; }> ``` ## Type Parameters ### T `T` *extends* [`TypedRecordInstance`](../../../../@warp-drive/core-types/record/interfaces/TypedRecordInstance.md) --- --- url: /api/@ember-data/model/migration-support/type-aliases/WithLegacyDerivations.md --- [Documentation](../../../../index.md) / [@ember-data/model](../../index.md) / [migration-support](../index.md) / WithLegacyDerivations ```ts type WithLegacyDerivations = T & MinimalLegacyRecord & object; ``` Defined in: warp-drive-packages/legacy/declarations/model/migration-support.d.ts:36 ## Type declaration ### belongsTo ```ts belongsTo: typeof belongsTo; ``` ### hasMany ```ts hasMany: typeof hasMany; ``` ## Type Parameters ### T `T` *extends* [`TypedRecordInstance`](../../../../@warp-drive/core-types/record/interfaces/TypedRecordInstance.md) --- --- url: /api/@ember-data/request-utils/deprecation-support.md --- [Documentation](../../../index.md) / [@ember-data/request-utils](../index.md) / deprecation-support --- --- url: /api/@ember-data/request-utils/handlers/classes/AutoCompress.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [handlers](../index.md) / AutoCompress Defined in: warp-drive-packages/utilities/declarations/-private/handlers/auto-compress.d.ts:145 A request handler that automatically compresses the request body if the request body is a string, array buffer, blob, or form data. This uses the [CompressionStream API](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream) The compression format as well as the kinds of data to compress can be configured using the `format` and `constraints` options. ```diff +import { AutoCompress } from '@ember-data/request-utils/handlers'; import Fetch from '@ember-data/request/fetch'; import RequestManager from '@ember-data/request'; import Store from '@ember-data/store'; class AppStore extends Store { requestManager = new RequestManager() .use([ + new AutoCompress(), Fetch ]); } ``` AutoCompress ## Since 5.5.0 ## Implements * [`Handler`](../../../request/index/interfaces/Handler.md) ## Constructors ### Constructor ```ts new AutoCompress(options?): AutoCompress; ``` Defined in: warp-drive-packages/utilities/declarations/-private/handlers/auto-compress.d.ts:149 #### Parameters ##### options? `CompressionOptions` #### Returns `AutoCompress` ## Properties ### options ```ts options: Required & object; ``` Defined in: warp-drive-packages/utilities/declarations/-private/handlers/auto-compress.d.ts:146 #### Type declaration ##### constraints ```ts constraints: Required; ``` ## Methods ### request() ```ts request(context, next): | Promise | Future; ``` Defined in: warp-drive-packages/utilities/declarations/-private/handlers/auto-compress.d.ts:150 Method to implement to handle requests. Receives the request context and a nextFn to call to pass-along the request to other handlers. #### Type Parameters ##### T `T` #### Parameters ##### context [`RequestContext`](../../../../@warp-drive/core-types/request/interfaces/RequestContext.md) ##### next [`NextFn`](../../../request/index/type-aliases/NextFn.md)<`T`> #### Returns | `Promise`<`T`> | [`Future`](../../../request/index/interfaces/Future.md)<`T`> #### Implementation of [`Handler`](../../../request/index/interfaces/Handler.md).[`request`](../../../request/index/interfaces/Handler.md#request) --- --- url: /api/@ember-data/request-utils/handlers.md --- [Documentation](../../../index.md) / [@ember-data/request-utils](../index.md) / handlers A selection of pre-built request handlers for handling common request scenarios. ## Classes * [AutoCompress](classes/AutoCompress.md) ## Variables * [SupportsRequestStreams](variables/SupportsRequestStreams.md) --- --- url: /api/@ember-data/request-utils.md --- [Documentation](../../index.md) / @ember-data/request-utils ## Modules * [deprecation-support](deprecation-support/index.md) * [handlers](handlers/index.md) * [index](index/index.md) * [string](string/index.md) --- --- url: /api/@ember-data/request-utils/handlers/variables/SupportsRequestStreams.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [handlers](../index.md) / SupportsRequestStreams ```ts const SupportsRequestStreams: boolean; ``` Defined in: warp-drive-packages/utilities/declarations/-private/handlers/auto-compress.d.ts:3 --- --- url: /api/@ember-data/request-utils/index/classes/CachePolicy.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / CachePolicy Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:283 A basic CachePolicy that can be added to the Store service. Determines staleness based on time since the request was last received from the API using the `date` header. Determines expiration based on configured constraints as well as a time based expiration strategy based on the `date` header. In order expiration is determined by: * Is explicitly invalidated * ↳ (if null) isExpired function \ * ↳ (if null) X-WarpDrive-Expires header \ * ↳ (if null) Cache-Control header \ * ↳ (if null) Expires header \ * ↳ (if null) Date header + apiCacheHardExpires < current time Invalidates any request for which `cacheOptions.types` was provided when a createRecord request for that type is successful. For this to work, the `createRecord` request must include the `cacheOptions.types` array with the types that should be invalidated, or its request should specify the identifiers of the records that are being created via `records`. Providing both is valid. > \[!NOTE] > only requests that had specified `cacheOptions.types` and occurred prior to the > createRecord request will be invalidated. This means that a given request should always > specify the types that would invalidate it to opt into this behavior. Abstracting this > behavior via builders is recommended to ensure consistency. This allows the Store's CacheHandler to determine if a request is expired and should be refetched upon next request. The `Fetch` handler provided by `@warp-drive/core` will automatically add the `date` header to responses if it is not present. > \[!NOTE] > Date headers do not have millisecond precision, so expiration times should > generally be larger than 1000ms. Usage: ```ts import { Store } from '@warp-drive/core'; import { DefaultCachePolicy } from '@warp-drive/core/store'; export class AppStore extends Store { lifetimes = new DefaultCachePolicy({ apiCacheSoftExpires: 30_000, apiCacheHardExpires: 60_000 }); } ``` In Testing environments, the `apiCacheSoftExpires` will always be `false` and `apiCacheHardExpires` will use the `apiCacheSoftExpires` value. This helps reduce flakiness and produce predictably rendered results in test suites. Requests that specifically set `cacheOptions.backgroundReload = true` will still be background reloaded in tests. This behavior can be opted out of by setting `disableTestOptimization = true` in the policy config. ## Extended by * [`LifetimesService`](LifetimesService.md) ## Constructors ### Constructor ```ts new CachePolicy(config): DefaultCachePolicy; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:293 #### Parameters ##### config [`PolicyConfig`](../type-aliases/PolicyConfig.md) #### Returns `DefaultCachePolicy` ## Properties ### \_stores ```ts _stores: WeakMap; types: Map>; }>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:285 *** ### config ```ts config: PolicyConfig; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:284 ## Methods ### \_getStore() ```ts _getStore(store): object; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:289 #### Parameters ##### store `Store` #### Returns `object` ##### invalidated ```ts invalidated: Set; ``` ##### types ```ts types: Map>; ``` *** ### didRequest() ```ts didRequest( request, response, identifier, store): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:347 Invoked when a request has been fulfilled from the configured request handlers. This is invoked by the CacheHandler for both foreground and background requests once the cache has been updated. Note, this is invoked by the CacheHandler regardless of whether the request has a cache-key. This method should not be invoked directly by consumers. #### Parameters ##### request [`ImmutableRequestInfo`](../../../../@warp-drive/core-types/request/type-aliases/ImmutableRequestInfo.md) ##### response `null` | `Response` | [`ResponseInfo`](../../../../@warp-drive/core-types/request/interfaces/ResponseInfo.md) ##### identifier `null` | [`StableDocumentIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store `Store` #### Returns `void` *** ### invalidateRequest() ```ts invalidateRequest(identifier, store): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:309 Invalidate a request by its identifier for a given store instance. While the store argument may seem redundant, the CachePolicy is designed to be shared across multiple stores / forks of the store. ```ts store.lifetimes.invalidateRequest(store, identifier); ``` #### Parameters ##### identifier [`StableDocumentIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store `Store` #### Returns `void` *** ### invalidateRequestsForType() ```ts invalidateRequestsForType(type, store): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:329 Invalidate all requests associated to a specific type for a given store instance. While the store argument may seem redundant, the CachePolicy is designed to be shared across multiple stores / forks of the store. This invalidation is done automatically when using this service for both the CacheHandler and the LegacyNetworkHandler. ```ts store.lifetimes.invalidateRequestsForType(store, 'person'); ``` #### Parameters ##### type `string` ##### store `Store` #### Returns `void` *** ### isHardExpired() ```ts isHardExpired(identifier, store): boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:364 Invoked to determine if the request may be fulfilled from cache if possible. Note, this is only invoked by the CacheHandler if the request has a cache-key. If no cache entry is found or the entry is hard expired, the request will be fulfilled from the configured request handlers and the cache will be updated before returning the response. #### Parameters ##### identifier [`StableDocumentIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store `Store` #### Returns `boolean` true if the request is considered hard expired *** ### isSoftExpired() ```ts isSoftExpired(identifier, store): boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:380 Invoked if `isHardExpired` is false to determine if the request should be update behind the scenes if cache data is already available. Note, this is only invoked by the CacheHandler if the request has a cache-key. If true, the request will be fulfilled from cache while a backgrounded request is made to update the cache via the configured request handlers. #### Parameters ##### identifier [`StableDocumentIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store `Store` #### Returns `boolean` true if the request is considered soft expired --- --- url: /api/@ember-data/request-utils/index/classes/LifetimesService.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / LifetimesService Defined in: [packages/request-utils/src/index.ts:54](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/packages/request-utils/src/index.ts#L54) A basic CachePolicy that can be added to the Store service. Determines staleness based on time since the request was last received from the API using the `date` header. Determines expiration based on configured constraints as well as a time based expiration strategy based on the `date` header. In order expiration is determined by: * Is explicitly invalidated * ↳ (if null) isExpired function \ * ↳ (if null) X-WarpDrive-Expires header \ * ↳ (if null) Cache-Control header \ * ↳ (if null) Expires header \ * ↳ (if null) Date header + apiCacheHardExpires < current time Invalidates any request for which `cacheOptions.types` was provided when a createRecord request for that type is successful. For this to work, the `createRecord` request must include the `cacheOptions.types` array with the types that should be invalidated, or its request should specify the identifiers of the records that are being created via `records`. Providing both is valid. > \[!NOTE] > only requests that had specified `cacheOptions.types` and occurred prior to the > createRecord request will be invalidated. This means that a given request should always > specify the types that would invalidate it to opt into this behavior. Abstracting this > behavior via builders is recommended to ensure consistency. This allows the Store's CacheHandler to determine if a request is expired and should be refetched upon next request. The `Fetch` handler provided by `@warp-drive/core` will automatically add the `date` header to responses if it is not present. > \[!NOTE] > Date headers do not have millisecond precision, so expiration times should > generally be larger than 1000ms. Usage: ```ts import { Store } from '@warp-drive/core'; import { DefaultCachePolicy } from '@warp-drive/core/store'; export class AppStore extends Store { lifetimes = new DefaultCachePolicy({ apiCacheSoftExpires: 30_000, apiCacheHardExpires: 60_000 }); } ``` In Testing environments, the `apiCacheSoftExpires` will always be `false` and `apiCacheHardExpires` will use the `apiCacheSoftExpires` value. This helps reduce flakiness and produce predictably rendered results in test suites. Requests that specifically set `cacheOptions.backgroundReload = true` will still be background reloaded in tests. This behavior can be opted out of by setting `disableTestOptimization = true` in the policy config. ## Extends * [`CachePolicy`](CachePolicy.md) ## Constructors ### Constructor ```ts new LifetimesService(config): LifetimesService; ``` Defined in: [packages/request-utils/src/index.ts:55](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/packages/request-utils/src/index.ts#L55) #### Parameters ##### config [`PolicyConfig`](../type-aliases/PolicyConfig.md) #### Returns `LifetimesService` #### Overrides [`CachePolicy`](CachePolicy.md).[`constructor`](CachePolicy.md#constructor) ## Properties ### \_stores ```ts _stores: WeakMap; types: Map>; }>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:285 #### Inherited from [`CachePolicy`](CachePolicy.md).[`_stores`](CachePolicy.md#stores) *** ### config ```ts config: PolicyConfig; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:284 #### Inherited from [`CachePolicy`](CachePolicy.md).[`config`](CachePolicy.md#config) ## Methods ### \_getStore() ```ts _getStore(store): object; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:289 #### Parameters ##### store `Store` #### Returns `object` ##### invalidated ```ts invalidated: Set; ``` ##### types ```ts types: Map>; ``` #### Inherited from [`CachePolicy`](CachePolicy.md).[`_getStore`](CachePolicy.md#getstore) *** ### didRequest() ```ts didRequest( request, response, identifier, store): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:347 Invoked when a request has been fulfilled from the configured request handlers. This is invoked by the CacheHandler for both foreground and background requests once the cache has been updated. Note, this is invoked by the CacheHandler regardless of whether the request has a cache-key. This method should not be invoked directly by consumers. #### Parameters ##### request [`ImmutableRequestInfo`](../../../../@warp-drive/core-types/request/type-aliases/ImmutableRequestInfo.md) ##### response `null` | `Response` | [`ResponseInfo`](../../../../@warp-drive/core-types/request/interfaces/ResponseInfo.md) ##### identifier `null` | [`StableDocumentIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store `Store` #### Returns `void` #### Inherited from [`CachePolicy`](CachePolicy.md).[`didRequest`](CachePolicy.md#didrequest) *** ### invalidateRequest() ```ts invalidateRequest(identifier, store): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:309 Invalidate a request by its identifier for a given store instance. While the store argument may seem redundant, the CachePolicy is designed to be shared across multiple stores / forks of the store. ```ts store.lifetimes.invalidateRequest(store, identifier); ``` #### Parameters ##### identifier [`StableDocumentIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store `Store` #### Returns `void` #### Inherited from [`CachePolicy`](CachePolicy.md).[`invalidateRequest`](CachePolicy.md#invalidaterequest) *** ### invalidateRequestsForType() ```ts invalidateRequestsForType(type, store): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:329 Invalidate all requests associated to a specific type for a given store instance. While the store argument may seem redundant, the CachePolicy is designed to be shared across multiple stores / forks of the store. This invalidation is done automatically when using this service for both the CacheHandler and the LegacyNetworkHandler. ```ts store.lifetimes.invalidateRequestsForType(store, 'person'); ``` #### Parameters ##### type `string` ##### store `Store` #### Returns `void` #### Inherited from [`CachePolicy`](CachePolicy.md).[`invalidateRequestsForType`](CachePolicy.md#invalidaterequestsfortype) *** ### isHardExpired() ```ts isHardExpired(identifier, store): boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:364 Invoked to determine if the request may be fulfilled from cache if possible. Note, this is only invoked by the CacheHandler if the request has a cache-key. If no cache entry is found or the entry is hard expired, the request will be fulfilled from the configured request handlers and the cache will be updated before returning the response. #### Parameters ##### identifier [`StableDocumentIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store `Store` #### Returns `boolean` true if the request is considered hard expired #### Inherited from [`CachePolicy`](CachePolicy.md).[`isHardExpired`](CachePolicy.md#ishardexpired) *** ### isSoftExpired() ```ts isSoftExpired(identifier, store): boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:380 Invoked if `isHardExpired` is false to determine if the request should be update behind the scenes if cache data is already available. Note, this is only invoked by the CacheHandler if the request has a cache-key. If true, the request will be fulfilled from cache while a backgrounded request is made to update the cache via the configured request handlers. #### Parameters ##### identifier [`StableDocumentIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store `Store` #### Returns `boolean` true if the request is considered soft expired #### Inherited from [`CachePolicy`](CachePolicy.md).[`isSoftExpired`](CachePolicy.md#issoftexpired) --- --- url: /api/@ember-data/request-utils/index/functions/buildBaseURL.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / buildBaseURL ```ts function buildBaseURL(urlOptions): string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:206 Builds a URL for a request based on the provided options. Does not include support for building query params (see `buildQueryParams`) so that it may be composed cleanly with other query-params strategies. Usage: ```ts import { buildBaseURL } from '@ember-data/request-utils'; const url = buildBaseURL({ host: 'https://api.example.com', namespace: 'api/v1', resourcePath: 'emberDevelopers', op: 'query', identifier: { type: 'ember-developer' } }); // => 'https://api.example.com/api/v1/emberDevelopers' ``` On the surface this may seem like a lot of work to do something simple, but it is designed to be composable with other utilities and interfaces that the average product engineer will never need to see or use. A few notes: * `resourcePath` is optional, but if it is not provided, `identifier.type` will be used. * `host` and `namespace` are optional, but if they are not provided, the values globally configured via `setBuildURLConfig` will be used. * `op` is required and must be one of the following: * 'findRecord' 'query' 'findMany' 'findRelatedCollection' 'findRelatedRecord'\` 'createRecord' 'updateRecord' 'deleteRecord' * Depending on the value of `op`, `identifier` or `identifiers` will be required. ## Parameters ### urlOptions [`UrlOptions`](../type-aliases/UrlOptions.md) ## Returns `string` --- --- url: /api/@ember-data/request-utils/index/functions/buildQueryParams.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / buildQueryParams ```ts function buildQueryParams(params, options?): string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:254 Sorts query params by both key and value, returning a query params string Treats `included` specially, splicing it into an array if it is a string and sorting the array. Options: * arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma' 'bracket': appends \[] to the key for every value e.g. `ids[]=1&ids[]=2` 'indices': appends \[i] to the key for every value e.g. `ids[0]=1&ids[1]=2` 'repeat': appends the key for every value e.g. `ids=1&ids=2` 'comma' (default): appends the key once with a comma separated list of values e.g. `ids=1,2` ## Parameters ### params [`QueryParamsSource`](../../../../@warp-drive/core-types/params/type-aliases/QueryParamsSource.md) ### options? [`QueryParamsSerializationOptions`](../../../../@warp-drive/core-types/params/type-aliases/QueryParamsSerializationOptions.md) ## Returns `string` A sorted query params string without the leading `?` --- --- url: /api/@ember-data/request-utils/index/functions/filterEmpty.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / filterEmpty ```ts function filterEmpty(source): Record; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:215 filter out keys of an object that have falsy values or point to empty arrays returning a new object with only those keys that have truthy values / non-empty arrays ## Parameters ### source `Record`<`string`, [`Serializable`](../../../../@warp-drive/core-types/params/type-aliases/Serializable.md)> object to filter keys with empty values from ## Returns `Record`<`string`, [`Serializable`](../../../../@warp-drive/core-types/params/type-aliases/Serializable.md)> A new object with the keys that contained empty values removed --- --- url: /api/@ember-data/request-utils/index/functions/parseCacheControl.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / parseCacheControl ```ts function parseCacheControl(header): CacheControlValue; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:73 Parses a string Cache-Control header value into an object with the following structure: ```ts interface CacheControlValue { immutable?: boolean; 'max-age'?: number; 'must-revalidate'?: boolean; 'must-understand'?: boolean; 'no-cache'?: boolean; 'no-store'?: boolean; 'no-transform'?: boolean; 'only-if-cached'?: boolean; private?: boolean; 'proxy-revalidate'?: boolean; public?: boolean; 's-maxage'?: number; 'stale-if-error'?: number; 'stale-while-revalidate'?: number; } ``` ## Parameters ### header `string` ## Returns [`CacheControlValue`](../interfaces/CacheControlValue.md) --- --- url: /api/@ember-data/request-utils/index/functions/setBuildURLConfig.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / setBuildURLConfig ```ts function setBuildURLConfig(config): void; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:81 Sets the global configuration for `buildBaseURL` for host and namespace values for the application. These values may still be overridden by passing them to buildBaseURL directly. This method may be called as many times as needed. host values of `''` or `'/'` are equivalent. Except for the value of `/` as host, host should not end with `/`. namespace should not start or end with a `/`. ```ts type BuildURLConfig = { host: string; namespace: string' } ``` Example: ```ts import { setBuildURLConfig } from '@ember-data/request-utils'; setBuildURLConfig({ host: 'https://api.example.com', namespace: 'api/v1' }); ``` ## Parameters ### config [`BuildURLConfig`](../interfaces/BuildURLConfig.md) ## Returns `void` --- --- url: /api/@ember-data/request-utils/index/functions/sortQueryParams.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / sortQueryParams ```ts function sortQueryParams(params, options?): URLSearchParams; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:235 Sorts query params by both key and value returning a new URLSearchParams object with the keys inserted in sorted order. Treats `included` specially, splicing it into an array if it is a string and sorting the array. Options: * arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma' 'bracket': appends \[] to the key for every value e.g. `&ids[]=1&ids[]=2` 'indices': appends \[i] to the key for every value e.g. `&ids[0]=1&ids[1]=2` 'repeat': appends the key for every value e.g. `&ids=1&ids=2` 'comma' (default): appends the key once with a comma separated list of values e.g. `&ids=1,2` ## Parameters ### params [`QueryParamsSource`](../../../../@warp-drive/core-types/params/type-aliases/QueryParamsSource.md) ### options? [`QueryParamsSerializationOptions`](../../../../@warp-drive/core-types/params/type-aliases/QueryParamsSerializationOptions.md) ## Returns `URLSearchParams` A URLSearchParams with keys inserted in sorted order --- --- url: /api/@ember-data/request-utils/index.md --- [Documentation](../../../index.md) / [@ember-data/request-utils](../index.md) / index Simple utility function to assist in url building, query params, and other common request operations. These primitives may be used directly or composed by request builders to provide a consistent interface for building requests. For instance: ```ts import { buildBaseURL, buildQueryParams } from '@ember-data/request-utils'; const baseURL = buildBaseURL({ host: 'https://api.example.com', namespace: 'api/v1', resourcePath: 'emberDevelopers', op: 'query', identifier: { type: 'ember-developer' } }); const url = `${baseURL}?${buildQueryParams({ name: 'Chris', include:['pets'] })}`; // => 'https://api.example.com/api/v1/emberDevelopers?include=pets&name=Chris' ``` This is useful, but not as useful as the REST request builder for query which is sugar over this (and more!): ```ts import { query } from '@ember-data/rest/request'; const options = query('ember-developer', { name: 'Chris', include:['pets'] }); // => { url: 'https://api.example.com/api/v1/emberDevelopers?include=pets&name=Chris' } // Note: options will also include other request options like headers, method, etc. ``` ## Classes * [CachePolicy](classes/CachePolicy.md) * [LifetimesService](classes/LifetimesService.md) ## Interfaces * [BuildURLConfig](interfaces/BuildURLConfig.md) * [CacheControlValue](interfaces/CacheControlValue.md) * [CreateRecordUrlOptions](interfaces/CreateRecordUrlOptions.md) * [DeleteRecordUrlOptions](interfaces/DeleteRecordUrlOptions.md) * [FindManyUrlOptions](interfaces/FindManyUrlOptions.md) * [FindRecordUrlOptions](interfaces/FindRecordUrlOptions.md) * [FindRelatedCollectionUrlOptions](interfaces/FindRelatedCollectionUrlOptions.md) * [FindRelatedResourceUrlOptions](interfaces/FindRelatedResourceUrlOptions.md) * [GenericUrlOptions](interfaces/GenericUrlOptions.md) * [QueryUrlOptions](interfaces/QueryUrlOptions.md) * [UpdateRecordUrlOptions](interfaces/UpdateRecordUrlOptions.md) ## Type Aliases * [PolicyConfig](type-aliases/PolicyConfig.md) * [UrlOptions](type-aliases/UrlOptions.md) ## Functions * [buildBaseURL](functions/buildBaseURL.md) * [buildQueryParams](functions/buildQueryParams.md) * [filterEmpty](functions/filterEmpty.md) * [parseCacheControl](functions/parseCacheControl.md) * [setBuildURLConfig](functions/setBuildURLConfig.md) * [sortQueryParams](functions/sortQueryParams.md) --- --- url: /api/@ember-data/request-utils/index/interfaces/BuildURLConfig.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / BuildURLConfig Defined in: warp-drive-packages/utilities/declarations/index.d.ts:40 ## Properties ### host ```ts host: null | string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:41 *** ### namespace ```ts namespace: null | string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:42 --- --- url: /api/@ember-data/request-utils/index/interfaces/CacheControlValue.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / CacheControlValue Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:31 ## Properties ### immutable? ```ts optional immutable: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:32 *** ### max-age? ```ts optional max-age: number; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:33 *** ### must-revalidate? ```ts optional must-revalidate: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:34 *** ### must-understand? ```ts optional must-understand: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:35 *** ### no-cache? ```ts optional no-cache: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:36 *** ### no-store? ```ts optional no-store: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:37 *** ### no-transform? ```ts optional no-transform: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:38 *** ### only-if-cached? ```ts optional only-if-cached: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:39 *** ### private? ```ts optional private: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:40 *** ### proxy-revalidate? ```ts optional proxy-revalidate: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:41 *** ### public? ```ts optional public: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:42 *** ### s-maxage? ```ts optional s-maxage: number; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:43 *** ### stale-if-error? ```ts optional stale-if-error: number; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:44 *** ### stale-while-revalidate? ```ts optional stale-while-revalidate: number; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:45 --- --- url: /api/@ember-data/request-utils/index/interfaces/CreateRecordUrlOptions.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / CreateRecordUrlOptions Defined in: warp-drive-packages/utilities/declarations/index.d.ts:133 ## Properties ### host? ```ts optional host: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:139 *** ### identifier ```ts identifier: object; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:135 #### type ```ts type: string; ``` *** ### namespace? ```ts optional namespace: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:140 *** ### op ```ts op: "createRecord"; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:134 *** ### resourcePath? ```ts optional resourcePath: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:138 --- --- url: /api/@ember-data/request-utils/index/interfaces/DeleteRecordUrlOptions.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / DeleteRecordUrlOptions Defined in: warp-drive-packages/utilities/declarations/index.d.ts:152 ## Properties ### host? ```ts optional host: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:159 *** ### identifier ```ts identifier: object; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:154 #### id ```ts id: string; ``` #### type ```ts type: string; ``` *** ### namespace? ```ts optional namespace: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:160 *** ### op ```ts op: "deleteRecord"; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:153 *** ### resourcePath? ```ts optional resourcePath: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:158 --- --- url: /api/@ember-data/request-utils/index/interfaces/FindManyUrlOptions.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / FindManyUrlOptions Defined in: warp-drive-packages/utilities/declarations/index.d.ts:101 ## Properties ### host? ```ts optional host: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:108 *** ### identifiers ```ts identifiers: object[]; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:103 #### id ```ts id: string; ``` #### type ```ts type: string; ``` *** ### namespace? ```ts optional namespace: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:109 *** ### op ```ts op: "findMany"; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:102 *** ### resourcePath? ```ts optional resourcePath: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:107 --- --- url: /api/@ember-data/request-utils/index/interfaces/FindRecordUrlOptions.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / FindRecordUrlOptions Defined in: warp-drive-packages/utilities/declarations/index.d.ts:82 ## Properties ### host? ```ts optional host: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:89 *** ### identifier ```ts identifier: object; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:84 #### id ```ts id: string; ``` #### type ```ts type: string; ``` *** ### namespace? ```ts optional namespace: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:90 *** ### op ```ts op: "findRecord"; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:83 *** ### resourcePath? ```ts optional resourcePath: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:88 --- --- url: >- /api/@ember-data/request-utils/index/interfaces/FindRelatedCollectionUrlOptions.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / FindRelatedCollectionUrlOptions Defined in: warp-drive-packages/utilities/declarations/index.d.ts:111 ## Properties ### fieldPath ```ts fieldPath: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:117 *** ### host? ```ts optional host: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:119 *** ### identifier ```ts identifier: object; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:113 #### id ```ts id: string; ``` #### type ```ts type: string; ``` *** ### namespace? ```ts optional namespace: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:120 *** ### op ```ts op: "findRelatedCollection"; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:112 *** ### resourcePath? ```ts optional resourcePath: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:118 --- --- url: >- /api/@ember-data/request-utils/index/interfaces/FindRelatedResourceUrlOptions.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / FindRelatedResourceUrlOptions Defined in: warp-drive-packages/utilities/declarations/index.d.ts:122 ## Properties ### fieldPath ```ts fieldPath: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:128 *** ### host? ```ts optional host: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:130 *** ### identifier ```ts identifier: object; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:124 #### id ```ts id: string; ``` #### type ```ts type: string; ``` *** ### namespace? ```ts optional namespace: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:131 *** ### op ```ts op: "findRelatedRecord"; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:123 *** ### resourcePath? ```ts optional resourcePath: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:129 --- --- url: /api/@ember-data/request-utils/index/interfaces/GenericUrlOptions.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / GenericUrlOptions Defined in: warp-drive-packages/utilities/declarations/index.d.ts:162 ## Properties ### host? ```ts optional host: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:164 *** ### namespace? ```ts optional namespace: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:165 *** ### resourcePath ```ts resourcePath: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:163 --- --- url: /api/@ember-data/request-utils/index/interfaces/QueryUrlOptions.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / QueryUrlOptions Defined in: warp-drive-packages/utilities/declarations/index.d.ts:92 ## Properties ### host? ```ts optional host: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:98 *** ### identifier ```ts identifier: object; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:94 #### type ```ts type: string; ``` *** ### namespace? ```ts optional namespace: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:99 *** ### op ```ts op: "query"; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:93 *** ### resourcePath? ```ts optional resourcePath: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:97 --- --- url: /api/@ember-data/request-utils/index/interfaces/UpdateRecordUrlOptions.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / UpdateRecordUrlOptions Defined in: warp-drive-packages/utilities/declarations/index.d.ts:142 ## Properties ### host? ```ts optional host: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:149 *** ### identifier ```ts identifier: object; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:144 #### id ```ts id: string; ``` #### type ```ts type: string; ``` *** ### namespace? ```ts optional namespace: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:150 *** ### op ```ts op: "updateRecord"; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:143 *** ### resourcePath? ```ts optional resourcePath: string; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:148 --- --- url: /api/@ember-data/request-utils/index/type-aliases/PolicyConfig.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / PolicyConfig ```ts type PolicyConfig = object; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:86 The configuration options for the [DefaultCachePolicy](../classes/CachePolicy.md) ```ts import { DefaultCachePolicy } from '@warp-drive/core/store'; new DefaultCachePolicy({ // ... PolicyConfig Settings ... // }); ``` ## Properties ### apiCacheHardExpires ```ts apiCacheHardExpires: number; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:116 the number of milliseconds after which a request is considered expired and should be re-fetched. If a request is issued again after this time, the request will disregard the cache and wait for a fresh response from the API. This is calculated against the `date` header of the response. If your API does not provide a `date` header, the `Fetch` handler provided by `@warp-drive/core` will automatically add it to responses if it is not present. Responses without a `date` header will be considered hard expired immediately. *** ### apiCacheSoftExpires ```ts apiCacheSoftExpires: number; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:101 the number of milliseconds after which a request is considered stale. If a request is issued again after this time, the request will respond from cache immediately while a background request is made to update the cache. This is calculated against the `date` header of the response. If your API does not provide a `date` header, the `Fetch` handler provided by `@warp-drive/core` will automatically add it to responses if it is not present. Responses without a `date` header will be considered stale immediately. *** ### constraints? ```ts optional constraints: object; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:161 In addition to the simple time-based expiration strategy, CachePolicy supports various common server-supplied expiration strategies via headers, as well as custom expiration strategies via the `isExpired` function. Requests will be validated for expiration against these constraints. If any of these constraints are not met, the request will be considered expired. If all constraints are met, the request will be considered valid and the time based expiration strategy will NOT be used. Meeting a constraint means BOTH that the properties the constraint requires are present AND that the expiration time indicated by those properties has not been exceeded. In other words, if the properties for a constraint are not present, this does not count either as meeting or as not meeting the constraint, the constraint simply does not apply. The `isExpired` function is called with the request and should return `true` if the request is expired, `false` if it is not expired, and `null` if the expiration status is unknown. In order constraints are checked: * isExpired function * ↳ (if null) X-WarpDrive-Expires header * ↳ (if null) Cache-Control header * ↳ (if null) Expires header #### headers? ```ts optional headers: object; ``` Headers that should be checked for expiration. ##### headers.Cache-Control? ```ts optional headers.Cache-Control: boolean; ``` Whether the `Cache-Control` header should be checked for expiration. If `true`, then the `max-age` and `s-maxage` directives are used alongside the `Age` and `Date` headers to determine if the expiration time has passed. Other directives are ignored. 'Cache-Control' will take precedence over 'Expires' if both are present and both configured to be checked. ##### headers.Expires? ```ts optional headers.Expires: boolean; ``` Whether the `Expires` header should be checked for expiration. If `true`, then the `Expires` header is used to caclulate the expiration time and determine if the expiration time has passed. 'Cache-Control' will take precedence over 'Expires' if both are present. ##### headers.X-WarpDrive-Expires? ```ts optional headers.X-WarpDrive-Expires: boolean; ``` Whether the `X-WarpDrive-Expires` header should be checked for expiration. If `true`, then the `X-WarpDrive-Expires` header is used to caclulate the expiration time and determine if the expiration time has passed. This header will take precedence over 'Cache-Control' and 'Expires' if all three are present. The header's value should be a [UTC date string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString). #### isExpired()? ```ts optional isExpired: (request) => boolean | null; ``` A function that should be called to determine if the request is expired. If present, this function will be called with the request and should return `true` if the request is expired, `false` if it is not expired, and `null` if the expiration status is unknown. If the function does not return `null`, ##### Parameters ###### request [`StructuredDocument`](../../../../@warp-drive/core-types/request/type-aliases/StructuredDocument.md)<[`ResourceDocument`](../../../../@warp-drive/core-types/spec/document/type-aliases/ResourceDocument.md)> ##### Returns `boolean` | `null` *** ### disableTestOptimization? ```ts optional disableTestOptimization: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/default-cache-policy.d.ts:129 In Testing environments, the `apiCacheSoftExpires` will always be `false` and `apiCacheHardExpires` will use the `apiCacheSoftExpires` value. This helps reduce flakiness and produce predictably rendered results in test suites. Requests that specifically set `cacheOptions.backgroundReload = true` will still be background reloaded in tests. This behavior can be opted out of by setting this value to `true`. --- --- url: /api/@ember-data/request-utils/index/type-aliases/UrlOptions.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [index](../index.md) / UrlOptions ```ts type UrlOptions = | FindRecordUrlOptions | QueryUrlOptions | FindManyUrlOptions | FindRelatedCollectionUrlOptions | FindRelatedResourceUrlOptions | CreateRecordUrlOptions | UpdateRecordUrlOptions | DeleteRecordUrlOptions | GenericUrlOptions; ``` Defined in: warp-drive-packages/utilities/declarations/index.d.ts:167 --- --- url: /api/@ember-data/request-utils/string/functions/camelize.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [string](../index.md) / camelize ```ts function camelize(str): string; ``` Defined in: warp-drive-packages/utilities/declarations/-private/string/transform.d.ts:40 Returns the lowerCamelCase form of a string. ```js import { camelize } from '@warp-drive/utilities/string'; camelize('innerHTML'); // 'innerHTML' camelize('action_name'); // 'actionName' camelize('css-class-name'); // 'cssClassName' camelize('my favorite items'); // 'myFavoriteItems' camelize('My Favorite Items'); // 'myFavoriteItems' camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice' ``` ## Parameters ### str `string` ## Returns `string` ## Since 4.13.0 --- --- url: /api/@ember-data/request-utils/string/functions/capitalize.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [string](../index.md) / capitalize ```ts function capitalize(str): string; ``` Defined in: warp-drive-packages/utilities/declarations/-private/string/transform.d.ts:78 Returns the Capitalized form of a string ```js import { capitalize } from '@warp-drive/utilities/string'; capitalize('innerHTML') // 'InnerHTML' capitalize('action_name') // 'Action_name' capitalize('css-class-name') // 'Css-class-name' capitalize('my favorite items') // 'My favorite items' capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice' ``` ## Parameters ### str `string` ## Returns `string` ## Since 4.13.0 --- --- url: /api/@ember-data/request-utils/string/functions/clear.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [string](../index.md) / clear ```ts function clear(): void; ``` Defined in: warp-drive-packages/utilities/declarations/-private/string/inflect.d.ts:49 Clears the caches for singularize and pluralize. ## Returns `void` ## Since 4.13.0 --- --- url: /api/@ember-data/request-utils/string/functions/clearRules.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [string](../index.md) / clearRules ```ts function clearRules(): void; ``` Defined in: warp-drive-packages/utilities/declarations/-private/string/inflect.d.ts:66 Clears all inflection rules and resets the caches for singularize and pluralize. ## Returns `void` ## Since 4.13.0 --- --- url: /api/@ember-data/request-utils/string/functions/loadIrregular.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [string](../index.md) / loadIrregular ```ts function loadIrregular(irregularPairs): void; ``` Defined in: warp-drive-packages/utilities/declarations/-private/string/inflect.d.ts:41 Marks a list of word pairs as irregular. Irregular words have unique pluralization and singularization rules. ## Parameters ### irregularPairs \[`string`, `string`]\[] ## Returns `void` ## Since 4.13.0 --- --- url: /api/@ember-data/request-utils/string/functions/irregular.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [string](../index.md) / irregular ```ts function irregular(single, plur): void; ``` Defined in: warp-drive-packages/utilities/declarations/-private/string/inflect.d.ts:31 Marks a word as irregular. Irregular words have unique pluralization and singularization rules. ## Parameters ### single `string` ### plur `string` ## Returns `void` ## Since 4.13.0 --- --- url: /api/@ember-data/request-utils/string/functions/loadUncountable.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [string](../index.md) / loadUncountable ```ts function loadUncountable(uncountables): void; ``` Defined in: warp-drive-packages/utilities/declarations/-private/string/inflect.d.ts:20 Marks a list of words as uncountable. Uncountable words are not pluralized or singularized. ## Parameters ### uncountables `string`\[] ## Returns `void` ## Since 4.13.0 --- --- url: /api/@ember-data/request-utils/string/functions/plural.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [string](../index.md) / plural ```ts function plural(regex, string): void; ``` Defined in: warp-drive-packages/utilities/declarations/-private/string/inflect.d.ts:94 Adds a pluralization rule. ## Parameters ### regex `RegExp` ### string `string` ## Returns `void` ## Since 4.13.0 --- --- url: /api/@ember-data/request-utils/string/functions/pluralize.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [string](../index.md) / pluralize ```ts function pluralize(word): string; ``` Defined in: warp-drive-packages/utilities/declarations/-private/string/inflect.d.ts:84 Pluralizes a word. ## Parameters ### word `string` ## Returns `string` ## Since 4.13.0 --- --- url: /api/@ember-data/request-utils/string/functions/setMaxLRUCacheSize.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [string](../index.md) / setMaxLRUCacheSize ```ts function setMaxLRUCacheSize(size): void; ``` Defined in: warp-drive-packages/utilities/declarations/-private/string/transform.d.ts:88 Sets the maximum size of the LRUCache for all string transformation functions. The default size is 10,000. ## Parameters ### size `number` ## Returns `void` ## Since 4.13.0 --- --- url: /api/@ember-data/request-utils/string/functions/singular.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [string](../index.md) / singular ```ts function singular(regex, string): void; ``` Defined in: warp-drive-packages/utilities/declarations/-private/string/inflect.d.ts:104 Adds a singularization rule. ## Parameters ### regex `RegExp` ### string `string` ## Returns `void` ## Since 4.13.0 --- --- url: /api/@ember-data/request-utils/string/functions/resetToDefaults.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [string](../index.md) / resetToDefaults ```ts function resetToDefaults(): void; ``` Defined in: warp-drive-packages/utilities/declarations/-private/string/inflect.d.ts:57 Resets the inflection rules to the defaults. ## Returns `void` ## Since 4.13.0 --- --- url: /api/@ember-data/request-utils/string/functions/singularize.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [string](../index.md) / singularize ```ts function singularize(word): string; ``` Defined in: warp-drive-packages/utilities/declarations/-private/string/inflect.d.ts:75 Singularizes a word. ## Parameters ### word `string` ## Returns `string` ## Since 4.13.0 --- --- url: /api/@ember-data/request-utils/string/functions/uncountable.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [string](../index.md) / uncountable ```ts function uncountable(word): void; ``` Defined in: warp-drive-packages/utilities/declarations/-private/string/inflect.d.ts:10 Marks a word as uncountable. Uncountable words are not pluralized or singularized. ## Parameters ### word `string` ## Returns `void` ## Since 4.13.0 --- --- url: /api/@ember-data/request-utils/string/functions/underscore.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [string](../index.md) / underscore ```ts function underscore(str): string; ``` Defined in: warp-drive-packages/utilities/declarations/-private/string/transform.d.ts:59 Returns the lower\_case\_and\_underscored form of a string. ```js import { underscore } from '@warp-drive/utilities/string'; underscore('innerHTML'); // 'inner_html' underscore('action_name'); // 'action_name' underscore('css-class-name'); // 'css_class_name' underscore('my favorite items'); // 'my_favorite_items' underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice' ``` ## Parameters ### str `string` ## Returns `string` ## Since 4.13.0 --- --- url: /api/@ember-data/request-utils/string.md --- [Documentation](../../../index.md) / [@ember-data/request-utils](../index.md) / string String utilties for transforming and inflecting strings useful for when the format provided by the server is not the format you want to use in your application. Each transformation function stores its results in an LRUCache to avoid recomputing the same value multiple times. The cache size can be set using the `setMaxLRUCacheSize` function. The default size is 10,000. ## Variables * [dasherize](variables/dasherize.md) ## Functions * [camelize](functions/camelize.md) * [capitalize](functions/capitalize.md) * [clear](functions/clear.md) * [clearRules](functions/clearRules.md) * [irregular](functions/irregular.md) * [loadIrregular](functions/loadIrregular.md) * [loadUncountable](functions/loadUncountable.md) * [plural](functions/plural.md) * [pluralize](functions/pluralize.md) * [resetToDefaults](functions/resetToDefaults.md) * [setMaxLRUCacheSize](functions/setMaxLRUCacheSize.md) * [singular](functions/singular.md) * [singularize](functions/singularize.md) * [uncountable](functions/uncountable.md) * [underscore](functions/underscore.md) --- --- url: /api/@ember-data/request-utils/string/variables/dasherize.md --- [Documentation](../../../../index.md) / [@ember-data/request-utils](../../index.md) / [string](../index.md) / dasherize ```ts const dasherize: typeof internalDasherize; ``` Defined in: warp-drive-packages/utilities/declarations/-private/string/transform.d.ts:20 Replaces underscores, spaces, or camelCase with dashes. ```js import { dasherize } from '@warp-drive/utilities/string'; dasherize('innerHTML'); // 'inner-html' dasherize('action_name'); // 'action-name' dasherize('css-class-name'); // 'css-class-name' dasherize('my favorite items'); // 'my-favorite-items' dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice' ``` ## Param ## Returns ## Since 4.13.0 --- --- url: /api/@ember-data/request/fetch/classes/default.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [fetch](../index.md) / default Defined in: warp-drive-packages/core/declarations/request/-private/fetch.d.ts:36 A basic handler which converts a request into a `fetch` call presuming the response to be `json`. ```ts import Fetch from '@ember-data/request/fetch'; manager.use([Fetch]); ``` Fetch ## Methods ### request() ```ts static request(context): Promise; ``` Defined in: warp-drive-packages/core/declarations/request/-private/fetch.d.ts:37 #### Type Parameters ##### T `T` #### Parameters ##### context [`Context`](../../index/classes/Context.md) #### Returns `Promise`<`T`> --- --- url: /api/@ember-data/request/fetch.md --- [Documentation](../../../index.md) / [@ember-data/request](../index.md) / fetch A basic Fetch Handler which converts a request into a `fetch` call presuming the response to be `json`. ```ts import Fetch from '@ember-data/request/fetch'; manager.use([Fetch]); ``` ## Classes * [default](classes/default.md) --- --- url: /api/@ember-data/request.md --- [Documentation](../../index.md) / @ember-data/request ## Modules * [fetch](fetch/index.md) * [index](index/index.md) --- --- url: /api/@ember-data/request/index/classes/Context.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [index](../index.md) / Context Defined in: warp-drive-packages/core/declarations/request/-private/context.d.ts:28 ## Constructors ### Constructor ```ts new Context(owner, isCacheHandler): Context; ``` Defined in: warp-drive-packages/core/declarations/request/-private/context.d.ts:34 #### Parameters ##### owner `ContextOwner` ##### isCacheHandler `boolean` #### Returns `Context` ## Properties ### id ```ts id: number; ``` Defined in: warp-drive-packages/core/declarations/request/-private/context.d.ts:31 *** ### request ```ts request: ImmutableRequestInfo; ``` Defined in: warp-drive-packages/core/declarations/request/-private/context.d.ts:30 ## Accessors ### hasRequestedStream #### Get Signature ```ts get hasRequestedStream(): boolean; ``` Defined in: warp-drive-packages/core/declarations/request/-private/context.d.ts:38 ##### Returns `boolean` ## Methods ### \_finalize() ```ts _finalize(): void; ``` Defined in: warp-drive-packages/core/declarations/request/-private/context.d.ts:39 #### Returns `void` *** ### setIdentifier() ```ts setIdentifier(identifier): void; ``` Defined in: warp-drive-packages/core/declarations/request/-private/context.d.ts:37 #### Parameters ##### identifier [`StableDocumentIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md) #### Returns `void` *** ### setResponse() ```ts setResponse(response): void; ``` Defined in: warp-drive-packages/core/declarations/request/-private/context.d.ts:36 #### Parameters ##### response `null` | `Response` | [`ResponseInfo`](../interfaces/ResponseInfo.md) #### Returns `void` *** ### setStream() ```ts setStream(stream): void; ``` Defined in: warp-drive-packages/core/declarations/request/-private/context.d.ts:35 #### Parameters ##### stream `ReadableStream`<`any`> | `Promise`<`null` | `ReadableStream`<`any`>> #### Returns `void` --- --- url: /api/@ember-data/request/index/functions/createDeferred.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [index](../index.md) / createDeferred ```ts function createDeferred(): Deferred; ``` Defined in: warp-drive-packages/core/declarations/request/-private/future.d.ts:5 ## Type Parameters ### T `T` ## Returns [`Deferred`](../type-aliases/Deferred.md)<`T`> --- --- url: /api/@ember-data/request/index/classes/default.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [index](../index.md) / default Defined in: warp-drive-packages/core/declarations/request/-private/manager.d.ts:80 ```js import RequestManager from '@ember-data/request'; ``` A RequestManager provides a request/response flow in which configured handlers are successively given the opportunity to handle, modify, or pass-along a request. ```ts interface RequestManager { request(req: RequestInfo): Future; } ``` For example: ```ts import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import Auth from 'ember-simple-auth/ember-data-handler'; import Config from './config'; const { apiUrl } = Config; // ... create manager const manager = new RequestManager().use([Auth, Fetch]); // ... execute a request const response = await manager.request({ url: `${apiUrl}/users` }); ``` ### Futures The return value of `manager.request` is a `Future`, which allows access to limited information about the request while it is still pending and fulfills with the final state when the request completes. A `Future` is cancellable via `abort`. Handlers may optionally expose a `ReadableStream` to the `Future` for streaming data; however, when doing so the future should not resolve until the response stream is fully read. ```ts interface Future extends Promise> { abort(): void; async getStream(): ReadableStream | null; } ``` ### StructuredDocuments A Future resolves with a `StructuredDataDocument` or rejects with a `StructuredErrorDocument`. ```ts interface StructuredDataDocument { request: ImmutableRequestInfo; response: ImmutableResponseInfo; content: T; } interface StructuredErrorDocument extends Error { request: ImmutableRequestInfo; response: ImmutableResponseInfo; error: string | object; } type StructuredDocument = StructuredDataDocument | StructuredErrorDocument; ``` RequestManager ## Constructors ### Constructor ```ts new default(options?): RequestManager; ``` Defined in: warp-drive-packages/core/declarations/request/-private/manager.d.ts:96 #### Parameters ##### options? `GenericCreateArgs` #### Returns `RequestManager` ## Properties ### \_deduped ```ts _deduped: Map; }>; ``` Defined in: warp-drive-packages/core/declarations/request/-private/manager.d.ts:92 *** ### \_hasCacheHandler ```ts _hasCacheHandler: boolean; ``` Defined in: warp-drive-packages/core/declarations/request/-private/manager.d.ts:82 ## Methods ### request() ```ts request(request): Future; ``` Defined in: warp-drive-packages/core/declarations/request/-private/manager.d.ts:132 Issue a Request. Returns a Future that fulfills with a StructuredDocument #### Type Parameters ##### RT `RT` ##### T `T` = `unknown` #### Parameters ##### request [`RequestInfo`](../interfaces/RequestInfo.md)<`RT`, `T`> #### Returns [`Future`](../interfaces/Future.md)<`RT`> *** ### use() ```ts use(newHandlers): this; ``` Defined in: warp-drive-packages/core/declarations/request/-private/manager.d.ts:122 Register handler(s) to use when a request is issued. Handlers will be invoked in the order they are registered. Each Handler is given the opportunity to handle the request, curry the request, or pass along a modified request. #### Parameters ##### newHandlers [`Handler`](../interfaces/Handler.md)\[] #### Returns `this` *** ### useCache() ```ts useCache(cacheHandler): this; ``` Defined in: warp-drive-packages/core/declarations/request/-private/manager.d.ts:108 Register a handler to use for primary cache intercept. Only one such handler may exist. If using the same RequestManager as the Store instance the Store registers itself as a Cache handler. #### Parameters ##### cacheHandler [`CacheHandler`](../interfaces/CacheHandler.md) & `object` #### Returns `this` *** ### create() ```ts static create(options?): RequestManager; ``` Defined in: warp-drive-packages/core/declarations/request/-private/manager.d.ts:133 #### Parameters ##### options? `GenericCreateArgs` #### Returns `RequestManager` --- --- url: /api/@ember-data/request/index/functions/getPromiseResult.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [index](../index.md) / getPromiseResult ```ts function getPromiseResult(promise): undefined | CacheResult; ``` Defined in: warp-drive-packages/core/declarations/request/-private/promise-cache.d.ts:19 ## Type Parameters ### T `T` ### E `E` ## Parameters ### promise `Promise`<`T`> | [`Awaitable`](../type-aliases/Awaitable.md)<`T`, `E`> ## Returns `undefined` | `CacheResult`<`T`, `E`> --- --- url: /api/@ember-data/request/index.md --- [Documentation](../../../index.md) / [@ember-data/request](../index.md) / index This package provides [*Ember*‍**Data**](https://github.com/emberjs/data/)'s `RequestManager`, a framework agnostic library that can be integrated with any Javascript application to make [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) happen. * [Installation](#installation) * [Basic Usage](#%F0%9F%9A%80-basic-usage) * [Architecture](#%F0%9F%AA%9C-architecture) * [Usage](#usage) * [Making Requests](#making-requests) * [Using The Response](#using-the-response) * [Request Handlers](#handling-requests) * [Handling Errors](#handling-errors) * [Handling Abort](#handling-abort) * [Stream Currying](#stream-currying) * [Automatic Currying](#automatic-currying-of-stream-and-response) * [Using as a Service](#using-as-a-service) * [Using with `@ember-data/store`](#using-with-ember-datastore) * [Using with `ember-data`](#using-with-ember-data) *** ## Installation Install using your javascript package manager of choice. For instance with [pnpm](https://pnpm.io/) ```no-highlight pnpm add @ember-data/request ``` *** ## 🚀 Basic Usage A `RequestManager` provides a request/response flow in which configured handlers are successively given the opportunity to handle, modify, or pass-along a request. The RequestManager on its own does not know how to fulfill requests. For this we must register at least one handler. A basic `Fetch` handler is provided that will take the request options provided and execute `fetch`. ```ts import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import { apiUrl } from './config'; // ... create manager and add our Fetch handler const manager = new RequestManager() .use([Fetch]); // ... execute a request const response = await manager.request({ url: `${apiUrl}/users` }); ``` *** ## 🪜 Architecture A `RequestManager` receives a request and manages fulfillment via configured handlers. It may be used standalone from the rest of *Ember*‍**Data** and is not specific to any library or framework. Each handler may choose to fulfill the request using some source of data or to pass the request along to other handlers. The same or a separate instance of a `RequestManager` may also be used to fulfill requests issued by [*Ember*‍**Data**{Store}](https://github.com/emberjs/data/tree/main/packages/store) When the same instance is used by both this allows for simple coordination throughout the application. Requests issued by the Store will use the in-memory cache and return hydrated responses, requests issued directly to the RequestManager will skip the in-memory cache and return raw responses. *** ## Usage ```ts const userList = await manager.request({ url: `/api/v1/users.list` }); const users = userList.content; ``` *** ### Making Requests `RequestManager` has a single asyncronous method as it's API: `request` ```ts class RequestManager { request(req: RequestInfo): Future; } ``` `manager.request()` accepts an object containing the information necessary for the request to be handled successfully. These options extend the [options](https://developer.mozilla.org/en-US/docs/Web/API/fetch#parameters) provided to `fetch`, and can accept a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request). All properties accepted by Request options and fetch options are valid. ```ts interface RequestInfo extends FetchOptions { op?: string; store?: Store; url: string; // data that a handler should convert into // the query (GET) or body (POST) data?: Record; // options specifically intended for handlers // to utilize to process the request options?: Record; } ``` > **note** > providing a `signal` is unnecessary as an `AbortController` is automatically provided if none is present. *** #### Using the Response `manager.request` returns a `Future`, which allows access to limited information about the request while it is still pending and fulfills with the final state when the request completes and the response has been read. ```ts const usersFuture = manager.request({ url: `/api/v1/users.list` }); ``` A `Future` is cancellable via `abort`. ```ts usersFuture.abort(); ``` Handlers may *optionally* expose a ReadableStream to the `Future` for streaming data; however, when doing so the handler should not resolve until it has fully read the response stream itself. ```ts interface Future extends Promise> { abort(): void; async getStream(): ReadableStream | null; } ``` A Future resolves or rejects with a `StructuredDocument`. ```ts interface StructuredDocument { request: RequestInfo; response: ResponseInfo | null; content?: T; error?: Error; } ``` The `RequestInfo` specified by `document.request` is the same as originally provided to `manager.request`. If any handler fulfilled this request using different request info it is not represented here. This contract helps to ensure that `retry` and `caching` are possible since the original arguments are correctly preserved. This also allows handlers to "fork" the request or fulfill from multiple sources without the details of fulfillment muddying the original request. The `ResponseInfo` is a serializable fulfilled subset of a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) if set via `setResponse`. If no response was ever set this will be `null`. ```ts interface ResponseInfo { headers?: Record; ok?: boolean; redirected?: boolean; status?: HTTPStatusCode; statusText?: string; type?: 'basic' | 'cors'; url?: string; } ``` *** ### Request Handlers Requests are fulfilled by handlers. A handler receives the request context as well as a `next` function with which to pass along a request to the next handler if it so chooses. A handler may be any object with a `request` method. This allows both stateful and non-stateful handlers to be utilized. If a handler calls `next`, it receives a `Future` which resolves to a `StructuredDocument` that it can then compose how it sees fit with its own response. ```ts type NextFn

= (req: RequestInfo) => Future

; interface Handler { async request(context: RequestContext, next: NextFn

): T; } ``` `RequestContext` contains a readonly version of the RequestInfo as well as a few methods for building up the `StructuredDocument` and `Future` that will be part of the response. ```ts interface RequestContext { readonly request: RequestInfo; setStream(stream: ReadableStream | Promise): void; setResponse(response: Response | ResponseInfo): void; } ``` A basic `fetch` handler with support for streaming content updates while the download is still underway might look like the following, where we use [`response.clone()`](https://developer.mozilla.org/en-US/docs/Web/API/Response/clone) to `tee` the `ReadableStream` into two streams. A more efficient handler might read from the response stream, building up the response content before passing along the chunk downstream. ```ts const FetchHandler = { async request(context) { const response = await fetch(context.request); context.setResponse(reponse); context.setStream(response.clone().body); return response.json(); } } ``` Request handlers are registered by configuring the manager via `use` ```ts manager.use([Handler1, Handler2]) ``` Handlers will be invoked in the order they are registered ("fifo", first-in first-out), and may only be registered up until the first request is made. It is recommended but not required to register all handlers at one time in order to ensure explicitly visible handler ordering. *** #### Handling Errors Each handler in the chain can catch errors from upstream and choose to either handle the error, re-throw the error, or throw a new error. ```ts const MAX_RETRIES = 5; const Handler = { async request(context, next) { let attempts = 0; while (attempts < MAX_RETRIES) { attempts++; try { const response = await next(context.request); return response; } catch (e) { if (isTimeoutError(e) && attempts < MAX_RETRIES) { // retry request continue; } // rethrow if it is not a timeout error throw e; } } } } ``` *** #### Handling Abort Aborting a request will reject the current handler in the chain. However, every handler can potentially catch this error. If your handler needs to separate AbortError from other Error types, it is recommended to check `context.request.signal.aborted` (or if a custom controller was supplied `controller.signal.aborted`). In this manner it is possible for a request to recover from an abort and still proceed; however, as a best practice this should be used for necessary cleanup only and the original AbortError rethrown if the abort signal comes from the root controller. *AbortControllers are Always Present and Always Entangled*\* If the initial request does not supply an [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController), one will be generated. The [signal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) for this controller is automatically added to the request passed into the first handler. Each handler has the option to supply a new controller to the request when calling `next`. If a new controller is provided it will be automatically entangled with the root controller. If the root controller aborts, so will any entangled controllers. If an entangled controller aborts, the root controller will not abort. This allows for advanced request-flow scenarios to abort subsections of the request tree without aborting the entire request. *** #### Stream Currying `RequestManager.request` and `next` differ from `fetch` in one **crucial detail** in that the outer Promise resolves only once the response stream has been processed. For context, it helps to understand a few of the use-cases that RequestManager is intended to allow. * to manage and return streaming content (such as video files) * to fulfill a request from multiple sources or by splitting one request into multiple requests * for instance one API call for a user and another for the user's friends * or e.g. fulfilling part of the request from one source (one API, in-memory, localStorage, IndexedDB etc.) and the rest from another source (a different API, a WebWorker, etc.) * to coalesce multiple requests * to decorate a request with additional info * e.g. an Auth handler that ensures the correct tokens or headers or cookies are attached. `await fetch()` resolves at the moment headers are received. This allows for the body of the request to be processed as a stream by application code *while chunks are still being received by the browser*. When an app chooses to `await response.json()` what occurs is the browser reads the stream to completion and then returns the result. Additionally, this stream may only be read **once**. The `RequestManager` preserves this ability to subscribe to and utilize the stream by either the application or the handler – thereby delivering the full power and flexibility of native APIs – without restricting developers in ways that lead to complicated workarounds. Each handler may call `setStream` only once, but may do so *at any time* until the promise that the handler returns has resolved. The associated promise returned by calling `future.getStream` will resolve with the stream set by `setStream` if that method is called, or `null` if that method has not been called by the time that the handler's request method has resolved. Handlers that do not create a stream of their own, but which call `next`, should defensively pipe the stream forward. While this is not required (see automatic currying below) it is better to do so in most cases as otherwise the stream may not become available to downstream handlers or the application until the upstream handler has fully read it. ```ts context.setStream(future.getStream()); ``` Handlers that either call `next` multiple times or otherwise have reason to create multiple fetch requests should either choose to return no stream, meaningfully combine the streams, or select a single prioritized stream. Of course, any handler may choose to read and handle the stream, and return either no stream or a different stream in the process. *** #### Automatic Currying of Stream and Response In order to simplify the common case for handlers which decorate a request, if `next` is called only a single time and `setResponse` was never called by the handler, the response set by the next handler in the chain will be applied to that handler's outcome. For instance, this makes the following pattern possible `return (await next()).content;`. Similarly, if `next` is called only a single time and neither `setStream` nor `getStream` was called, we automatically curry the stream from the future returned by `next` onto the future returned by the handler. Finally, if the return value of a handler is a `Future`, we curry `content` and `errors` as well, thus enabling the simplest form `return next()`. In the case of the `Future` being returned, `Stream` proxying is automatic and immediate and does not wait for the `Future` to resolve. *** #### Using with `@ember-data/store` To have a request service unique to a Store: ```ts import Store, { CacheHandler } from '@ember-data/store'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; class extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); } ``` *** ### Using as a Service Some applications will desire to have a single `RequestManager` instance, which can be achieved using module-state patterns for singletons, or for [Ember](https://emberjs.com) applications by exporting the manager as a [service](https://guides.emberjs.com/release/services/). services/request.ts\* ```ts import { CacheHandler } from '@ember-data/store'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import Auth from 'ember-simple-auth/ember-data-handler'; export default { create() { return new RequestManager() .use([Auth, Fetch]) .use(CacheHandler); } } ``` *** #### Using with `ember-data` If using the package [ember-data](https://github.com/emberjs/data/tree/main/packages/-ember-data), the following configuration will automatically be done in order to preserve the legacy [Adapter](https://github.com/emberjs/data/tree/main/packages/adapter) and [Serializer](https://github.com/emberjs/data/tree/main/packages/serializer) behavior. Additional handlers or a service injection like the above would need to be done by the consuming application in order to make broader use of `RequestManager`. ```ts import Store from 'ember-data/store'; import { CacheHandler } from '@ember-data/store'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import { LegacyNetworkHandler } from '@ember-data/legacy-compat'; export default class extends Store { requestManager = new RequestManager() .use([LegacyNetworkHandler, Fetch]) .useCache(CacheHandler); } ``` To provide a different configuration, import and extend `ember-data/store`. The default configuration will be ignored if the `requestManager` property is set, though the store will still register the CacheHandler. For usage of the store's `requestManager` via `store.request()` see the [Store](https://api.emberjs.com/ember-data/release/modules/@ember-data%2Fstore) documentation. ## Classes * [Context](classes/Context.md) * [default](classes/default.md) ## Interfaces * [CacheHandler](interfaces/CacheHandler.md) * [Future](interfaces/Future.md) * [Handler](interfaces/Handler.md) * [RequestContext](interfaces/RequestContext.md) * [RequestInfo](interfaces/RequestInfo.md) * [ResponseInfo](interfaces/ResponseInfo.md) * [StructuredDataDocument](interfaces/StructuredDataDocument.md) * [StructuredErrorDocument](interfaces/StructuredErrorDocument.md) ## Type Aliases * [Awaitable](type-aliases/Awaitable.md) * [Deferred](type-aliases/Deferred.md) * [ImmutableRequestInfo](type-aliases/ImmutableRequestInfo.md) * [ManagedRequestPriority](type-aliases/ManagedRequestPriority.md) * [NextFn](type-aliases/NextFn.md) * [StructuredDocument](type-aliases/StructuredDocument.md) ## Functions * [createDeferred](functions/createDeferred.md) * [getPromiseResult](functions/getPromiseResult.md) * [setPromiseResult](functions/setPromiseResult.md) --- --- url: /api/@ember-data/request/index/functions/setPromiseResult.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [index](../index.md) / setPromiseResult ```ts function setPromiseResult(promise, result): void; ``` Defined in: warp-drive-packages/core/declarations/request/-private/promise-cache.d.ts:18 ## Parameters ### promise `Promise`<`unknown`> | [`Awaitable`](../type-aliases/Awaitable.md)<`unknown`, `unknown`> ### result `CacheResult` ## Returns `void` --- --- url: /api/@ember-data/request/index/interfaces/CacheHandler.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [index](../index.md) / CacheHandler Defined in: warp-drive-packages/core/declarations/request/-private/types.d.ts:219 The CacheHandler is identical to other handlers ecxept that it is allowed to return a value synchronously. This is useful for features like reducing microtask queueing when de-duping. A RequestManager may only have one CacheHandler, registered via `manager.useCache(CacheHandler)`. (Interface) CacheHandler ## Methods ### request() ```ts request(context, next): | T | Promise> | Future; ``` Defined in: warp-drive-packages/core/declarations/request/-private/types.d.ts:229 Method to implement to handle requests. Receives the request context and a nextFn to call to pass-along the request to other handlers. #### Type Parameters ##### T `T` = `unknown` #### Parameters ##### context [`RequestContext`](RequestContext.md) ##### next [`NextFn`](../type-aliases/NextFn.md)<`T`> #### Returns | `T` | `Promise`<`T` | [`StructuredDataDocument`](StructuredDataDocument.md)<`T`>> | [`Future`](Future.md)<`T`> --- --- url: /api/@ember-data/request/index/interfaces/Future.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [index](../index.md) / Future Defined in: warp-drive-packages/core/declarations/request/-private/types.d.ts:34 A Future is a Promise which resolves to a StructuredDocument while providing the ability to `abort` the underlying request, `getStream` the response before the outer promise resolves; Future ## Extends * `Promise`<[`StructuredDataDocument`](StructuredDataDocument.md)<`T`>> ## Type Parameters ### T `T` ## Properties ### \_\_\_(unique) Symbol(IS\_FUTURE) ```ts ___(unique) Symbol(IS_FUTURE): true; ``` Defined in: warp-drive-packages/core/declarations/request/-private/types.d.ts:35 *** ### \[toStringTag] ```ts readonly [toStringTag]: string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:176 #### Inherited from ```ts Promise.[toStringTag] ``` *** ### id ```ts id: number; ``` Defined in: warp-drive-packages/core/declarations/request/-private/types.d.ts:77 The id of the associated request, if any, as assigned by the RequestManager *** ### lid ```ts lid: | null | StableDocumentIdentifier; ``` Defined in: warp-drive-packages/core/declarations/request/-private/types.d.ts:68 The identifier of the associated request, if any, as assigned by the CacheHandler. ## Methods ### abort() ```ts abort(reason?): void; ``` Defined in: warp-drive-packages/core/declarations/request/-private/types.d.ts:43 Cancel this request by firing the AbortController's signal. #### Parameters ##### reason? `string` optional reason for aborting the request #### Returns `void` *** ### catch() ```ts catch(onrejected?): Promise | TResult>; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1557 Attaches a callback for only the rejection of the Promise. #### Type Parameters ##### TResult `TResult` = `never` #### Parameters ##### onrejected? The callback to execute when the Promise is rejected. `null` | (`reason`) => `TResult` | `PromiseLike`<`TResult`> #### Returns `Promise`<[`StructuredDataDocument`](StructuredDataDocument.md)<`T`> | `TResult`> A Promise for the completion of the callback. #### Inherited from ```ts Promise.catch ``` *** ### finally() ```ts finally(onfinally?): Promise>; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2018.promise.d.ts:29 Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback. #### Parameters ##### onfinally? The callback to execute when the Promise is settled (fulfilled or rejected). `null` | () => `void` #### Returns `Promise`<[`StructuredDataDocument`](StructuredDataDocument.md)<`T`>> A Promise for the completion of the callback. #### Inherited from ```ts Promise.finally ``` *** ### getStream() ```ts getStream(): Promise>; ``` Defined in: warp-drive-packages/core/declarations/request/-private/types.d.ts:50 Get the response stream, if any, once made available. #### Returns `Promise`<`null` | `ReadableStream`<`any`>> *** ### onFinalize() ```ts onFinalize(cb): void; ``` Defined in: warp-drive-packages/core/declarations/request/-private/types.d.ts:59 Run a callback when this request completes. Use sparingly, mostly useful for instrumentation and infrastructure. #### Parameters ##### cb () => `void` the callback to run #### Returns `void` *** ### then() ```ts then(onfulfilled?, onrejected?): Promise; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1550 Attaches callbacks for the resolution and/or rejection of the Promise. #### Type Parameters ##### TResult1 `TResult1` = [`StructuredDataDocument`](StructuredDataDocument.md)<`T`> ##### TResult2 `TResult2` = `never` #### Parameters ##### onfulfilled? The callback to execute when the Promise is resolved. `null` | (`value`) => `TResult1` | `PromiseLike`<`TResult1`> ##### onrejected? The callback to execute when the Promise is rejected. `null` | (`reason`) => `TResult2` | `PromiseLike`<`TResult2`> #### Returns `Promise`<`TResult1` | `TResult2`> A Promise for the completion of which ever callback is executed. #### Inherited from ```ts Promise.then ``` --- --- url: /api/@ember-data/request/index/interfaces/Handler.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [index](../index.md) / Handler Defined in: warp-drive-packages/core/declarations/request/-private/types.d.ts:196 Requests are fulfilled by handlers. A handler receives the request context as well as a `next` function with which to pass along a request to the next handler if it so chooses. A handler may be any object with a `request` method. This allows both stateful and non-stateful handlers to be utilized. If a handler calls `next`, it receives a `Future` which resolves to a `StructuredDocument` that it can then compose how it sees fit with its own response. ```ts type NextFn

= (req: RequestInfo) => Future

; interface Handler { async request(context: RequestContext, next: NextFn

): T; } ``` `RequestContext` contains a readonly version of the RequestInfo as well as a few methods for building up the `StructuredDocument` and `Future` that will be part of the response. ```ts interface RequestContext { readonly request: RequestInfo; setStream(stream: ReadableStream | Promise): void; setResponse(response: Response | ResponseInfo): void; } ``` A basic `fetch` handler with support for streaming content updates while the download is still underway might look like the following, where we use [`response.clone()`](https://developer.mozilla.org/en-US/docs/Web/API/Response/clone) to `tee` the `ReadableStream` into two streams. A more efficient handler might read from the response stream, building up the response content before passing along the chunk downstream. ```ts const FetchHandler = { async request(context) { const response = await fetch(context.request); context.setResponse(reponse); context.setStream(response.clone().body); return response.json(); } } ``` ### Stream Currying `RequestManager.request` and `next` differ from `fetch` in one **crucial detail** in that the outer Promise resolves only once the response stream has been processed. For context, it helps to understand a few of the use-cases that RequestManager is intended to allow. * to manage and return streaming content (such as video files) * to fulfill a request from multiple sources or by splitting one request into multiple requests * for instance one API call for a user and another for the user's friends * or e.g. fulfilling part of the request from one source (one API, in-memory, localStorage, IndexedDB etc.) and the rest from another source (a different API, a WebWorker, etc.) * to coalesce multiple requests * to decorate a request with additional info * e.g. an Auth handler that ensures the correct tokens or headers or cookies are attached. *** `await fetch()` resolves at the moment headers are received. This allows for the body of the request to be processed as a stream by application code *while chunks are still being received by the browser*. When an app chooses to `await response.json()` what occurs is the browser reads the stream to completion and then returns the result. Additionally, this stream may only be read **once**. The `RequestManager` preserves this ability to subscribe to and utilize the stream by either the application or the handler – thereby delivering the full power and flexibility of native APIs – without restricting developers in ways that lead to complicated workarounds. Each handler may call `setStream` only once, but may do so *at any time* until the promise that the handler returns has resolved. The associated promise returned by calling `future.getStream` will resolve with the stream set by `setStream` if that method is called, or `null` if that method has not been called by the time that the handler's request method has resolved. Handlers that do not create a stream of their own, but which call `next`, should defensively pipe the stream forward. While this is not required (see automatic currying below) it is better to do so in most cases as otherwise the stream may not become available to downstream handlers or the application until the upstream handler has fully read it. ```ts context.setStream(future.getStream()); ``` Handlers that either call `next` multiple times or otherwise have reason to create multiple fetch requests should either choose to return no stream, meaningfully combine the streams, or select a single prioritized stream. Of course, any handler may choose to read and handle the stream, and return either no stream or a different stream in the process. ### Automatic Currying of Stream and Response In order to simplify the common case for handlers which decorate a request, if `next` is called only a single time and `setResponse` was never called by the handler, the response set by the next handler in the chain will be applied to that handler's outcome. For instance, this makes the following pattern possible `return (await next()).content;`. Similarly, if `next` is called only a single time and neither `setStream` nor `getStream` was called, we automatically curry the stream from the future returned by `next` onto the future returned by the handler. Finally, if the return value of a handler is a `Future`, we curry `content` and `errors` as well, thus enabling the simplest form `return next()`. In the case of the `Future` being returned, `Stream` proxying is automatic and immediate and does not wait for the `Future` to resolve. ### Handler Order Request handlers are registered by configuring the manager via `use` ```ts const manager = new RequestManager() .use([Handler1, Handler2]); ``` Handlers will be invoked in the order they are registered ("fifo", first-in first-out), and may only be registered up until the first request is made. It is recommended but not required to register all handlers at one time in order to ensure explicitly visible handler ordering. (Interface) Handler ## Methods ### request() ```ts request(context, next): | Promise> | Future; ``` Defined in: warp-drive-packages/core/declarations/request/-private/types.d.ts:206 Method to implement to handle requests. Receives the request context and a nextFn to call to pass-along the request to other handlers. #### Type Parameters ##### T `T` = `unknown` #### Parameters ##### context [`RequestContext`](RequestContext.md) ##### next [`NextFn`](../type-aliases/NextFn.md)<`T`> #### Returns | `Promise`<`T` | [`StructuredDataDocument`](StructuredDataDocument.md)<`T`>> | [`Future`](Future.md)<`T`> --- --- url: /api/@ember-data/request/index/interfaces/RequestContext.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [index](../index.md) / RequestContext Defined in: warp-drive-packages/core/declarations/types/request.d.ts:295 ## Properties ### id ```ts id: number; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:300 *** ### request ```ts request: ImmutableRequestInfo; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:299 #### See [ImmutableRequestInfo](../type-aliases/ImmutableRequestInfo.md) ## Methods ### setResponse() ```ts setResponse(response): void; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:302 #### Parameters ##### response `null` | `Response` | [`ResponseInfo`](ResponseInfo.md) #### Returns `void` *** ### setStream() ```ts setStream(stream): void; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:301 #### Parameters ##### stream `ReadableStream`<`any`> | `Promise`<`null` | `ReadableStream`<`any`>> #### Returns `void` --- --- url: /api/@ember-data/request/index/interfaces/RequestInfo.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [index](../index.md) / RequestInfo Defined in: warp-drive-packages/core/declarations/types/request.d.ts:235 Extends JavaScript's native Request object with additional properties specific to the RequestManager's capabilities. ## Extends * `Request` ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(EnableHydration)? ```ts optional ___(unique) Symbol(EnableHydration): boolean; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:271 *** ### \_\_\_(unique) Symbol(RequestSignature)? ```ts optional ___(unique) Symbol(RequestSignature): RT; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:270 *** ### body? ```ts optional body: null | BodyInit; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:216 Any body that you want to add to your request. Note that a GET or HEAD request may not have a body. #### Inherited from ```ts Request.body ``` *** ### cache? ```ts optional cache: RequestCache; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:174 Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching. #### Inherited from ```ts Request.cache ``` *** ### cacheOptions? ```ts optional cacheOptions: CacheOptions; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:244 #### See [CacheOptions](../../../../@warp-drive/core-types/request/type-aliases/CacheOptions.md) *** ### controller? ```ts optional controller: AbortController; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:240 If provided, used instead of the AbortController auto-configured for each request by the RequestManager *** ### credentials? ```ts optional credentials: RequestCredentials; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:177 Returns the credentials mode associated with request, which is a string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. #### Inherited from ```ts Request.credentials ``` *** ### data? ```ts optional data: Record; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:263 data that a handler should convert into the query (GET) or body (POST). Note: It is recommended that builders set query params and body directly in most scenarios. *** ### destination? ```ts optional destination: RequestDestination; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:180 Returns the kind of resource requested by request, e.g., "document" or "script". #### Inherited from ```ts Request.destination ``` *** ### disableTestWaiter? ```ts optional disableTestWaiter: boolean; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:254 *** ### duplex? ```ts optional duplex: "half"; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:224 When sending a ReadableStream as the body of a request, 'half' must be specified. [Half Duplex Further Reading](https://developer.chrome.com/docs/capabilities/web-apis/fetch-streaming-requests#half_duplex) #### Inherited from ```ts Request.duplex ``` *** ### headers? ```ts optional headers: Headers; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:183 Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header. #### Inherited from ```ts Request.headers ``` *** ### integrity? ```ts optional integrity: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:186 Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. \[SRI] #### Inherited from ```ts Request.integrity ``` *** ### keepalive? ```ts optional keepalive: boolean; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:189 Returns a boolean indicating whether or not request can outlive the global in which it was created. #### Inherited from ```ts Request.keepalive ``` *** ### method? ```ts optional method: HTTPMethod; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:192 Returns request's HTTP method, which is "GET" by default. #### Inherited from ```ts Request.method ``` *** ### mode? ```ts optional mode: RequestMode; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:198 Returns the mode associated with request, which is a string indicating whether the request will use CORS, or will be restricted to same-origin URLs. `no-cors` is not allowed for streaming request bodies. #### Inherited from ```ts Request.mode ``` *** ### op? ```ts optional op: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:246 *** ### options? ```ts optional options: Record; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:269 options specifically intended for handlers to utilize to process the request *** ### records? ```ts optional records: StableRecordIdentifier[]; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:253 The identifiers of the primary resources involved in the request (if any). This may be used by handlers to perform transactional operations on the store. *** ### redirect? ```ts optional redirect: RequestRedirect; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:201 Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default. #### Inherited from ```ts Request.redirect ``` *** ### referrer? ```ts optional referrer: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:204 Returns the referrer of request. Its value can be a same-origin URL if explicitly set in init, the empty string to indicate no referrer, and "about:client" when defaulting to the global's default. This is used during fetching to determine the value of the `Referer` header of the request being made. #### Inherited from ```ts Request.referrer ``` *** ### referrerPolicy? ```ts optional referrerPolicy: ReferrerPolicy; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:207 Returns the referrer policy associated with request. This is used during fetching to compute the value of the request's referrer. #### Inherited from ```ts Request.referrerPolicy ``` *** ### signal? ```ts optional signal: AbortSignal; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:210 Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler. #### Inherited from ```ts Request.signal ``` *** ### store? ```ts optional store: unknown; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:245 *** ### url? ```ts optional url: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:213 Returns the URL of request as a string. #### Inherited from ```ts Request.url ``` --- --- url: /api/@ember-data/request/index/interfaces/ResponseInfo.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [index](../index.md) / ResponseInfo Defined in: warp-drive-packages/core/declarations/types/request.d.ts:286 ## Properties ### headers ```ts readonly headers: ImmutableHeaders; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:287 *** ### ok ```ts readonly ok: boolean; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:288 *** ### redirected ```ts readonly redirected: boolean; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:289 *** ### status ```ts readonly status: number; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:290 *** ### statusText ```ts readonly statusText: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:291 *** ### type ```ts readonly type: ResponseType; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:292 *** ### url ```ts readonly url: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:293 --- --- url: /api/@ember-data/request/index/interfaces/StructuredDataDocument.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [index](../index.md) / StructuredDataDocument Defined in: warp-drive-packages/core/declarations/types/request.d.ts:148 ## Type Parameters ### T `T` ## Properties ### \_\_\_(unique) Symbol(DOC)? ```ts optional ___(unique) Symbol(DOC): true; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:149 *** ### content ```ts content: T; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:155 *** ### request ```ts request: ImmutableRequestInfo; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:153 #### See [ImmutableRequestInfo](../type-aliases/ImmutableRequestInfo.md) *** ### response ```ts response: null | Response | ResponseInfo; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:154 --- --- url: /api/@ember-data/request/index/type-aliases/Awaitable.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [index](../index.md) / Awaitable ```ts type Awaitable = object; ``` Defined in: warp-drive-packages/core/declarations/request/-private/promise-cache.d.ts:8 ## Type Parameters ### T `T` = `unknown` ### E `E` = `unknown` ## Properties ### catch() ```ts catch: (onRejected) => unknown; ``` Defined in: warp-drive-packages/core/declarations/request/-private/promise-cache.d.ts:10 #### Parameters ##### onRejected (`reason`) => `unknown` #### Returns `unknown` *** ### finally() ```ts finally: (onFinally) => unknown; ``` Defined in: warp-drive-packages/core/declarations/request/-private/promise-cache.d.ts:11 #### Parameters ##### onFinally () => `unknown` #### Returns `unknown` *** ### then() ```ts then: (onFulfilled, onRejected) => unknown; ``` Defined in: warp-drive-packages/core/declarations/request/-private/promise-cache.d.ts:9 #### Parameters ##### onFulfilled (`value`) => `unknown` ##### onRejected (`reason`) => `unknown` #### Returns `unknown` --- --- url: /api/@ember-data/request/index/interfaces/StructuredErrorDocument.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [index](../index.md) / StructuredErrorDocument Defined in: warp-drive-packages/core/declarations/types/request.d.ts:157 ## Extends * `Error` ## Type Parameters ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(DOC)? ```ts optional ___(unique) Symbol(DOC): true; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:158 *** ### cause? ```ts optional cause: unknown; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26 #### Inherited from ```ts Error.cause ``` *** ### content? ```ts optional content: T; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:162 *** ### error ```ts error: string | object; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:161 *** ### message ```ts message: string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1077 #### Inherited from ```ts Error.message ``` *** ### name ```ts name: string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 #### Inherited from ```ts Error.name ``` *** ### request ```ts request: ImmutableRequestInfo; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:159 *** ### response ```ts response: null | Response | ResponseInfo; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:160 *** ### stack? ```ts optional stack: string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1078 #### Inherited from ```ts Error.stack ``` --- --- url: /api/@ember-data/request/index/type-aliases/Deferred.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [index](../index.md) / Deferred ```ts type Deferred = object; ``` Defined in: warp-drive-packages/core/declarations/request/-private/types.d.ts:11 ## Type Parameters ### T `T` ## Properties ### promise ```ts promise: Promise; ``` Defined in: warp-drive-packages/core/declarations/request/-private/types.d.ts:14 ## Methods ### reject() ```ts reject(v): void; ``` Defined in: warp-drive-packages/core/declarations/request/-private/types.d.ts:13 #### Parameters ##### v `unknown` #### Returns `void` *** ### resolve() ```ts resolve(v): void; ``` Defined in: warp-drive-packages/core/declarations/request/-private/types.d.ts:12 #### Parameters ##### v `T` #### Returns `void` --- --- url: /api/@ember-data/request/index/type-aliases/ImmutableRequestInfo.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [index](../index.md) / ImmutableRequestInfo ```ts type ImmutableRequestInfo = Readonly, "controller">> & object; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:277 Immutable version of [RequestInfo](../interfaces/RequestInfo.md). This is what is passed to handlers. ## Type declaration ### bodyUsed? ```ts readonly optional bodyUsed: boolean; ``` Whether the request body has been read. ### cacheOptions? ```ts readonly optional cacheOptions: Readonly>; ``` ### data? ```ts readonly optional data: Readonly>; ``` ### headers? ```ts readonly optional headers: ImmutableHeaders; ``` ### options? ```ts readonly optional options: Readonly>; ``` ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` --- --- url: /api/@ember-data/request/index/type-aliases/ManagedRequestPriority.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [index](../index.md) / ManagedRequestPriority ```ts type ManagedRequestPriority = object; ``` Defined in: warp-drive-packages/core/declarations/request/-private/types.d.ts:16 ## Properties ### blocking ```ts blocking: boolean; ``` Defined in: warp-drive-packages/core/declarations/request/-private/types.d.ts:17 --- --- url: /api/@ember-data/request/index/type-aliases/NextFn.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [index](../index.md) / NextFn ```ts type NextFn

= (req) => Future

; ``` Defined in: warp-drive-packages/core/declarations/request/-private/types.d.ts:84 ## Type Parameters ### P `P` = `unknown` ## Parameters ### req [`RequestInfo`](../interfaces/RequestInfo.md) ## Returns [`Future`](../interfaces/Future.md)<`P`> --- --- url: /api/@ember-data/request/index/type-aliases/StructuredDocument.md --- [Documentation](../../../../index.md) / [@ember-data/request](../../index.md) / [index](../index.md) / StructuredDocument ```ts type StructuredDocument = | StructuredDataDocument | StructuredErrorDocument; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:164 ## Type Parameters ### T `T` --- --- url: /api/@ember-data/rest/functions/createRecord.md --- [Documentation](../../../index.md) / [@ember-data/rest](../index.md) / createRecord ## Call Signature ```ts function createRecord(record, options?): CreateRequestOptions; ``` Defined in: save-record.d.ts:94 Builds request options to create new record for resources, configured for the url, method and header expectations of most REST APIs. **Basic Usage** ```ts import { createRecord } from '@warp-drive/utilities/rest'; const person = store.createRecord('person', { name: 'Ted' }); const data = await store.request(createRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { createRecord } from '@warp-drive/utilities/rest'; const person = store.createRecord('person', { name: 'Ted' }); const options = createRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### record `T` #### options? [`ConstrainedRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`CreateRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/CreateRequestOptions.md)<`T`> ## Call Signature ```ts function createRecord(record, options?): CreateRequestOptions; ``` Defined in: save-record.d.ts:95 Builds request options to create new record for resources, configured for the url, method and header expectations of most REST APIs. **Basic Usage** ```ts import { createRecord } from '@warp-drive/utilities/rest'; const person = store.createRecord('person', { name: 'Ted' }); const data = await store.request(createRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { createRecord } from '@warp-drive/utilities/rest'; const person = store.createRecord('person', { name: 'Ted' }); const options = createRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Parameters #### record `unknown` #### options? [`ConstrainedRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`CreateRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/CreateRequestOptions.md) --- --- url: /api/@ember-data/rest/functions/deleteRecord.md --- [Documentation](../../../index.md) / [@ember-data/rest](../index.md) / deleteRecord ## Call Signature ```ts function deleteRecord(record, options?): DeleteRequestOptions; ``` Defined in: save-record.d.ts:53 Builds request options to delete record for resources, configured for the url, method and header expectations of REST APIs. **Basic Usage** ```ts import { deleteRecord } from '@warp-drive/utilities/rest'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const data = await store.request(deleteRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { deleteRecord } from '@warp-drive/utilities/rest'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const options = deleteRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### record `T` #### options? [`ConstrainedRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`DeleteRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/DeleteRequestOptions.md)<`T`> ## Call Signature ```ts function deleteRecord(record, options?): DeleteRequestOptions; ``` Defined in: save-record.d.ts:54 Builds request options to delete record for resources, configured for the url, method and header expectations of REST APIs. **Basic Usage** ```ts import { deleteRecord } from '@warp-drive/utilities/rest'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const data = await store.request(deleteRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { deleteRecord } from '@warp-drive/utilities/rest'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const options = deleteRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Parameters #### record `unknown` #### options? [`ConstrainedRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`DeleteRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/DeleteRequestOptions.md) --- --- url: /api/@ember-data/rest/functions/findRecord.md --- [Documentation](../../../index.md) / [@ember-data/rest](../index.md) / findRecord ## Call Signature ```ts function findRecord(identifier, options?): FindRecordRequestOptions, T>; ``` Defined in: find-record.d.ts:62 ### Type Parameters #### T `T` ### Parameters #### identifier [`RemotelyAccessibleIdentifier`](../../../@warp-drive/core-types/request/type-aliases/RemotelyAccessibleIdentifier.md)<[`TypeFromInstance`](../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`>> #### options? [`FindRecordOptions`](../../../@warp-drive/core-types/request/type-aliases/FindRecordOptions.md)<`T`> ### Returns [`FindRecordRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/FindRecordRequestOptions.md)<`FindRecordResultDocument`<`T`>, `T`> ## Call Signature ```ts function findRecord(identifier, options?): FindRecordRequestOptions; ``` Defined in: find-record.d.ts:63 ### Parameters #### identifier [`RemotelyAccessibleIdentifier`](../../../@warp-drive/core-types/request/type-aliases/RemotelyAccessibleIdentifier.md) #### options? [`FindRecordOptions`](../../../@warp-drive/core-types/request/type-aliases/FindRecordOptions.md) ### Returns [`FindRecordRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/FindRecordRequestOptions.md) ## Call Signature ```ts function findRecord( type, id, options?): FindRecordRequestOptions, T>; ``` Defined in: find-record.d.ts:64 ### Type Parameters #### T `T` ### Parameters #### type [`TypeFromInstance`](../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> #### id `string` #### options? [`FindRecordOptions`](../../../@warp-drive/core-types/request/type-aliases/FindRecordOptions.md)<`T`> ### Returns [`FindRecordRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/FindRecordRequestOptions.md)<`FindRecordResultDocument`<`T`>, `T`> ## Call Signature ```ts function findRecord( type, id, options?): FindRecordRequestOptions; ``` Defined in: find-record.d.ts:65 ### Parameters #### type `string` #### id `string` #### options? [`FindRecordOptions`](../../../@warp-drive/core-types/request/type-aliases/FindRecordOptions.md) ### Returns [`FindRecordRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/FindRecordRequestOptions.md) --- --- url: /api/@ember-data/rest/functions/query.md --- [Documentation](../../../index.md) / [@ember-data/rest](../index.md) / query ## Call Signature ```ts function query( type, query?, options?): QueryRequestOptions, T>; ``` Defined in: query.d.ts:52 Builds request options to query for resources, usually by a primary type, configured for the url and header expectations of most REST APIs. **Basic Usage** ```ts import { query } from '@warp-drive/utilities/rest'; const data = await store.request(query('person')); ``` **With Query Params** ```ts import { query } from '@warp-drive/utilities/rest'; const options = query('person', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing and camelCasing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSettings` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { query } from '@warp-drive/utilities/rest'; const options = query('person', { include: ['pets', 'friends'] }, { reload: true }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### type [`TypeFromInstance`](../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> #### query? [`QueryParamsSource`](../../../@warp-drive/core-types/params/type-aliases/QueryParamsSource.md) #### options? [`ConstrainedRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`QueryRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/QueryRequestOptions.md)<[`CollectionResourceDataDocument`](../../../@warp-drive/core-types/spec/document/interfaces/CollectionResourceDataDocument.md)<`T`>, `T`> ## Call Signature ```ts function query( type, query?, options?): QueryRequestOptions; ``` Defined in: query.d.ts:53 Builds request options to query for resources, usually by a primary type, configured for the url and header expectations of most REST APIs. **Basic Usage** ```ts import { query } from '@warp-drive/utilities/rest'; const data = await store.request(query('person')); ``` **With Query Params** ```ts import { query } from '@warp-drive/utilities/rest'; const options = query('person', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing and camelCasing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSettings` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { query } from '@warp-drive/utilities/rest'; const options = query('person', { include: ['pets', 'friends'] }, { reload: true }); const data = await store.request(options); ``` ### Parameters #### type `string` #### query? [`QueryParamsSource`](../../../@warp-drive/core-types/params/type-aliases/QueryParamsSource.md) #### options? [`ConstrainedRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`QueryRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/QueryRequestOptions.md) --- --- url: /api/@ember-data/rest/functions/updateRecord.md --- [Documentation](../../../index.md) / [@ember-data/rest](../index.md) / updateRecord ## Call Signature ```ts function updateRecord(record, options?): UpdateRequestOptions>, T>; ``` Defined in: save-record.d.ts:138 Builds request options to update existing record for resources, configured for the url, method and header expectations of most REST APIs. **Basic Usage** ```ts import { updateRecord } from '@warp-drive/utilities/rest'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const data = await store.request(updateRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`. * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { updateRecord } from '@warp-drive/utilities/rest'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const options = updateRecord(person, { patch: true }); const data = await store.request(options); ``` ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../../../@warp-drive/core-types/record/interfaces/TypedRecordInstance.md) #### RT `RT` *extends* [`TypedRecordInstance`](../../../@warp-drive/core-types/record/interfaces/TypedRecordInstance.md) = `T` ### Parameters #### record `T` #### options? [`ConstrainedRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) & `object` ### Returns [`UpdateRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/UpdateRequestOptions.md)<[`SingleResourceDataDocument`](../../../@warp-drive/core-types/spec/document/interfaces/SingleResourceDataDocument.md)<`RT`, `StableExistingRecordIdentifier`<`string`>>, `T`> ## Call Signature ```ts function updateRecord(record, options?): UpdateRequestOptions; ``` Defined in: save-record.d.ts:141 Builds request options to update existing record for resources, configured for the url, method and header expectations of most REST APIs. **Basic Usage** ```ts import { updateRecord } from '@warp-drive/utilities/rest'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const data = await store.request(updateRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`. * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { updateRecord } from '@warp-drive/utilities/rest'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const options = updateRecord(person, { patch: true }); const data = await store.request(options); ``` ### Parameters #### record `unknown` #### options? [`ConstrainedRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md) & `object` ### Returns [`UpdateRequestOptions`](../../../@warp-drive/core-types/request/type-aliases/UpdateRequestOptions.md) --- --- url: /api/@ember-data/rest.md --- [Documentation](../../index.md) / @ember-data/rest This package provides utilities for working with **REST**ful APIs with [*Ember***Data**](https://github.com/emberjs/data/). ## Installation Install using your javascript package manager of choice. For instance with [pnpm](https://pnpm.io/) ```no-highlight pnpm add @ember-data/json-api ``` ## Usage Request builders are functions that produce [Fetch Options](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). They take a few contextual inputs about the request you want to make, abstracting away the gnarlier details. For instance, to fetch a resource from your API ```ts import { findRecord } from '@ember-data/rest/request'; const options = findRecord('ember-developer', '1', { include: ['pets', 'friends'] }); /* => { url: 'https://api.example.com/v1/emberDevelopers/1?include=friends,pets', method: 'GET', headers: , // 'Content-Type': 'application/json;charset=utf-8' op: 'findRecord'; records: [{ type: 'ember-developer', id: '1' }] } / ``` Request builder output is ready to go for use with [store.request](https://api.emberjs.com/ember-data/release/classes/Store/methods/request?anchor=request), [manager.request](https://api.emberjs.com/ember-data/release/classes/RequestManager/methods/request?anchor=request) and most conventional REST APIs. Resource types are pluralized and camelized for the url. URLs are stable. The same query will produce the same URL every time, even if the order of keys in the query or values in an array changes. URLs follow the most common REST format (camelCase pluralized resource types). ### Available Builders * [createRecord](https://api.emberjs.com/ember-data/release/functions/@ember-data%2Frest/createRecord) * [deleteRecord](https://api.emberjs.com/ember-data/release/functions/@ember-data%2Frest/deleteRecord) * [findRecord](https://api.emberjs.com/ember-data/release/functions/@ember-data%2Frest/findRecord) * [query](https://api.emberjs.com/ember-data/release/functions/@ember-data%2Frest/query) * [updateRecord](https://api.emberjs.com/ember-data/release/functions/@ember-data%2Frest/updateRecord) ## Functions * [createRecord](functions/createRecord.md) * [deleteRecord](functions/deleteRecord.md) * [findRecord](functions/findRecord.md) * [query](functions/query.md) * [updateRecord](functions/updateRecord.md) --- --- url: /api/@ember-data/serializer.md --- [Documentation](../../index.md) / @ember-data/serializer ## Modules * [index](index/index.md) * [json](json/index.md) * [json-api](json-api/index.md) * [rest](rest/index.md) * [transform](transform/index.md) --- --- url: /api/@ember-data/serializer/index/classes/default.md --- [Documentation](../../../../index.md) / [@ember-data/serializer](../../index.md) / [index](../index.md) / default Defined in: warp-drive-packages/legacy/declarations/serializer.d.ts:133 > ⚠️ CAUTION you likely want the docs for MinimumSerializerInterface > as extending this abstract class is unnecessary. `Serializer` is an abstract base class that you may override in your application to customize it for your backend. The minimum set of methods that you should implement is: * `normalizeResponse()` * `serialize()` And you can optionally override the following methods: * `normalize()` For an example implementation, see [JSONSerializer](JSONSerializer), the included JSON serializer. Serializer ## Extends * `unknown` ## Constructors ### Constructor ```ts new default(): Serializer; ``` #### Returns `Serializer` #### Inherited from ```ts EmberObject.constructor ``` ## Properties ### store ```ts store: default; ``` Defined in: warp-drive-packages/legacy/declarations/serializer.d.ts:134 ## Methods ### normalize() ```ts normalize(_typeClass, hash): | SingleResourceDocument | EmptyResourceDocument; ``` Defined in: warp-drive-packages/legacy/declarations/serializer.d.ts:256 The `normalize` method is used to convert a payload received from your external data source into the normalized form `store.push()` expects. You should override this method, munge the hash and return the normalized payload. Example: ```js Serializer.extend({ normalize(modelClass, resourceHash) { let data = { id: resourceHash.id, type: modelClass.modelName, attributes: resourceHash }; return { data: data }; } }) ``` #### Parameters ##### \_typeClass [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### hash `Record`<`string`, `unknown`> #### Returns | [`SingleResourceDocument`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md) | [`EmptyResourceDocument`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/EmptyResourceDocument.md) --- --- url: /api/@ember-data/serializer/index.md --- [Documentation](../../../index.md) / [@ember-data/serializer](../index.md) / index ## Overview In order to properly manage and present your data, EmberData needs to understand the structure of data it receives. `Serializers` convert data between the server's API format and the format EmberData understands. Data received from an API response is **normalized** into [JSON:API](https://jsonapi.org/) (the format used internally by EmberData), while data sent to an API is **serialized** into the format the API expects. ### Implementing a Serializer There are only two required serializer methods, one for normalizing data from the server API format into JSON:API, and another for serializing records via `Snapshots` into the expected server API format. To implement a serializer, export a class that conforms to the structure described by MinimumSerializerInterface from the `app/serializers/` directory. An example is below. ```ts import EmberObject from '@ember/object'; export default class ApplicationSerializer extends EmberObject { normalizeResponse(store, schema, rawPayload) { return rawPayload; } serialize(snapshot, options) { const serializedResource = { id: snapshot.id, type: snapshot.modelName, attributes: snapshot.attributes() }; return serializedResource; } } ``` ### Serializer Resolution `store.serializerFor(name)` will lookup serializers defined in `app/serializers/` and return an instance. If no serializer is found, an error will be thrown. `serializerFor` first attempts to find a serializer with an exact match on `name`, then falls back to checking for the presence of a serializer named `application`. ```ts store.serializerFor('author'); // lookup paths (in order) => // app/serializers/author.js // app/serializers/application.js ``` Most requests in EmberData are made with respect to a particular `type` (or `modelName`) (e.g., "get me the full collection of **books**" or "get me the **employee** whose id is 37"). We refer to this as the **primary** resource `type`. Typically `serializerFor` will be used to find a serializer with a name matching that of the primary resource `type` for the request, falling back to the `application` serializer for those types that do not have a defined serializer. This is often described as a `per-model` or `per-type` strategy for defining serializers. However, because APIs rarely format payloads per-type but rather per-API-version, this may not be a desired strategy. It is recommended that applications define only a single `application` adapter and serializer where possible. If you have multiple API formats and the per-type strategy is not viable, one strategy is to write an `application` adapter and serializer that make use of `options` to specify the desired format when making a request. ### Using a Serializer Any serializer in `app/serializers/` can be looked up by `name` using `store.serializerFor(name)`. ### Default Serializers For applications whose APIs are *very close to* or *exactly* the **REST** format or **JSON:API** format the `@ember-data/serializer` package contains implementations these applications can extend. It also contains a simple `JSONSerializer` for serializing to/from very basic JSON objects. Many applications will find writing their own serializer to be more performant and less complex than extending these classes even when their API format is very close to that expected by these serializers. It is recommended that apps write their own serializer to best suit the needs of their API and application. ## Classes * [default](classes/default.md) --- --- url: /api/@ember-data/serializer/json-api/classes/default.md --- [Documentation](../../../../index.md) / [@ember-data/serializer](../../index.md) / [json-api](../index.md) / default Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:124 In EmberData a Serializer is used to serialize and deserialize records when they are transferred in and out of an external source. This process involves normalizing property names, transforming attribute values and serializing relationships. `JSONAPISerializer` supports the http://jsonapi.org/ spec and is the serializer recommended by Ember Data. This serializer normalizes a JSON API payload that looks like: ```js [app/models/player.js] import Model, { attr, belongsTo } from '@ember-data/model'; export default class Player extends Model { @attr('string') name; @attr('string') skill; @attr('number') gamesPlayed; @belongsTo('club') club; } ``` ```js [app/models/club.js] import Model, { attr, hasMany } from '@ember-data/model'; export default class Club extends Model { @attr('string') name; @attr('string') location; @hasMany('player') players; } ``` ```js { "data": [ { "attributes": { "name": "Benfica", "location": "Portugal" }, "id": "1", "relationships": { "players": { "data": [ { "id": "3", "type": "players" } ] } }, "type": "clubs" } ], "included": [ { "attributes": { "name": "Eusebio Silva Ferreira", "skill": "Rocket shot", "games-played": 431 }, "id": "3", "relationships": { "club": { "data": { "id": "1", "type": "clubs" } } }, "type": "players" } ] } ``` to the format that the Ember Data store expects. ### Customizing meta Since a JSON API Document can have meta defined in multiple locations you can use the specific serializer hooks if you need to customize the meta. One scenario would be to camelCase the meta keys of your payload. The example below shows how this could be done using `normalizeArrayResponse` and `extractRelationship`. ```js [app/serializers/application.js] import JSONAPISerializer from '@ember-data/serializer/json-api'; export default class ApplicationSerializer extends JSONAPISerializer { normalizeArrayResponse(store, primaryModelClass, payload, id, requestType) { let normalizedDocument = super.normalizeArrayResponse(...arguments); // Customize document meta normalizedDocument.meta = camelCaseKeys(normalizedDocument.meta); return normalizedDocument; } extractRelationship(relationshipHash) { let normalizedRelationship = super.extractRelationship(...arguments); // Customize relationship meta normalizedRelationship.meta = camelCaseKeys(normalizedRelationship.meta); return normalizedRelationship; } } ``` ## Since 1.13.0 JSONAPISerializer ## Constructors ### Constructor ```ts new default(owner?): default; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:168 #### Parameters ##### owner? `any` #### Returns `default` ## Properties ### store ```ts store: default; ``` Defined in: warp-drive-packages/legacy/declarations/serializer.d.ts:134 *** ### mergedProperties ```ts readonly static mergedProperties: any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:126 *** ### primaryKey ```ts readonly static primaryKey: string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:125 ## Methods ### normalize() ```ts normalize(_typeClass, hash): | SingleResourceDocument | EmptyResourceDocument; ``` Defined in: warp-drive-packages/legacy/declarations/serializer.d.ts:256 The `normalize` method is used to convert a payload received from your external data source into the normalized form `store.push()` expects. You should override this method, munge the hash and return the normalized payload. Example: ```js Serializer.extend({ normalize(modelClass, resourceHash) { let data = { id: resourceHash.id, type: modelClass.modelName, attributes: resourceHash }; return { data: data }; } }) ``` #### Parameters ##### \_typeClass [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### hash `Record`<`string`, `unknown`> #### Returns | [`SingleResourceDocument`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md) | [`EmptyResourceDocument`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/EmptyResourceDocument.md) *** ### \_canSerialize() ```ts readonly static _canSerialize(key): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:153 #### Parameters ##### key `string` #### Returns `boolean` *** ### \_getMappedKey() ```ts readonly static _getMappedKey(key, modelClass): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:152 #### Parameters ##### key `string` ##### modelClass `any` #### Returns `string` *** ### \_mustSerialize() ```ts readonly static _mustSerialize(key): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:154 #### Parameters ##### key `string` #### Returns `boolean` *** ### \_normalizeResponse() ```ts static _normalizeResponse( store, primaryModelClass, payload, id, requestType, isSingle): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:142 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### isSingle `boolean` #### Returns `any` *** ### applyTransforms() ```ts readonly static applyTransforms(typeClass, data): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:127 #### Parameters ##### typeClass `Model` ##### data `any` #### Returns `any` *** ### extractAttributes() #### Call Signature ```ts static extractAttributes(modelClass, resourceHash): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:145 ##### Parameters ###### modelClass `any` ###### resourceHash `any` ##### Returns `any` #### Call Signature ```ts static extractAttributes(modelClass, resourceHash): object; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:207 ##### Parameters ###### modelClass `any` ###### resourceHash `any` ##### Returns `object` *** ### extractErrors() ```ts readonly static extractErrors( store, typeClass, payload, id): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:163 #### Parameters ##### store `Store` ##### typeClass `Model` ##### payload `any` ##### id `string` | `number` #### Returns `any` *** ### extractId() ```ts readonly static extractId(modelClass, resourceHash): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:144 #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `string` *** ### extractMeta() ```ts readonly static extractMeta( store, modelClass, payload): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:162 #### Parameters ##### store `Store` ##### modelClass `Model` ##### payload `any` #### Returns `any` *** ### extractPolymorphicRelationship() ```ts readonly static extractPolymorphicRelationship( relationshipModelName, relationshipHash, relationshipOptions): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:147 #### Parameters ##### relationshipModelName `any` ##### relationshipHash `any` ##### relationshipOptions `any` #### Returns `any` *** ### extractRelationship() #### Call Signature ```ts static extractRelationship(relationshipModelName, relationshipHash): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:146 ##### Parameters ###### relationshipModelName `any` ###### relationshipHash `any` ##### Returns `any` #### Call Signature ```ts static extractRelationship(relationshipHash): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:217 Returns a relationship formatted as a JSON-API "relationship object". http://jsonapi.org/format/#document-resource-object-relationships ##### Parameters ###### relationshipHash `any` ##### Returns `any` *** ### extractRelationships() ```ts static extractRelationships(modelClass, resourceHash): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:148 #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `any` *** ### keyForAttribute() ```ts static keyForAttribute(key, method): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:164 #### Parameters ##### key `string` ##### method `string` #### Returns `string` *** ### keyForLink() ```ts readonly static keyForLink(key, kind): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:166 #### Parameters ##### key `string` ##### kind `string` #### Returns `string` *** ### keyForRelationship() ```ts static keyForRelationship( key, typeClass, method): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:165 #### Parameters ##### key `string` ##### typeClass `string` ##### method `string` #### Returns `string` *** ### modelNameFromPayloadKey() ```ts static modelNameFromPayloadKey(key): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:149 #### Parameters ##### key `string` #### Returns `string` *** ### normalize() #### Call Signature ```ts static normalize(modelClass, resourceHash): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:143 ##### Parameters ###### modelClass `any` ###### resourceHash `any` ##### Returns `any` #### Call Signature ```ts static normalize(modelClass, resourceHash): object; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:259 ##### Parameters ###### modelClass `any` ###### resourceHash `any` ##### Returns `object` ###### data ```ts data: object; ``` ###### data.attributes ```ts data.attributes: object; ``` ###### data.id ```ts data.id: any; ``` ###### data.relationships ```ts data.relationships: any; ``` ###### data.type ```ts data.type: string; ``` *** ### normalizeArrayResponse() ```ts readonly static normalizeArrayResponse( store, primaryModelClass, payload, id, requestType): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:141 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` #### Returns `any` *** ### normalizeCreateRecordResponse() ```ts readonly static normalizeCreateRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:136 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeDeleteRecordResponse() ```ts readonly static normalizeDeleteRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:137 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeFindAllResponse() ```ts readonly static normalizeFindAllResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:131 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeFindBelongsToResponse() ```ts readonly static normalizeFindBelongsToResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:132 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeFindHasManyResponse() ```ts readonly static normalizeFindHasManyResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:133 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeFindManyResponse() ```ts readonly static normalizeFindManyResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:134 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeFindRecordResponse() ```ts readonly static normalizeFindRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:129 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeQueryRecordResponse() #### Call Signature ```ts static normalizeQueryRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:130 ##### Parameters ###### store `Store` ###### primaryModelClass `Model` ###### payload `any` ###### id `string` | `number` ###### requestType `string` ###### args ...`any`\[] ##### Returns `any` #### Call Signature ```ts static normalizeQueryRecordResponse(...args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:206 ##### Parameters ###### args ...`any`\[] ##### Returns `any` *** ### normalizeQueryResponse() ```ts readonly static normalizeQueryResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:135 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeRelationships() ```ts readonly static normalizeRelationships(typeClass, hash): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:150 #### Parameters ##### typeClass `any` ##### hash `any` #### Returns `void` *** ### normalizeResponse() ```ts readonly static normalizeResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:128 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeSaveResponse() ```ts readonly static normalizeSaveResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:139 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeSingleResponse() ```ts readonly static normalizeSingleResponse( store, primaryModelClass, payload, id, requestType): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:140 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` #### Returns `any` *** ### normalizeUpdateRecordResponse() ```ts readonly static normalizeUpdateRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:138 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeUsingDeclaredMapping() ```ts readonly static normalizeUsingDeclaredMapping(modelClass, hash): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:151 #### Parameters ##### modelClass `any` ##### hash `any` #### Returns `void` *** ### payloadKeyFromModelName() ```ts static payloadKeyFromModelName(modelName): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:258 Converts the model name to a pluralized version of the model name. For example `post` would be converted to `posts` and `student-assesment` would be converted to `student-assesments`. #### Parameters ##### modelName `string` #### Returns `string` *** ### pushPayload() ```ts static pushPayload(store, payload): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:194 Normalize some data and push it into the store. #### Parameters ##### store `Store` ##### payload `any` #### Returns `void` *** ### serialize() #### Call Signature ```ts static serialize(snapshot, options): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:156 ##### Parameters ###### snapshot `Snapshot` ###### options `any` ##### Returns `any` #### Call Signature ```ts static serialize( snapshot, options, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:491 Called when a record is saved in order to convert the record into JSON. For example, consider this model: ```js [app/models/comment.js] import Model, { attr, belongsTo } from '@ember-data/model'; export default class CommentModel extends Model { @attr title; @attr body; @belongsTo('user', { async: false, inverse: null }) author; } ``` The default serialization would create a JSON-API resource object like: ```javascript { "data": { "type": "comments", "attributes": { "title": "Rails is unagi", "body": "Rails? Omakase? O_O", }, "relationships": { "author": { "data": { "id": "12", "type": "users" } } } } } ``` By default, attributes are passed through as-is, unless you specified an attribute type (`attr('date')`). If you specify a transform, the JavaScript value will be serialized when inserted into the attributes hash. Belongs-to relationships are converted into JSON-API resource identifier objects. ## IDs `serialize` takes an options hash with a single option: `includeId`. If this option is `true`, `serialize` will, by default include the ID in the JSON object it builds. The JSONAPIAdapter passes in `includeId: true` when serializing a record for `createRecord` or `updateRecord`. ## Customization Your server may expect data in a different format than the built-in serialization format. In that case, you can implement `serialize` yourself and return data formatted to match your API's expectations, or override the invoked adapter method and do the serialization in the adapter directly by using the provided snapshot. If your API's format differs greatly from the JSON:API spec, you should consider authoring your own adapter and serializer instead of extending this class. ```js [app/serializers/post.js] import JSONAPISerializer from '@ember-data/serializer/json-api'; export default class PostSerializer extends JSONAPISerializer { serialize(snapshot, options) { let json = { POST_TTL: snapshot.attr('title'), POST_BDY: snapshot.attr('body'), POST_CMS: snapshot.hasMany('comments', { ids: true }) }; if (options.includeId) { json.POST_ID_ = snapshot.id; } return json; } } ``` ## Customizing an App-Wide Serializer If you want to define a serializer for your entire application, you'll probably want to use `eachAttribute` and `eachRelationship` on the record. ```js [app/serializers/application.js] import JSONAPISerializer from '@ember-data/serializer/json-api'; import { underscore, singularize } from '/utils/string-utils'; export default class ApplicationSerializer extends JSONAPISerializer { serialize(snapshot, options) { let json = {}; snapshot.eachAttribute((name) => { json[serverAttributeName(name)] = snapshot.attr(name); }); snapshot.eachRelationship((name, relationship) => { if (relationship.kind === 'hasMany') { json[serverHasManyName(name)] = snapshot.hasMany(name, { ids: true }); } }); if (options.includeId) { json.ID_ = snapshot.id; } return json; } } function serverAttributeName(attribute) { return underscore(attribute).toUpperCase(); } function serverHasManyName(name) { return serverAttributeName(singularize(name)) + '_IDS'; } ``` This serializer will generate JSON that looks like this: ```javascript { "TITLE": "Rails is omakase", "BODY": "Yep. Omakase.", "COMMENT_IDS": [ "1", "2", "3" ] } ``` ## Tweaking the Default Formatting If you just want to do some small tweaks on the default JSON:API formatted response, you can call `super.serialize` first and make the tweaks on the returned object. ```js [app/serializers/post.js] import JSONAPISerializer from '@ember-data/serializer/json-api'; export default class PostSerializer extends JSONAPISerializer { serialize(snapshot, options) { let json = super.serialize(...arguments); json.data.attributes.subject = json.data.attributes.title; delete json.data.attributes.title; return json; } } ``` ##### Parameters ###### snapshot `Snapshot` ###### options `any` ###### args ...`any`\[] ##### Returns `any` json *** ### serializeAttribute() #### Call Signature ```ts static serializeAttribute( snapshot, json, key, attribute): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:158 ##### Parameters ###### snapshot `Snapshot` ###### json `any` ###### key `string` ###### attribute `any` ##### Returns `void` #### Call Signature ```ts static serializeAttribute( snapshot, json, key, attribute): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:492 ##### Parameters ###### snapshot `any` ###### json `any` ###### key `any` ###### attribute `any` ##### Returns `void` *** ### serializeBelongsTo() ```ts static serializeBelongsTo( snapshot, json, relationship): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:159 #### Parameters ##### snapshot `Snapshot` ##### json `any` ##### relationship `any` #### Returns `void` *** ### serializeHasMany() ```ts static serializeHasMany( snapshot, json, relationship): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:160 #### Parameters ##### snapshot `Snapshot` ##### json `any` ##### relationship `any` #### Returns `void` *** ### serializeIntoHash() ```ts readonly static serializeIntoHash( hash, typeClass, snapshot, options): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:157 #### Parameters ##### hash `any` ##### typeClass `Model` ##### snapshot `Snapshot` ##### options `any` #### Returns `void` *** ### serializePolymorphicType() ```ts readonly static serializePolymorphicType(): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:161 #### Returns `void` *** ### shouldSerializeHasMany() ```ts readonly static shouldSerializeHasMany( snapshot, key, relationship): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:155 #### Parameters ##### snapshot `Snapshot` ##### key `string` ##### relationship `RelationshipSchema` #### Returns `boolean` *** ### transformFor() ```ts readonly static transformFor(attributeType, skipAssertion): Transform; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json-api.d.ts:167 #### Parameters ##### attributeType `string` ##### skipAssertion `boolean` #### Returns `Transform` --- --- url: /api/@ember-data/serializer/json-api.md --- [Documentation](../../../index.md) / [@ember-data/serializer](../index.md) / json-api ## Classes * [default](classes/default.md) --- --- url: /api/@ember-data/serializer/json.md --- [Documentation](../../../index.md) / [@ember-data/serializer](../index.md) / json ## Classes * [default](classes/default.md) --- --- url: /api/@ember-data/serializer/json/classes/default.md --- [Documentation](../../../../index.md) / [@ember-data/serializer](../../index.md) / [json](../index.md) / default Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:76 In EmberData a Serializer is used to serialize and deserialize records when they are transferred in and out of an external source. This process involves normalizing property names, transforming attribute values and serializing relationships. By default, EmberData uses and recommends the `JSONAPISerializer`. `JSONSerializer` is useful for simpler or legacy backends that may not support the http://jsonapi.org/ spec. For example, given the following `User` model and JSON payload: ```js [app/models/user.js] import Model, { attr, belongsTo, hasMany } from '@ember-data/model'; export default class UserModel extends Model { @hasMany('user') friends; @belongsTo('location') house; @attr('string') name; } ``` ```js { id: 1, name: 'Sebastian', friends: [3, 4], links: { house: '/houses/lefkada' } } ``` `JSONSerializer` will normalize the JSON payload to the JSON API format that the Ember Data store expects. You can customize how JSONSerializer processes its payload by passing options in the `attrs` hash or by subclassing the `JSONSerializer` and overriding hooks: * To customize how a single record is normalized, use the `normalize` hook. * To customize how `JSONSerializer` normalizes the whole server response, use the `normalizeResponse` hook. * To customize how `JSONSerializer` normalizes a specific response from the server, use one of the many specific `normalizeResponse` hooks. * To customize how `JSONSerializer` normalizes your id, attributes or relationships, use the `extractId`, `extractAttributes` and `extractRelationships` hooks. The `JSONSerializer` normalization process follows these steps: 1. `normalizeResponse` * entry method to the serializer. 2. `normalizeCreateRecordResponse` * a `normalizeResponse` for a specific operation is called. 3. `normalizeSingleResponse`|`normalizeArrayResponse` * for methods like `createRecord` we expect a single record back, while for methods like `findAll` we expect multiple records back. 4. `normalize` * `normalizeArrayResponse` iterates and calls `normalize` for each of its records while `normalizeSingle` calls it once. This is the method you most likely want to subclass. 5. `extractId` | `extractAttributes` | `extractRelationships` * `normalize` delegates to these methods to turn the record payload into the JSON API format. JSONSerializer ## Constructors ### Constructor ```ts new default(owner?): default; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:76 #### Parameters ##### owner? `any` #### Returns `default` ## Properties ### store ```ts store: default; ``` Defined in: warp-drive-packages/legacy/declarations/serializer.d.ts:134 *** ### mergedProperties ```ts static mergedProperties: any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:168 The `attrs` object can be used to declare a simple mapping between property names on `Model` records and payload keys in the serialized JSON object representing the record. An object with the property `key` can also be used to designate the attribute's key on the response payload. Example ```js [app/models/person.js] import Model, { attr } from '@ember-data/model'; export default class PersonModel extends Model { @attr('string') firstName; @attr('string') lastName; @attr('string') occupation; @attr('boolean') admin; } ``` ```js [app/serializers/person.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PersonSerializer extends JSONSerializer { attrs = { admin: 'is_admin', occupation: { key: 'career' } } } ``` You can also remove attributes and relationships by setting the `serialize` key to `false` in your mapping object. Example ```js [app/serializers/person.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { attrs = { admin: { serialize: false }, occupation: { key: 'career' } } } ``` When serialized: ```javascript { "firstName": "Harry", "lastName": "Houdini", "career": "magician" } ``` Note that the `admin` is now not included in the payload. Setting `serialize` to `true` enforces serialization for hasMany relationships even if it's neither a many-to-many nor many-to-none relationship. *** ### primaryKey ```ts static primaryKey: string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:100 The `primaryKey` is used when serializing and deserializing data. Ember Data always uses the `id` property to store the id of the record. The external source may not always follow this convention. In these cases it is useful to override the `primaryKey` property to match the `primaryKey` of your external store. Example ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class ApplicationSerializer extends JSONSerializer { primaryKey = '_id' } ``` #### Default ```ts 'id' ``` ## Methods ### normalize() ```ts normalize(_typeClass, hash): | SingleResourceDocument | EmptyResourceDocument; ``` Defined in: warp-drive-packages/legacy/declarations/serializer.d.ts:256 The `normalize` method is used to convert a payload received from your external data source into the normalized form `store.push()` expects. You should override this method, munge the hash and return the normalized payload. Example: ```js Serializer.extend({ normalize(modelClass, resourceHash) { let data = { id: resourceHash.id, type: modelClass.modelName, attributes: resourceHash }; return { data: data }; } }) ``` #### Parameters ##### \_typeClass [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### hash `Record`<`string`, `unknown`> #### Returns | [`SingleResourceDocument`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md) | [`EmptyResourceDocument`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/EmptyResourceDocument.md) *** ### extractAttributes() ```ts static extractAttributes(modelClass, resourceHash): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:472 Returns the resource's attributes formatted as a JSON-API "attributes object". http://jsonapi.org/format/#document-resource-object-attributes #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `any` *** ### extractErrors() ```ts static extractErrors( store, typeClass, payload, id): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:979 `extractErrors` is used to extract model errors when a call to `Model#save` fails with an `InvalidError`. By default Ember Data expects error information to be located on the `errors` property of the payload object. This serializer expects this `errors` object to be an Array similar to the following, compliant with the https://jsonapi.org/format/#errors specification: ```js { "errors": [ { "detail": "This username is already taken!", "source": { "pointer": "data/attributes/username" } }, { "detail": "Doesn't look like a valid email.", "source": { "pointer": "data/attributes/email" } } ] } ``` The key `detail` provides a textual description of the problem. Alternatively, the key `title` can be used for the same purpose. The nested keys `source.pointer` detail which specific element of the request data was invalid. Note that JSON-API also allows for object-level errors to be placed in an object with pointer `data`, signifying that the problem cannot be traced to a specific attribute: ```javascript { "errors": [ { "detail": "Some generic non property error message", "source": { "pointer": "data" } } ] } ``` When turn into a `Errors` object, you can read these errors through the property `base`: ```handlebars {{#each @model.errors.base as |error|}}

{{error.message}}
{{/each}} ``` Example of alternative implementation, overriding the default behavior to deal with a different format of errors: ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { extractErrors(store, typeClass, payload, id) { if (payload && typeof payload === 'object' && payload._problems) { payload = payload._problems; this.normalizeErrors(typeClass, payload); } return payload; } } ``` #### Parameters ##### store `Store` ##### typeClass `Model` ##### payload `any` ##### id `string` | `number` #### Returns `any` json The deserialized errors *** ### extractId() ```ts static extractId(modelClass, resourceHash): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:461 Returns the resource's ID. #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `string` *** ### extractMeta() ```ts static extractMeta( store, modelClass, payload): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:893 `extractMeta` is used to deserialize any meta information in the adapter payload. By default Ember Data expects meta information to be located on the `meta` property of the payload object. Example ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { extractMeta(store, typeClass, payload) { if (payload && payload.hasOwnProperty('_pagination')) { let meta = payload._pagination; delete payload._pagination; return meta; } } } ``` #### Parameters ##### store `Store` ##### modelClass `Model` ##### payload `any` #### Returns `any` *** ### extractPolymorphicRelationship() ```ts static extractPolymorphicRelationship( relationshipModelName, relationshipHash, relationshipOptions): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:503 Returns a polymorphic relationship formatted as a JSON-API "relationship object". http://jsonapi.org/format/#document-resource-object-relationships `relationshipOptions` is a hash which contains more information about the polymorphic relationship which should be extracted: * `resourceHash` complete hash of the resource the relationship should be extracted from * `relationshipKey` key under which the value for the relationship is extracted from the resourceHash * `relationshipMeta` meta information about the relationship #### Parameters ##### relationshipModelName `any` ##### relationshipHash `any` ##### relationshipOptions `any` #### Returns `any` *** ### extractRelationship() ```ts static extractRelationship(relationshipModelName, relationshipHash): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:483 Returns a relationship formatted as a JSON-API "relationship object". http://jsonapi.org/format/#document-resource-object-relationships #### Parameters ##### relationshipModelName `any` ##### relationshipHash `any` #### Returns `any` *** ### extractRelationships() ```ts static extractRelationships(modelClass, resourceHash): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:514 Returns the resource's relationships formatted as a JSON-API "relationships object". http://jsonapi.org/format/#document-resource-object-relationships #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `any` *** ### keyForAttribute() ```ts static keyForAttribute(key, method): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:1002 `keyForAttribute` can be used to define rules for how to convert an attribute name in your model to a key in your JSON. Example ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; import { underscore } from '/utils/string-utils'; export default class ApplicationSerializer extends JSONSerializer { keyForAttribute(attr, method) { return underscore(attr).toUpperCase(); } } ``` #### Parameters ##### key `string` ##### method `string` #### Returns `string` normalized key *** ### keyForLink() ```ts static keyForLink(key, kind): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:1037 `keyForLink` can be used to define a custom key when deserializing link properties. #### Parameters ##### key `string` ##### kind `string` `belongsTo` or `hasMany` #### Returns `string` normalized key *** ### keyForRelationship() ```ts static keyForRelationship( key, typeClass, method): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:1027 `keyForRelationship` can be used to define a custom key when serializing and deserializing relationship properties. By default `JSONSerializer` does not provide an implementation of this method. Example ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; import { underscore } from '/utils/string-utils'; export default class PostSerializer extends JSONSerializer { keyForRelationship(key, relationship, method) { return `rel_${underscore(key)}`; } } ``` #### Parameters ##### key `string` ##### typeClass `string` ##### method `string` #### Returns `string` normalized key *** ### modelNameFromPayloadKey() ```ts static modelNameFromPayloadKey(key): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:522 Dasherizes the model name in the payload #### Parameters ##### key `string` #### Returns `string` the model's modelName *** ### normalize() ```ts static normalize(modelClass, resourceHash): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:452 Normalizes a part of the JSON payload returned by the server. You should override this method, munge the hash and call super if you have generic normalization to do. It takes the type of the record that is being normalized (as a Model class), the property where the hash was originally found, and the hash to normalize. You can use this method, for example, to normalize underscored keys to camelized or other general-purpose normalizations. Example ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; import { underscore } from '/utils/string-utils'; import { get } from '@ember/object'; export default class ApplicationSerializer extends JSONSerializer { normalize(typeClass, hash) { let fields = typeClass.fields; fields.forEach(function(type, field) { let payloadField = underscore(field); if (field === payloadField) { return; } hash[field] = hash[payloadField]; delete hash[payloadField]; }); return super.normalize(...arguments); } } ``` #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `any` *** ### normalizeArrayResponse() ```ts static normalizeArrayResponse( store, primaryModelClass, payload, id, requestType): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:399 normalizeQueryResponse, normalizeFindManyResponse, and normalizeFindHasManyResponse delegate to this method by default. #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeCreateRecordResponse() ```ts static normalizeCreateRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:329 Called by the default normalizeResponse implementation when the type of request is `createRecord` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeDeleteRecordResponse() ```ts static normalizeDeleteRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:343 Called by the default normalizeResponse implementation when the type of request is `deleteRecord` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindAllResponse() ```ts static normalizeFindAllResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:259 Called by the default normalizeResponse implementation when the type of request is `findAll` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindBelongsToResponse() ```ts static normalizeFindBelongsToResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:273 Called by the default normalizeResponse implementation when the type of request is `findBelongsTo` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindHasManyResponse() ```ts static normalizeFindHasManyResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:287 Called by the default normalizeResponse implementation when the type of request is `findHasMany` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindManyResponse() ```ts static normalizeFindManyResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:301 Called by the default normalizeResponse implementation when the type of request is `findMany` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindRecordResponse() ```ts static normalizeFindRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:231 Called by the default normalizeResponse implementation when the type of request is `findRecord` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeQueryRecordResponse() ```ts static normalizeQueryRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:245 Called by the default normalizeResponse implementation when the type of request is `queryRecord` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeQueryResponse() ```ts static normalizeQueryResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:315 Called by the default normalizeResponse implementation when the type of request is `query` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeResponse() ```ts static normalizeResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:217 The `normalizeResponse` method is used to normalize a payload from the server to a JSON-API Document. http://jsonapi.org/format/#document-structure This method delegates to a more specific normalize method based on the `requestType`. To override this method with a custom one, make sure to call `return super.normalizeResponse(store, primaryModelClass, payload, id, requestType)` with your pre-processed data. Here's an example of using `normalizeResponse` manually: ```javascript socket.on('message', function(message) { let data = message.data; let modelClass = store.modelFor(data.modelName); let serializer = store.serializerFor(data.modelName); let normalized = serializer.normalizeSingleResponse(store, modelClass, data, data.id); store.push(normalized); }); ``` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeSaveResponse() ```ts static normalizeSaveResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:371 normalizeUpdateRecordResponse, normalizeCreateRecordResponse and normalizeDeleteRecordResponse delegate to this method by default. #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeSingleResponse() ```ts static normalizeSingleResponse( store, primaryModelClass, payload, id, requestType): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:385 normalizeQueryResponse and normalizeFindRecordResponse delegate to this method by default. #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeUpdateRecordResponse() ```ts static normalizeUpdateRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:357 Called by the default normalizeResponse implementation when the type of request is `updateRecord` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### serialize() ```ts static serialize(snapshot, options): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:724 Called when a record is saved in order to convert the record into JSON. By default, it creates a JSON object with a key for each attribute and belongsTo relationship. For example, consider this model: ```js [app/models/comment.js] import Model, { attr, belongsTo } from '@ember-data/model'; export default class CommentModel extends Model { @attr title; @attr body; @belongsTo('user') author; } ``` The default serialization would create a JSON object like: ```javascript { "title": "Rails is unagi", "body": "Rails? Omakase? O_O", "author": 12 } ``` By default, attributes are passed through as-is, unless you specified an attribute type (`attr('date')`). If you specify a transform, the JavaScript value will be serialized when inserted into the JSON hash. By default, belongs-to relationships are converted into IDs when inserted into the JSON hash. ## IDs `serialize` takes an options hash with a single option: `includeId`. If this option is `true`, `serialize` will, by default include the ID in the JSON object it builds. The adapter passes in `includeId: true` when serializing a record for `createRecord`, but not for `updateRecord`. ## Customization Your server may expect a different JSON format than the built-in serialization format. In that case, you can implement `serialize` yourself and return a JSON hash of your choosing. ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { serialize(snapshot, options) { let json = { POST_TTL: snapshot.attr('title'), POST_BDY: snapshot.attr('body'), POST_CMS: snapshot.hasMany('comments', { ids: true }) }; if (options.includeId) { json.POST_ID_ = snapshot.id; } return json; } } ``` ## Customizing an App-Wide Serializer If you want to define a serializer for your entire application, you'll probably want to use `eachAttribute` and `eachRelationship` on the record. ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; import { singularize } from '/utils/string-utils'; export default class ApplicationSerializer extends JSONSerializer { serialize(snapshot, options) { let json = {}; snapshot.eachAttribute((name) => { json[serverAttributeName(name)] = snapshot.attr(name); }); snapshot.eachRelationship((name, relationship) => { if (relationship.kind === 'hasMany') { json[serverHasManyName(name)] = snapshot.hasMany(name, { ids: true }); } }); if (options.includeId) { json.ID_ = snapshot.id; } return json; } } function serverAttributeName(attribute) { return attribute.underscore().toUpperCase(); } function serverHasManyName(name) { return serverAttributeName(singularize(name)) + "_IDS"; } ``` This serializer will generate JSON that looks like this: ```javascript { "TITLE": "Rails is omakase", "BODY": "Yep. Omakase.", "COMMENT_IDS": [ "1", "2", "3" ] } ``` ## Tweaking the Default JSON If you just want to do some small tweaks on the default JSON, you can call `super.serialize` first and make the tweaks on the returned JSON. ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { serialize(snapshot, options) { let json = super.serialize(...arguments); json.subject = json.title; delete json.title; return json; } } ``` #### Parameters ##### snapshot `Snapshot` ##### options `any` #### Returns `any` json *** ### serializeAttribute() ```ts static serializeAttribute( snapshot, json, key, attribute): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:779 `serializeAttribute` can be used to customize how `attr` properties are serialized For example if you wanted to ensure all your attributes were always serialized as properties on an `attributes` object you could write: ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class ApplicationSerializer extends JSONSerializer { serializeAttribute(snapshot, json, key, attributes) { json.attributes = json.attributes || {}; super.serializeAttribute(snapshot, json.attributes, key, attributes); } } ``` #### Parameters ##### snapshot `Snapshot` ##### json `any` ##### key `string` ##### attribute `any` #### Returns `void` *** ### serializeBelongsTo() ```ts static serializeBelongsTo( snapshot, json, relationship): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:806 `serializeBelongsTo` can be used to customize how `belongsTo` properties are serialized. Example ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { serializeBelongsTo(snapshot, json, relationship) { let key = relationship.name; let belongsTo = snapshot.belongsTo(key); key = this.keyForRelationship ? this.keyForRelationship(key, "belongsTo", "serialize") : key; json[key] = !belongsTo ? null : belongsTo.record.toJSON(); } } ``` #### Parameters ##### snapshot `Snapshot` ##### json `any` ##### relationship `any` #### Returns `void` *** ### serializeHasMany() ```ts static serializeHasMany( snapshot, json, relationship): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:833 `serializeHasMany` can be used to customize how `hasMany` properties are serialized. Example ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { serializeHasMany(snapshot, json, relationship) { let key = relationship.name; if (key === 'comments') { return; } else { super.serializeHasMany(...arguments); } } } ``` #### Parameters ##### snapshot `Snapshot` ##### json `any` ##### relationship `any` #### Returns `void` *** ### serializeIntoHash() ```ts static serializeIntoHash( hash, typeClass, snapshot, options): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:753 You can use this method to customize how a serialized record is added to the complete JSON hash to be sent to the server. By default the JSON Serializer does not namespace the payload and just sends the raw serialized JSON object. If your server expects namespaced keys, you should consider using the RESTSerializer. Otherwise you can override this method to customize how the record is added to the hash. The hash property should be modified by reference. For example, your server may expect underscored root objects. ```js [app/serializers/application.js] import RESTSerializer from '@ember-data/serializer/rest'; import { underscoren} from '/utils/string-utils'; export default class ApplicationSerializer extends RESTSerializer { serializeIntoHash(data, type, snapshot, options) { let root = underscore(type.modelName); data[root] = this.serialize(snapshot, options); } } ``` #### Parameters ##### hash `any` ##### typeClass `Model` ##### snapshot `Snapshot` ##### options `any` #### Returns `void` *** ### serializePolymorphicType() ```ts static serializePolymorphicType(): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:866 You can use this method to customize how polymorphic objects are serialized. Objects are considered to be polymorphic if `{ polymorphic: true }` is pass as the second argument to the `belongsTo` function. Example ```js [app/serializers/comment.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class CommentSerializer extends JSONSerializer { serializePolymorphicType(snapshot, json, relationship) { let key = relationship.name; let belongsTo = snapshot.belongsTo(key); key = this.keyForAttribute ? this.keyForAttribute(key, 'serialize') : key; if (!belongsTo) { json[key + '_type'] = null; } else { json[key + '_type'] = belongsTo.modelName; } } } ``` #### Returns `void` *** ### shouldSerializeHasMany() ```ts static shouldSerializeHasMany( snapshot, key, relationship): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/json.d.ts:571 Check if the given hasMany relationship should be serialized By default only many-to-many and many-to-none relationships are serialized. This could be configured per relationship by Serializer's `attrs` object. #### Parameters ##### snapshot `Snapshot` ##### key `string` ##### relationship `RelationshipSchema` #### Returns `boolean` true if the hasMany relationship should be serialized --- --- url: /api/@ember-data/serializer/rest/classes/EmbeddedRecordsMixin.md --- [Documentation](../../../../index.md) / [@ember-data/serializer](../../index.md) / [rest](../index.md) / EmbeddedRecordsMixin Defined in: warp-drive-packages/legacy/declarations/serializer/-private/embedded-records-mixin.d.ts:95 ## Using Embedded Records `EmbeddedRecordsMixin` supports serializing embedded records. To set up embedded records, include the mixin when extending a serializer, then define and configure embedded (model) relationships. Note that embedded records will serialize with the serializer for their model instead of the serializer in which they are defined. Note also that this mixin does not work with JSONAPISerializer because the JSON:API specification does not describe how to format embedded resources. Below is an example of a per-type serializer (`post` type). ```js [app/serializers/post.js] import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest'; export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) { attrs = { author: { embedded: 'always' }, comments: { serialize: 'ids' } } } ``` Note that this use of `{ embedded: 'always' }` is unrelated to the `{ embedded: 'always' }` that is defined as an option on `attr` as part of defining a model while working with the `ActiveModelSerializer`. Nevertheless, using `{ embedded: 'always' }` as an option to `attr` is not a valid way to set up embedded records. The `attrs` option for a resource `{ embedded: 'always' }` is shorthand for: ```js { serialize: 'records', deserialize: 'records' } ``` ### Configuring Attrs A resource's `attrs` option may be set to use `ids`, `records` or false for the `serialize` and `deserialize` settings. The `attrs` property can be set on the `ApplicationSerializer` or a per-type serializer. In the case where embedded JSON is expected while extracting a payload (reading) the setting is `deserialize: 'records'`, there is no need to use `ids` when extracting as that is the default behaviour without this mixin if you are using the vanilla `EmbeddedRecordsMixin`. Likewise, to embed JSON in the payload while serializing `serialize: 'records'` is the setting to use. There is an option of not embedding JSON in the serialized payload by using `serialize: 'ids'`. If you do not want the relationship sent at all, you can use `serialize: false`. ### EmbeddedRecordsMixin defaults If you do not overwrite `attrs` for a specific relationship, the `EmbeddedRecordsMixin` will behave in the following way: BelongsTo: `{ serialize: 'id', deserialize: 'id' }` HasMany: `{ serialize: false, deserialize: 'ids' }` ### Model Relationships Embedded records must have a model defined to be extracted and serialized. Note that when defining any relationships on your model such as `belongsTo` and `hasMany`, you should not both specify `async: true` and also indicate through the serializer's `attrs` attribute that the related model should be embedded for deserialization. If a model is declared embedded for deserialization (`embedded: 'always'` or `deserialize: 'records'`), then do not use `async: true`. To successfully extract and serialize embedded records the model relationships must be set up correctly. See the [defining relationships](https://guides.emberjs.com/current/models/relationships) section of the **Defining Models** guide page. Records without an `id` property are not considered embedded records, model instances must have an `id` property to be used with Ember Data. ### Example JSON payloads, Models and Serializers **When customizing a serializer it is important to grok what the customizations are. Please read the docs for the methods this mixin provides, in case you need to modify it to fit your specific needs.** For example, review the docs for each method of this mixin: * [normalize](/ember-data/release/classes/EmbeddedRecordsMixin/methods/normalize?anchor=normalize) * [serializeBelongsTo](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeBelongsTo?anchor=serializeBelongsTo) * [serializeHasMany](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeHasMany?anchor=serializeHasMany) EmbeddedRecordsMixin --- --- url: /api/@ember-data/serializer/rest/classes/default.md --- [Documentation](../../../../index.md) / [@ember-data/serializer](../../index.md) / [rest](../index.md) / default Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:52 Normally, applications will use the `RESTSerializer` by implementing the `normalize` method. This allows you to do whatever kind of munging you need and is especially useful if your server is inconsistent and you need to do munging differently for many different kinds of responses. See the `normalize` documentation for more information. ## Across the Board Normalization There are also a number of hooks that you might find useful to define across-the-board rules for your payload. These rules will be useful if your server is consistent, or if you're building an adapter for an infrastructure service, like Firebase, and want to encode service conventions. For example, if all of your keys are underscored and all-caps, but otherwise consistent with the names you use in your models, you can implement across-the-board rules for how to convert an attribute name in your model to a key in your JSON. ```js [app/serializers/application.js] import { RESTSerializer } from '@warp-drive/legacy/serializer/rest'; import { underscore } from '/utils/string-utils'; export default class ApplicationSerializer extends RESTSerializer { keyForAttribute(attr, method) { return underscore(attr).toUpperCase(); } } ``` You can also implement `keyForRelationship`, which takes the name of the relationship as the first parameter, the kind of relationship (`hasMany` or `belongsTo`) as the second parameter, and the method (`serialize` or `deserialize`) as the third parameter. RESTSerializer ## Constructors ### Constructor ```ts new default(owner?): default; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:96 #### Parameters ##### owner? `any` #### Returns `default` ## Properties ### store ```ts store: default; ``` Defined in: warp-drive-packages/legacy/declarations/serializer.d.ts:134 *** ### mergedProperties ```ts readonly static mergedProperties: any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:54 *** ### primaryKey ```ts readonly static primaryKey: string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:53 ## Methods ### normalize() ```ts normalize(_typeClass, hash): | SingleResourceDocument | EmptyResourceDocument; ``` Defined in: warp-drive-packages/legacy/declarations/serializer.d.ts:256 The `normalize` method is used to convert a payload received from your external data source into the normalized form `store.push()` expects. You should override this method, munge the hash and return the normalized payload. Example: ```js Serializer.extend({ normalize(modelClass, resourceHash) { let data = { id: resourceHash.id, type: modelClass.modelName, attributes: resourceHash }; return { data: data }; } }) ``` #### Parameters ##### \_typeClass [`ModelSchema`](../../../../@warp-drive/core-types/index/interfaces/ModelSchema.md) ##### hash `Record`<`string`, `unknown`> #### Returns | [`SingleResourceDocument`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md) | [`EmptyResourceDocument`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/EmptyResourceDocument.md) *** ### \_canSerialize() ```ts readonly static _canSerialize(key): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:81 #### Parameters ##### key `string` #### Returns `boolean` *** ### \_getMappedKey() ```ts readonly static _getMappedKey(key, modelClass): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:80 #### Parameters ##### key `string` ##### modelClass `any` #### Returns `string` *** ### \_mustSerialize() ```ts readonly static _mustSerialize(key): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:82 #### Parameters ##### key `string` #### Returns `boolean` *** ### \_normalizePolymorphicRecord() ```ts static _normalizePolymorphicRecord( store, hash, prop, primaryModelClass, primarySerializer): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:201 #### Parameters ##### store `any` ##### hash `any` ##### prop `any` ##### primaryModelClass `any` ##### primarySerializer `any` #### Returns `any` *** ### \_normalizeResponse() ```ts static _normalizeResponse( store, primaryModelClass, payload, id, requestType, isSingle): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:70 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### isSingle `boolean` #### Returns `any` *** ### applyTransforms() ```ts readonly static applyTransforms(typeClass, data): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:55 #### Parameters ##### typeClass `Model` ##### data `any` #### Returns `any` *** ### extractAttributes() ```ts readonly static extractAttributes(modelClass, resourceHash): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:73 #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `any` *** ### extractErrors() ```ts readonly static extractErrors( store, typeClass, payload, id): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:91 #### Parameters ##### store `Store` ##### typeClass `Model` ##### payload `any` ##### id `string` | `number` #### Returns `any` *** ### extractId() ```ts readonly static extractId(modelClass, resourceHash): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:72 #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `string` *** ### extractMeta() ```ts readonly static extractMeta( store, modelClass, payload): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:90 #### Parameters ##### store `Store` ##### modelClass `Model` ##### payload `any` #### Returns `any` *** ### extractPolymorphicRelationship() #### Call Signature ```ts static extractPolymorphicRelationship( relationshipModelName, relationshipHash, relationshipOptions): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:75 ##### Parameters ###### relationshipModelName `any` ###### relationshipHash `any` ###### relationshipOptions `any` ##### Returns `any` #### Call Signature ```ts static extractPolymorphicRelationship( relationshipType, relationshipHash, relationshipOptions, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:552 You can use this method to customize how a polymorphic relationship should be extracted. ##### Parameters ###### relationshipType `any` ###### relationshipHash `any` ###### relationshipOptions `any` ###### args ...`any`\[] ##### Returns `any` *** ### extractRelationship() ```ts readonly static extractRelationship(relationshipModelName, relationshipHash): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:74 #### Parameters ##### relationshipModelName `any` ##### relationshipHash `any` #### Returns `any` *** ### extractRelationships() ```ts readonly static extractRelationships(modelClass, resourceHash): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:76 #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `any` *** ### isPrimaryType() ```ts static isPrimaryType( store, modelName, primaryModelClass): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:213 #### Parameters ##### store `any` ##### modelName `any` ##### primaryModelClass `any` #### Returns `boolean` *** ### keyForAttribute() ```ts readonly static keyForAttribute(key, method): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:92 #### Parameters ##### key `string` ##### method `string` #### Returns `string` *** ### keyForLink() ```ts readonly static keyForLink(key, kind): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:94 #### Parameters ##### key `string` ##### kind `string` #### Returns `string` *** ### keyForPolymorphicType() ```ts static keyForPolymorphicType( key, typeClass, method): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:122 `keyForPolymorphicType` can be used to define a custom key when serializing and deserializing a polymorphic type. By default, the returned key is `${key}Type`. Example ```js [app/serializers/post.js] import { RESTSerializer } from '@warp-drive/legacy/serializer/rest'; export default class ApplicationSerializer extends RESTSerializer { keyForPolymorphicType(key, relationship) { let relationshipKey = this.keyForRelationship(key); return 'type-' + relationshipKey; } } ``` #### Parameters ##### key `string` ##### typeClass `string` ##### method `string` #### Returns `string` normalized key *** ### keyForRelationship() ```ts readonly static keyForRelationship( key, typeClass, method): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:93 #### Parameters ##### key `string` ##### typeClass `string` ##### method `string` #### Returns `string` *** ### modelNameFromPayloadKey() ```ts static modelNameFromPayloadKey(key): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:77 #### Parameters ##### key `string` #### Returns `string` *** ### normalize() ```ts readonly static normalize(modelClass, resourceHash): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:71 #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `any` *** ### normalizeArrayResponse() ```ts readonly static normalizeArrayResponse( store, primaryModelClass, payload, id, requestType): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:69 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` #### Returns `any` *** ### normalizeCreateRecordResponse() ```ts readonly static normalizeCreateRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:64 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeDeleteRecordResponse() ```ts readonly static normalizeDeleteRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:65 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeFindAllResponse() ```ts readonly static normalizeFindAllResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:59 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeFindBelongsToResponse() ```ts readonly static normalizeFindBelongsToResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:60 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeFindHasManyResponse() ```ts readonly static normalizeFindHasManyResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:61 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeFindManyResponse() ```ts readonly static normalizeFindManyResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:62 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeFindRecordResponse() ```ts readonly static normalizeFindRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:57 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeQueryRecordResponse() ```ts readonly static normalizeQueryRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:58 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeQueryResponse() ```ts readonly static normalizeQueryResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:63 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeRelationships() ```ts readonly static normalizeRelationships(typeClass, hash): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:78 #### Parameters ##### typeClass `any` ##### hash `any` #### Returns `void` *** ### normalizeResponse() ```ts readonly static normalizeResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:56 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeSaveResponse() ```ts readonly static normalizeSaveResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:67 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeSingleResponse() ```ts readonly static normalizeSingleResponse( store, primaryModelClass, payload, id, requestType): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:68 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` #### Returns `any` *** ### normalizeUpdateRecordResponse() ```ts readonly static normalizeUpdateRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:66 #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any`\[] #### Returns `any` *** ### normalizeUsingDeclaredMapping() ```ts readonly static normalizeUsingDeclaredMapping(modelClass, hash): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:79 #### Parameters ##### modelClass `any` ##### hash `any` #### Returns `void` *** ### payloadKeyFromModelName() ```ts static payloadKeyFromModelName(modelName): string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:530 You can use `payloadKeyFromModelName` to override the root key for an outgoing request. By default, the RESTSerializer returns a camelized version of the model's name. For a model called TacoParty, its `modelName` would be the string `taco-party`. The RESTSerializer will send it to the server with `tacoParty` as the root key in the JSON payload: ```js { "tacoParty": { "id": "1", "location": "Matthew Beale's House" } } ``` For example, your server may expect dasherized root objects: ```js [app/serializers/application.js] import { RESTSerializer } from '@warp-drive/legacy/serializer/rest'; import { dasherize } from '/utils/string-utils'; export default class ApplicationSerializer extends RESTSerializer { payloadKeyFromModelName(modelName) { return dasherize(modelName); } } ``` Given a `TacoParty` model, calling `save` on it would produce an outgoing request like: ```js { "taco-party": { "id": "1", "location": "Matthew Beale's House" } } ``` #### Parameters ##### modelName `string` #### Returns `string` *** ### pushPayload() ```ts static pushPayload(store, payload): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:245 This method allows you to push a payload containing top-level collections of records organized per type. ```js { "posts": [{ "id": "1", "title": "Rails is omakase", "author", "1", "comments": [ "1" ] }], "comments": [{ "id": "1", "body": "FIRST" }], "users": [{ "id": "1", "name": "@d2h" }] } ``` It will first normalize the payload, so you can use this to push in data streaming in from your server structured the same way that fetches and saves are structured. #### Parameters ##### store `Store` ##### payload `any` #### Returns `void` *** ### serialize() #### Call Signature ```ts static serialize(snapshot, options): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:84 ##### Parameters ###### snapshot `Snapshot` ###### options `any` ##### Returns `any` #### Call Signature ```ts static serialize( snapshot, options, ... args): any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:456 Called when a record is saved in order to convert the record into JSON. By default, it creates a JSON object with a key for each attribute and belongsTo relationship. For example, consider this model: ```js [app/models/comment.js] import Model, { attr, belongsTo } from '@ember-data/model'; export default class Comment extends Model { @attr title @attr body @belongsTo('user') author } ``` The default serialization would create a JSON object like: ```js { "title": "Rails is unagi", "body": "Rails? Omakase? O_O", "author": 12 } ``` By default, attributes are passed through as-is, unless you specified an attribute type (`attr('date')`). If you specify a transform, the JavaScript value will be serialized when inserted into the JSON hash. By default, belongs-to relationships are converted into IDs when inserted into the JSON hash. ## IDs `serialize` takes an options hash with a single option: `includeId`. If this option is `true`, `serialize` will, by default include the ID in the JSON object it builds. The adapter passes in `includeId: true` when serializing a record for `createRecord`, but not for `updateRecord`. ## Customization Your server may expect a different JSON format than the built-in serialization format. In that case, you can implement `serialize` yourself and return a JSON hash of your choosing. ```js [app/serializers/post.js] import { RESTSerializer } from '@warp-drive/legacy/serializer/rest'; export default class ApplicationSerializer extends RESTSerializer { serialize(snapshot, options) { let json = { POST_TTL: snapshot.attr('title'), POST_BDY: snapshot.attr('body'), POST_CMS: snapshot.hasMany('comments', { ids: true }) }; if (options.includeId) { json.POST_ID_ = snapshot.id; } return json; } } ``` ## Customizing an App-Wide Serializer If you want to define a serializer for your entire application, you'll probably want to use `eachAttribute` and `eachRelationship` on the record. ```js [app/serializers/application.js] import { RESTSerializer } from '@warp-drive/legacy/serializer/rest'; import { pluralize } from '/utils/string-utils'; export default class ApplicationSerializer extends RESTSerializer { serialize(snapshot, options) { let json = {}; snapshot.eachAttribute(function(name) { json[serverAttributeName(name)] = snapshot.attr(name); }); snapshot.eachRelationship(function(name, relationship) { if (relationship.kind === 'hasMany') { json[serverHasManyName(name)] = snapshot.hasMany(name, { ids: true }); } }); if (options.includeId) { json.ID_ = snapshot.id; } return json; } } function serverAttributeName(attribute) { return attribute.underscore().toUpperCase(); } function serverHasManyName(name) { return serverAttributeName(singularize(name)) + "_IDS"; } ``` This serializer will generate JSON that looks like this: ```js { "TITLE": "Rails is omakase", "BODY": "Yep. Omakase.", "COMMENT_IDS": [ 1, 2, 3 ] } ``` ## Tweaking the Default JSON If you just want to do some small tweaks on the default JSON, you can call super first and make the tweaks on the returned JSON. ```js [app/serializers/post.js] import { RESTSerializer } from '@warp-drive/legacy/serializer/rest'; export default class ApplicationSerializer extends RESTSerializer { serialize(snapshot, options) { let json = super.serialize(snapshot, options); json.subject = json.title; delete json.title; return json; } } ``` ##### Parameters ###### snapshot `Snapshot` ###### options `any` ###### args ...`any`\[] ##### Returns `any` json *** ### serializeAttribute() ```ts readonly static serializeAttribute( snapshot, json, key, attribute): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:86 #### Parameters ##### snapshot `Snapshot` ##### json `any` ##### key `string` ##### attribute `any` #### Returns `void` *** ### serializeBelongsTo() ```ts readonly static serializeBelongsTo( snapshot, json, relationship): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:87 #### Parameters ##### snapshot `Snapshot` ##### json `any` ##### relationship `any` #### Returns `void` *** ### serializeHasMany() ```ts readonly static serializeHasMany( snapshot, json, relationship): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:88 #### Parameters ##### snapshot `Snapshot` ##### json `any` ##### relationship `any` #### Returns `void` *** ### serializeIntoHash() ```ts static serializeIntoHash( hash, typeClass, snapshot, options): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:85 #### Parameters ##### hash `any` ##### typeClass `Model` ##### snapshot `Snapshot` ##### options `any` #### Returns `void` *** ### serializePolymorphicType() #### Call Signature ```ts static serializePolymorphicType(): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:89 ##### Returns `void` #### Call Signature ```ts static serializePolymorphicType( snapshot, json, relationship): void; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:541 You can use this method to customize how polymorphic objects are serialized. By default the REST Serializer creates the key by appending `Type` to the attribute and value from the model's camelcased model name. ##### Parameters ###### snapshot `Snapshot` ###### json `any` ###### relationship `any` ##### Returns `void` *** ### shouldSerializeHasMany() ```ts readonly static shouldSerializeHasMany( snapshot, key, relationship): boolean; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:83 #### Parameters ##### snapshot `Snapshot` ##### key `string` ##### relationship `RelationshipSchema` #### Returns `boolean` *** ### transformFor() ```ts readonly static transformFor(attributeType, skipAssertion): Transform; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/rest.d.ts:95 #### Parameters ##### attributeType `string` ##### skipAssertion `boolean` #### Returns `Transform` --- --- url: /api/@ember-data/serializer/transform/classes/BooleanTransform.md --- [Documentation](../../../../index.md) / [@ember-data/serializer](../../index.md) / [transform](../index.md) / BooleanTransform Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/boolean.d.ts:37 The `BooleanTransform` class is used to serialize and deserialize boolean attributes on Ember Data record objects. This transform is used when `boolean` is passed as the type parameter to the [attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function. Usage ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('boolean') isAdmin; @attr('string') name; @attr('string') email; } ``` By default, the boolean transform only allows for values of `true` or `false`. You can opt into allowing `null` values for boolean attributes via `attr('boolean', { allowNull: true })` ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') email; @attr('string') username; @attr('boolean', { allowNull: true }) wantsWeeklyEmail; } ``` BooleanTransform ## Constructors ### Constructor ```ts new BooleanTransform(): BooleanTransform; ``` #### Returns `BooleanTransform` ## Properties ### \_\_\_(unique) Symbol($type) ```ts ___(unique) Symbol($type): "boolean"; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/boolean.d.ts:44 ## Methods ### deserialize() ```ts deserialize(serialized, options?): null | boolean; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/boolean.d.ts:38 #### Parameters ##### serialized `null` | `string` | `number` | `boolean` ##### options? ###### allowNull? `boolean` #### Returns `null` | `boolean` *** ### serialize() ```ts serialize(deserialized, options?): null | boolean; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/boolean.d.ts:41 #### Parameters ##### deserialized `null` | `boolean` ##### options? ###### allowNull? `boolean` #### Returns `null` | `boolean` *** ### create() ```ts static create(): BooleanTransform; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/boolean.d.ts:45 #### Returns `BooleanTransform` --- --- url: /api/@ember-data/serializer/rest.md --- [Documentation](../../../index.md) / [@ember-data/serializer](../index.md) / rest ## Classes * [default](classes/default.md) * [EmbeddedRecordsMixin](classes/EmbeddedRecordsMixin.md) --- --- url: /api/@ember-data/serializer/transform/classes/DateTransform.md --- [Documentation](../../../../index.md) / [@ember-data/serializer](../../index.md) / [transform](../index.md) / DateTransform Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/date.d.ts:22 The `DateTransform` class is used to serialize and deserialize date attributes on Ember Data record objects. This transform is used when `date` is passed as the type parameter to the [attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function. It uses the [`ISO 8601`](https://en.wikipedia.org/wiki/ISO_8601) standard. ```js [app/models/score.js] import Model, { attr, belongsTo } from '@ember-data/model'; export default class ScoreModel extends Model { @attr('number') value; @belongsTo('player') player; @attr('date') date; } ``` DateTransform ## Constructors ### Constructor ```ts new DateTransform(): DateTransform; ``` #### Returns `DateTransform` ## Properties ### \_\_\_(unique) Symbol($type) ```ts ___(unique) Symbol($type): "date"; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/date.d.ts:25 ## Methods ### deserialize() ```ts deserialize(serialized, _options?): null | Date; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/date.d.ts:23 #### Parameters ##### serialized `null` | `string` | `number` ##### \_options? `Record`<`string`, `unknown`> #### Returns `null` | `Date` *** ### serialize() ```ts serialize(date, _options?): null | string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/date.d.ts:24 #### Parameters ##### date `Date` ##### \_options? `Record`<`string`, `unknown`> #### Returns `null` | `string` *** ### create() ```ts static create(): DateTransform; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/date.d.ts:26 #### Returns `DateTransform` --- --- url: /api/@ember-data/serializer/transform/classes/NumberTransform.md --- [Documentation](../../../../index.md) / [@ember-data/serializer](../../index.md) / [transform](../index.md) / NumberTransform Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/number.d.ts:23 The `NumberTransform` class is used to serialize and deserialize numeric attributes on Ember Data record objects. This transform is used when `number` is passed as the type parameter to the [attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function. Usage ```js [app/models/score.js] import Model, { attr, belongsTo } from '@ember-data/model'; export default class ScoreModel extends Model { @attr('number') value; @belongsTo('player') player; @attr('date') date; } ``` NumberTransform ## Constructors ### Constructor ```ts new NumberTransform(): NumberTransform; ``` #### Returns `NumberTransform` ## Properties ### \_\_\_(unique) Symbol($type) ```ts ___(unique) Symbol($type): "number"; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/number.d.ts:26 ## Methods ### deserialize() ```ts deserialize(serialized, _options?): null | number; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/number.d.ts:24 #### Parameters ##### serialized `undefined` | `null` | `string` | `number` ##### \_options? `Record`<`string`, `unknown`> #### Returns `null` | `number` *** ### serialize() ```ts serialize(deserialized, _options?): null | number; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/number.d.ts:25 #### Parameters ##### deserialized `undefined` | `null` | `string` | `number` ##### \_options? `Record`<`string`, `unknown`> #### Returns `null` | `number` *** ### create() ```ts static create(): NumberTransform; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/number.d.ts:27 #### Returns `NumberTransform` --- --- url: /api/@ember-data/serializer/transform/classes/StringTransform.md --- [Documentation](../../../../index.md) / [@ember-data/serializer](../../index.md) / [transform](../index.md) / StringTransform Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/string.d.ts:23 The `StringTransform` class is used to serialize and deserialize string attributes on Ember Data record objects. This transform is used when `string` is passed as the type parameter to the [attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function. Usage ```js [app/models/user.js] import Model, { attr, belongsTo } from '@ember-data/model'; export default class UserModel extends Model { @attr('boolean') isAdmin; @attr('string') name; @attr('string') email; } ``` StringTransform ## Constructors ### Constructor ```ts new StringTransform(): StringTransform; ``` #### Returns `StringTransform` ## Properties ### \_\_\_(unique) Symbol($type) ```ts ___(unique) Symbol($type): "string"; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/string.d.ts:26 ## Methods ### deserialize() ```ts deserialize(serialized, _options?): null | string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/string.d.ts:24 #### Parameters ##### serialized `unknown` ##### \_options? `Record`<`string`, `unknown`> #### Returns `null` | `string` *** ### serialize() ```ts serialize(deserialized, _options?): null | string; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/string.d.ts:25 #### Parameters ##### deserialized `unknown` ##### \_options? `Record`<`string`, `unknown`> #### Returns `null` | `string` *** ### create() ```ts static create(): StringTransform; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/string.d.ts:27 #### Returns `StringTransform` --- --- url: /api/@ember-data/serializer/transform.md --- [Documentation](../../../index.md) / [@ember-data/serializer](../index.md) / transform ## Classes * [BooleanTransform](classes/BooleanTransform.md) * [DateTransform](classes/DateTransform.md) * [NumberTransform](classes/NumberTransform.md) * [StringTransform](classes/StringTransform.md) ## Interfaces * [default](interfaces/default.md) ## Variables * [default](variables/default.md) --- --- url: /api/@ember-data/serializer/transform/interfaces/default.md --- [Documentation](../../../../index.md) / [@ember-data/serializer](../../index.md) / [transform](../index.md) / default Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/transform.d.ts:114 When given a serialized value from a JSON object this method must return the deserialized value for the record attribute. Example ```javascript deserialize(serialized, options) { return empty(serialized) ? null : Number(serialized); } ``` ## Param The serialized value ## Param hash of options passed to `attr` ## Methods ### deserialize() ```ts deserialize(value, options): unknown; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/transform.d.ts:116 #### Parameters ##### value `unknown` ##### options `undefined` | [`ObjectValue`](../../../../@warp-drive/core-types/json/raw/interfaces/ObjectValue.md) #### Returns `unknown` *** ### serialize() ```ts serialize(value, options): unknown; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/transform.d.ts:115 #### Parameters ##### value `unknown` ##### options `undefined` | [`ObjectValue`](../../../../@warp-drive/core-types/json/raw/interfaces/ObjectValue.md) #### Returns `unknown` --- --- url: /api/@ember-data/serializer/transform/variables/default.md --- [Documentation](../../../../index.md) / [@ember-data/serializer](../../index.md) / [transform](../index.md) / default ```ts default: any; ``` Defined in: warp-drive-packages/legacy/declarations/serializer/-private/transforms/transform.d.ts:114 --- --- url: /api/@ember-data/store/configure.md --- [Documentation](../../../index.md) / [@ember-data/store](../index.md) / configure Provides a configuration API for the reactivity system that WarpDrive should use. --- --- url: /api/@ember-data/store.md --- [Documentation](../../index.md) / @ember-data/store ## Modules * [configure](configure/index.md) * [index](index/index.md) * [types](types/index.md) --- --- url: /api/@ember-data/store/index/classes/Document.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [index](../index.md) / Document Defined in: warp-drive-packages/core/declarations/store/-private/document.d.ts:18 A Document is a class that wraps the response content from a request to the API returned by `Cache.put` or `Cache.peek`, converting resource-identifiers into record instances. It is not directly instantiated by the user, and its properties should not be directly modified. Whether individual properties are mutable or not is determined by the record instance itself. ReactiveDocument ## Type Parameters ### T `T` ## Constructors ### Constructor ```ts new Document( store, identifier, localCache): ReactiveDocument; ``` Defined in: warp-drive-packages/core/declarations/store/-private/document.d.ts:79 #### Parameters ##### store [`default`](default.md) ##### identifier `null` | [`StableDocumentIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md) ##### localCache `null` | { `document`: [`ResourceDocument`](../../../../@warp-drive/core-types/spec/document/type-aliases/ResourceDocument.md); `request`: [`ImmutableRequestInfo`](../../../../@warp-drive/core-types/request/type-aliases/ImmutableRequestInfo.md); } #### Returns `ReactiveDocument`<`T`> ## Properties ### \_localCache ```ts protected readonly _localCache: | null | { document: ResourceDocument; request: ImmutableRequestInfo; }; ``` Defined in: warp-drive-packages/core/declarations/store/-private/document.d.ts:75 *** ### \_store ```ts protected readonly _store: default; ``` Defined in: warp-drive-packages/core/declarations/store/-private/document.d.ts:74 *** ### data? ```ts readonly optional data: T; ``` Defined in: warp-drive-packages/core/declarations/store/-private/document.d.ts:49 The primary data for this document, if any. If this document has no primary data (e.g. because it is an error document) this property will be `undefined`. For collections this will be an array of record instances, for single resource requests it will be a single record instance or null. *** ### errors? ```ts readonly optional errors: object[]; ``` Defined in: warp-drive-packages/core/declarations/store/-private/document.d.ts:57 The errors returned by the API for this request, if any *** ### identifier ```ts readonly identifier: | null | StableDocumentIdentifier; ``` Defined in: warp-drive-packages/core/declarations/store/-private/document.d.ts:73 The identifier associated with this document, if any *** ### links? ```ts readonly optional links: PaginationLinks; ``` Defined in: warp-drive-packages/core/declarations/store/-private/document.d.ts:35 The links object for this document, if any e.g. ``` { self: '/articles?page[number]=3', } ``` *** ### meta? ```ts readonly optional meta: ObjectValue; ``` Defined in: warp-drive-packages/core/declarations/store/-private/document.d.ts:65 The meta object for this document, if any ## Methods ### fetch() ```ts fetch(options?): Promise>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/document.d.ts:92 Fetches the related link for this document, returning a promise that resolves with the document when the request completes. If no related link is present, will fallback to the self link if present #### Parameters ##### options? [`RequestInfo`](../../../../@warp-drive/core-types/request/interfaces/RequestInfo.md)<`ReactiveDocument`<`T`>, `T`> #### Returns `Promise`<`ReactiveDocument`<`T`>> *** ### first() ```ts first(options): Promise>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/document.d.ts:122 Fetches the first link for this document, returning a promise that resolves with the new document when the request completes, or null if there is no first link. #### Parameters ##### options [`RequestInfo`](../../../../@warp-drive/core-types/request/interfaces/RequestInfo.md)<`ReactiveDocument`<`T`>, `T`> #### Returns `Promise`<`null` | `ReactiveDocument`<`T`>> *** ### last() ```ts last(options): Promise>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/document.d.ts:132 Fetches the last link for this document, returning a promise that resolves with the new document when the request completes, or null if there is no last link. #### Parameters ##### options [`RequestInfo`](../../../../@warp-drive/core-types/request/interfaces/RequestInfo.md)<`ReactiveDocument`<`T`>, `T`> #### Returns `Promise`<`null` | `ReactiveDocument`<`T`>> *** ### next() ```ts next(options?): Promise>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/document.d.ts:102 Fetches the next link for this document, returning a promise that resolves with the new document when the request completes, or null if there is no next link. #### Parameters ##### options? [`RequestInfo`](../../../../@warp-drive/core-types/request/interfaces/RequestInfo.md)<`ReactiveDocument`<`T`>, `T`> #### Returns `Promise`<`null` | `ReactiveDocument`<`T`>> *** ### prev() ```ts prev(options): Promise>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/document.d.ts:112 Fetches the prev link for this document, returning a promise that resolves with the new document when the request completes, or null if there is no prev link. #### Parameters ##### options [`RequestInfo`](../../../../@warp-drive/core-types/request/interfaces/RequestInfo.md)<`ReactiveDocument`<`T`>, `T`> #### Returns `Promise`<`null` | `ReactiveDocument`<`T`>> *** ### toJSON() ```ts toJSON(): object; ``` Defined in: warp-drive-packages/core/declarations/store/-private/document.d.ts:145 Implemented for `JSON.stringify` support. Returns the JSON representation of the document wrapper. This is a shallow serialization, it does not deeply serialize the document's contents, leaving that to the individual record instances to determine how to do, if at all. #### Returns `object` --- --- url: /api/@ember-data/store/index/classes/default.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [index](../index.md) / default Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:54 ## Extends * `BaseClass` ## Properties ### identifierCache ```ts identifierCache: IdentifierCache; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:288 Provides access to the IdentifierCache instance for this store. The IdentifierCache can be used to generate or retrieve a stable unique identifier for any resource. *** ### lifetimes? ```ts optional lifetimes: CachePolicy; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:345 A Property which an App may set to provide a CachePolicy to control when a cached request becomes stale. Note, when defined, these methods will only be invoked if a cache key exists for the request, either because the request contains `cacheOptions.key` or because the [IdentifierCache](/ember-data/release/classes/IdentifierCache) was able to generate a key for the request using the configured [generation method](/ember-data/release/functions/@ember-data%2Fstore/setIdentifierGenerationMethod). `isSoftExpired` will only be invoked if `isHardExpired` returns `false`. ```ts store.lifetimes = { // make the request and ignore the current cache state isHardExpired(identifier: StableDocumentIdentifier): boolean { return false; } // make the request in the background if true, return cache state isSoftExpired(identifier: StableDocumentIdentifier): boolean { return false; } } ``` *** ### notifications ```ts notifications: NotificationManager; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:262 Provides access to the NotificationManager associated with this Store instance. The NotificationManager can be used to subscribe to changes to the cache. *** ### requestManager ```ts requestManager: default; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:314 Provides access to the requestManager instance associated with this Store instance. When using `ember-data` this property is automatically set to an instance of `RequestManager`. When not using `ember-data` you must configure this property yourself, either by declaring it as a service or by initializing it. ```ts import Store, { CacheHandler } from '@ember-data/store'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; class extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); } ``` ## Accessors ### cache #### Get Signature ```ts get cache(): ReturnType; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1591 Returns the cache instance associated to this Store, instantiates the Cache if necessary via `Store.createCache` ##### Returns `ReturnType`<`this`\[`"createCache"`]> *** ### isDestroyed #### Set Signature ```ts set isDestroyed(value): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:382 ##### Parameters ###### value `boolean` ##### Returns `void` *** ### isDestroying #### Set Signature ```ts set isDestroying(value): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:379 ##### Parameters ###### value `boolean` ##### Returns `void` *** ### schema #### Get Signature ```ts get schema(): ReturnType; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:274 Provides access to the SchemaService instance for this Store instance. The SchemaService can be used to query for information about the schema of a resource. ##### Returns `ReturnType`<`this`\[`"createSchemaService"`]> ## Methods ### createCache() ```ts createCache(capabilities): Cache; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:55 #### Parameters ##### capabilities [`CacheCapabilitiesManager`](../../types/type-aliases/CacheCapabilitiesManager.md) #### Returns [`Cache`](../../../../@warp-drive/core-types/cache/interfaces/Cache.md) *** ### createRecord() #### Call Signature ```ts createRecord(type, inputProperties): T; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:546 Create a new record in the current store. The properties passed to this method are set on the newly created record. To create a new instance of a `Post`: ```js store.createRecord('post', { title: 'Ember is awesome!' }); ``` To create a new instance of a `Post` that has a relationship with a `User` record: ```js let user = this.store.peekRecord('user', '1'); store.createRecord('post', { title: 'Ember is awesome!', user: user }); ``` ##### Type Parameters ###### T `T` ##### Parameters ###### type [`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> the name of the resource ###### inputProperties `CreateRecordProperties`<`T`> a hash of properties to set on the newly created record. ##### Returns `T` record #### Call Signature ```ts createRecord(type, inputProperties): unknown; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:547 Create a new record in the current store. The properties passed to this method are set on the newly created record. To create a new instance of a `Post`: ```js store.createRecord('post', { title: 'Ember is awesome!' }); ``` To create a new instance of a `Post` that has a relationship with a `User` record: ```js let user = this.store.peekRecord('user', '1'); store.createRecord('post', { title: 'Ember is awesome!', user: user }); ``` ##### Parameters ###### type `string` the name of the resource ###### inputProperties `MaybeHasId` & `Partial`<`FilteredKeys`<`MaybeHasId` & `Record`<`string`, `unknown`>>> a hash of properties to set on the newly created record. ##### Returns `unknown` record *** ### createSchemaService() ```ts createSchemaService(): SchemaService; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:125 This hook enables an app to supply a SchemaService for use when information about a resource's schema needs to be queried. This method will only be called once to instantiate the singleton service, which can then be accessed via `store.schema`. For Example, to use the default SchemaService for SchemaRecord ```ts import { SchemaService } from '@warp-drive/schema-record'; class extends Store { createSchemaService() { return new SchemaService(); } } ``` Or to use the SchemaService for @ember-data/model ```ts import { buildSchema } from '@ember-data/model'; class extends Store { createSchemaService() { return buildSchema(this); } } ``` If you wish to chain services, you must either instantiate each schema source directly or super to retrieve an existing service. For convenience, when migrating from `@ember-data/model` to `@warp-drive/schema-record` a SchemaService is provided that handles this transition for you: ```ts import { DelegatingSchemaService } from '@ember-data/model/migration-support'; import { SchemaService } from '@warp-drive/schema-record'; class extends Store { createSchemaService() { const schema = new SchemaService(); return new DelegatingSchemaService(this, schema); } } ``` When using the DelegateSchemaService, the schema will first be sourced from directly registered schemas, then will fallback to sourcing a schema from available models if no schema is found. #### Returns [`SchemaService`](../../types/interfaces/SchemaService.md) *** ### deleteRecord() ```ts deleteRecord(record): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:564 For symmetry, a record can be deleted via the store. Example ```javascript let post = store.createRecord('post', { title: 'Ember is awesome!' }); store.deleteRecord(post); ``` #### Type Parameters ##### T `T` #### Parameters ##### record `T` #### Returns `void` *** ### destroy() ```ts destroy(): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1592 #### Returns `void` *** ### findAll() #### Call Signature ```ts findAll(type, options?): Promise>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1353 `findAll` asks the adapter's `findAll` method to find the records for the given type, and returns a promise which will resolve with all records of this type present in the store, even if the adapter only returns a subset of them. ```js [app/routes/authors.js] export default class AuthorsRoute extends Route { model(params) { return this.store.findAll('author'); } } ``` *When* the returned promise resolves depends on the reload behavior, configured via the passed `options` hash and the result of the adapter's `shouldReloadAll` method. ### Reloading If `{ reload: true }` is passed or `adapter.shouldReloadAll` evaluates to `true`, then the returned promise resolves once the adapter returns data, regardless if there are already records in the store: ```js store.push({ data: { id: 'first', type: 'author' } }); // adapter#findAll resolves with // [ // { // id: 'second', // type: 'author' // } // ] store.findAll('author', { reload: true }).then(function(authors) { authors.getEach('id'); // ['first', 'second'] }); ``` If no reload is indicated via the above mentioned ways, then the promise immediately resolves with all the records currently loaded in the store. ### Background Reloading Optionally, if `adapter.shouldBackgroundReloadAll` evaluates to `true`, then a background reload is started. Once this resolves, the array with which the promise resolves, is updated automatically so it contains all the records in the store: ```js [app/adapters/application.js] import Adapter from '@ember-data/adapter'; export default class ApplicationAdapter extends Adapter { shouldReloadAll(store, snapshotsArray) { return false; }, shouldBackgroundReloadAll(store, snapshotsArray) { return true; } }); // ... store.push({ data: { id: 'first', type: 'author' } }); let allAuthors; store.findAll('author').then(function(authors) { authors.getEach('id'); // ['first'] allAuthors = authors; }); // later, once adapter#findAll resolved with // [ // { // id: 'second', // type: 'author' // } // ] allAuthors.getEach('id'); // ['first', 'second'] ``` If you would like to force or prevent background reloading, you can set a boolean value for `backgroundReload` in the options object for `findAll`. ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model() { return this.store.findAll('post', { backgroundReload: false }); } } ``` If you pass an object on the `adapterOptions` property of the options argument it will be passed to you adapter via the `snapshotRecordArray` ```js [app/routes/posts.js] export default class PostsRoute extends Route { model(params) { return this.store.findAll('post', { adapterOptions: { subscribe: false } }); } } ``` ```js [app/adapters/post.js] import MyCustomAdapter from './custom-adapter'; export default class UserAdapter extends MyCustomAdapter { findAll(store, type, sinceToken, snapshotRecordArray) { if (snapshotRecordArray.adapterOptions.subscribe) { // ... } // ... } } ``` See [peekAll](../methods/peekAll?anchor=peekAll) to get an array of current records in the store, without waiting until a reload is finished. ### Retrieving Related Model Records If you use an adapter such as Ember's default [`JSONAPIAdapter`](/ember-data/release/classes/JSONAPIAdapter) that supports the [JSON API specification](http://jsonapi.org/) and if your server endpoint supports the use of an ['include' query parameter](http://jsonapi.org/format/#fetching-includes), you can use `findAll()` to automatically retrieve additional records related to those requested by supplying an `include` parameter in the `options` object. For example, given a `post` model that has a `hasMany` relationship with a `comment` model, when we retrieve all of the post records we can have the server also return all of the posts' comments in the same request: ```js [app/routes/posts.js] export default class PostsRoute extends Route { model() { return this.store.findAll('post', { include: ['comments'] }); } } ``` Multiple relationships can be requested using an `include` parameter consisting of a list or relationship names, while nested relationships can be specified using a dot-separated sequence of relationship names. So to request both the posts' comments and the authors of those comments the request would look like this: ```js [app/routes/posts.js] export default class PostsRoute extends Route { model() { return this.store.findAll('post', { include: ['comments','comments.author'] }); } } ``` See [query](../methods/query?anchor=query) to only get a subset of records from the server. ##### Type Parameters ###### T `T` ##### Parameters ###### type [`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> the name of the resource ###### options? [`FindAllOptions`](../../types/type-aliases/FindAllOptions.md)<`T`> ##### Returns `Promise`<`IdentifierArray`<`T`>> promise ##### Since 1.13.0 #### Call Signature ```ts findAll(type, options?): Promise>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1354 `findAll` asks the adapter's `findAll` method to find the records for the given type, and returns a promise which will resolve with all records of this type present in the store, even if the adapter only returns a subset of them. ```js [app/routes/authors.js] export default class AuthorsRoute extends Route { model(params) { return this.store.findAll('author'); } } ``` *When* the returned promise resolves depends on the reload behavior, configured via the passed `options` hash and the result of the adapter's `shouldReloadAll` method. ### Reloading If `{ reload: true }` is passed or `adapter.shouldReloadAll` evaluates to `true`, then the returned promise resolves once the adapter returns data, regardless if there are already records in the store: ```js store.push({ data: { id: 'first', type: 'author' } }); // adapter#findAll resolves with // [ // { // id: 'second', // type: 'author' // } // ] store.findAll('author', { reload: true }).then(function(authors) { authors.getEach('id'); // ['first', 'second'] }); ``` If no reload is indicated via the above mentioned ways, then the promise immediately resolves with all the records currently loaded in the store. ### Background Reloading Optionally, if `adapter.shouldBackgroundReloadAll` evaluates to `true`, then a background reload is started. Once this resolves, the array with which the promise resolves, is updated automatically so it contains all the records in the store: ```js [app/adapters/application.js] import Adapter from '@ember-data/adapter'; export default class ApplicationAdapter extends Adapter { shouldReloadAll(store, snapshotsArray) { return false; }, shouldBackgroundReloadAll(store, snapshotsArray) { return true; } }); // ... store.push({ data: { id: 'first', type: 'author' } }); let allAuthors; store.findAll('author').then(function(authors) { authors.getEach('id'); // ['first'] allAuthors = authors; }); // later, once adapter#findAll resolved with // [ // { // id: 'second', // type: 'author' // } // ] allAuthors.getEach('id'); // ['first', 'second'] ``` If you would like to force or prevent background reloading, you can set a boolean value for `backgroundReload` in the options object for `findAll`. ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model() { return this.store.findAll('post', { backgroundReload: false }); } } ``` If you pass an object on the `adapterOptions` property of the options argument it will be passed to you adapter via the `snapshotRecordArray` ```js [app/routes/posts.js] export default class PostsRoute extends Route { model(params) { return this.store.findAll('post', { adapterOptions: { subscribe: false } }); } } ``` ```js [app/adapters/post.js] import MyCustomAdapter from './custom-adapter'; export default class UserAdapter extends MyCustomAdapter { findAll(store, type, sinceToken, snapshotRecordArray) { if (snapshotRecordArray.adapterOptions.subscribe) { // ... } // ... } } ``` See [peekAll](../methods/peekAll?anchor=peekAll) to get an array of current records in the store, without waiting until a reload is finished. ### Retrieving Related Model Records If you use an adapter such as Ember's default [`JSONAPIAdapter`](/ember-data/release/classes/JSONAPIAdapter) that supports the [JSON API specification](http://jsonapi.org/) and if your server endpoint supports the use of an ['include' query parameter](http://jsonapi.org/format/#fetching-includes), you can use `findAll()` to automatically retrieve additional records related to those requested by supplying an `include` parameter in the `options` object. For example, given a `post` model that has a `hasMany` relationship with a `comment` model, when we retrieve all of the post records we can have the server also return all of the posts' comments in the same request: ```js [app/routes/posts.js] export default class PostsRoute extends Route { model() { return this.store.findAll('post', { include: ['comments'] }); } } ``` Multiple relationships can be requested using an `include` parameter consisting of a list or relationship names, while nested relationships can be specified using a dot-separated sequence of relationship names. So to request both the posts' comments and the authors of those comments the request would look like this: ```js [app/routes/posts.js] export default class PostsRoute extends Route { model() { return this.store.findAll('post', { include: ['comments','comments.author'] }); } } ``` See [query](../methods/query?anchor=query) to only get a subset of records from the server. ##### Parameters ###### type `string` the name of the resource ###### options? [`FindAllOptions`](../../types/type-aliases/FindAllOptions.md) ##### Returns `Promise`<`IdentifierArray`<`unknown`>> promise ##### Since 1.13.0 *** ### findRecord() #### Call Signature ```ts findRecord( type, id, options?): Promise; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:932 This method returns a record for a given identifier or type and id combination. The `findRecord` method will always resolve its promise with the same object for a given identifier or type and `id`. The `findRecord` method will always return a **promise** that will be resolved with the record. **Example 1** ```js [app/routes/post.js] export default class PostRoute extends Route { model({ post_id }) { return this.store.findRecord('post', post_id); } } ``` **Example 2** `findRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) ```js [app/routes/post.js] export default class PostRoute extends Route { model({ post_id: id }) { return this.store.findRecord({ type: 'post', id }); } } ``` **Example 3** If you have previously received an lid via an Identifier for this record, and the record has already been assigned an id, you can find the record again using just the lid. ```js [app/routes/post.js] store.findRecord({ lid }); ``` If the record is not yet available, the store will ask the adapter's `findRecord` method to retrieve and supply the necessary data. If the record is already present in the store, it depends on the reload behavior *when* the returned promise resolves. ### Preloading You can optionally `preload` specific attributes and relationships that you know of by passing them via the passed `options`. For example, if your Ember route looks like `/posts/1/comments/2` and your API route for the comment also looks like `/posts/1/comments/2` if you want to fetch the comment without also fetching the post you can pass in the post to the `findRecord` call: ```js [app/routes/post-comments.js] export default class PostRoute extends Route { model({ post_id, comment_id: id }) { return this.store.findRecord({ type: 'comment', id, { preload: { post: post_id }} }); } } ``` In your adapter you can then access this id without triggering a network request via the snapshot: ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'comment') let postId = snapshot.belongsTo('post', { id: true }); return fetch(`./posts/${postId}/comments/${id}`) .then(response => response.json()) } } static create() { return new this(); } } ``` This could also be achieved by supplying the post id to the adapter via the adapterOptions property on the options hash. ```js [app/routes/post-comments.js] export default class PostRoute extends Route { model({ post_id, comment_id: id }) { return this.store.findRecord({ type: 'comment', id, { adapterOptions: { post: post_id }} }); } } ``` ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'comment') let postId = snapshot.adapterOptions.post; return fetch(`./posts/${postId}/comments/${id}`) .then(response => response.json()) } } static create() { return new this(); } } ``` If you have access to the post model you can also pass the model itself to preload: ```javascript let post = await store.findRecord('post', '1'); let comment = await store.findRecord('comment', '2', { post: myPostModel }); ``` ### Reloading The reload behavior is configured either via the passed `options` hash or the result of the adapter's `shouldReloadRecord`. If `{ reload: true }` is passed or `adapter.shouldReloadRecord` evaluates to `true`, then the returned promise resolves once the adapter returns data, regardless if the requested record is already in the store: ```js store.push({ data: { id: 1, type: 'post', revision: 1 } }); // adapter#findRecord resolves with // [ // { // id: 1, // type: 'post', // revision: 2 // } // ] store.findRecord('post', '1', { reload: true }).then(function(post) { post.revision; // 2 }); ``` If no reload is indicated via the above mentioned ways, then the promise immediately resolves with the cached version in the store. ### Background Reloading Optionally, if `adapter.shouldBackgroundReloadRecord` evaluates to `true`, then a background reload is started, which updates the records' data, once it is available: ```js // app/adapters/post.js import ApplicationAdapter from "./application"; export default class PostAdapter extends ApplicationAdapter { shouldReloadRecord(store, snapshot) { return false; }, shouldBackgroundReloadRecord(store, snapshot) { return true; } }); // ... store.push({ data: { id: 1, type: 'post', revision: 1 } }); let blogPost = store.findRecord('post', '1').then(function(post) { post.revision; // 1 }); // later, once adapter#findRecord resolved with // [ // { // id: 1, // type: 'post', // revision: 2 // } // ] blogPost.revision; // 2 ``` If you would like to force or prevent background reloading, you can set a boolean value for `backgroundReload` in the options object for `findRecord`. ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { backgroundReload: false }); } } ``` If you pass an object on the `adapterOptions` property of the options argument it will be passed to your adapter via the snapshot ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { subscribe: false } }); } } ``` ```js [app/adapters/post.js] import MyCustomAdapter from './custom-adapter'; export default class PostAdapter extends MyCustomAdapter { findRecord(store, type, id, snapshot) { if (snapshot.adapterOptions.subscribe) { // ... } // ... } } ``` See [peekRecord](../methods/peekRecord?anchor=peekRecord) to get the cached version of a record. ### Retrieving Related Model Records If you use an adapter such as Ember's default [`JSONAPIAdapter`](/ember-data/release/classes/JSONAPIAdapter) that supports the [JSON API specification](http://jsonapi.org/) and if your server endpoint supports the use of an ['include' query parameter](http://jsonapi.org/format/#fetching-includes), you can use `findRecord()` or `findAll()` to automatically retrieve additional records related to the one you request by supplying an `include` parameter in the `options` object. For example, given a `post` model that has a `hasMany` relationship with a `comment` model, when we retrieve a specific post we can have the server also return that post's comments in the same request: ```js [app/routes/post.js] export default class PostRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { include: ['comments'] }); } } ``` ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'post') let includes = snapshot.adapterOptions.include; return fetch(`./posts/${postId}?include=${includes}`) .then(response => response.json()) } } static create() { return new this(); } } ``` In this case, the post's comments would then be available in your template as `model.comments`. Multiple relationships can be requested using an `include` parameter consisting of a list of relationship names, while nested relationships can be specified using a dot-separated sequence of relationship names. So to request both the post's comments and the authors of those comments the request would look like this: ```js [app/routes/post.js] export default class PostRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { include: ['comments','comments.author'] }); } } ``` ### Retrieving Specific Fields by Type If your server endpoint supports the use of a ['fields' query parameter](https://jsonapi.org/format/#fetching-sparse-fieldsets), you can use pass those fields through to your server. At this point in time, this requires a few manual steps on your part. 1. Implement `buildQuery` in your adapter. ```js [app/adapters/application.js] buildQuery(snapshot) { let query = super.buildQuery(...arguments); let { fields } = snapshot.adapterOptions; if (fields) { query.fields = fields; } return query; } ``` 2. Then pass through the applicable fields to your `findRecord` request. Given a `post` model with attributes body, title, publishDate and meta, you can retrieve a filtered list of attributes. ```js [app/routes/post.js] export default class extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title' } }); } } ``` Moreover, you can filter attributes on related models as well. If a `post` has a `belongsTo` relationship to a user, just include the relationship key and attributes. ```js [app/routes/post.js] export default class extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title', user: 'name,email' } }); } } ``` ##### Type Parameters ###### T `T` ##### Parameters ###### type [`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record ###### id optional object with options for the request only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved `string` | `number` ###### options? [`FindRecordOptions`](../../types/interfaces/FindRecordOptions.md)<`T`> if the first param is a string this will be the optional options for the request. See examples for available options. ##### Returns `Promise`<`T`> promise ##### Since 1.13.0 #### Call Signature ```ts findRecord( type, id, options?): Promise; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:933 This method returns a record for a given identifier or type and id combination. The `findRecord` method will always resolve its promise with the same object for a given identifier or type and `id`. The `findRecord` method will always return a **promise** that will be resolved with the record. **Example 1** ```js [app/routes/post.js] export default class PostRoute extends Route { model({ post_id }) { return this.store.findRecord('post', post_id); } } ``` **Example 2** `findRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) ```js [app/routes/post.js] export default class PostRoute extends Route { model({ post_id: id }) { return this.store.findRecord({ type: 'post', id }); } } ``` **Example 3** If you have previously received an lid via an Identifier for this record, and the record has already been assigned an id, you can find the record again using just the lid. ```js [app/routes/post.js] store.findRecord({ lid }); ``` If the record is not yet available, the store will ask the adapter's `findRecord` method to retrieve and supply the necessary data. If the record is already present in the store, it depends on the reload behavior *when* the returned promise resolves. ### Preloading You can optionally `preload` specific attributes and relationships that you know of by passing them via the passed `options`. For example, if your Ember route looks like `/posts/1/comments/2` and your API route for the comment also looks like `/posts/1/comments/2` if you want to fetch the comment without also fetching the post you can pass in the post to the `findRecord` call: ```js [app/routes/post-comments.js] export default class PostRoute extends Route { model({ post_id, comment_id: id }) { return this.store.findRecord({ type: 'comment', id, { preload: { post: post_id }} }); } } ``` In your adapter you can then access this id without triggering a network request via the snapshot: ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'comment') let postId = snapshot.belongsTo('post', { id: true }); return fetch(`./posts/${postId}/comments/${id}`) .then(response => response.json()) } } static create() { return new this(); } } ``` This could also be achieved by supplying the post id to the adapter via the adapterOptions property on the options hash. ```js [app/routes/post-comments.js] export default class PostRoute extends Route { model({ post_id, comment_id: id }) { return this.store.findRecord({ type: 'comment', id, { adapterOptions: { post: post_id }} }); } } ``` ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'comment') let postId = snapshot.adapterOptions.post; return fetch(`./posts/${postId}/comments/${id}`) .then(response => response.json()) } } static create() { return new this(); } } ``` If you have access to the post model you can also pass the model itself to preload: ```javascript let post = await store.findRecord('post', '1'); let comment = await store.findRecord('comment', '2', { post: myPostModel }); ``` ### Reloading The reload behavior is configured either via the passed `options` hash or the result of the adapter's `shouldReloadRecord`. If `{ reload: true }` is passed or `adapter.shouldReloadRecord` evaluates to `true`, then the returned promise resolves once the adapter returns data, regardless if the requested record is already in the store: ```js store.push({ data: { id: 1, type: 'post', revision: 1 } }); // adapter#findRecord resolves with // [ // { // id: 1, // type: 'post', // revision: 2 // } // ] store.findRecord('post', '1', { reload: true }).then(function(post) { post.revision; // 2 }); ``` If no reload is indicated via the above mentioned ways, then the promise immediately resolves with the cached version in the store. ### Background Reloading Optionally, if `adapter.shouldBackgroundReloadRecord` evaluates to `true`, then a background reload is started, which updates the records' data, once it is available: ```js // app/adapters/post.js import ApplicationAdapter from "./application"; export default class PostAdapter extends ApplicationAdapter { shouldReloadRecord(store, snapshot) { return false; }, shouldBackgroundReloadRecord(store, snapshot) { return true; } }); // ... store.push({ data: { id: 1, type: 'post', revision: 1 } }); let blogPost = store.findRecord('post', '1').then(function(post) { post.revision; // 1 }); // later, once adapter#findRecord resolved with // [ // { // id: 1, // type: 'post', // revision: 2 // } // ] blogPost.revision; // 2 ``` If you would like to force or prevent background reloading, you can set a boolean value for `backgroundReload` in the options object for `findRecord`. ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { backgroundReload: false }); } } ``` If you pass an object on the `adapterOptions` property of the options argument it will be passed to your adapter via the snapshot ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { subscribe: false } }); } } ``` ```js [app/adapters/post.js] import MyCustomAdapter from './custom-adapter'; export default class PostAdapter extends MyCustomAdapter { findRecord(store, type, id, snapshot) { if (snapshot.adapterOptions.subscribe) { // ... } // ... } } ``` See [peekRecord](../methods/peekRecord?anchor=peekRecord) to get the cached version of a record. ### Retrieving Related Model Records If you use an adapter such as Ember's default [`JSONAPIAdapter`](/ember-data/release/classes/JSONAPIAdapter) that supports the [JSON API specification](http://jsonapi.org/) and if your server endpoint supports the use of an ['include' query parameter](http://jsonapi.org/format/#fetching-includes), you can use `findRecord()` or `findAll()` to automatically retrieve additional records related to the one you request by supplying an `include` parameter in the `options` object. For example, given a `post` model that has a `hasMany` relationship with a `comment` model, when we retrieve a specific post we can have the server also return that post's comments in the same request: ```js [app/routes/post.js] export default class PostRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { include: ['comments'] }); } } ``` ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'post') let includes = snapshot.adapterOptions.include; return fetch(`./posts/${postId}?include=${includes}`) .then(response => response.json()) } } static create() { return new this(); } } ``` In this case, the post's comments would then be available in your template as `model.comments`. Multiple relationships can be requested using an `include` parameter consisting of a list of relationship names, while nested relationships can be specified using a dot-separated sequence of relationship names. So to request both the post's comments and the authors of those comments the request would look like this: ```js [app/routes/post.js] export default class PostRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { include: ['comments','comments.author'] }); } } ``` ### Retrieving Specific Fields by Type If your server endpoint supports the use of a ['fields' query parameter](https://jsonapi.org/format/#fetching-sparse-fieldsets), you can use pass those fields through to your server. At this point in time, this requires a few manual steps on your part. 1. Implement `buildQuery` in your adapter. ```js [app/adapters/application.js] buildQuery(snapshot) { let query = super.buildQuery(...arguments); let { fields } = snapshot.adapterOptions; if (fields) { query.fields = fields; } return query; } ``` 2. Then pass through the applicable fields to your `findRecord` request. Given a `post` model with attributes body, title, publishDate and meta, you can retrieve a filtered list of attributes. ```js [app/routes/post.js] export default class extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title' } }); } } ``` Moreover, you can filter attributes on related models as well. If a `post` has a `belongsTo` relationship to a user, just include the relationship key and attributes. ```js [app/routes/post.js] export default class extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title', user: 'name,email' } }); } } ``` ##### Parameters ###### type `string` either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record ###### id optional object with options for the request only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved `string` | `number` ###### options? [`FindRecordOptions`](../../types/interfaces/FindRecordOptions.md)<`unknown`> if the first param is a string this will be the optional options for the request. See examples for available options. ##### Returns `Promise`<`unknown`> promise ##### Since 1.13.0 #### Call Signature ```ts findRecord(resource, options?): Promise; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:934 This method returns a record for a given identifier or type and id combination. The `findRecord` method will always resolve its promise with the same object for a given identifier or type and `id`. The `findRecord` method will always return a **promise** that will be resolved with the record. **Example 1** ```js [app/routes/post.js] export default class PostRoute extends Route { model({ post_id }) { return this.store.findRecord('post', post_id); } } ``` **Example 2** `findRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) ```js [app/routes/post.js] export default class PostRoute extends Route { model({ post_id: id }) { return this.store.findRecord({ type: 'post', id }); } } ``` **Example 3** If you have previously received an lid via an Identifier for this record, and the record has already been assigned an id, you can find the record again using just the lid. ```js [app/routes/post.js] store.findRecord({ lid }); ``` If the record is not yet available, the store will ask the adapter's `findRecord` method to retrieve and supply the necessary data. If the record is already present in the store, it depends on the reload behavior *when* the returned promise resolves. ### Preloading You can optionally `preload` specific attributes and relationships that you know of by passing them via the passed `options`. For example, if your Ember route looks like `/posts/1/comments/2` and your API route for the comment also looks like `/posts/1/comments/2` if you want to fetch the comment without also fetching the post you can pass in the post to the `findRecord` call: ```js [app/routes/post-comments.js] export default class PostRoute extends Route { model({ post_id, comment_id: id }) { return this.store.findRecord({ type: 'comment', id, { preload: { post: post_id }} }); } } ``` In your adapter you can then access this id without triggering a network request via the snapshot: ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'comment') let postId = snapshot.belongsTo('post', { id: true }); return fetch(`./posts/${postId}/comments/${id}`) .then(response => response.json()) } } static create() { return new this(); } } ``` This could also be achieved by supplying the post id to the adapter via the adapterOptions property on the options hash. ```js [app/routes/post-comments.js] export default class PostRoute extends Route { model({ post_id, comment_id: id }) { return this.store.findRecord({ type: 'comment', id, { adapterOptions: { post: post_id }} }); } } ``` ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'comment') let postId = snapshot.adapterOptions.post; return fetch(`./posts/${postId}/comments/${id}`) .then(response => response.json()) } } static create() { return new this(); } } ``` If you have access to the post model you can also pass the model itself to preload: ```javascript let post = await store.findRecord('post', '1'); let comment = await store.findRecord('comment', '2', { post: myPostModel }); ``` ### Reloading The reload behavior is configured either via the passed `options` hash or the result of the adapter's `shouldReloadRecord`. If `{ reload: true }` is passed or `adapter.shouldReloadRecord` evaluates to `true`, then the returned promise resolves once the adapter returns data, regardless if the requested record is already in the store: ```js store.push({ data: { id: 1, type: 'post', revision: 1 } }); // adapter#findRecord resolves with // [ // { // id: 1, // type: 'post', // revision: 2 // } // ] store.findRecord('post', '1', { reload: true }).then(function(post) { post.revision; // 2 }); ``` If no reload is indicated via the above mentioned ways, then the promise immediately resolves with the cached version in the store. ### Background Reloading Optionally, if `adapter.shouldBackgroundReloadRecord` evaluates to `true`, then a background reload is started, which updates the records' data, once it is available: ```js // app/adapters/post.js import ApplicationAdapter from "./application"; export default class PostAdapter extends ApplicationAdapter { shouldReloadRecord(store, snapshot) { return false; }, shouldBackgroundReloadRecord(store, snapshot) { return true; } }); // ... store.push({ data: { id: 1, type: 'post', revision: 1 } }); let blogPost = store.findRecord('post', '1').then(function(post) { post.revision; // 1 }); // later, once adapter#findRecord resolved with // [ // { // id: 1, // type: 'post', // revision: 2 // } // ] blogPost.revision; // 2 ``` If you would like to force or prevent background reloading, you can set a boolean value for `backgroundReload` in the options object for `findRecord`. ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { backgroundReload: false }); } } ``` If you pass an object on the `adapterOptions` property of the options argument it will be passed to your adapter via the snapshot ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { subscribe: false } }); } } ``` ```js [app/adapters/post.js] import MyCustomAdapter from './custom-adapter'; export default class PostAdapter extends MyCustomAdapter { findRecord(store, type, id, snapshot) { if (snapshot.adapterOptions.subscribe) { // ... } // ... } } ``` See [peekRecord](../methods/peekRecord?anchor=peekRecord) to get the cached version of a record. ### Retrieving Related Model Records If you use an adapter such as Ember's default [`JSONAPIAdapter`](/ember-data/release/classes/JSONAPIAdapter) that supports the [JSON API specification](http://jsonapi.org/) and if your server endpoint supports the use of an ['include' query parameter](http://jsonapi.org/format/#fetching-includes), you can use `findRecord()` or `findAll()` to automatically retrieve additional records related to the one you request by supplying an `include` parameter in the `options` object. For example, given a `post` model that has a `hasMany` relationship with a `comment` model, when we retrieve a specific post we can have the server also return that post's comments in the same request: ```js [app/routes/post.js] export default class PostRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { include: ['comments'] }); } } ``` ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'post') let includes = snapshot.adapterOptions.include; return fetch(`./posts/${postId}?include=${includes}`) .then(response => response.json()) } } static create() { return new this(); } } ``` In this case, the post's comments would then be available in your template as `model.comments`. Multiple relationships can be requested using an `include` parameter consisting of a list of relationship names, while nested relationships can be specified using a dot-separated sequence of relationship names. So to request both the post's comments and the authors of those comments the request would look like this: ```js [app/routes/post.js] export default class PostRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { include: ['comments','comments.author'] }); } } ``` ### Retrieving Specific Fields by Type If your server endpoint supports the use of a ['fields' query parameter](https://jsonapi.org/format/#fetching-sparse-fieldsets), you can use pass those fields through to your server. At this point in time, this requires a few manual steps on your part. 1. Implement `buildQuery` in your adapter. ```js [app/adapters/application.js] buildQuery(snapshot) { let query = super.buildQuery(...arguments); let { fields } = snapshot.adapterOptions; if (fields) { query.fields = fields; } return query; } ``` 2. Then pass through the applicable fields to your `findRecord` request. Given a `post` model with attributes body, title, publishDate and meta, you can retrieve a filtered list of attributes. ```js [app/routes/post.js] export default class extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title' } }); } } ``` Moreover, you can filter attributes on related models as well. If a `post` has a `belongsTo` relationship to a user, just include the relationship key and attributes. ```js [app/routes/post.js] export default class extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title', user: 'name,email' } }); } } ``` ##### Type Parameters ###### T `T` ##### Parameters ###### resource [`ResourceIdentifierObject`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/ResourceIdentifierObject.md)<[`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`>> ###### options? [`FindRecordOptions`](../../types/interfaces/FindRecordOptions.md)<`T`> if the first param is a string this will be the optional options for the request. See examples for available options. ##### Returns `Promise`<`T`> promise ##### Since 1.13.0 #### Call Signature ```ts findRecord(resource, options?): Promise; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:935 This method returns a record for a given identifier or type and id combination. The `findRecord` method will always resolve its promise with the same object for a given identifier or type and `id`. The `findRecord` method will always return a **promise** that will be resolved with the record. **Example 1** ```js [app/routes/post.js] export default class PostRoute extends Route { model({ post_id }) { return this.store.findRecord('post', post_id); } } ``` **Example 2** `findRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) ```js [app/routes/post.js] export default class PostRoute extends Route { model({ post_id: id }) { return this.store.findRecord({ type: 'post', id }); } } ``` **Example 3** If you have previously received an lid via an Identifier for this record, and the record has already been assigned an id, you can find the record again using just the lid. ```js [app/routes/post.js] store.findRecord({ lid }); ``` If the record is not yet available, the store will ask the adapter's `findRecord` method to retrieve and supply the necessary data. If the record is already present in the store, it depends on the reload behavior *when* the returned promise resolves. ### Preloading You can optionally `preload` specific attributes and relationships that you know of by passing them via the passed `options`. For example, if your Ember route looks like `/posts/1/comments/2` and your API route for the comment also looks like `/posts/1/comments/2` if you want to fetch the comment without also fetching the post you can pass in the post to the `findRecord` call: ```js [app/routes/post-comments.js] export default class PostRoute extends Route { model({ post_id, comment_id: id }) { return this.store.findRecord({ type: 'comment', id, { preload: { post: post_id }} }); } } ``` In your adapter you can then access this id without triggering a network request via the snapshot: ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'comment') let postId = snapshot.belongsTo('post', { id: true }); return fetch(`./posts/${postId}/comments/${id}`) .then(response => response.json()) } } static create() { return new this(); } } ``` This could also be achieved by supplying the post id to the adapter via the adapterOptions property on the options hash. ```js [app/routes/post-comments.js] export default class PostRoute extends Route { model({ post_id, comment_id: id }) { return this.store.findRecord({ type: 'comment', id, { adapterOptions: { post: post_id }} }); } } ``` ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'comment') let postId = snapshot.adapterOptions.post; return fetch(`./posts/${postId}/comments/${id}`) .then(response => response.json()) } } static create() { return new this(); } } ``` If you have access to the post model you can also pass the model itself to preload: ```javascript let post = await store.findRecord('post', '1'); let comment = await store.findRecord('comment', '2', { post: myPostModel }); ``` ### Reloading The reload behavior is configured either via the passed `options` hash or the result of the adapter's `shouldReloadRecord`. If `{ reload: true }` is passed or `adapter.shouldReloadRecord` evaluates to `true`, then the returned promise resolves once the adapter returns data, regardless if the requested record is already in the store: ```js store.push({ data: { id: 1, type: 'post', revision: 1 } }); // adapter#findRecord resolves with // [ // { // id: 1, // type: 'post', // revision: 2 // } // ] store.findRecord('post', '1', { reload: true }).then(function(post) { post.revision; // 2 }); ``` If no reload is indicated via the above mentioned ways, then the promise immediately resolves with the cached version in the store. ### Background Reloading Optionally, if `adapter.shouldBackgroundReloadRecord` evaluates to `true`, then a background reload is started, which updates the records' data, once it is available: ```js // app/adapters/post.js import ApplicationAdapter from "./application"; export default class PostAdapter extends ApplicationAdapter { shouldReloadRecord(store, snapshot) { return false; }, shouldBackgroundReloadRecord(store, snapshot) { return true; } }); // ... store.push({ data: { id: 1, type: 'post', revision: 1 } }); let blogPost = store.findRecord('post', '1').then(function(post) { post.revision; // 1 }); // later, once adapter#findRecord resolved with // [ // { // id: 1, // type: 'post', // revision: 2 // } // ] blogPost.revision; // 2 ``` If you would like to force or prevent background reloading, you can set a boolean value for `backgroundReload` in the options object for `findRecord`. ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { backgroundReload: false }); } } ``` If you pass an object on the `adapterOptions` property of the options argument it will be passed to your adapter via the snapshot ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { subscribe: false } }); } } ``` ```js [app/adapters/post.js] import MyCustomAdapter from './custom-adapter'; export default class PostAdapter extends MyCustomAdapter { findRecord(store, type, id, snapshot) { if (snapshot.adapterOptions.subscribe) { // ... } // ... } } ``` See [peekRecord](../methods/peekRecord?anchor=peekRecord) to get the cached version of a record. ### Retrieving Related Model Records If you use an adapter such as Ember's default [`JSONAPIAdapter`](/ember-data/release/classes/JSONAPIAdapter) that supports the [JSON API specification](http://jsonapi.org/) and if your server endpoint supports the use of an ['include' query parameter](http://jsonapi.org/format/#fetching-includes), you can use `findRecord()` or `findAll()` to automatically retrieve additional records related to the one you request by supplying an `include` parameter in the `options` object. For example, given a `post` model that has a `hasMany` relationship with a `comment` model, when we retrieve a specific post we can have the server also return that post's comments in the same request: ```js [app/routes/post.js] export default class PostRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { include: ['comments'] }); } } ``` ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'post') let includes = snapshot.adapterOptions.include; return fetch(`./posts/${postId}?include=${includes}`) .then(response => response.json()) } } static create() { return new this(); } } ``` In this case, the post's comments would then be available in your template as `model.comments`. Multiple relationships can be requested using an `include` parameter consisting of a list of relationship names, while nested relationships can be specified using a dot-separated sequence of relationship names. So to request both the post's comments and the authors of those comments the request would look like this: ```js [app/routes/post.js] export default class PostRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { include: ['comments','comments.author'] }); } } ``` ### Retrieving Specific Fields by Type If your server endpoint supports the use of a ['fields' query parameter](https://jsonapi.org/format/#fetching-sparse-fieldsets), you can use pass those fields through to your server. At this point in time, this requires a few manual steps on your part. 1. Implement `buildQuery` in your adapter. ```js [app/adapters/application.js] buildQuery(snapshot) { let query = super.buildQuery(...arguments); let { fields } = snapshot.adapterOptions; if (fields) { query.fields = fields; } return query; } ``` 2. Then pass through the applicable fields to your `findRecord` request. Given a `post` model with attributes body, title, publishDate and meta, you can retrieve a filtered list of attributes. ```js [app/routes/post.js] export default class extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title' } }); } } ``` Moreover, you can filter attributes on related models as well. If a `post` has a `belongsTo` relationship to a user, just include the relationship key and attributes. ```js [app/routes/post.js] export default class extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title', user: 'name,email' } }); } } ``` ##### Parameters ###### resource [`ResourceIdentifierObject`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/ResourceIdentifierObject.md) ###### options? [`FindRecordOptions`](../../types/interfaces/FindRecordOptions.md)<`unknown`> if the first param is a string this will be the optional options for the request. See examples for available options. ##### Returns `Promise`<`unknown`> promise ##### Since 1.13.0 *** ### getReference() ```ts getReference(resource, id): RecordReference; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:973 Get the reference for the specified record. Example ```javascript let userRef = store.getReference('user', '1'); // check if the user is loaded let isLoaded = userRef.value() !== null; // get the record of the reference (null if not yet available) let user = userRef.value(); // get the identifier of the reference if (userRef.remoteType() === 'id') { let id = userRef.id(); } // load user (via store.find) userRef.load().then(...) // or trigger a reload userRef.reload().then(...) // provide data for reference userRef.push({ id: 1, username: '@user' }).then(function(user) { userRef.value() === user; }); ``` #### Parameters ##### resource modelName (string) or Identifier (object) `string` | [`ResourceIdentifierObject`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/ResourceIdentifierObject.md) ##### id `string` | `number` #### Returns `RecordReference` #### Since 2.5.0 *** ### getRequestStateService() ```ts getRequestStateService(): RequestStateService; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:411 Retrieve the RequestStateService instance associated with this Store. This can be used to query the status of requests that have been initiated for a given identifier. #### Returns `RequestStateService` *** ### ~~getSchemaDefinitionService()~~ ```ts getSchemaDefinitionService(): SchemaService; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:138 DEPRECATED - Use the property `store.schema` instead. Provides access to the SchemaDefinitionService instance for this Store instance. The SchemaDefinitionService can be used to query for information about the schema of a resource. #### Returns [`SchemaService`](../../types/interfaces/SchemaService.md) #### Deprecated *** ### instantiateRecord() ```ts instantiateRecord(identifier, createRecordArgs): unknown; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:60 This is the hook WarpDrive uses to create a record instance to give reactive access to a resource in the cache. #### Type Parameters ##### T `T` #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### createRecordArgs #### Returns `unknown` *** ### ~~modelFor()~~ #### Call Signature ```ts modelFor(type): ModelSchema; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:516 Returns the schema for a particular resource type (modelName). When used with Model from @ember-data/model the return is the model class, but this is not guaranteed. If looking to query attribute or relationship information it is recommended to use `getSchemaDefinitionService` instead. This method should be considered legacy and exists primarily to continue to support Adapter/Serializer APIs which expect it's return value in their method signatures. The class of a model might be useful if you want to get a list of all the relationship names of the model, see [`relationshipNames`](/ember-data/release/classes/Model?anchor=relationshipNames) for example. ##### Type Parameters ###### T `T` ##### Parameters ###### type [`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> ##### Returns [`ModelSchema`](../../types/interfaces/ModelSchema.md)<`T`> ##### Deprecated #### Call Signature ```ts modelFor(type): ModelSchema; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:517 Returns the schema for a particular resource type (modelName). When used with Model from @ember-data/model the return is the model class, but this is not guaranteed. If looking to query attribute or relationship information it is recommended to use `getSchemaDefinitionService` instead. This method should be considered legacy and exists primarily to continue to support Adapter/Serializer APIs which expect it's return value in their method signatures. The class of a model might be useful if you want to get a list of all the relationship names of the model, see [`relationshipNames`](/ember-data/release/classes/Model?anchor=relationshipNames) for example. ##### Parameters ###### type `string` ##### Returns [`ModelSchema`](../../types/interfaces/ModelSchema.md) ##### Deprecated *** ### peekAll() #### Call Signature ```ts peekAll(type): IdentifierArray; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1379 This method returns a filtered array that contains all of the known records for a given type in the store. Note that because it's just a filter, the result will contain any locally created records of the type, however, it will not make a request to the backend to retrieve additional records. If you would like to request all the records from the backend please use [store.findAll](../methods/findAll?anchor=findAll). Also note that multiple calls to `peekAll` for a given type will always return the same `RecordArray`. Example ```javascript let localPosts = store.peekAll('post'); ``` ##### Type Parameters ###### T `T` ##### Parameters ###### type [`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> the name of the resource ##### Returns `IdentifierArray`<`T`> ##### Since 1.13.0 #### Call Signature ```ts peekAll(type): IdentifierArray; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1380 This method returns a filtered array that contains all of the known records for a given type in the store. Note that because it's just a filter, the result will contain any locally created records of the type, however, it will not make a request to the backend to retrieve additional records. If you would like to request all the records from the backend please use [store.findAll](../methods/findAll?anchor=findAll). Also note that multiple calls to `peekAll` for a given type will always return the same `RecordArray`. Example ```javascript let localPosts = store.peekAll('post'); ``` ##### Parameters ###### type `string` the name of the resource ##### Returns `IdentifierArray` ##### Since 1.13.0 *** ### peekRecord() #### Call Signature ```ts peekRecord(type, id): null | T; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1021 Get a record by a given type and ID without triggering a fetch. This method will synchronously return the record if it is available in the store, otherwise it will return `null`. A record is available if it has been fetched earlier, or pushed manually into the store. See [findRecord](../methods/findRecord?anchor=findRecord) if you would like to request this record from the backend. *Note: This is a synchronous method and does not return a promise.* **Example 1** ```js let post = store.peekRecord('post', '1'); post.id; // '1' ``` `peekRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) **Example 2** ```js let post = store.peekRecord({ type: 'post', id }); post.id; // '1' ``` If you have previously received an lid from an Identifier for this record, you can lookup the record again using just the lid. **Example 3** ```js let post = store.peekRecord({ lid }); post.id; // '1' ``` ##### Type Parameters ###### T `T` ##### Parameters ###### type [`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> ###### id optional only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved. `string` | `number` ##### Returns `null` | `T` record ##### Since 1.13.0 #### Call Signature ```ts peekRecord(type, id): unknown; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1022 Get a record by a given type and ID without triggering a fetch. This method will synchronously return the record if it is available in the store, otherwise it will return `null`. A record is available if it has been fetched earlier, or pushed manually into the store. See [findRecord](../methods/findRecord?anchor=findRecord) if you would like to request this record from the backend. *Note: This is a synchronous method and does not return a promise.* **Example 1** ```js let post = store.peekRecord('post', '1'); post.id; // '1' ``` `peekRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) **Example 2** ```js let post = store.peekRecord({ type: 'post', id }); post.id; // '1' ``` If you have previously received an lid from an Identifier for this record, you can lookup the record again using just the lid. **Example 3** ```js let post = store.peekRecord({ lid }); post.id; // '1' ``` ##### Parameters ###### type `string` ###### id optional only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved. `string` | `number` ##### Returns `unknown` record ##### Since 1.13.0 #### Call Signature ```ts peekRecord(identifier): null | T; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1023 Get a record by a given type and ID without triggering a fetch. This method will synchronously return the record if it is available in the store, otherwise it will return `null`. A record is available if it has been fetched earlier, or pushed manually into the store. See [findRecord](../methods/findRecord?anchor=findRecord) if you would like to request this record from the backend. *Note: This is a synchronous method and does not return a promise.* **Example 1** ```js let post = store.peekRecord('post', '1'); post.id; // '1' ``` `peekRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) **Example 2** ```js let post = store.peekRecord({ type: 'post', id }); post.id; // '1' ``` If you have previously received an lid from an Identifier for this record, you can lookup the record again using just the lid. **Example 3** ```js let post = store.peekRecord({ lid }); post.id; // '1' ``` ##### Type Parameters ###### T `T` ##### Parameters ###### identifier [`ResourceIdentifierObject`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/ResourceIdentifierObject.md)<[`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`>> ##### Returns `null` | `T` record ##### Since 1.13.0 #### Call Signature ```ts peekRecord(identifier): unknown; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1024 Get a record by a given type and ID without triggering a fetch. This method will synchronously return the record if it is available in the store, otherwise it will return `null`. A record is available if it has been fetched earlier, or pushed manually into the store. See [findRecord](../methods/findRecord?anchor=findRecord) if you would like to request this record from the backend. *Note: This is a synchronous method and does not return a promise.* **Example 1** ```js let post = store.peekRecord('post', '1'); post.id; // '1' ``` `peekRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) **Example 2** ```js let post = store.peekRecord({ type: 'post', id }); post.id; // '1' ``` If you have previously received an lid from an Identifier for this record, you can lookup the record again using just the lid. **Example 3** ```js let post = store.peekRecord({ lid }); post.id; // '1' ``` ##### Parameters ###### identifier [`ResourceIdentifierObject`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/ResourceIdentifierObject.md) ##### Returns `unknown` record ##### Since 1.13.0 *** ### push() #### Call Signature ```ts push(data): null; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1547 Push some data for a given type into the store. This method expects normalized [JSON API](http://jsonapi.org/) document. This means you have to follow [JSON API specification](http://jsonapi.org/format/) with few minor adjustments: * record's `type` should always be in singular, dasherized form * members (properties) should be camelCased [Your primary data should be wrapped inside `data` property](http://jsonapi.org/format/#document-top-level): ```js store.push({ data: { // primary data for single record of type `Person` id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } } }); ``` [Demo.](http://ember-twiddle.com/fb99f18cd3b4d3e2a4c7) `data` property can also hold an array (of records): ```js store.push({ data: [ // an array of records { id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } }, { id: '2', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' } } ] }); ``` [Demo.](http://ember-twiddle.com/69cdbeaa3702159dc355) There are some typical properties for `JSONAPI` payload: * `id` - mandatory, unique record's key * `type` - mandatory string which matches `model`'s dasherized name in singular form * `attributes` - object which holds data for record attributes - `attr`'s declared in model * `relationships` - object which must contain any of the following properties under each relationships' respective key (example path is `relationships.achievements.data`): * [`links`](http://jsonapi.org/format/#document-links) * [`data`](http://jsonapi.org/format/#document-resource-object-linkage) - place for primary data * [`meta`](http://jsonapi.org/format/#document-meta) - object which contains meta-information about relationship For this model: ```js [app/models/person.js] import Model, { attr, hasMany } from '@ember-data/model'; export default class PersonRoute extends Route { @attr('string') firstName; @attr('string') lastName; @hasMany('person') children; } ``` To represent the children as IDs: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { data: [ { id: '2', type: 'person' }, { id: '3', type: 'person' }, { id: '4', type: 'person' } ] } } } } ``` [Demo.](http://ember-twiddle.com/343e1735e034091f5bde) To represent the children relationship as a URL: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { links: { related: '/people/1/children' } } } } } ``` If you're streaming data or implementing an adapter, make sure that you have converted the incoming data into this form. The store's [normalize](../methods/normalize?anchor=normalize) method is a convenience helper for converting a json payload into the form Ember Data expects. ```js store.push(store.normalize('person', data)); ``` This method can be used both to push in brand new records, as well as to update existing records. ##### Parameters ###### data [`EmptyResourceDocument`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/EmptyResourceDocument.md) ##### Returns `null` the record(s) that was created or updated. #### Call Signature ```ts push(data): T; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1548 Push some data for a given type into the store. This method expects normalized [JSON API](http://jsonapi.org/) document. This means you have to follow [JSON API specification](http://jsonapi.org/format/) with few minor adjustments: * record's `type` should always be in singular, dasherized form * members (properties) should be camelCased [Your primary data should be wrapped inside `data` property](http://jsonapi.org/format/#document-top-level): ```js store.push({ data: { // primary data for single record of type `Person` id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } } }); ``` [Demo.](http://ember-twiddle.com/fb99f18cd3b4d3e2a4c7) `data` property can also hold an array (of records): ```js store.push({ data: [ // an array of records { id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } }, { id: '2', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' } } ] }); ``` [Demo.](http://ember-twiddle.com/69cdbeaa3702159dc355) There are some typical properties for `JSONAPI` payload: * `id` - mandatory, unique record's key * `type` - mandatory string which matches `model`'s dasherized name in singular form * `attributes` - object which holds data for record attributes - `attr`'s declared in model * `relationships` - object which must contain any of the following properties under each relationships' respective key (example path is `relationships.achievements.data`): * [`links`](http://jsonapi.org/format/#document-links) * [`data`](http://jsonapi.org/format/#document-resource-object-linkage) - place for primary data * [`meta`](http://jsonapi.org/format/#document-meta) - object which contains meta-information about relationship For this model: ```js [app/models/person.js] import Model, { attr, hasMany } from '@ember-data/model'; export default class PersonRoute extends Route { @attr('string') firstName; @attr('string') lastName; @hasMany('person') children; } ``` To represent the children as IDs: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { data: [ { id: '2', type: 'person' }, { id: '3', type: 'person' }, { id: '4', type: 'person' } ] } } } } ``` [Demo.](http://ember-twiddle.com/343e1735e034091f5bde) To represent the children relationship as a URL: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { links: { related: '/people/1/children' } } } } } ``` If you're streaming data or implementing an adapter, make sure that you have converted the incoming data into this form. The store's [normalize](../methods/normalize?anchor=normalize) method is a convenience helper for converting a json payload into the form Ember Data expects. ```js store.push(store.normalize('person', data)); ``` This method can be used both to push in brand new records, as well as to update existing records. ##### Type Parameters ###### T `T` ##### Parameters ###### data [`SingleResourceDocument`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md)<[`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`>> ##### Returns `T` the record(s) that was created or updated. #### Call Signature ```ts push(data): unknown; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1549 Push some data for a given type into the store. This method expects normalized [JSON API](http://jsonapi.org/) document. This means you have to follow [JSON API specification](http://jsonapi.org/format/) with few minor adjustments: * record's `type` should always be in singular, dasherized form * members (properties) should be camelCased [Your primary data should be wrapped inside `data` property](http://jsonapi.org/format/#document-top-level): ```js store.push({ data: { // primary data for single record of type `Person` id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } } }); ``` [Demo.](http://ember-twiddle.com/fb99f18cd3b4d3e2a4c7) `data` property can also hold an array (of records): ```js store.push({ data: [ // an array of records { id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } }, { id: '2', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' } } ] }); ``` [Demo.](http://ember-twiddle.com/69cdbeaa3702159dc355) There are some typical properties for `JSONAPI` payload: * `id` - mandatory, unique record's key * `type` - mandatory string which matches `model`'s dasherized name in singular form * `attributes` - object which holds data for record attributes - `attr`'s declared in model * `relationships` - object which must contain any of the following properties under each relationships' respective key (example path is `relationships.achievements.data`): * [`links`](http://jsonapi.org/format/#document-links) * [`data`](http://jsonapi.org/format/#document-resource-object-linkage) - place for primary data * [`meta`](http://jsonapi.org/format/#document-meta) - object which contains meta-information about relationship For this model: ```js [app/models/person.js] import Model, { attr, hasMany } from '@ember-data/model'; export default class PersonRoute extends Route { @attr('string') firstName; @attr('string') lastName; @hasMany('person') children; } ``` To represent the children as IDs: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { data: [ { id: '2', type: 'person' }, { id: '3', type: 'person' }, { id: '4', type: 'person' } ] } } } } ``` [Demo.](http://ember-twiddle.com/343e1735e034091f5bde) To represent the children relationship as a URL: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { links: { related: '/people/1/children' } } } } } ``` If you're streaming data or implementing an adapter, make sure that you have converted the incoming data into this form. The store's [normalize](../methods/normalize?anchor=normalize) method is a convenience helper for converting a json payload into the form Ember Data expects. ```js store.push(store.normalize('person', data)); ``` This method can be used both to push in brand new records, as well as to update existing records. ##### Parameters ###### data [`SingleResourceDocument`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md) ##### Returns `unknown` the record(s) that was created or updated. #### Call Signature ```ts push(data): T[]; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1550 Push some data for a given type into the store. This method expects normalized [JSON API](http://jsonapi.org/) document. This means you have to follow [JSON API specification](http://jsonapi.org/format/) with few minor adjustments: * record's `type` should always be in singular, dasherized form * members (properties) should be camelCased [Your primary data should be wrapped inside `data` property](http://jsonapi.org/format/#document-top-level): ```js store.push({ data: { // primary data for single record of type `Person` id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } } }); ``` [Demo.](http://ember-twiddle.com/fb99f18cd3b4d3e2a4c7) `data` property can also hold an array (of records): ```js store.push({ data: [ // an array of records { id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } }, { id: '2', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' } } ] }); ``` [Demo.](http://ember-twiddle.com/69cdbeaa3702159dc355) There are some typical properties for `JSONAPI` payload: * `id` - mandatory, unique record's key * `type` - mandatory string which matches `model`'s dasherized name in singular form * `attributes` - object which holds data for record attributes - `attr`'s declared in model * `relationships` - object which must contain any of the following properties under each relationships' respective key (example path is `relationships.achievements.data`): * [`links`](http://jsonapi.org/format/#document-links) * [`data`](http://jsonapi.org/format/#document-resource-object-linkage) - place for primary data * [`meta`](http://jsonapi.org/format/#document-meta) - object which contains meta-information about relationship For this model: ```js [app/models/person.js] import Model, { attr, hasMany } from '@ember-data/model'; export default class PersonRoute extends Route { @attr('string') firstName; @attr('string') lastName; @hasMany('person') children; } ``` To represent the children as IDs: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { data: [ { id: '2', type: 'person' }, { id: '3', type: 'person' }, { id: '4', type: 'person' } ] } } } } ``` [Demo.](http://ember-twiddle.com/343e1735e034091f5bde) To represent the children relationship as a URL: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { links: { related: '/people/1/children' } } } } } ``` If you're streaming data or implementing an adapter, make sure that you have converted the incoming data into this form. The store's [normalize](../methods/normalize?anchor=normalize) method is a convenience helper for converting a json payload into the form Ember Data expects. ```js store.push(store.normalize('person', data)); ``` This method can be used both to push in brand new records, as well as to update existing records. ##### Type Parameters ###### T `T` ##### Parameters ###### data [`CollectionResourceDocument`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/CollectionResourceDocument.md)<[`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`>> ##### Returns `T`\[] the record(s) that was created or updated. #### Call Signature ```ts push(data): unknown[]; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1551 Push some data for a given type into the store. This method expects normalized [JSON API](http://jsonapi.org/) document. This means you have to follow [JSON API specification](http://jsonapi.org/format/) with few minor adjustments: * record's `type` should always be in singular, dasherized form * members (properties) should be camelCased [Your primary data should be wrapped inside `data` property](http://jsonapi.org/format/#document-top-level): ```js store.push({ data: { // primary data for single record of type `Person` id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } } }); ``` [Demo.](http://ember-twiddle.com/fb99f18cd3b4d3e2a4c7) `data` property can also hold an array (of records): ```js store.push({ data: [ // an array of records { id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } }, { id: '2', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' } } ] }); ``` [Demo.](http://ember-twiddle.com/69cdbeaa3702159dc355) There are some typical properties for `JSONAPI` payload: * `id` - mandatory, unique record's key * `type` - mandatory string which matches `model`'s dasherized name in singular form * `attributes` - object which holds data for record attributes - `attr`'s declared in model * `relationships` - object which must contain any of the following properties under each relationships' respective key (example path is `relationships.achievements.data`): * [`links`](http://jsonapi.org/format/#document-links) * [`data`](http://jsonapi.org/format/#document-resource-object-linkage) - place for primary data * [`meta`](http://jsonapi.org/format/#document-meta) - object which contains meta-information about relationship For this model: ```js [app/models/person.js] import Model, { attr, hasMany } from '@ember-data/model'; export default class PersonRoute extends Route { @attr('string') firstName; @attr('string') lastName; @hasMany('person') children; } ``` To represent the children as IDs: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { data: [ { id: '2', type: 'person' }, { id: '3', type: 'person' }, { id: '4', type: 'person' } ] } } } } ``` [Demo.](http://ember-twiddle.com/343e1735e034091f5bde) To represent the children relationship as a URL: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { links: { related: '/people/1/children' } } } } } ``` If you're streaming data or implementing an adapter, make sure that you have converted the incoming data into this form. The store's [normalize](../methods/normalize?anchor=normalize) method is a convenience helper for converting a json payload into the form Ember Data expects. ```js store.push(store.normalize('person', data)); ``` This method can be used both to push in brand new records, as well as to update existing records. ##### Parameters ###### data [`CollectionResourceDocument`](../../../../@warp-drive/core-types/spec/json-api-raw/type-aliases/CollectionResourceDocument.md) ##### Returns `unknown`\[] the record(s) that was created or updated. *** ### query() #### Call Signature ```ts query( type, query, options?): Promise>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1075 This method delegates a query to the adapter. This is the one place where adapter-level semantics are exposed to the application. Each time this method is called a new request is made through the adapter. Exposing queries this way seems preferable to creating an abstract query language for all server-side queries, and then require all adapters to implement them. *** If you do something like this: ```javascript store.query('person', { page: 1 }); ``` The request made to the server will look something like this: ``` GET "/api/v1/person?page=1" ``` *** If you do something like this: ```javascript store.query('person', { ids: ['1', '2', '3'] }); ``` The request made to the server will look something like this: ``` GET "/api/v1/person?ids%5B%5D=1&ids%5B%5D=2&ids%5B%5D=3" decoded: "/api/v1/person?ids[]=1&ids[]=2&ids[]=3" ``` This method returns a promise, which is resolved with a [`Collection`](/ember-data/release/classes/Collection) once the server returns. ##### Type Parameters ###### T `T` ##### Parameters ###### type [`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> the name of the resource ###### query [`LegacyResourceQuery`](../../types/type-aliases/LegacyResourceQuery.md)<`T`> a query to be used by the adapter ###### options? [`QueryOptions`](../../types/type-aliases/QueryOptions.md) optional, may include `adapterOptions` hash which will be passed to adapter.query ##### Returns `Promise`<`Collection`<`T`>> promise ##### Since 1.13.0 #### Call Signature ```ts query( type, query, options?): Promise>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1076 This method delegates a query to the adapter. This is the one place where adapter-level semantics are exposed to the application. Each time this method is called a new request is made through the adapter. Exposing queries this way seems preferable to creating an abstract query language for all server-side queries, and then require all adapters to implement them. *** If you do something like this: ```javascript store.query('person', { page: 1 }); ``` The request made to the server will look something like this: ``` GET "/api/v1/person?page=1" ``` *** If you do something like this: ```javascript store.query('person', { ids: ['1', '2', '3'] }); ``` The request made to the server will look something like this: ``` GET "/api/v1/person?ids%5B%5D=1&ids%5B%5D=2&ids%5B%5D=3" decoded: "/api/v1/person?ids[]=1&ids[]=2&ids[]=3" ``` This method returns a promise, which is resolved with a [`Collection`](/ember-data/release/classes/Collection) once the server returns. ##### Parameters ###### type `string` the name of the resource ###### query [`LegacyResourceQuery`](../../types/type-aliases/LegacyResourceQuery.md) a query to be used by the adapter ###### options? [`QueryOptions`](../../types/type-aliases/QueryOptions.md) optional, may include `adapterOptions` hash which will be passed to adapter.query ##### Returns `Promise`<`Collection`<`unknown`>> promise ##### Since 1.13.0 *** ### queryRecord() #### Call Signature ```ts queryRecord( type, query, options?): Promise; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1174 This method makes a request for one record, where the `id` is not known beforehand (if the `id` is known, use [`findRecord`](../methods/findRecord?anchor=findRecord) instead). This method can be used when it is certain that the server will return a single object for the primary data. Each time this method is called a new request is made through the adapter. Let's assume our API provides an endpoint for the currently logged in user via: ``` // GET /api/current_user { user: { id: 1234, username: 'admin' } } ``` Since the specific `id` of the `user` is not known beforehand, we can use `queryRecord` to get the user: ```javascript store.queryRecord('user', {}).then(function(user) { let username = user.username; // do thing }); ``` The request is made through the adapters' `queryRecord`: ```js [app/adapters/user.js] import Adapter from '@ember-data/adapter'; import $ from 'jquery'; export default class UserAdapter extends Adapter { queryRecord(modelName, query) { return $.getJSON('/api/current_user'); } } ``` Note: the primary use case for `store.queryRecord` is when a single record is queried and the `id` is not known beforehand. In all other cases `store.query` and using the first item of the array is likely the preferred way: ``` // GET /users?username=unique { data: [{ id: 1234, type: 'user', attributes: { username: "unique" } }] } ``` ```javascript store.query('user', { username: 'unique' }).then(function(users) { return users.firstObject; }).then(function(user) { let id = user.id; }); ``` This method returns a promise, which resolves with the found record. If the adapter returns no data for the primary data of the payload, then `queryRecord` resolves with `null`: ``` // GET /users?username=unique { data: null } ``` ```javascript store.queryRecord('user', { username: 'unique' }).then(function(user) { // user is null }); ``` ##### Type Parameters ###### T `T` ##### Parameters ###### type [`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> ###### query [`LegacyResourceQuery`](../../types/type-aliases/LegacyResourceQuery.md)<`T`> an opaque query to be used by the adapter ###### options? [`QueryOptions`](../../types/type-aliases/QueryOptions.md) optional, may include `adapterOptions` hash which will be passed to adapter.queryRecord ##### Returns `Promise`<`null` | `T`> promise which resolves with the found record or `null` ##### Since 1.13.0 #### Call Signature ```ts queryRecord( type, query, options?): Promise; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1175 This method makes a request for one record, where the `id` is not known beforehand (if the `id` is known, use [`findRecord`](../methods/findRecord?anchor=findRecord) instead). This method can be used when it is certain that the server will return a single object for the primary data. Each time this method is called a new request is made through the adapter. Let's assume our API provides an endpoint for the currently logged in user via: ``` // GET /api/current_user { user: { id: 1234, username: 'admin' } } ``` Since the specific `id` of the `user` is not known beforehand, we can use `queryRecord` to get the user: ```javascript store.queryRecord('user', {}).then(function(user) { let username = user.username; // do thing }); ``` The request is made through the adapters' `queryRecord`: ```js [app/adapters/user.js] import Adapter from '@ember-data/adapter'; import $ from 'jquery'; export default class UserAdapter extends Adapter { queryRecord(modelName, query) { return $.getJSON('/api/current_user'); } } ``` Note: the primary use case for `store.queryRecord` is when a single record is queried and the `id` is not known beforehand. In all other cases `store.query` and using the first item of the array is likely the preferred way: ``` // GET /users?username=unique { data: [{ id: 1234, type: 'user', attributes: { username: "unique" } }] } ``` ```javascript store.query('user', { username: 'unique' }).then(function(users) { return users.firstObject; }).then(function(user) { let id = user.id; }); ``` This method returns a promise, which resolves with the found record. If the adapter returns no data for the primary data of the payload, then `queryRecord` resolves with `null`: ``` // GET /users?username=unique { data: null } ``` ```javascript store.queryRecord('user', { username: 'unique' }).then(function(user) { // user is null }); ``` ##### Parameters ###### type `string` ###### query [`LegacyResourceQuery`](../../types/type-aliases/LegacyResourceQuery.md) an opaque query to be used by the adapter ###### options? [`QueryOptions`](../../types/type-aliases/QueryOptions.md) optional, may include `adapterOptions` hash which will be passed to adapter.queryRecord ##### Returns `Promise`<`unknown`> promise which resolves with the found record or `null` ##### Since 1.13.0 *** ### ~~registerSchema()~~ ```ts registerSchema(schema): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:246 DEPRECATED - Use `createSchemaService` instead. Allows an app to register a custom SchemaService for use when information about a resource's schema needs to be queried. This method can only be called more than once, but only one schema definition service may exist. Therefore if you wish to chain services you must lookup the existing service and close over it with the new service by accessing `store.schema` prior to registration. For Example: ```ts import Store from '@ember-data/store'; class SchemaDelegator { constructor(schema) { this._schema = schema; } hasResource(resource: { type: string }): boolean { if (AbstractSchemas.has(resource.type)) { return true; } return this._schema.hasResource(resource); } attributesDefinitionFor(identifier: RecordIdentifier | { type: string }): AttributesSchema { return this._schema.attributesDefinitionFor(identifier); } relationshipsDefinitionFor(identifier: RecordIdentifier | { type: string }): RelationshipsSchema { const schema = AbstractSchemas.get(identifier.type); return schema || this._schema.relationshipsDefinitionFor(identifier); } } export default class extends Store { constructor(...args) { super(...args); const schema = this.schema; this.registerSchema(new SchemaDelegator(schema)); } } ``` #### Parameters ##### schema [`SchemaService`](../../types/interfaces/SchemaService.md) #### Returns `void` #### Deprecated *** ### ~~registerSchemaDefinitionService()~~ ```ts registerSchemaDefinitionService(schema): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:192 DEPRECATED - Use `createSchemaService` instead. Allows an app to register a custom SchemaService for use when information about a resource's schema needs to be queried. This method can only be called more than once, but only one schema definition service may exist. Therefore if you wish to chain services you must lookup the existing service and close over it with the new service by accessing `store.schema` prior to registration. For Example: ```ts import Store from '@ember-data/store'; class SchemaDelegator { constructor(schema) { this._schema = schema; } hasResource(resource: { type: string }): boolean { if (AbstractSchemas.has(resource.type)) { return true; } return this._schema.hasResource(resource); } attributesDefinitionFor(identifier: RecordIdentifier | { type: string }): AttributesSchema { return this._schema.attributesDefinitionFor(identifier); } relationshipsDefinitionFor(identifier: RecordIdentifier | { type: string }): RelationshipsSchema { const schema = AbstractSchemas.get(identifier.type); return schema || this._schema.relationshipsDefinitionFor(identifier); } } export default class extends Store { constructor(...args) { super(...args); const schema = this.createSchemaService(); this.registerSchemaDefinitionService(new SchemaDelegator(schema)); } } ``` #### Parameters ##### schema [`SchemaService`](../../types/interfaces/SchemaService.md) #### Returns `void` #### Deprecated *** ### request() ```ts request(requestConfig): Future; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:468 Issue a request via the configured RequestManager, inserting the response into the cache and handing back a Future which resolves to a ResponseDocument ## Cache Keys Only GET requests with a url or requests with an explicit cache key (`cacheOptions.key`) will have the request result and document cached. The cache key used is `requestConfig.cacheOptions.key` if present, falling back to `requestConfig.url`. Params are not serialized as part of the cache-key, so either ensure they are already in the url or utilize `requestConfig.cacheOptions.key`. For queries issued via the `POST` method `requestConfig.cacheOptions.key` MUST be supplied for the document to be cached. ## Requesting Without a Cache Key Resource data within the request is always updated in the cache, regardless of whether a cache key is present for the request. ## Fulfilling From Cache When a cache-key is determined, the request may fulfill from cache provided the cache is not stale. Cache staleness is determined by the configured CachePolicy with priority given to the `cacheOptions.reload` and `cacheOptions.backgroundReload` on the request if present. If the cache data has soft expired or the request asks for a background reload, the request will fulfill from cache if possible and make a non-blocking request in the background to update the cache. If the cache data has hard expired or the request asks for a reload, the request will not fulfill from cache and will make a blocking request to update the cache. ## The Response The primary difference between `requestManager.request` and `store.request` is that `store.request` will attempt to hydrate the response content into a response Document containing RecordInstances. #### Type Parameters ##### RT `RT` ##### T `T` = `unknown` #### Parameters ##### requestConfig [`StoreRequestInput`](../type-aliases/StoreRequestInput.md)<`RT`, `T`> #### Returns [`Future`](../../../request/index/interfaces/Future.md)<`RT`> *** ### saveRecord() ```ts saveRecord(record, options?): Promise; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1571 Trigger a save for a Record. Returns a promise resolving with the same record when the save is complete. #### Type Parameters ##### T `T` #### Parameters ##### record `T` ##### options? `Record`<`string`, `unknown`> #### Returns `Promise`<`T`> *** ### teardownRecord() ```ts teardownRecord(record): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:66 This is the hook WarpDrive uses to remove a record instance that is no longer needed #### Parameters ##### record `unknown` #### Returns `void` *** ### unloadAll() #### Call Signature ```ts unloadAll(type): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1395 This method unloads all records in the store. It schedules unloading to happen during the next run loop. Optionally you can pass a type which unload all records for a given type. ```javascript store.unloadAll(); store.unloadAll('post'); ``` ##### Type Parameters ###### T `T` ##### Parameters ###### type [`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`> the name of the resource ##### Returns `void` #### Call Signature ```ts unloadAll(type?): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1396 This method unloads all records in the store. It schedules unloading to happen during the next run loop. Optionally you can pass a type which unload all records for a given type. ```javascript store.unloadAll(); store.unloadAll('post'); ``` ##### Parameters ###### type? `string` the name of the resource ##### Returns `void` *** ### unloadRecord() ```ts unloadRecord(record): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:579 For symmetry, a record can be unloaded via the store. This will cause the record to be destroyed and freed up for garbage collection. Example ```javascript const { content: { data: post } } = await store.request(findRecord({ type: 'post', id: '1' })); store.unloadRecord(post); ``` #### Type Parameters ##### T `T` #### Parameters ##### record `T` #### Returns `void` *** ### create() ```ts static create(args?): Store; ``` Defined in: warp-drive-packages/core/declarations/store/-private/store-service.d.ts:1593 #### Parameters ##### args? `Record`<`string`, `unknown`> #### Returns `Store` --- --- url: /api/@ember-data/store/index/functions/recordIdentifierFor.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [index](../index.md) / recordIdentifierFor ## Call Signature ```ts function recordIdentifierFor(record): StableRecordIdentifier>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/caches/instance-cache.d.ts:30 Retrieves the unique referentially-stable [RecordIdentifier](/ember-data/release/classes/StableRecordIdentifier) assigned to the given record instance. ```js import { recordIdentifierFor } from "@ember-data/store"; // ... gain access to a record, for instance with peekRecord or findRecord const record = store.peekRecord("user", "1"); // get the identifier for the record (see docs for StableRecordIdentifier) const identifier = recordIdentifierFor(record); // access the identifier's properties. const { id, type, lid } = identifier; ``` ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../../../../@warp-drive/core-types/record/interfaces/TypedRecordInstance.md) ### Parameters #### record `T` a record instance previously obstained from the store. ### Returns [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md)<[`TypeFromInstance`](../../../../@warp-drive/core-types/record/type-aliases/TypeFromInstance.md)<`T`>> ## Call Signature ```ts function recordIdentifierFor(record): StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/store/-private/caches/instance-cache.d.ts:31 Retrieves the unique referentially-stable [RecordIdentifier](/ember-data/release/classes/StableRecordIdentifier) assigned to the given record instance. ```js import { recordIdentifierFor } from "@ember-data/store"; // ... gain access to a record, for instance with peekRecord or findRecord const record = store.peekRecord("user", "1"); // get the identifier for the record (see docs for StableRecordIdentifier) const identifier = recordIdentifierFor(record); // access the identifier's properties. const { id, type, lid } = identifier; ``` ### Parameters #### record `unknown` a record instance previously obstained from the store. ### Returns [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) --- --- url: /api/@ember-data/store/index/functions/setIdentifierForgetMethod.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [index](../index.md) / setIdentifierForgetMethod ```ts function setIdentifierForgetMethod(method): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/caches/identifier-cache.d.ts:28 ## Parameters ### method `null` | `ForgetMethod` ## Returns `void` --- --- url: /api/@ember-data/store/index/functions/setIdentifierGenerationMethod.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [index](../index.md) / setIdentifierGenerationMethod ```ts function setIdentifierGenerationMethod(method): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/caches/identifier-cache.d.ts:26 ## Parameters ### method `null` | `GenerationMethod` ## Returns `void` --- --- url: /api/@ember-data/store/index/functions/setIdentifierResetMethod.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [index](../index.md) / setIdentifierResetMethod ```ts function setIdentifierResetMethod(method): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/caches/identifier-cache.d.ts:29 ## Parameters ### method `null` | `ResetMethod` ## Returns `void` --- --- url: /api/@ember-data/store/index/functions/setIdentifierUpdateMethod.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [index](../index.md) / setIdentifierUpdateMethod ```ts function setIdentifierUpdateMethod(method): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/caches/identifier-cache.d.ts:27 ## Parameters ### method `null` | `UpdateMethod` ## Returns `void` --- --- url: /api/@ember-data/store/index/functions/setKeyInfoForResource.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [index](../index.md) / setKeyInfoForResource ```ts function setKeyInfoForResource(method): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/caches/identifier-cache.d.ts:30 ## Parameters ### method `null` | `KeyInfoMethod` ## Returns `void` --- --- url: /api/@ember-data/store/index/functions/storeFor.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [index](../index.md) / storeFor ```ts function storeFor(record): undefined | default; ``` Defined in: warp-drive-packages/core/declarations/store/-private/caches/instance-cache.d.ts:34 ## Parameters ### record `unknown` ## Returns `undefined` | [`default`](../classes/default.md) --- --- url: /api/@ember-data/store/index.md --- [Documentation](../../../index.md) / [@ember-data/store](../index.md) / index This package provides [*Ember***Data**](https://github.com/emberjs/data/)'s `Store` class. A [Store](https://api.emberjs.com/ember-data/release/classes/Store) coordinates interaction between your application, a [Cache](https://api.emberjs.com/ember-data/release/classes/%3CInterface%3E%20Cache), and sources of data (such as your API or a local persistence layer) accessed via a [RequestManager](https://github.com/emberjs/data/tree/main/packages/request). Optionally, a Store can be configured to hydrate the response data into rich presentation classes. ## Installation If you have installed `ember-data` then you already have this package installed. Otherwise you can install it using your javascript package manager of choice. For instance with [pnpm](https://pnpm.io/) ``` pnpm add @ember-data/store ``` After installing you will want to configure your first `Store`. Read more below for how to create and configure stores for your application. ## 🔨 Creating A Store To use a `Store` we will need to do few things: add a [Cache](https://api.emberjs.com/ember-data/release/classes/%3CInterface%3E%20Cache) to store data **in-memory**, add a [Handler](https://api.emberjs.com/ember-data/release/classes/%3CInterface%3E%20Cache) to fetch data from a source, and implement `instantiateRecord` to tell the store how to display the data for individual resources. > **Note** > If you are using the package `ember-data` then a JSON:API cache, RequestManager, LegacyNetworkHandler, > and `instantiateRecord` are configured for you by default. ### Configuring A Cache To start, let's install a [JSON:API](https://jsonapi.org/) cache. If your app uses `GraphQL` or `REST` other caches may better fit your data. You can author your own cache by creating one that conforms to the [spec](https://api.emberjs.com/ember-data/release/classes/%3CInterface%3E%20Cache). The package `@ember-data/json-api` provides a [JSON:API](https://jsonapi.org/) cache we can use. After installing it, we can configure the store to use this cache. ```js import Store from '@ember-data/store'; import Cache from '@ember-data/json-api'; class extends Store { createCache(storeWrapper) { return new Cache(storeWrapper); } } ``` Now that we have a `cache` let's setup something to handle fetching and saving data via our API. > **Note** > The `ember-data` package automatically includes and configures > the `@ember-data/json-api` cache for you. ### Handling Requests When *Ember***Data** needs to fetch or save data it will pass that request to your application's `RequestManager` for fulfillment. How this fulfillment occurs (in-memory, device storage, via single or multiple API requests, etc.) is then up to the registered request handlers. To start, let's install the `RequestManager` from `@ember-data/request` and the basic `Fetch` handler from \`\`@ember-data/request/fetch\`. > **Note** > If your app uses `GraphQL`, `REST` or different conventions for `JSON:API` than your cache expects, other handlers may better fit your data. You can author your own handler by creating one that conforms to the [handler interface](https://github.com/emberjs/data/tree/main/packages/request#handling-requests). ```ts import Store from '@ember-data/store'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; export default class extends Store { requestManager = new RequestManager() .use([Fetch]); } ``` **Using RequestManager as a Service** Alternatively if you have configured the `RequestManager` to be a service you may re-use it. *app/services/request.js* ```ts import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; export default { create() { return new RequestManager() .use([Fetch]) .useCache(CacheHandler); } } ``` *app/services/store.js* ```ts import Store from '@ember-data/store'; import { service } from '@ember/service'; export default class extends Store { @service('request') requestManager } ``` ### Presenting Data from the Cache Now that we have a source and a cache for our data, we need to configure how the Store delivers that data back to our application. We do this via the hook [instantiateRecord](https://api.emberjs.com/ember-data/release/classes/Store/methods/instantiateRecord%20\(hook\)?anchor=instantiateRecord%20\(hook\)), which allows us to transform the data for a resource before handing it to the application. A naive way to present the data would be to return it as JSON. Typically instead this hook will be used to add reactivity and make each unique resource a singleton, ensuring that if the cache updates our presented data will reflect the new state. Below is an example of using the hooks `instantiateRecord` and a `teardownRecord` to provide minimal read-only reactive state for simple resources. ```ts import Store, { recordIdentifierFor } from '@ember-data/store'; import { TrackedObject } from 'tracked-built-ins'; class extends Store { instantiateRecord(identifier) { const { cache, notifications } = this; // create a TrackedObject with our attributes, id and type const record = new TrackedObject(Object.assign({}, cache.peek(identifier))); record.type = identifier.type; record.id = identifier.id; notifications.subscribe(identifier, (_, change) => { if (change === 'attributes') { Object.assign(record, cache.peek(identifier)); } }); return record; } } ``` Because `instantiateRecord` is opaque to the nature of the record, an implementation can be anything from a fairly simple object to a robust proxy that intelligently links together associated records through relationships. This also enables creating a record that separates `edit` flows from `create` flows entirely. A record class might choose to implement a `checkout`method that gives access to an editable instance while the primary record continues to be read-only and reflect only persisted (non-mutated) state. Typically you will choose an existing record implementation such as `@ember-data/model` for your application. Because of the boundaries around instantiation and the cache, record implementations should be capable of interop both with each other and with any `Cache`. Due to this, if needed an application can utilize multiple record implementations and multiple cache implementations either to support enhanced features for only a subset of records or to be able to incrementally migrate from one record/cache to another record or cache. > **Note** > The `ember-data` package automatically includes the `@ember-data/model` > package and configures it for you. ## Classes * [default](classes/default.md) * [Document](classes/Document.md) ## Interfaces * [CachePolicy](interfaces/CachePolicy.md) * [StoreRequestContext](interfaces/StoreRequestContext.md) ## Type Aliases * [CacheOperation](type-aliases/CacheOperation.md) * [DocumentCacheOperation](type-aliases/DocumentCacheOperation.md) * [NotificationType](type-aliases/NotificationType.md) * [StoreRequestInput](type-aliases/StoreRequestInput.md) ## Variables * [CacheHandler](variables/CacheHandler.md) ## Functions * [recordIdentifierFor](functions/recordIdentifierFor.md) * [setIdentifierForgetMethod](functions/setIdentifierForgetMethod.md) * [setIdentifierGenerationMethod](functions/setIdentifierGenerationMethod.md) * [setIdentifierResetMethod](functions/setIdentifierResetMethod.md) * [setIdentifierUpdateMethod](functions/setIdentifierUpdateMethod.md) * [setKeyInfoForResource](functions/setKeyInfoForResource.md) * [storeFor](functions/storeFor.md) --- --- url: /api/@ember-data/store/index/interfaces/CachePolicy.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [index](../index.md) / CachePolicy Defined in: warp-drive-packages/core/declarations/store/-private/cache-handler/types.d.ts:18 A service which an application may provide to the store via the store's `lifetimes` property to configure the behavior of the CacheHandler. The default behavior for request lifetimes is to never expire unless manually refreshed via `cacheOptions.reload` or `cacheOptions.backgroundReload`. Implementing this service allows you to programatically define when a request should be considered expired. (Interface) CachePolicy ## Methods ### didRequest()? ```ts optional didRequest( request, response, identifier, store): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/cache-handler/types.d.ts:97 Invoked when a request has been fulfilled from the configured request handlers. This is invoked for both foreground and background requests once the cache has been updated. Note, this is invoked regardless of whether the request has a cache-key. It is best practice to notify the store of any requests marked as invalidated so that request subscriptions can reload when needed. ```ts store.notifications.notify(identifier, 'invalidated'); ``` This allows anything subscribed to the request to be notified of the change e.g. ```ts store.notifications.subscribe(identifier, (_, type) => { if (type === 'invalidated') { // do update } }); ``` #### Parameters ##### request [`ImmutableRequestInfo`](../../../../@warp-drive/core-types/request/type-aliases/ImmutableRequestInfo.md) ##### response `null` | `Response` | [`ResponseInfo`](../../../../@warp-drive/core-types/request/interfaces/ResponseInfo.md) ##### identifier `null` | [`StableDocumentIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store [`default`](../classes/default.md) #### Returns `void` *** ### isHardExpired() ```ts isHardExpired(identifier, store): boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/cache-handler/types.d.ts:34 Invoked to determine if the request may be fulfilled from cache if possible. Note, this is only invoked if the request has a cache-key. If no cache entry is found or the entry is hard expired, the request will be fulfilled from the configured request handlers and the cache will be updated before returning the response. #### Parameters ##### identifier [`StableDocumentIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store [`default`](../classes/default.md) #### Returns `boolean` true if the request is considered hard expired *** ### isSoftExpired() ```ts isSoftExpired(identifier, store): boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/cache-handler/types.d.ts:49 Invoked if `isHardExpired` is false to determine if the request should be update behind the scenes if cache data is already available. Note, this is only invoked if the request has a cache-key. If true, the request will be fulfilled from cache while a backgrounded request is made to update the cache via the configured request handlers. #### Parameters ##### identifier [`StableDocumentIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store [`default`](../classes/default.md) #### Returns `boolean` true if the request is considered soft expired *** ### willRequest()? ```ts optional willRequest( request, identifier, store): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/cache-handler/types.d.ts:62 Invoked when a request will be sent to the configured request handlers. This is invoked for both foreground and background requests. Note, this is invoked regardless of whether the request has a cache-key. #### Parameters ##### request [`ImmutableRequestInfo`](../../../../@warp-drive/core-types/request/type-aliases/ImmutableRequestInfo.md) ##### identifier `null` | [`StableDocumentIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store [`default`](../classes/default.md) #### Returns `void` --- --- url: /api/@ember-data/store/index/interfaces/StoreRequestContext.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [index](../index.md) / StoreRequestContext Defined in: warp-drive-packages/core/declarations/store/-private/cache-handler/handler.d.ts:11 ## Extends * [`RequestContext`](../../../../@warp-drive/core-types/request/interfaces/RequestContext.md) ## Properties ### id ```ts id: number; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:300 #### Inherited from [`RequestContext`](../../../../@warp-drive/core-types/request/interfaces/RequestContext.md).[`id`](../../../../@warp-drive/core-types/request/interfaces/RequestContext.md#id) *** ### request ```ts request: Readonly, "controller">> & object & object; ``` Defined in: warp-drive-packages/core/declarations/store/-private/cache-handler/handler.d.ts:12 #### Type declaration ##### bodyUsed? ```ts readonly optional bodyUsed: boolean; ``` Whether the request body has been read. ##### cacheOptions? ```ts readonly optional cacheOptions: Readonly>; ``` ##### data? ```ts readonly optional data: Readonly>; ``` ##### headers? ```ts readonly optional headers: ImmutableHeaders; ``` ##### options? ```ts readonly optional options: Readonly>; ``` #### Type declaration ##### store ```ts store: default; ``` #### See [ImmutableRequestInfo](../../../../@warp-drive/core-types/request/type-aliases/ImmutableRequestInfo.md) #### Overrides [`RequestContext`](../../../../@warp-drive/core-types/request/interfaces/RequestContext.md).[`request`](../../../../@warp-drive/core-types/request/interfaces/RequestContext.md#request) ## Methods ### setResponse() ```ts setResponse(response): void; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:302 #### Parameters ##### response `null` | `Response` | [`ResponseInfo`](../../../../@warp-drive/core-types/request/interfaces/ResponseInfo.md) #### Returns `void` #### Inherited from [`RequestContext`](../../../../@warp-drive/core-types/request/interfaces/RequestContext.md).[`setResponse`](../../../../@warp-drive/core-types/request/interfaces/RequestContext.md#setresponse) *** ### setStream() ```ts setStream(stream): void; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:301 #### Parameters ##### stream `ReadableStream`<`any`> | `Promise`<`null` | `ReadableStream`<`any`>> #### Returns `void` #### Inherited from [`RequestContext`](../../../../@warp-drive/core-types/request/interfaces/RequestContext.md).[`setStream`](../../../../@warp-drive/core-types/request/interfaces/RequestContext.md#setstream) --- --- url: /api/@ember-data/store/index/type-aliases/CacheOperation.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [index](../index.md) / CacheOperation ```ts type CacheOperation = "added" | "removed" | "updated" | "state"; ``` Defined in: warp-drive-packages/core/declarations/store/-private/managers/notification-manager.d.ts:4 --- --- url: /api/@ember-data/store/index/type-aliases/DocumentCacheOperation.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [index](../index.md) / DocumentCacheOperation ```ts type DocumentCacheOperation = "invalidated" | "added" | "removed" | "updated" | "state"; ``` Defined in: warp-drive-packages/core/declarations/store/-private/managers/notification-manager.d.ts:5 --- --- url: /api/@ember-data/store/index/type-aliases/NotificationType.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [index](../index.md) / NotificationType ```ts type NotificationType = | "attributes" | "relationships" | "identity" | "errors" | "meta" | CacheOperation; ``` Defined in: warp-drive-packages/core/declarations/store/-private/managers/notification-manager.d.ts:6 --- --- url: /api/@ember-data/store/index/type-aliases/StoreRequestInput.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [index](../index.md) / StoreRequestInput ```ts type StoreRequestInput = | ImmutableRequestInfo | LooseStoreRequestInfo; ``` Defined in: warp-drive-packages/core/declarations/store/-private/cache-handler/handler.d.ts:10 ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` --- --- url: /api/@ember-data/store/index/variables/CacheHandler.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [index](../index.md) / CacheHandler ```ts const CacheHandler: CacheHandler; ``` Defined in: warp-drive-packages/core/declarations/store/-private/cache-handler/handler.d.ts:56 A CacheHandler that adds support for using an WarpDrive Cache with a RequestManager. This handler will only run when a request has supplied a `store` instance. Requests issued by the store via `store.request()` will automatically have the `store` instance attached to the request. ```ts requestManager.request({ store: store, url: '/api/posts', method: 'GET' }); ``` When this handler elects to handle a request, it will return the raw `StructuredDocument` unless the request has `[EnableHydration]` set to `true`. In this case, the handler will return a `Document` instance that will automatically update the UI when the cache is updated in the future and will hydrate any identifiers in the StructuredDocument into Record instances. When issuing a request via the store, \[EnableHydration] is automatically set to `true`. This means that if desired you can issue requests that utilize the cache without needing to also utilize Record instances if desired. Said differently, you could elect to issue all requests via a RequestManager, without ever using the store directly, by setting \[EnableHydration] to `true` and providing a store instance. Not necessarily the most useful thing, but the decoupled nature of the RequestManager and incremental-feature approach of WarpDrive allows for this flexibility. ```ts import { EnableHydration } from '@warp-drive/core/types/request'; requestManager.request({ store: store, url: '/api/posts', method: 'GET', [EnableHydration]: true }); ``` --- --- url: /api/@ember-data/store/types.md --- [Documentation](../../../index.md) / [@ember-data/store](../index.md) / types ## Interfaces * [BaseFinderOptions](interfaces/BaseFinderOptions.md) * [FindRecordOptions](interfaces/FindRecordOptions.md) * [ModelSchema](interfaces/ModelSchema.md) * [SchemaService](interfaces/SchemaService.md) ## Type Aliases * [CacheCapabilitiesManager](type-aliases/CacheCapabilitiesManager.md) * [FindAllOptions](type-aliases/FindAllOptions.md) * [LegacyResourceQuery](type-aliases/LegacyResourceQuery.md) * [QueryOptions](type-aliases/QueryOptions.md) --- --- url: /api/@ember-data/store/types/interfaces/BaseFinderOptions.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [types](../index.md) / BaseFinderOptions Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:3 ## Extended by * [`FindRecordOptions`](FindRecordOptions.md) ## Type Parameters ### T `T` = `unknown` ## Properties ### adapterOptions? ```ts optional adapterOptions: Record; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:7 *** ### backgroundReload? ```ts optional backgroundReload: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:5 *** ### include? ```ts optional include: T extends TypedRecordInstance ? Includes>[] : string | string[]; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:6 *** ### reload? ```ts optional reload: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:4 --- --- url: /api/@ember-data/store/types/interfaces/FindRecordOptions.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [types](../index.md) / FindRecordOptions Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:9 ## Extends * [`BaseFinderOptions`](BaseFinderOptions.md)<`T`> ## Type Parameters ### T `T` = `unknown` ## Properties ### adapterOptions? ```ts optional adapterOptions: Record; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:7 #### Inherited from [`BaseFinderOptions`](BaseFinderOptions.md).[`adapterOptions`](BaseFinderOptions.md#adapteroptions) *** ### backgroundReload? ```ts optional backgroundReload: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:5 #### Inherited from [`BaseFinderOptions`](BaseFinderOptions.md).[`backgroundReload`](BaseFinderOptions.md#backgroundreload) *** ### include? ```ts optional include: T extends TypedRecordInstance ? Exclude<_ExtractUnion<3, T, true, NONE, NONE, 1>, NONE>[] : string | string[]; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:6 #### Inherited from [`BaseFinderOptions`](BaseFinderOptions.md).[`include`](BaseFinderOptions.md#include) *** ### preload? ```ts optional preload: Record; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:25 Data to preload into the store before the request is made. This feature is *highly* discouraged and has no corresponding feature when using builders and handlers. Excepting relationships: the data should be in the form of a JSON object where the keys are fields on the record and the value is the raw value to be added to the cache. Relationships can either be provided as string IDs from which an identifier will be built base upon the relationship's expected resource type, or be record instances from which the identifier will be extracted. *** ### reload? ```ts optional reload: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:4 #### Inherited from [`BaseFinderOptions`](BaseFinderOptions.md).[`reload`](BaseFinderOptions.md#reload) --- --- url: /api/@ember-data/store/types/interfaces/ModelSchema.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [types](../index.md) / ModelSchema Defined in: warp-drive-packages/core/declarations/store/-types/q/ds-model.d.ts:13 Minimum subset of static schema methods and properties on the "model" class. Only used when using the legacy schema-service implementation for @ember-data/model or when wrapping schema for legacy Adapters/Serializers. ## Type Parameters ### T `T` = `unknown` ## Properties ### attributes ```ts attributes: Map, LegacyAttributeField>; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/ds-model.d.ts:16 *** ### fields ```ts fields: Map, "attribute" | "belongsTo" | "hasMany">; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/ds-model.d.ts:15 *** ### modelName ```ts modelName: T extends TypedRecordInstance ? TypeFromInstance> : string; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/ds-model.d.ts:14 *** ### relationshipsByName ```ts relationshipsByName: Map, LegacyRelationshipField>; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/ds-model.d.ts:17 ## Methods ### eachAttribute() ```ts eachAttribute(callback, binding?): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/ds-model.d.ts:18 #### Type Parameters ##### K `K` *extends* `string` #### Parameters ##### callback (`this`, `key`, `attribute`) => `void` ##### binding? `T` #### Returns `void` *** ### eachRelationship() ```ts eachRelationship(callback, binding?): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/ds-model.d.ts:19 #### Type Parameters ##### K `K` *extends* `string` #### Parameters ##### callback (`this`, `key`, `relationship`) => `void` ##### binding? `T` #### Returns `void` *** ### eachTransformedAttribute() ```ts eachTransformedAttribute(callback, binding?): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/ds-model.d.ts:20 #### Type Parameters ##### K `K` *extends* `string` #### Parameters ##### callback (`this`, `key`, `type`) => `void` ##### binding? `T` #### Returns `void` --- --- url: /api/@ember-data/store/types/interfaces/SchemaService.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [types](../index.md) / SchemaService Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:61 The SchemaService provides the ability to query for information about the structure of any resource type. Applications can provide any implementation of the SchemaService they please so long as it conforms to this interface. The design of the service means that schema information could be lazily populated, derived-on-demand, or progressively enhanced during the course of an application's runtime. The primary requirement is merely that any information the service needs to correctly respond to an inquest is available by the time it is asked. The `@ember-data/model` package provides an implementation of this service which makes use of your model classes as the source of information to respond to queries about resource schema. While this is useful, this may not be ideal for your application. For instance, Schema information could be sideloaded or pre-flighted for API calls, resulting in no need to bundle and ship potentially large and expensive JSON or large Javascript based Models to pull information from. To register a custom schema implementation, implement the store's `createSchemaService` hook to return an instance of your service. ```ts import Store from '@ember-data/store'; import CustomSchemas from './custom-schemas'; export default class extends Store { createSchemaService() { return new CustomSchemas(); } } ``` At runtime, both the `Store` and the `CacheCapabilitiesManager` provide access to this service via the `schema` property. ```ts export default class extends Component { @service store; get fields() { return this.store .schema .fields(this.args.dataType); } } ``` (Interface) SchemaService ## Methods ### ~~attributesDefinitionFor()?~~ ```ts optional attributesDefinitionFor(identifier): AttributesSchema; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:240 DEPRECATED - use `fields` instead Returns definitions for all properties of the specified resource that are considered "attributes". Generally these are properties that are not related to book-keeping state on the client and do not represent a linkage to another resource. The return value should be a dictionary of key:value pairs where the `key` is the attribute or property's name and `value` is an object with at least the property `name` which should also match `key`. Optionally, this object may also specify `type`, which should be a string reference to a `transform`, and `options` which should be dictionary in which any key:value pairs are permissable. For instance, when using `@ember-data/model`, the following attribute definition: ```ts class extends Model { @attr('string', { defaultValue: 'hello' }) greeting; @attr('date') birthday; @attr firstName; } ``` Would be returned as: ```js { greeting: { name: 'greeting', type: 'string', options: { defaultValue: 'hello' } }, birthday: { name: 'birthday', type: 'date' }, firstName: { name: 'firstName' } } ``` #### Parameters ##### identifier `ObjectWithStringTypeProperty` | `RecordIdentifier` #### Returns `AttributesSchema` #### Deprecated *** ### derivation() ```ts derivation(field): Derivation; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:134 Returns the derivation registered with the name provided by `field.type`. Validates that the field is a valid DerivedField. #### Parameters ##### field `ObjectWithStringTypeProperty` | [`DerivedField`](../../../../@warp-drive/core-types/schema/fields/interfaces/DerivedField.md) #### Returns [`Derivation`](../../../../@warp-drive/core-types/schema/concepts/type-aliases/Derivation.md) *** ### ~~doesTypeExist()?~~ ```ts optional doesTypeExist(type): boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:72 DEPRECATED - use `hasResource` instead Queries whether the SchemaService recognizes `type` as a resource type #### Parameters ##### type `string` #### Returns `boolean` #### Deprecated *** ### fields() ```ts fields(resource): Map; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:107 Queries for the fields of a given resource type or resource identity. Should error if the resource type is not recognized. #### Parameters ##### resource [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) | `ObjectWithStringTypeProperty` #### Returns `Map`<`string`, [`FieldSchema`](../../../../@warp-drive/core-types/schema/fields/type-aliases/FieldSchema.md)> *** ### hashFn() ```ts hashFn(field): HashFn; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:125 Returns the hash function registered with the name provided by `field.type`. Validates that the field is a valid HashField. #### Parameters ##### field `ObjectWithStringTypeProperty` | [`HashField`](../../../../@warp-drive/core-types/schema/fields/interfaces/HashField.md) #### Returns [`HashFn`](../../../../@warp-drive/core-types/schema/concepts/type-aliases/HashFn.md) *** ### hasResource() ```ts hasResource(resource): boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:80 Queries whether the SchemaService recognizes `type` as a resource type #### Parameters ##### resource [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) | `ObjectWithStringTypeProperty` #### Returns `boolean` *** ### hasTrait() ```ts hasTrait(type): boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:88 Queries whether the SchemaService recognizes `type` as a resource trait #### Parameters ##### type `string` #### Returns `boolean` *** ### registerDerivation() ```ts registerDerivation(derivation): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:186 Enables registration of a derivation. The derivation can later be retrieved by the name attached to it's `[Type]` property. #### Type Parameters ##### R `R` ##### T `T` ##### FM `FM` *extends* | `null` | [`ObjectValue`](../../../../@warp-drive/core-types/json/raw/interfaces/ObjectValue.md) #### Parameters ##### derivation [`Derivation`](../../../../@warp-drive/core-types/schema/concepts/type-aliases/Derivation.md)<`R`, `T`, `FM`> #### Returns `void` *** ### registerHashFn() ```ts registerHashFn(hashFn): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:196 Enables registration of a hashing function The hashing function can later be retrieved by the name attached to it's `[Type]` property. #### Parameters ##### hashFn [`HashFn`](../../../../@warp-drive/core-types/schema/concepts/type-aliases/HashFn.md) #### Returns `void` *** ### registerResource() ```ts registerResource(schema): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:166 Enables registration of a single Schema representing either a resource in PolarisMode or LegacyMode or an ObjectSchema representing an embedded structure in other schemas. This can be useful for either pre-loading schema information or for registering schema information delivered by API calls or other sources just-in-time. #### Parameters ##### schema [`Schema`](../../../../@warp-drive/core-types/schema/fields/type-aliases/Schema.md) #### Returns `void` *** ### registerResources() ```ts registerResources(schemas): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:153 Enables registration of multiple Schemas at once. This can be useful for either pre-loading schema information or for registering schema information delivered by API calls or other sources just-in-time. #### Parameters ##### schemas [`Schema`](../../../../@warp-drive/core-types/schema/fields/type-aliases/Schema.md)\[] #### Returns `void` *** ### registerTransformation() ```ts registerTransformation(transform): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:176 Enables registration of a transformation. The transformation can later be retrieved by the name attached to it's `[Type]` property. #### Parameters ##### transform [`Transformation`](../../../../@warp-drive/core-types/schema/concepts/type-aliases/Transformation.md) #### Returns `void` *** ### ~~relationshipsDefinitionFor()?~~ ```ts optional relationshipsDefinitionFor(identifier): RelationshipsSchema; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:321 DEPRECATED - use `fields` instead Returns definitions for all properties of the specified resource that are considered "relationships". Generally these are properties that represent a linkage to another resource. The return value should be a dictionary of key:value pairs where the `key` is the relationship or property's name and `value` is an object with at least the following properties: * `name` which should also match the `key` used in the dictionary. * `kind` which should be either `belongsTo` or `hasMany` * `type` which should be the related resource's string "type" * `options` which should be a dictionary allowing any key but with at least the below keys present. * `options.async` a boolean representing whether data for this relationship is typically loaded on-demand. * `options.inverse` a string or null representing the field name / key of the corresponding relationship on the inverse resource. Additionally the following options properties are optional. See [Polymorphic Relationships](https://rfcs.emberjs.com/id/0793-polymporphic-relations-without-inheritance) * `options.polymorphic` a boolean representing whether multiple resource types can be used to satisfy this relationship. * `options.as` a string representing the abstract type that the concrete side of a relationship must specify when fulfilling a polymorphic inverse. For example, the following Model using @ember-data/model would generate this relationships definition by default: ```js class User extends Model { @belongsTo('user', { async: false, inverse: null }) bestFriend; @hasMany('user', { async: true, inverse: 'friends' }) friends; @hasMany('pet', { async: false, polymorphic: true, inverse: 'owner' }) pets; } ``` Which would be returned as ```js { bestFriend: { name: 'bestFriend', kind: 'belongsTo', type: 'user', options: { async: false, inverse: null } }, friends: { name: 'friends', kind: 'hasMany', type: 'user', options: { async: true, inverse: 'friends' } }, pets: { name: 'pets', kind: 'hasMany', type: 'pet', options: { async: false, polymorphic: true, inverse: 'owner' } }, } ``` #### Parameters ##### identifier `ObjectWithStringTypeProperty` | `RecordIdentifier` #### Returns `RelationshipsSchema` #### Deprecated *** ### resource() ```ts resource(resource): Schema; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:142 Returns the schema for the provided resource type. #### Parameters ##### resource [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) | `ObjectWithStringTypeProperty` #### Returns [`Schema`](../../../../@warp-drive/core-types/schema/fields/type-aliases/Schema.md) *** ### resourceHasTrait() ```ts resourceHasTrait(resource, trait): boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:97 Queries whether the given resource has the given trait #### Parameters ##### resource [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) | `ObjectWithStringTypeProperty` ##### trait `string` #### Returns `boolean` *** ### resourceTypes() ```ts resourceTypes(): readonly string[]; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:328 Returns all known resource types #### Returns readonly `string`\[] *** ### transformation() ```ts transformation(field): Transformation; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:116 Returns the transformation registered with the name provided by `field.type`. Validates that the field is a valid transformable. #### Parameters ##### field `ObjectWithStringTypeProperty` | [`GenericField`](../../../../@warp-drive/core-types/schema/fields/interfaces/GenericField.md) | [`ObjectField`](../../../../@warp-drive/core-types/schema/fields/interfaces/ObjectField.md) | [`ArrayField`](../../../../@warp-drive/core-types/schema/fields/interfaces/ArrayField.md) #### Returns [`Transformation`](../../../../@warp-drive/core-types/schema/concepts/type-aliases/Transformation.md) --- --- url: /api/@ember-data/store/types/type-aliases/CacheCapabilitiesManager.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [types](../index.md) / CacheCapabilitiesManager ```ts type CacheCapabilitiesManager = object; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:17 CacheCapabilitiesManager provides encapsulated API access to the minimal subset of the Store's functionality that Cache implementations should interact with. It is provided to the Store's `createCache` hook. Cache implementations should not need more than this API provides. This class cannot be directly instantiated. CacheCapabilitiesManager ## Properties ### identifierCache ```ts identifierCache: IdentifierCache; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:29 Provides access to the IdentifierCache instance for this Store instance. The IdentifierCache can be used to peek, generate or retrieve a stable unique identifier for any resource. *** ### schema ```ts schema: SchemaService; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:53 Provides access to the SchemaService instance for this Store instance. The SchemaService can be used to query for information about the schema of a resource. ## Methods ### disconnectRecord() ```ts disconnectRecord(identifier): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:72 Signal to the store that the specified record may be considered fully removed from the cache. Generally this means that not only does no data exist for the identified resource, no known relationships still point to it either. #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `void` *** ### ~~getSchemaDefinitionService()~~ ```ts getSchemaDefinitionService(): SchemaService; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:42 DEPRECATED - use the schema property Provides access to the SchemaService instance for this Store instance. The SchemaService can be used to query for information about the schema of a resource. #### Returns [`SchemaService`](../interfaces/SchemaService.md) #### Deprecated *** ### hasRecord() ```ts hasRecord(identifier): boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:81 Use this method to determine if the Store has an instantiated record associated with an identifier. #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` *** ### notifyChange() #### Call Signature ```ts notifyChange( identifier, namespace, key): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:95 Notify subscribers of the NotificationManager that cache state has changed. `attributes` and `relationships` do not require a key, but if one is specified it is assumed to be the name of the attribute or relationship that has been updated. No other namespaces currently expect the `key` argument. ##### Parameters ###### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ###### namespace `"added"` | `"removed"` ###### key `null` ##### Returns `void` #### Call Signature ```ts notifyChange( identifier, namespace, key): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:96 ##### Parameters ###### identifier [`StableDocumentIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md) ###### namespace `"added"` | `"removed"` | `"updated"` ###### key `null` ##### Returns `void` #### Call Signature ```ts notifyChange( identifier, namespace, key): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:97 ##### Parameters ###### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ###### namespace [`NotificationType`](../../index/type-aliases/NotificationType.md) ###### key `null` | `string` ##### Returns `void` #### Call Signature ```ts notifyChange( identifier, namespace, key): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:98 ##### Parameters ###### identifier [`StableDocumentIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md) | [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ###### namespace [`NotificationType`](../../index/type-aliases/NotificationType.md) ###### key `null` | `string` ##### Returns `void` *** ### setRecordId() ```ts setRecordId(identifier, id): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:62 Update the `id` for the record corresponding to the identifier This operation can only be done for records whose `id` is `null`. #### Parameters ##### identifier [`StableRecordIdentifier`](../../../../@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### id `string` #### Returns `void` --- --- url: /api/@ember-data/store/types/type-aliases/FindAllOptions.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [types](../index.md) / FindAllOptions ```ts type FindAllOptions = BaseFinderOptions; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:30 ## Type Parameters ### T `T` = `unknown` --- --- url: /api/@ember-data/store/types/type-aliases/LegacyResourceQuery.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [types](../index.md) / LegacyResourceQuery ```ts type LegacyResourceQuery = object; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:31 ## Type Parameters ### T `T` = `unknown` ## Indexable ```ts [key: string]: | undefined | Value ``` ## Properties ### include? ```ts optional include: T extends TypedRecordInstance ? Includes[] : string | string[]; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:32 --- --- url: /api/@ember-data/store/types/type-aliases/QueryOptions.md --- [Documentation](../../../../index.md) / [@ember-data/store](../../index.md) / [types](../index.md) / QueryOptions ```ts type QueryOptions = { [K in string | "adapterOptions"]?: K extends "adapterOptions" ? Record : unknown }; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:27 --- --- url: /api/@ember-data/tracking/functions/buildSignalConfig.md --- [Documentation](../../../index.md) / [@ember-data/tracking](../index.md) / buildSignalConfig ```ts function buildSignalConfig(options): object; ``` Defined in: [index.ts:88](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/packages/tracking/src/index.ts#L88) Creates a signal configuration object for WarpDrive that integrates with Ember's reactivity system. This will be automatically imported and registered by `@ember-data/store` if the deprecation has not been resolved. This function should not be called directly in your application code and this package is deprecated entirely, see the [package overview](../../) for more details. ## Parameters ### options #### wellknown { `Array`: `string` | `symbol`; } #### wellknown.Array `string` | `symbol` ## Returns `object` ### ~~createMemo()~~ ```ts createMemo: (object, key, fn) => () => F; ``` #### Type Parameters ##### F `F` #### Parameters ##### object `object` ##### key `string` | `symbol` ##### fn () => `F` #### Returns ```ts (): F; ``` ##### Returns `F` ### ~~waitFor()~~ ```ts waitFor: (promise) => Promise; ``` #### Type Parameters ##### K `K` #### Parameters ##### promise `Promise`<`K`> #### Returns `Promise`<`K`> ### ~~willSyncFlushWatchers()~~ ```ts willSyncFlushWatchers: () => boolean; ``` #### Returns `boolean` ### ~~consumeSignal()~~ ```ts consumeSignal(signal): void; ``` #### Parameters ##### signal `unknown` #### Returns `void` ### ~~createSignal()~~ ```ts createSignal(obj, key): unknown; ``` #### Parameters ##### obj `object` ##### key `string` | `symbol` #### Returns `unknown` ### ~~notifySignal()~~ ```ts notifySignal(signal): void; ``` #### Parameters ##### signal `unknown` #### Returns `void` ## Deprecated --- --- url: /api/@warp-drive/build-config/babel-macros/functions/macros.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [babel-macros](../index.md) / macros ```ts function macros(): BabelPlugin[]; ``` Defined in: [babel-macros.ts:54](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/babel-macros.ts#L54) ## Returns `BabelPlugin`\[] an array of Babel plugins that can be used for code-stripping based on the configuration supplied to `setConfig` and the current ENV. * deprecation constants imported from `@warp-drive/build-config/deprecations` * feature flags imported from `@warp-drive/build-config/canary-features` * debug logging constants imported from `@warp-drive/build-config/debugging` * environment constants imported from `@warp-drive/build-config/env` * expressionts imported from `@warp-drive/build-config/macros` --- --- url: /api/@warp-drive/build-config/babel-macros.md --- [Documentation](../../../index.md) / [@warp-drive/build-config](../index.md) / babel-macros Babel plugins that convert constants and expressions into [macroConditions](https://www.npmjs.com/package/@embroider/macros#the-macros) so that they can be stripped from the code during the build process. This allows us to have great DX around common configuration patterns while still being able to ship a small and fast library. Transforms * deprecation constants imported from `@warp-drive/build-config/deprecations` * feature flags imported from `@warp-drive/build-config/canary-features` * debug logging constants imported from `@warp-drive/build-config/debugging` * environment constants imported from `@warp-drive/build-config/env` * expressionts imported from `@warp-drive/build-config/macros` Addons and apps can use these plugins to match the code-stripping behaviors of ***Warp*Drive**. This is useful when managing migrations for canary features and deprecations. ## Functions * [macros](functions/macros.md) --- --- url: >- /api/@warp-drive/build-config/canary-features/variables/JSON_API_CACHE_VALIDATION_ERRORS.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [canary-features](../index.md) / JSON\_API\_CACHE\_VALIDATION\_ERRORS ```ts const JSON_API_CACHE_VALIDATION_ERRORS: boolean | null = false; ``` Defined in: [canary-features.ts:161](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/canary-features.ts#L161) This upcoming feature adds a validation step to payloads received by the JSONAPICache implementation. When a request completes and the result is given to the cache via `cache.put`, the cache will validate the payload against registered schemas as well as the JSON:API spec. ## Since 5.4 --- --- url: >- /api/@warp-drive/build-config/debugging/variables/DEBUG_RELATIONSHIP_NOTIFICATIONS.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [debugging](../index.md) / DEBUG\_RELATIONSHIP\_NOTIFICATIONS ```ts const DEBUG_RELATIONSHIP_NOTIFICATIONS: boolean = false; ``` Defined in: [debugging.ts:166](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/debugging.ts#L166) Helps when debugging causes of a change notification when processing an update to a hasMany relationship. --- --- url: /api/@warp-drive/build-config/debugging/variables/LOG_CACHE.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [debugging](../index.md) / LOG\_CACHE ```ts const LOG_CACHE: boolean = false; ``` Defined in: [debugging.ts:68](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/debugging.ts#L68) log cache updates for both local and remote state. Note in some older versions this was called `LOG_PAYLOADS` and was one of three flags that controlled logging of cache updates. This is now the only flag. The others were `LOG_OPERATIONS` and `LOG_MUTATIONS`. ## Since 5.5 --- --- url: /api/@warp-drive/build-config/debugging/variables/LOG_CACHE_POLICY.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [debugging](../index.md) / LOG\_CACHE\_POLICY ```ts const LOG_CACHE_POLICY: boolean = false; ``` Defined in: [debugging.ts:111](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/debugging.ts#L111) Log decisions made by the Basic CachePolicy --- --- url: /api/@warp-drive/build-config/debugging/variables/LOG_GRAPH.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [debugging](../index.md) / LOG\_GRAPH ```ts const LOG_GRAPH: boolean = false; ``` Defined in: [debugging.ts:145](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/debugging.ts#L145) log updates received by the graph (relationship pointer storage) --- --- url: /api/@warp-drive/build-config/debugging/variables/LOG_INSTANCE_CACHE.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [debugging](../index.md) / LOG\_INSTANCE\_CACHE ```ts const LOG_INSTANCE_CACHE: boolean = false; ``` Defined in: [debugging.ts:152](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/debugging.ts#L152) log creation/removal of RecordData and Record instances. --- --- url: /api/@warp-drive/build-config/debugging/variables/LOG_IDENTIFIERS.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [debugging](../index.md) / LOG\_IDENTIFIERS ```ts const LOG_IDENTIFIERS: boolean = false; ``` Defined in: [debugging.ts:139](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/debugging.ts#L139) log peek, generation and updates to Record Identifiers. --- --- url: /api/@warp-drive/build-config/debugging/variables/LOG_METRIC_COUNTS.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [debugging](../index.md) / LOG\_METRIC\_COUNTS ```ts const LOG_METRIC_COUNTS: boolean = false; ``` Defined in: [debugging.ts:159](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/debugging.ts#L159) Log key count metrics, useful for performance debugging. --- --- url: /api/@warp-drive/build-config/debugging/variables/LOG_MUTATIONS.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [debugging](../index.md) / LOG\_MUTATIONS ```ts const LOG_MUTATIONS: boolean = false; ``` Defined in: [debugging.ts:104](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/debugging.ts#L104) This flag no longer has any effect. Use [LOG\_CACHE](LOG_CACHE.md) instead. ## Deprecated removed in version 5.5 --- --- url: /api/@warp-drive/build-config/debugging/variables/LOG_NOTIFICATIONS.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [debugging](../index.md) / LOG\_NOTIFICATIONS ```ts const LOG_NOTIFICATIONS: boolean = false; ``` Defined in: [debugging.ts:118](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/debugging.ts#L118) log notifications received by the NotificationManager --- --- url: /api/@warp-drive/build-config/debugging/variables/LOG_PAYLOADS.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [debugging](../index.md) / LOG\_PAYLOADS ```ts const LOG_PAYLOADS: boolean = false; ``` Defined in: [debugging.ts:80](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/debugging.ts#L80) This flag no longer has any effect. Use [LOG\_CACHE](LOG_CACHE.md) instead. ## Deprecated removed in version 5.5 --- --- url: /api/@warp-drive/build-config/debugging/variables/LOG_OPERATIONS.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [debugging](../index.md) / LOG\_OPERATIONS ```ts const LOG_OPERATIONS: boolean = false; ``` Defined in: [debugging.ts:92](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/debugging.ts#L92) This flag no longer has any effect. Use [LOG\_CACHE](LOG_CACHE.md) instead. ## Deprecated removed in version 5.5 --- --- url: /api/@warp-drive/build-config/debugging/variables/LOG_REQUESTS.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [debugging](../index.md) / LOG\_REQUESTS ```ts const LOG_REQUESTS: boolean = false; ``` Defined in: [debugging.ts:124](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/debugging.ts#L124) log requests issued by the RequestManager --- --- url: /api/@warp-drive/build-config/debugging/variables/LOG_REQUEST_STATUS.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [debugging](../index.md) / LOG\_REQUEST\_STATUS ```ts const LOG_REQUEST_STATUS: boolean = false; ``` Defined in: [debugging.ts:131](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/debugging.ts#L131) log updates to requests the store has issued to the network (adapter) to fulfill. --- --- url: >- /api/@warp-drive/build-config/deprecations/variables/DEPRECATE_COMPUTED_CHAINS.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [deprecations](../index.md) / DEPRECATE\_COMPUTED\_CHAINS ```ts const DEPRECATE_COMPUTED_CHAINS: boolean = true; ``` Defined in: [deprecations.ts:129](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/deprecations.ts#L129) This is a planned deprecation which will trigger when observer or computed chains are used to watch for changes on any WarpDrive LiveArray, CollectionRecordArray, ManyArray or PromiseManyArray. Support for these chains is currently guarded by the deprecation flag listed here, enabling removal of the behavior if desired. The instrumentation was added in 5.0 but the version number is set to 7.0 as we do not want to strip support without adding a deprecation message. Once we've added the deprecation message, we will update this version number to the proper version. ## Since 5.0 ## Until 8.0 --- --- url: >- /api/@warp-drive/build-config/deprecations/variables/DEPRECATE_EMBER_INFLECTOR.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [deprecations](../index.md) / DEPRECATE\_EMBER\_INFLECTOR ```ts const DEPRECATE_EMBER_INFLECTOR: boolean = true; ``` Defined in: [deprecations.ts:475](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/deprecations.ts#L475) Deprecates the use of ember-inflector for pluralization and singularization in favor of the `@ember-data/request-utils` package. Rule configuration methods (singular, plural, uncountable, irregular) and usage methods (singularize, pluralize) are are available as imports from `@ember-data/request-utils/string` Notable differences with ember-inflector: * there cannot be multiple inflector instances with separate rules * pluralization does not support a count argument * string caches now default to 10k entries instead of 1k, and this size is now configurable. Additionally, the cache is now a LRU cache instead of a first-N cache. This deprecation can be resolved by removing usage of ember-inflector or by using both ember-inflector and @ember-data/request-utils in parallel and updating your EmberData/WarpDrive build config to mark the deprecation as resolved in ember-cli-build ```js setConfig(app, __dirname, { deprecations: { DEPRECATE_EMBER_INFLECTOR: false }}); ``` ## Since 5.3 ## Until 6.0 --- --- url: >- /api/@warp-drive/build-config/deprecations/variables/DEPRECATE_LEGACY_IMPORTS.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [deprecations](../index.md) / DEPRECATE\_LEGACY\_IMPORTS ```ts const DEPRECATE_LEGACY_IMPORTS: boolean = true; ``` Defined in: [deprecations.ts:203](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/deprecations.ts#L203) Deprecates when importing from `ember-data/*` instead of `@ember-data/*` in order to prepare for the eventual removal of the legacy `ember-data/*` All imports from `ember-data/*` should be updated to `@ember-data/*` except for `ember-data/store`. When you are using `ember-data` (as opposed to installing the indivudal packages) you should import from `ember-data/store` instead of `@ember-data/store` in order to receive the appropriate configuration of defaults. ## Since 5.3 ## Until 6.0 --- --- url: >- /api/@warp-drive/build-config/deprecations/variables/DEPRECATE_MANY_ARRAY_DUPLICATES.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [deprecations](../index.md) / DEPRECATE\_MANY\_ARRAY\_DUPLICATES ```ts const DEPRECATE_MANY_ARRAY_DUPLICATES: boolean = true; ``` Defined in: [deprecations.ts:407](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/deprecations.ts#L407) When the flag is `true` (default), adding duplicate records to a `ManyArray` is deprecated in non-production environments. In production environments, duplicate records added to a `ManyArray` will be deduped and no error will be thrown. When the flag is `false`, an error will be thrown when duplicates are added. ## Since 5.3 ## Until 6.0 --- --- url: >- /api/@warp-drive/build-config/deprecations/variables/DEPRECATE_NON_STRICT_ID.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [deprecations](../index.md) / DEPRECATE\_NON\_STRICT\_ID ```ts const DEPRECATE_NON_STRICT_ID: boolean = true; ``` Defined in: [deprecations.ts:185](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/deprecations.ts#L185) Currently, WarpDrive expects that the `id` property associated with a resource is a string. However, for legacy support in many locations we would accept a number which would then immediately be coerced into a string. We are deprecating this legacy support for numeric IDs. The goal is that in the future, you will be able to use any ID format so long as everywhere you refer to the ID you use the same format. However, for identifiers we will always use string IDs and so any custom identifier configuration should provide a string ID. ## Since 5.3 ## Until 6.0 --- --- url: >- /api/@warp-drive/build-config/deprecations/variables/DEPRECATE_NON_STRICT_TYPES.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [deprecations](../index.md) / DEPRECATE\_NON\_STRICT\_TYPES ```ts const DEPRECATE_NON_STRICT_TYPES: boolean = true; ``` Defined in: [deprecations.ts:162](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/deprecations.ts#L162) Currently, ***Warp*Drive** expects that the `type` property associated with a resource follows several conventions. * The `type` property must be a non-empty string * The `type` property must be singular * The `type` property must be dasherized We are deprecating support for types that do not match this pattern in order to unlock future improvements in which we can support `type` being any string of your choosing. The goal is that in the future, you will be able to use any string so long as it matches what your configured cache, identifier generation, and schemas expect. E.G. It will matter not that your string is in a specific format like singular, dasherized, etc. so long as everywhere you refer to the type you use the same string. If using @ember-data/model, there will always be a restriction that the `type` must match the path on disk where the model is defined. e.g. `app/models/foo/bar-bem.js` must have a type of `foo/bar-bem` ## Since 5.3 ## Until 6.0 --- --- url: >- /api/@warp-drive/build-config/deprecations/variables/DEPRECATE_NON_UNIQUE_PAYLOADS.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [deprecations](../index.md) / DEPRECATE\_NON\_UNIQUE\_PAYLOADS ```ts const DEPRECATE_NON_UNIQUE_PAYLOADS: boolean = true; ``` Defined in: [deprecations.ts:245](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/deprecations.ts#L245) Deprecates when the data for a hasMany relationship contains duplicate identifiers. Previously, relationships would silently de-dupe the data when received, but this behavior is being removed in favor of erroring if the same related record is included multiple times. For instance, in JSON:API the below relationship data would be considered invalid: ```json { "data": { "type": "article", "id": "1", "relationships": { "comments": { "data": [ { "type": "comment", "id": "1" }, { "type": "comment", "id": "2" }, { "type": "comment", "id": "1" } // duplicate ] } } } ``` To resolve this deprecation, either update your server to not include duplicate data, or implement normalization logic in either a request handler or serializer which removes duplicate data from relationship payloads. ## Since 5.3 ## Until 6.0 --- --- url: >- /api/@warp-drive/build-config/deprecations/variables/DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [deprecations](../index.md) / DEPRECATE\_RELATIONSHIP\_REMOTE\_UPDATE\_CLEARING\_LOCAL\_STATE ```ts const DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE: boolean = true; ``` Defined in: [deprecations.ts:391](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/deprecations.ts#L391) Deprecates when a relationship is updated remotely and the local state is cleared of all changes except for "new" records. Instead, any records not present in the new payload will be considered "removed" while any records present in the new payload will be considered "added". This allows us to "commit" local additions and removals, preserving any additions or removals that are not yet reflected in the remote state. For instance, given the following initial state: remote: A, B, C local: add D, E remove B, C \=> A, D, E If after an update, the remote state is now A, B, D, F then the new state will be remote: A, B, D, F local: add E remove B \=> A, D, E, F Under the old behavior the updated local state would instead have been \=> A, B, D, F Similarly, if a belongsTo remote State was A while its local state was B, then under the old behavior if the remote state changed to C, the local state would be updated to C. Under the new behavior, the local state would remain B. If the remote state was A while its local state was `null`, then under the old behavior if the remote state changed to C, the local state would be updated to C. Under the new behavior, the local state would remain `null`. Thus the new correct mental model is that the state of the relationship at any point in time is whatever the most recent remote state is, plus any local additions or removals you have made that have not yet been reflected by the remote state. > Note: The old behavior extended to modifying the inverse of a relationship. So if > you had local state not reflected in the new remote state, inverses would be notified > and their state reverted as well when "resetting" the relationship. > Under the new behavior, since the local state is preserved the inverses will also > not be reverted. ### Resolving this deprecation Resolving this deprecation can be done individually for each relationship or globally for all relationships. To resolve it globally, set the `DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE` to `false` in ember-cli-build.js ```js const { setConfig } = await import('@warp-drive/build-config'); let app = new EmberApp(defaults, {}); setConfig(app, __dirname, { deprecations: { // set to false to strip the deprecated code (thereby opting into the new behavior) DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE: false } }); ``` To resolve this deprecation on an individual relationship, adjust the `options` passed to the relationship. For relationships with inverses, both sides MUST be migrated to the new behavior at the same time. ```js class Person extends Model { @hasMany('person', { async: false, inverse: null, resetOnRemoteUpdate: false }) children; @belongsTo('person', { async: false, inverse: null, resetOnRemoteUpdate: false }) parent; } ``` > Note: false is the only valid value here, all other values (including missing) > will be treated as true, where `true` is the legacy behavior that is now deprecated. Once you have migrated all relationships, you can remove the the resetOnRemoteUpdate option and set the deprecation flag to false in ember-cli-build. ### What if I don't want the new behavior? WarpDrive's philosophy is to not make assumptions about your application. Where possible we seek out "100%" solutions – solutions that work for all use cases - and where that is not possible we default to "90%" solutions – solutions that work for the vast majority of use cases. In the case of "90%" solutions we look for primitives that allow you to resolve the 10% case in your application. If no such primitives exist, we provide an escape hatch that ensures you can build the behavior you need without adopting the cost of the default solution. In this case, the old behavior was a "40%" solution. The inability for an application developer to determine what changes were made locally, and thus what changes should be preserved, made it impossible to build certain features easily, or in some cases at all. The proliferation of feature requests, bug reports (from folks surprised by the prior behavior) and addon attempts in this space are all evidence of this. We believe the new behavior is a "90%" solution. It works for the vast majority of use cases, often without noticeable changes to existing application behavior, and provides primitives that allow you to build the behavior you need for the remaining 10%. The great news is that this behavior defaults to trusting your API similar to the old behavior. If your API is correct, you will not need to make any changes to your application to adopt the new behavior. This means the 10% cases are those where you can't trust your API to provide the correct information. In these cases, because you now have cheap access to a diff of the relationship state, there are a few options that weren't available before: * you can adjust returned API payloads to contain the expected changes that it doesn't include * you can modify local state by adding or removing records on the HasMany record array to remove any local changes that were not returned by the API. * you can use `.mutate(mutation)` to directly modify the local cache state of the relationship to match the expected state. What this version (5.3) does not yet provide is a way to directly modify the cache's remote state for the relationship via public APIs other than via the broader action of upserting a response via `.put(document)`. However, such an API was sketched in the Cache 2.1 RFC `.patch(operation)` and is likely to be added in a future 5.x release of WarpDrive. This version (5.3) also does not yet provide a way to directly modify the graph (a general purpose subset of cache behaviors specific to relationships) via public APIs. However, during the 5.x release series we will be working on finalizing the Graph API and making it public. If none of these options work for you, you can always opt-out more broadly by implementing a custom Cache with the relationship behaviors you need. ## Since 5.3 ## Until 6.0 --- --- url: >- /api/@warp-drive/build-config/deprecations/variables/DEPRECATE_STORE_EXTENDS_EMBER_OBJECT.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [deprecations](../index.md) / DEPRECATE\_STORE\_EXTENDS\_EMBER\_OBJECT ```ts const DEPRECATE_STORE_EXTENDS_EMBER_OBJECT: boolean = true; ``` Defined in: [deprecations.ts:420](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/deprecations.ts#L420) When the flag is `true` (default), the Store class will extend from `@ember/object`. When the flag is `false` or `ember-source` is not present, the Store will not extend from EmberObject. ## Since 5.4 ## Until 6.0 --- --- url: >- /api/@warp-drive/build-config/deprecations/variables/DEPRECATE_TRACKING_PACKAGE.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [deprecations](../index.md) / DEPRECATE\_TRACKING\_PACKAGE ```ts const DEPRECATE_TRACKING_PACKAGE: boolean = true; ``` Defined in: [deprecations.ts:513](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/deprecations.ts#L513) Deprecates the use of the @ember-data/tracking package which historically provided bindings into Ember's reactivity system. This package is no longer needed as the configuration is now provided by the @warp-drive/ember package. This deprecation can be resolved by removing the @ember-data/tracking package from your project and ensuring that your app.js file has the following import: ```js import '@warp-drive/ember/install'; ``` Once this import is present, you can remove the deprecation by setting the deprecation to `false` in your build config: ```js // inside of ember-cli-build.js const { setConfig } = await import('@warp-drive/build-config'); setConfig(app, __dirname, { deprecations: { DEPRECATE_TRACKING_PACKAGE: false } }); ``` ## Since 5.5 ## Until 6.0 --- --- url: >- /api/@warp-drive/build-config/deprecations/variables/DISABLE_7X_DEPRECATIONS.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [deprecations](../index.md) / DISABLE\_7X\_DEPRECATIONS ```ts const DISABLE_7X_DEPRECATIONS: boolean = true; ``` Defined in: [deprecations.ts:529](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/deprecations.ts#L529) This is a special flag that can be used to opt-in early to receiving deprecations introduced in 6.x which have had their infra backported to 5.x versions of ***Warp*Drive**. When this flag is not present or set to `true`, the deprecations from the 6.x branch will not print their messages and the deprecation cannot be resolved. When this flag is present and set to `false`, the deprecations from the 6.x branch will print and can be resolved. ## Since 5.3 ## Until 7.0 --- --- url: >- /api/@warp-drive/build-config/deprecations/variables/ENABLE_LEGACY_SCHEMA_SERVICE.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [deprecations](../index.md) / ENABLE\_LEGACY\_SCHEMA\_SERVICE ```ts const ENABLE_LEGACY_SCHEMA_SERVICE: boolean = true; ``` Defined in: [deprecations.ts:443](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/deprecations.ts#L443) When the flag is `true` (default), the legacy schema service features will be enabled on the store and the service, and deprecations will be thrown when they are used. Deprecated features include: * `Store.registerSchema` method is deprecated in favor of the `Store.createSchemaService` hook * `Store.registerSchemaDefinitionService` method is deprecated in favor of the `Store.createSchemaService` hook * `Store.getSchemaDefinitionService` method is deprecated in favor of `Store.schema` property * `SchemaService.doesTypeExist` method is deprecated in favor of the `SchemaService.hasResource` method * `SchemaService.attributesDefinitionFor` method is deprecated in favor of the `SchemaService.fields` method * `SchemaService.relationshipsDefinitionFor` method is deprecated in favor of the `SchemaService.fields` method ## Since 5.4 ## Until 6.0 --- --- url: /api/@warp-drive/build-config.md --- [Documentation](../../index.md) / @warp-drive/build-config ## Modules * [babel-macros](babel-macros/index.md) * [canary-features](canary-features/index.md) * [debugging](debugging/index.md) * [deprecations](deprecations/index.md) * [index](index/index.md) --- --- url: /api/@warp-drive/build-config/index.md --- [Documentation](../../../index.md) / [@warp-drive/build-config](../index.md) / index This package provides a build-plugin that enables configuration of deprecations, optional features, development/testing support and debug logging. This configuration is done using `setConfig` in `ember-cli-build`. ```ts [ember-cli-build.js] 'use strict'; const EmberApp = require('ember-cli/lib/broccoli/ember-app'); module.exports = async function (defaults) { const { setConfig } = await import('@warp-drive/build-config'); // [!code focus] const app = new EmberApp(defaults, {}); setConfig(app, __dirname, { // [!code focus:3] // settings here }); const { Webpack } = require('@embroider/webpack'); return require('@embroider/compat').compatBuild(app, Webpack, {}); }; ``` Available settings include: * [debugging](../debugging/index.md) * [deprecations](../deprecations/index.md) * [features](../canary-features/index.md) * [polyfillUUID](type-aliases/WarpDriveConfig.md#polyfilluuid) * [includeDataAdapterInProduction](type-aliases/WarpDriveConfig.md#includedataadapterinproduction) * [compatWith](type-aliases/WarpDriveConfig.md#compatwith) ## Type Aliases * [WarpDriveConfig](type-aliases/WarpDriveConfig.md) ## Functions * [setConfig](functions/setConfig.md) --- --- url: /api/@warp-drive/build-config/index/functions/setConfig.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [index](../index.md) / setConfig ## Call Signature ```ts function setConfig(macros, config): void; ``` Defined in: [index.ts:159](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/index.ts#L159) ### Parameters #### macros `object` #### config [`WarpDriveConfig`](../type-aliases/WarpDriveConfig.md) ### Returns `void` ## Call Signature ```ts function setConfig( context, appRoot, config): void; ``` Defined in: [index.ts:160](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/index.ts#L160) ### Parameters #### context `object` #### appRoot `string` #### config [`WarpDriveConfig`](../type-aliases/WarpDriveConfig.md) ### Returns `void` --- --- url: /api/@warp-drive/build-config/index/type-aliases/WarpDriveConfig.md --- [Documentation](../../../../index.md) / [@warp-drive/build-config](../../index.md) / [index](../index.md) / WarpDriveConfig ```ts type WarpDriveConfig = object; ``` Defined in: [index.ts:52](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/index.ts#L52) ## Properties ### compatWith? ```ts optional compatWith: `${number}.${number}`; ``` Defined in: [index.ts:100](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/index.ts#L100) The most recent version of the library from which all deprecations have been resolved. For instance if all deprecations released prior to or within `5.3` have been resolved, then setting this to `5.3` will remove all the support for the deprecated features for associated deprecations. See [deprecations](../../deprecations/index.md) for more details. *** ### debug? ```ts optional debug: Partial; ``` Defined in: [index.ts:66](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/index.ts#L66) An object of key/value pairs of logging flags see [debugging](../../debugging/index.md) for the available flags. ```ts { LOG_CACHE: true, } ``` *** ### deprecations? ```ts optional deprecations: Partial; ``` Defined in: [index.ts:115](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/index.ts#L115) An object of key/value pairs of logging flags see [deprecations](../../deprecations/index.md) for the available flags. ```ts { DEPRECATE_THING: false, } ``` *** ### features? ```ts optional features: Partial; ``` Defined in: [index.ts:132](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/index.ts#L132) An object of key/value pairs of canary feature flags for use when testing new features gated behind a flag in a canary release version. see [features](../../canary-features/index.md) for the available flags. ```ts { FEATURE_A: true, } ``` *** ### includeDataAdapterInProduction? ```ts optional includeDataAdapterInProduction: boolean; ``` Defined in: [index.ts:87](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/index.ts#L87) By default, the integration required to support the ember-inspector browser extension is included in production builds only when using the `ember-data` package. Otherwise the default is to exclude it. This setting allows to explicitly enable/disable it in production builds. *** ### polyfillUUID? ```ts optional polyfillUUID: boolean; ``` Defined in: [index.ts:75](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/build-config/src/index.ts#L75) If you are using the library in an environment that does not support `window.crypto.randomUUID` you can enable a polyfill for it. --- --- url: /api/@warp-drive/core-types/cache/aliases.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / cache/aliases ## Type Aliases * [ResourceBlob](type-aliases/ResourceBlob.md) --- --- url: /api/@warp-drive/core-types/cache/aliases/type-aliases/ResourceBlob.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/aliases](../index.md) / ResourceBlob ```ts type ResourceBlob = unknown; ``` Defined in: warp-drive-packages/core/declarations/types/cache/aliases.d.ts:1 --- --- url: /api/@warp-drive/core-types/cache/change/interfaces/Change.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/change](../index.md) / Change Defined in: warp-drive-packages/core/declarations/types/cache/change.d.ts:2 ## Properties ### identifier ```ts identifier: | StableRecordIdentifier | StableDocumentIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/change.d.ts:3 *** ### op ```ts op: "upsert" | "remove"; ``` Defined in: warp-drive-packages/core/declarations/types/cache/change.d.ts:4 *** ### patch? ```ts optional patch: unknown; ``` Defined in: warp-drive-packages/core/declarations/types/cache/change.d.ts:5 --- --- url: /api/@warp-drive/core-types/cache/change.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / cache/change ## Interfaces * [Change](interfaces/Change.md) --- --- url: /api/@warp-drive/core-types/cache.md --- [Documentation](../../../index.md) / [@warp-drive/core-types](../index.md) / cache ## Interfaces * [Cache](interfaces/Cache.md) ## Type Aliases * [RelationshipDiff](type-aliases/RelationshipDiff.md) --- --- url: /api/@warp-drive/core-types/cache/interfaces/Cache.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [cache](../index.md) / Cache Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:40 The interface for WarpDrive Caches. A Cache handles in-memory storage of Document and Resource data. (Interface) Cache ## Properties ### version ```ts version: "2"; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:48 The Cache Version that this implementation implements. ## Methods ### changedAttrs() ```ts changedAttrs(identifier): ChangedAttributesHash; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:353 Query the cache for the changed attributes of a resource. Returns a map of field names to tuples of \[old, new] values ``` { : [, ] } ``` #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `ChangedAttributesHash` `{ : [, ] }` *** ### changedRelationships() ```ts changedRelationships(identifier): Map; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:398 Query the cache for the changes to relationships of a resource. Returns a map of relationship names to RelationshipDiff objects. ```ts type RelationshipDiff = | { kind: 'collection'; remoteState: StableRecordIdentifier[]; additions: Set; removals: Set; localState: StableRecordIdentifier[]; reordered: boolean; } | { kind: 'resource'; remoteState: StableRecordIdentifier | null; localState: StableRecordIdentifier | null; }; ``` #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `Map`<`string`, [`RelationshipDiff`](../type-aliases/RelationshipDiff.md)> *** ### clientDidCreate() ```ts clientDidCreate(identifier, createArgs?): Record; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:273 \[LIFECYCLE] Signal to the cache that a new record has been instantiated on the client It returns properties from options that should be set on the record during the create process. This return value behavior is deprecated. #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### createArgs? `Record`<`string`, `unknown`> #### Returns `Record`<`string`, `unknown`> *** ### commitWasRejected() ```ts commitWasRejected(identifier, errors?): void; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:300 \[LIFECYCLE] Signals to the cache that a resource was update via a save transaction failed. #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### errors? [`ApiError`](../../spec/error/interfaces/ApiError.md)\[] #### Returns `void` *** ### didCommit() ```ts didCommit(identifier, result): SingleResourceDataDocument; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:291 \[LIFECYCLE] Signals to the cache that a resource was successfully updated as part of a save transaction. #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) the primary identifier that was operated on ##### result [`StructuredDataDocument`](../../request/interfaces/StructuredDataDocument.md)<`unknown`> #### Returns [`SingleResourceDataDocument`](../../spec/document/interfaces/SingleResourceDataDocument.md) *** ### diff() ```ts diff(): Promise; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:236 Generate the list of changes applied to all record in the store. Each individual resource or document that has been mutated should be described as an individual `Change` entry in the returned array. A `Change` is described by an object containing up to three properties: (1) the `identifier` of the entity that changed; (2) the `op` code of that change being one of `upsert` or `remove`, and if the op is `upsert` a `patch` containing the data to merge into the cache for the given entity. This `patch` is opaque to the Store but should be understood by the Cache and may expect to be utilized by an Adapter when generating data during a `save` operation. It is generally recommended that the `patch` contain only the updated state, ignoring fields that are unchanged ```ts interface Change { identifier: StableRecordIdentifier | StableDocumentIdentifier; op: 'upsert' | 'remove'; patch?: unknown; } ``` #### Returns `Promise`<[`Change`](../change/interfaces/Change.md)\[]> *** ### dump() ```ts dump(): Promise>; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:245 Serialize the entire contents of the Cache into a Stream which may be fed back into a new instance of the same Cache via `cache.hydrate`. #### Returns `Promise`<`ReadableStream`<`unknown`>> *** ### fork() ```ts fork(): Promise; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:191 Create a fork of the cache from the current state. Applications should typically not call this method themselves, preferring instead to fork at the Store level, which will utilize this method to fork the cache. #### Returns `Promise`<`Cache`> *** ### getAttr() ```ts getAttr(identifier, field): undefined | Value; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:319 Retrieve the data for an attribute from the cache #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### field `string` | `string`\[] #### Returns `undefined` | [`Value`](../../json/raw/type-aliases/Value.md) *** ### getErrors() ```ts getErrors(identifier): ApiError[]; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:455 Query the cache for any validation errors applicable to the given resource. #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns [`ApiError`](../../spec/error/interfaces/ApiError.md)\[] *** ### getRelationship() ```ts getRelationship( identifier, field, isCollection?): | ResourceRelationship | CollectionRelationship; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:427 Query the cache for the current state of a relationship property #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### field `string` ##### isCollection? `boolean` #### Returns | [`ResourceRelationship`](../relationship/interfaces/ResourceRelationship.md)<[`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md)> | [`CollectionRelationship`](../relationship/interfaces/CollectionRelationship.md)<[`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md)> resource relationship object *** ### getRemoteAttr() ```ts getRemoteAttr(identifier, field): undefined | Value; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:328 Retrieve remote state without any local changes for a specific attribute #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### field `string` | `string`\[] #### Returns `undefined` | [`Value`](../../json/raw/type-aliases/Value.md) *** ### getRemoteRelationship() ```ts getRemoteRelationship( identifier, field, isCollection?): | ResourceRelationship | CollectionRelationship; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:436 Query the cache for the server state of a relationship property without any local changes #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### field `string` ##### isCollection? `boolean` #### Returns | [`ResourceRelationship`](../relationship/interfaces/ResourceRelationship.md)<[`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md)> | [`CollectionRelationship`](../relationship/interfaces/CollectionRelationship.md)<[`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md)> resource relationship object *** ### hasChangedAttrs() ```ts hasChangedAttrs(identifier): boolean; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:361 Query the cache for whether any mutated attributes exist #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` *** ### hasChangedRelationships() ```ts hasChangedRelationships(identifier): boolean; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:406 Query the cache for whether any mutated attributes exist #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` *** ### hydrate() ```ts hydrate(stream): Promise; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:262 hydrate a Cache from a Stream with content previously serialized from another instance of the same Cache, resolving when hydration is complete. This method should expect to be called both in the context of restoring the Cache during application rehydration after SSR **AND** at unknown times during the lifetime of an already booted application when it is desired to bulk-load additional information into the cache. This latter behavior supports optimizing pre/fetching of data for route transitions via data-only SSR modes. #### Parameters ##### stream `ReadableStream`<`unknown`> #### Returns `Promise`<`void`> *** ### isDeleted() ```ts isDeleted(identifier): boolean; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:481 Query the cache for whether a given resource is marked as deleted (but not necessarily persisted yet). #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` *** ### isDeletionCommitted() ```ts isDeletionCommitted(identifier): boolean; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:490 Query the cache for whether a given resource has been deleted and that deletion has also been persisted. #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` *** ### isEmpty() ```ts isEmpty(identifier): boolean; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:463 Query the cache for whether a given resource has any available data #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` *** ### isNew() ```ts isNew(identifier): boolean; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:472 Query the cache for whether a given resource was created locally and not yet persisted. #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` *** ### merge() ```ts merge(cache): Promise; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:203 Merge a fork back into a parent Cache. Applications should typically not call this method themselves, preferring instead to merge at the Store level, which will utilize this method to merge the caches. #### Parameters ##### cache `Cache` #### Returns `Promise`<`void`> *** ### mutate() ```ts mutate(mutation): void; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:89 Update the "local" or "current" (unpersisted) state of the Cache #### Parameters ##### mutation [`Mutation`](../mutations/type-aliases/Mutation.md) #### Returns `void` *** ### patch() ```ts patch(op): void; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:81 Update the "remote" or "canonical" (persisted) state of the Cache by merging new information into the existing state. #### Parameters ##### op the operation(s) to perform [`Operation`](../operations/type-aliases/Operation.md) | [`Operation`](../operations/type-aliases/Operation.md)\[] #### Returns `void` *** ### peek() #### Call Signature ```ts peek(identifier): null | T; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:121 Peek resource data from the Cache. In development, if the return value is JSON the return value will be deep-cloned and deep-frozen to prevent mutation thereby enforcing cache Immutability. This form of peek is useful for implementations that want to feed raw-data from cache to the UI or which want to interact with a blob of data directly from the presentation cache. An implementation might want to do this because de-referencing records which read from their own blob is generally safer because the record does not require retainining connections to the Store and Cache to present data on a per-field basis. This generally takes the place of `getAttr` as an API and may even take the place of `getRelationship` depending on implementation specifics, though this latter usage is less recommended due to the advantages of the Graph handling necessary entanglements and notifications for relational data. ##### Type Parameters ###### T `T` = `unknown` ##### Parameters ###### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md)<[`TypeFromInstanceOrString`](../../record/type-aliases/TypeFromInstanceOrString.md)<`T`>> ##### Returns `null` | `T` the known resource data #### Call Signature ```ts peek(identifier): | null | ResourceDocument; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:122 ##### Parameters ###### identifier [`StableDocumentIdentifier`](../../identifier/type-aliases/StableDocumentIdentifier.md) ##### Returns | `null` | [`ResourceDocument`](../../spec/document/type-aliases/ResourceDocument.md) *** ### peekRemoteState() #### Call Signature ```ts peekRemoteState(identifier): null | T; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:156 Peek remote resource data from the Cache. This will give the data provided from the server without any local changes. In development, if the return value is JSON the return value will be deep-cloned and deep-frozen to prevent mutation thereby enforcing cache Immutability. This form of peek is useful for implementations that want to feed raw-data from cache to the UI or which want to interact with a blob of data directly from the presentation cache. An implementation might want to do this because de-referencing records which read from their own blob is generally safer because the record does not require retainining connections to the Store and Cache to present data on a per-field basis. This generally takes the place of `getAttr` as an API and may even take the place of `getRelationship` depending on implementation specifics, though this latter usage is less recommended due to the advantages of the Graph handling necessary entanglements and notifications for relational data. ##### Type Parameters ###### T `T` = `unknown` ##### Parameters ###### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md)<[`TypeFromInstanceOrString`](../../record/type-aliases/TypeFromInstanceOrString.md)<`T`>> ##### Returns `null` | `T` the known resource data #### Call Signature ```ts peekRemoteState(identifier): | null | ResourceDocument; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:157 ##### Parameters ###### identifier [`StableDocumentIdentifier`](../../identifier/type-aliases/StableDocumentIdentifier.md) ##### Returns | `null` | [`ResourceDocument`](../../spec/document/type-aliases/ResourceDocument.md) *** ### peekRequest() ```ts peekRequest(identifier): | null | StructuredDocument; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:170 Peek the Cache for the existing request data associated with a cacheable request This is effectively the reverse of `put` for a request in that it will return the the request, response, and content whereas `peek` will return just the `content`. #### Parameters ##### identifier [`StableDocumentIdentifier`](../../identifier/type-aliases/StableDocumentIdentifier.md) #### Returns | `null` | [`StructuredDocument`](../../request/type-aliases/StructuredDocument.md)<[`ResourceDocument`](../../spec/document/type-aliases/ResourceDocument.md)> *** ### put() ```ts put(doc): ResourceDocument; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:70 Cache the response to a request Unlike `store.push` which has UPSERT semantics, `put` has `replace` semantics similar to the `http` method `PUT` the individually cacheable resource data it may contain should upsert, but the document data surrounding it should fully replace any existing information Note that in order to support inserting arbitrary data to the cache that did not originate from a request `put` should expect to sometimes encounter a document with only a `content` member and therefor must not assume the existence of `request` and `response` on the document. #### Type Parameters ##### T `T` #### Parameters ##### doc [`StructuredDocument`](../../request/type-aliases/StructuredDocument.md)<`T`> | { `content`: `T`; } #### Returns [`ResourceDocument`](../../spec/document/type-aliases/ResourceDocument.md) *** ### rollbackAttrs() ```ts rollbackAttrs(identifier): string[]; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:371 Tell the cache to discard any uncommitted mutations to attributes This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `string`\[] the names of fields that were restored *** ### rollbackRelationships() ```ts rollbackRelationships(identifier): string[]; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:418 Tell the cache to discard any uncommitted mutations to relationships. This will also discard the change on any appropriate inverses. This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `string`\[] the names of relationships that were restored *** ### setAttr() ```ts setAttr( identifier, field, value): void; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:339 Mutate the data for an attribute in the cache This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### field `string` | `string`\[] ##### value [`Value`](../../json/raw/type-aliases/Value.md) #### Returns `void` *** ### setIsDeleted() ```ts setIsDeleted(identifier, isDeleted): void; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:447 Update the cache state for the given resource to be marked as locally deleted, or remove such a mark. This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### isDeleted `boolean` #### Returns `void` *** ### unloadRecord() ```ts unloadRecord(identifier): void; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:310 \[LIFECYCLE] Signals to the cache that all data for a resource should be cleared. This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `void` *** ### upsert() ```ts upsert( identifier, data, hasRecord): void | string[]; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:180 Push resource data from a remote source into the cache for this identifier #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### data `unknown` ##### hasRecord `boolean` #### Returns `void` | `string`\[] if `hasRecord` is true then calculated key changes should be returned *** ### willCommit() ```ts willCommit(identifier, context): void; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:281 \[LIFECYCLE] Signals to the cache that a resource will be part of a save transaction. #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### context [`RequestContext`](../../request/interfaces/RequestContext.md) #### Returns `void` --- --- url: /api/@warp-drive/core-types/cache/mutations.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / cache/mutations ## Interfaces * [AddToResourceRelationshipMutation](interfaces/AddToResourceRelationshipMutation.md) * [RemoveFromResourceRelationshipMutation](interfaces/RemoveFromResourceRelationshipMutation.md) * [ReplaceRelatedRecordMutation](interfaces/ReplaceRelatedRecordMutation.md) * [ReplaceRelatedRecordsMutation](interfaces/ReplaceRelatedRecordsMutation.md) * [SortRelatedRecordsMutation](interfaces/SortRelatedRecordsMutation.md) ## Type Aliases * [Mutation](type-aliases/Mutation.md) --- --- url: >- /api/@warp-drive/core-types/cache/mutations/interfaces/RemoveFromResourceRelationshipMutation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/mutations](../index.md) / RemoveFromResourceRelationshipMutation Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:9 ## Properties ### field ```ts field: string; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:12 *** ### index? ```ts optional index: number; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:14 *** ### op ```ts op: "remove"; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:10 *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:11 *** ### value ```ts value: | StableRecordIdentifier | StableRecordIdentifier[]; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:13 --- --- url: >- /api/@warp-drive/core-types/cache/mutations/interfaces/AddToResourceRelationshipMutation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/mutations](../index.md) / AddToResourceRelationshipMutation Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:2 ## Properties ### field ```ts field: string; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:5 *** ### index? ```ts optional index: number; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:7 *** ### op ```ts op: "add"; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:3 *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:4 *** ### value ```ts value: | StableRecordIdentifier | StableRecordIdentifier[]; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:6 --- --- url: >- /api/@warp-drive/core-types/cache/mutations/interfaces/ReplaceRelatedRecordMutation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/mutations](../index.md) / ReplaceRelatedRecordMutation Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:16 ## Properties ### field ```ts field: string; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:19 *** ### index? ```ts optional index: number; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:22 *** ### op ```ts op: "replaceRelatedRecord"; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:17 *** ### prior? ```ts optional prior: StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:21 *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:18 *** ### value ```ts value: | null | StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:20 --- --- url: >- /api/@warp-drive/core-types/cache/mutations/interfaces/ReplaceRelatedRecordsMutation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/mutations](../index.md) / ReplaceRelatedRecordsMutation Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:24 ## Properties ### field ```ts field: string; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:27 *** ### index? ```ts optional index: number; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:30 *** ### op ```ts op: "replaceRelatedRecords"; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:25 *** ### prior? ```ts optional prior: StableRecordIdentifier[]; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:29 *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:26 *** ### value ```ts value: StableRecordIdentifier[]; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:28 --- --- url: >- /api/@warp-drive/core-types/cache/mutations/interfaces/SortRelatedRecordsMutation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/mutations](../index.md) / SortRelatedRecordsMutation Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:32 ## Properties ### field ```ts field: string; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:35 *** ### op ```ts op: "sortRelatedRecords"; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:33 *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:34 *** ### value ```ts value: StableRecordIdentifier[]; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:36 --- --- url: /api/@warp-drive/core-types/cache/mutations/type-aliases/Mutation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/mutations](../index.md) / Mutation ```ts type Mutation = | ReplaceRelatedRecordsMutation | ReplaceRelatedRecordMutation | RemoveFromResourceRelationshipMutation | AddToResourceRelationshipMutation | SortRelatedRecordsMutation; ``` Defined in: warp-drive-packages/core/declarations/types/cache/mutations.d.ts:38 --- --- url: /api/@warp-drive/core-types/cache/operations.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / cache/operations ## Interfaces * [AddResourceOperation](interfaces/AddResourceOperation.md) * [AddToDocumentOperation](interfaces/AddToDocumentOperation.md) * [AddToResourceRelationshipOperation](interfaces/AddToResourceRelationshipOperation.md) * [MergeOperation](interfaces/MergeOperation.md) * [Op](interfaces/Op.md) * [RemoveDocumentOperation](interfaces/RemoveDocumentOperation.md) * [RemoveFromDocumentOperation](interfaces/RemoveFromDocumentOperation.md) * [RemoveFromResourceRelationshipOperation](interfaces/RemoveFromResourceRelationshipOperation.md) * [RemoveResourceOperation](interfaces/RemoveResourceOperation.md) * [UpdateResourceFieldOperation](interfaces/UpdateResourceFieldOperation.md) * [UpdateResourceOperation](interfaces/UpdateResourceOperation.md) * [UpdateResourceRelationshipOperation](interfaces/UpdateResourceRelationshipOperation.md) ## Type Aliases * [Operation](type-aliases/Operation.md) --- --- url: >- /api/@warp-drive/core-types/cache/operations/interfaces/AddResourceOperation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/operations](../index.md) / AddResourceOperation Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:21 ## Extends * [`Op`](Op.md) ## Properties ### op ```ts op: "add"; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:22 #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableExistingRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:23 *** ### value ```ts value: ExistingResourceObject; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:24 --- --- url: >- /api/@warp-drive/core-types/cache/operations/interfaces/AddToDocumentOperation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/operations](../index.md) / AddToDocumentOperation Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:43 ## Extends * [`Op`](Op.md) ## Properties ### field ```ts field: "data" | "included"; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:46 *** ### index? ```ts optional index: number; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:48 *** ### op ```ts op: "add"; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:44 #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableDocumentIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:45 *** ### value ```ts value: | StableExistingRecordIdentifier | StableExistingRecordIdentifier[]; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:47 --- --- url: >- /api/@warp-drive/core-types/cache/operations/interfaces/AddToResourceRelationshipOperation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/operations](../index.md) / AddToResourceRelationshipOperation Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:50 ## Extends * [`Op`](Op.md) ## Properties ### field ```ts field: string; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:53 *** ### index? ```ts optional index: number; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:55 *** ### op ```ts op: "add"; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:51 #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableExistingRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:52 *** ### value ```ts value: | StableExistingRecordIdentifier | StableExistingRecordIdentifier[]; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:54 --- --- url: /api/@warp-drive/core-types/cache/operations/interfaces/MergeOperation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/operations](../index.md) / MergeOperation Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:8 ## Extends * [`Op`](Op.md) ## Properties ### op ```ts op: "mergeIdentifiers"; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:9 #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:10 *** ### value ```ts value: StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:11 --- --- url: >- /api/@warp-drive/core-types/cache/operations/interfaces/RemoveDocumentOperation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/operations](../index.md) / RemoveDocumentOperation Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:13 ## Extends * [`Op`](Op.md) ## Properties ### op ```ts op: "remove"; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:14 #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableDocumentIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:15 --- --- url: /api/@warp-drive/core-types/cache/operations/interfaces/Op.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/operations](../index.md) / Op Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:5 ## Extended by * [`MergeOperation`](MergeOperation.md) * [`RemoveDocumentOperation`](RemoveDocumentOperation.md) * [`RemoveResourceOperation`](RemoveResourceOperation.md) * [`AddResourceOperation`](AddResourceOperation.md) * [`UpdateResourceOperation`](UpdateResourceOperation.md) * [`UpdateResourceFieldOperation`](UpdateResourceFieldOperation.md) * [`UpdateResourceRelationshipOperation`](UpdateResourceRelationshipOperation.md) * [`AddToDocumentOperation`](AddToDocumentOperation.md) * [`AddToResourceRelationshipOperation`](AddToResourceRelationshipOperation.md) * [`RemoveFromResourceRelationshipOperation`](RemoveFromResourceRelationshipOperation.md) * [`RemoveFromDocumentOperation`](RemoveFromDocumentOperation.md) ## Properties ### op ```ts op: string; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:6 --- --- url: >- /api/@warp-drive/core-types/cache/operations/interfaces/RemoveFromDocumentOperation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/operations](../index.md) / RemoveFromDocumentOperation Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:64 ## Extends * [`Op`](Op.md) ## Properties ### field ```ts field: "data" | "included"; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:67 *** ### index? ```ts optional index: number; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:69 *** ### op ```ts op: "remove"; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:65 #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableDocumentIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:66 *** ### value ```ts value: | StableExistingRecordIdentifier | StableExistingRecordIdentifier[]; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:68 --- --- url: >- /api/@warp-drive/core-types/cache/operations/interfaces/RemoveFromResourceRelationshipOperation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/operations](../index.md) / RemoveFromResourceRelationshipOperation Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:57 ## Extends * [`Op`](Op.md) ## Properties ### field ```ts field: string; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:60 *** ### index? ```ts optional index: number; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:62 *** ### op ```ts op: "remove"; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:58 #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableExistingRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:59 *** ### value ```ts value: | StableExistingRecordIdentifier | StableExistingRecordIdentifier[]; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:61 --- --- url: >- /api/@warp-drive/core-types/cache/operations/interfaces/RemoveResourceOperation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/operations](../index.md) / RemoveResourceOperation Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:17 ## Extends * [`Op`](Op.md) ## Properties ### op ```ts op: "remove"; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:18 #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableExistingRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:19 --- --- url: >- /api/@warp-drive/core-types/cache/operations/interfaces/UpdateResourceFieldOperation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/operations](../index.md) / UpdateResourceFieldOperation Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:31 ## Extends * [`Op`](Op.md) ## Properties ### field ```ts field: string; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:34 *** ### op ```ts op: "update"; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:32 #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableExistingRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:33 *** ### value ```ts value: Value; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:35 --- --- url: >- /api/@warp-drive/core-types/cache/operations/interfaces/UpdateResourceOperation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/operations](../index.md) / UpdateResourceOperation Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:26 ## Extends * [`Op`](Op.md) ## Properties ### op ```ts op: "update"; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:27 #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableExistingRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:28 *** ### value ```ts value: ExistingResourceObject; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:29 --- --- url: >- /api/@warp-drive/core-types/cache/operations/interfaces/UpdateResourceRelationshipOperation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/operations](../index.md) / UpdateResourceRelationshipOperation Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:37 ## Extends * [`Op`](Op.md) ## Properties ### field ```ts field: string; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:40 *** ### op ```ts op: "update"; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:38 #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableExistingRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:39 *** ### value ```ts value: Relationship>; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:41 --- --- url: /api/@warp-drive/core-types/cache/relationship.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / cache/relationship ## Interfaces * [CollectionRelationship](interfaces/CollectionRelationship.md) * [ResourceRelationship](interfaces/ResourceRelationship.md) ## Type Aliases * [Relationship](type-aliases/Relationship.md) --- --- url: >- /api/@warp-drive/core-types/cache/relationship/interfaces/CollectionRelationship.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/relationship](../index.md) / CollectionRelationship Defined in: warp-drive-packages/core/declarations/types/cache/relationship.d.ts:8 ## Type Parameters ### T `T` = [`StableRecordIdentifier`](../../../identifier/type-aliases/StableRecordIdentifier.md) ## Properties ### data? ```ts optional data: T[]; ``` Defined in: warp-drive-packages/core/declarations/types/cache/relationship.d.ts:9 *** ### links? ```ts optional links: PaginationLinks; ``` Defined in: warp-drive-packages/core/declarations/types/cache/relationship.d.ts:11 *** ### meta? ```ts optional meta: ObjectValue; ``` Defined in: warp-drive-packages/core/declarations/types/cache/relationship.d.ts:10 --- --- url: /api/@warp-drive/core-types/cache/operations/type-aliases/Operation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/operations](../index.md) / Operation ```ts type Operation = | MergeOperation | RemoveResourceOperation | RemoveDocumentOperation | AddResourceOperation | UpdateResourceOperation | UpdateResourceFieldOperation | AddToResourceRelationshipOperation | RemoveFromResourceRelationshipOperation | AddToDocumentOperation | RemoveFromDocumentOperation; ``` Defined in: warp-drive-packages/core/declarations/types/cache/operations.d.ts:71 --- --- url: >- /api/@warp-drive/core-types/cache/relationship/interfaces/ResourceRelationship.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/relationship](../index.md) / ResourceRelationship Defined in: warp-drive-packages/core/declarations/types/cache/relationship.d.ts:3 ## Type Parameters ### T `T` = [`StableRecordIdentifier`](../../../identifier/type-aliases/StableRecordIdentifier.md) ## Properties ### data? ```ts optional data: null | T; ``` Defined in: warp-drive-packages/core/declarations/types/cache/relationship.d.ts:4 *** ### links? ```ts optional links: Links; ``` Defined in: warp-drive-packages/core/declarations/types/cache/relationship.d.ts:6 *** ### meta? ```ts optional meta: ObjectValue; ``` Defined in: warp-drive-packages/core/declarations/types/cache/relationship.d.ts:5 --- --- url: /api/@warp-drive/core-types/cache/relationship/type-aliases/Relationship.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [cache/relationship](../index.md) / Relationship ```ts type Relationship = | ResourceRelationship | CollectionRelationship; ``` Defined in: warp-drive-packages/core/declarations/types/cache/relationship.d.ts:13 ## Type Parameters ### T `T` = [`StableRecordIdentifier`](../../../identifier/type-aliases/StableRecordIdentifier.md) --- --- url: /api/@warp-drive/core-types/cache/type-aliases/RelationshipDiff.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [cache](../index.md) / RelationshipDiff ```ts type RelationshipDiff = | { additions: Set; kind: "collection"; localState: StableRecordIdentifier[]; remoteState: StableRecordIdentifier[]; removals: Set; reordered: boolean; } | { kind: "resource"; localState: | StableRecordIdentifier | null; remoteState: | StableRecordIdentifier | null; }; ``` Defined in: warp-drive-packages/core/declarations/types/cache.d.ts:19 --- --- url: /api/@warp-drive/core-types/graph/interfaces/DeleteRecordOperation.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [graph](../index.md) / DeleteRecordOperation Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:14 ## Properties ### isNew ```ts isNew: boolean; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:17 *** ### op ```ts op: "deleteRecord"; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:15 *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:16 --- --- url: /api/@warp-drive/core-types/graph.md --- [Documentation](../../../index.md) / [@warp-drive/core-types](../index.md) / graph ## Interfaces * [DeleteRecordOperation](interfaces/DeleteRecordOperation.md) * [Operation](interfaces/Operation.md) * [ReplaceRelatedRecordOperation](interfaces/ReplaceRelatedRecordOperation.md) * [ReplaceRelatedRecordsOperation](interfaces/ReplaceRelatedRecordsOperation.md) * [SortRelatedRecords](interfaces/SortRelatedRecords.md) * [UnknownOperation](interfaces/UnknownOperation.md) * [UpdateRelationshipOperation](interfaces/UpdateRelationshipOperation.md) ## Type Aliases * [LocalRelationshipOperation](type-aliases/LocalRelationshipOperation.md) * [RemoteRelationshipOperation](type-aliases/RemoteRelationshipOperation.md) --- --- url: /api/@warp-drive/core-types/graph/interfaces/Operation.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [graph](../index.md) / Operation Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:5 ## Properties ### op ```ts op: string; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:6 --- --- url: /api/@warp-drive/core-types/graph/interfaces/ReplaceRelatedRecordOperation.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [graph](../index.md) / ReplaceRelatedRecordOperation Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:24 ## Properties ### field ```ts field: string; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:27 *** ### index? ```ts optional index: number; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:30 *** ### op ```ts op: "replaceRelatedRecord"; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:25 *** ### prior? ```ts optional prior: StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:29 *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:26 *** ### value ```ts value: | null | StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:28 --- --- url: /api/@warp-drive/core-types/graph/interfaces/SortRelatedRecords.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [graph](../index.md) / SortRelatedRecords Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:32 ## Properties ### field ```ts field: string; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:35 *** ### op ```ts op: "sortRelatedRecords"; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:33 *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:34 *** ### value ```ts value: StableRecordIdentifier[]; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:36 --- --- url: /api/@warp-drive/core-types/graph/interfaces/ReplaceRelatedRecordsOperation.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [graph](../index.md) / ReplaceRelatedRecordsOperation Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:38 ## Properties ### field ```ts field: string; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:41 *** ### index? ```ts optional index: number; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:44 *** ### op ```ts op: "replaceRelatedRecords"; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:39 *** ### prior? ```ts optional prior: StableRecordIdentifier[]; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:43 *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:40 *** ### value ```ts value: StableRecordIdentifier[]; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:42 --- --- url: /api/@warp-drive/core-types/graph/interfaces/UnknownOperation.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [graph](../index.md) / UnknownOperation Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:19 ## Properties ### field ```ts field: string; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:22 *** ### op ```ts op: "never"; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:20 *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:21 --- --- url: /api/@warp-drive/core-types/graph/interfaces/UpdateRelationshipOperation.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [graph](../index.md) / UpdateRelationshipOperation Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:8 ## Properties ### field ```ts field: string; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:11 *** ### op ```ts op: "updateRelationship"; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:9 *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:10 *** ### value ```ts value: | SingleResourceRelationship< | ExistingResourceIdentifierObject | NewResourceIdentifierObject> | CollectionResourceRelationship< | ExistingResourceIdentifierObject | NewResourceIdentifierObject>; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:12 --- --- url: /api/@warp-drive/core-types/graph/type-aliases/RemoteRelationshipOperation.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [graph](../index.md) / RemoteRelationshipOperation ```ts type RemoteRelationshipOperation = | UpdateResourceRelationshipOperation | UpdateRelationshipOperation | ReplaceRelatedRecordOperation | ReplaceRelatedRecordsOperation | RemoveFromResourceRelationshipOperation | AddToResourceRelationshipOperation | DeleteRecordOperation | SortRelatedRecords; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:46 --- --- url: /api/@warp-drive/core-types/identifier.md --- [Documentation](../../../index.md) / [@warp-drive/core-types](../index.md) / identifier ## Interfaces * [ExistingRecordIdentifier](interfaces/ExistingRecordIdentifier.md) * [Identifier](interfaces/Identifier.md) * [NewRecordIdentifier](interfaces/NewRecordIdentifier.md) ## Type Aliases * [IdentifierBucket](type-aliases/IdentifierBucket.md) * [RequestKey](type-aliases/RequestKey.md) * [ResourceKey](type-aliases/ResourceKey.md) * [StableDocumentIdentifier](type-aliases/StableDocumentIdentifier.md) * [StableRecordIdentifier](type-aliases/StableRecordIdentifier.md) ## Variables * [CACHE\_OWNER](variables/CACHE_OWNER.md) * [DEBUG\_CLIENT\_ORIGINATED](variables/DEBUG_CLIENT_ORIGINATED.md) * [DEBUG\_IDENTIFIER\_BUCKET](variables/DEBUG_IDENTIFIER_BUCKET.md) * [DEBUG\_STALE\_CACHE\_OWNER](variables/DEBUG_STALE_CACHE_OWNER.md) --- --- url: /api/@warp-drive/core-types/graph/type-aliases/LocalRelationshipOperation.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [graph](../index.md) / LocalRelationshipOperation ```ts type LocalRelationshipOperation = | ReplaceRelatedRecordsOperation | ReplaceRelatedRecordOperation | AddToResourceRelationshipMutation | RemoveFromResourceRelationshipMutation | SortRelatedRecords; ``` Defined in: warp-drive-packages/core/declarations/types/graph.d.ts:47 --- --- url: /api/@warp-drive/core-types/identifier/interfaces/ExistingRecordIdentifier.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [identifier](../index.md) / ExistingRecordIdentifier Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:10 ## Extends * [`Identifier`](Identifier.md) ## Type Parameters ### T `T` *extends* `string` = `string` ## Properties ### clientId? ```ts optional clientId: string; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:8 #### Inherited from [`Identifier`](Identifier.md).[`clientId`](Identifier.md#clientid) *** ### id ```ts id: string; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:11 *** ### lid ```ts lid: string; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:7 #### Inherited from [`Identifier`](Identifier.md).[`lid`](Identifier.md#lid) *** ### type ```ts type: T; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:12 --- --- url: /api/@warp-drive/core-types/identifier/interfaces/Identifier.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [identifier](../index.md) / Identifier Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:6 ## Extended by * [`ExistingRecordIdentifier`](ExistingRecordIdentifier.md) * [`NewRecordIdentifier`](NewRecordIdentifier.md) ## Properties ### clientId? ```ts optional clientId: string; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:8 *** ### lid ```ts lid: string; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:7 --- --- url: /api/@warp-drive/core-types/identifier/type-aliases/IdentifierBucket.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [identifier](../index.md) / IdentifierBucket ```ts type IdentifierBucket = "record" | "document"; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:5 --- --- url: /api/@warp-drive/core-types/identifier/type-aliases/RequestKey.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [identifier](../index.md) / RequestKey ```ts type RequestKey = StableDocumentIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:21 --- --- url: /api/@warp-drive/core-types/identifier/interfaces/NewRecordIdentifier.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [identifier](../index.md) / NewRecordIdentifier Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:14 ## Extends * [`Identifier`](Identifier.md) ## Type Parameters ### T `T` *extends* `string` = `string` ## Properties ### clientId? ```ts optional clientId: string; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:8 #### Inherited from [`Identifier`](Identifier.md).[`clientId`](Identifier.md#clientid) *** ### id ```ts id: null | string; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:15 *** ### lid ```ts lid: string; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:7 #### Inherited from [`Identifier`](Identifier.md).[`lid`](Identifier.md#lid) *** ### type ```ts type: T; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:16 --- --- url: /api/@warp-drive/core-types/identifier/type-aliases/ResourceKey.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [identifier](../index.md) / ResourceKey ```ts type ResourceKey = StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:110 ## Type Parameters ### T `T` *extends* `string` = `string` --- --- url: /api/@warp-drive/core-types/identifier/type-aliases/StableRecordIdentifier.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [identifier](../index.md) / StableRecordIdentifier ```ts type StableRecordIdentifier = | StableExistingRecordIdentifier | StableNewRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:109 the primary id for the record this identity belongs to. `null` if not yet assigned an id. ## Type Parameters ### T `T` *extends* `string` = `string` --- --- url: >- /api/@warp-drive/core-types/identifier/type-aliases/StableDocumentIdentifier.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [identifier](../index.md) / StableDocumentIdentifier ```ts type StableDocumentIdentifier = object; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:18 ## Properties ### lid ```ts lid: string; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:19 --- --- url: /api/@warp-drive/core-types/identifier/variables/CACHE_OWNER.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [identifier](../index.md) / CACHE\_OWNER ```ts const CACHE_OWNER: "__$co"; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:4 --- --- url: /api/@warp-drive/core-types/identifier/variables/DEBUG_IDENTIFIER_BUCKET.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [identifier](../index.md) / DEBUG\_IDENTIFIER\_BUCKET ```ts const DEBUG_IDENTIFIER_BUCKET: unique symbol; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:2 --- --- url: /api/@warp-drive/core-types/identifier/variables/DEBUG_CLIENT_ORIGINATED.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [identifier](../index.md) / DEBUG\_CLIENT\_ORIGINATED ```ts const DEBUG_CLIENT_ORIGINATED: unique symbol; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:1 --- --- url: /api/@warp-drive/core-types/identifier/variables/DEBUG_STALE_CACHE_OWNER.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [identifier](../index.md) / DEBUG\_STALE\_CACHE\_OWNER ```ts const DEBUG_STALE_CACHE_OWNER: unique symbol; ``` Defined in: warp-drive-packages/core/declarations/types/identifier.d.ts:3 --- --- url: /api/@warp-drive/core-types.md --- [Documentation](../../index.md) / @warp-drive/core-types ## Modules * [cache](cache/index.md) * [cache/aliases](cache/aliases/index.md) * [cache/change](cache/change/index.md) * [cache/mutations](cache/mutations/index.md) * [cache/operations](cache/operations/index.md) * [cache/relationship](cache/relationship/index.md) * [graph](graph/index.md) * [identifier](identifier/index.md) * [index](index/index.md) * [json/raw](json/raw/index.md) * [params](params/index.md) * [record](record/index.md) * [request](request/index.md) * [runtime](runtime/index.md) * [schema/concepts](schema/concepts/index.md) * [schema/fields](schema/fields/index.md) * [spec/document](spec/document/index.md) * [spec/error](spec/error/index.md) * [spec/json-api-raw](spec/json-api-raw/index.md) * [symbols](symbols/index.md) * [utils](utils/index.md) --- --- url: /api/@warp-drive/core-types/index.md --- [Documentation](../../../index.md) / [@warp-drive/core-types](../index.md) / index ## Interfaces * [BaseFinderOptions](interfaces/BaseFinderOptions.md) * [FindRecordOptions](interfaces/FindRecordOptions.md) * [ModelSchema](interfaces/ModelSchema.md) * [SchemaService](interfaces/SchemaService.md) ## Type Aliases * [CacheCapabilitiesManager](type-aliases/CacheCapabilitiesManager.md) * [FindAllOptions](type-aliases/FindAllOptions.md) * [LegacyResourceQuery](type-aliases/LegacyResourceQuery.md) * [QueryOptions](type-aliases/QueryOptions.md) ## References ### ResourceKey Re-exports [ResourceKey](../identifier/type-aliases/ResourceKey.md) *** ### StableRecordIdentifier Re-exports [StableRecordIdentifier](../identifier/type-aliases/StableRecordIdentifier.md) --- --- url: /api/@warp-drive/core-types/index/interfaces/FindRecordOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [index](../index.md) / FindRecordOptions Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:9 ## Extends * [`BaseFinderOptions`](BaseFinderOptions.md)<`T`> ## Type Parameters ### T `T` = `unknown` ## Properties ### adapterOptions? ```ts optional adapterOptions: Record; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:7 #### Inherited from [`BaseFinderOptions`](BaseFinderOptions.md).[`adapterOptions`](BaseFinderOptions.md#adapteroptions) *** ### backgroundReload? ```ts optional backgroundReload: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:5 #### Inherited from [`BaseFinderOptions`](BaseFinderOptions.md).[`backgroundReload`](BaseFinderOptions.md#backgroundreload) *** ### include? ```ts optional include: T extends TypedRecordInstance ? Exclude<_ExtractUnion<3, T, true, NONE, NONE, 1>, NONE>[] : string | string[]; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:6 #### Inherited from [`BaseFinderOptions`](BaseFinderOptions.md).[`include`](BaseFinderOptions.md#include) *** ### preload? ```ts optional preload: Record; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:25 Data to preload into the store before the request is made. This feature is *highly* discouraged and has no corresponding feature when using builders and handlers. Excepting relationships: the data should be in the form of a JSON object where the keys are fields on the record and the value is the raw value to be added to the cache. Relationships can either be provided as string IDs from which an identifier will be built base upon the relationship's expected resource type, or be record instances from which the identifier will be extracted. *** ### reload? ```ts optional reload: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:4 #### Inherited from [`BaseFinderOptions`](BaseFinderOptions.md).[`reload`](BaseFinderOptions.md#reload) --- --- url: /api/@warp-drive/core-types/index/interfaces/ModelSchema.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [index](../index.md) / ModelSchema Defined in: warp-drive-packages/core/declarations/store/-types/q/ds-model.d.ts:13 Minimum subset of static schema methods and properties on the "model" class. Only used when using the legacy schema-service implementation for @ember-data/model or when wrapping schema for legacy Adapters/Serializers. ## Type Parameters ### T `T` = `unknown` ## Properties ### attributes ```ts attributes: Map, LegacyAttributeField>; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/ds-model.d.ts:16 *** ### fields ```ts fields: Map, "attribute" | "belongsTo" | "hasMany">; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/ds-model.d.ts:15 *** ### modelName ```ts modelName: T extends TypedRecordInstance ? TypeFromInstance> : string; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/ds-model.d.ts:14 *** ### relationshipsByName ```ts relationshipsByName: Map, LegacyRelationshipField>; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/ds-model.d.ts:17 ## Methods ### eachAttribute() ```ts eachAttribute(callback, binding?): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/ds-model.d.ts:18 #### Type Parameters ##### K `K` *extends* `string` #### Parameters ##### callback (`this`, `key`, `attribute`) => `void` ##### binding? `T` #### Returns `void` *** ### eachRelationship() ```ts eachRelationship(callback, binding?): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/ds-model.d.ts:19 #### Type Parameters ##### K `K` *extends* `string` #### Parameters ##### callback (`this`, `key`, `relationship`) => `void` ##### binding? `T` #### Returns `void` *** ### eachTransformedAttribute() ```ts eachTransformedAttribute(callback, binding?): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/ds-model.d.ts:20 #### Type Parameters ##### K `K` *extends* `string` #### Parameters ##### callback (`this`, `key`, `type`) => `void` ##### binding? `T` #### Returns `void` --- --- url: /api/@warp-drive/core-types/index/interfaces/BaseFinderOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [index](../index.md) / BaseFinderOptions Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:3 ## Extended by * [`FindRecordOptions`](FindRecordOptions.md) ## Type Parameters ### T `T` = `unknown` ## Properties ### adapterOptions? ```ts optional adapterOptions: Record; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:7 *** ### backgroundReload? ```ts optional backgroundReload: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:5 *** ### include? ```ts optional include: T extends TypedRecordInstance ? Includes>[] : string | string[]; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:6 *** ### reload? ```ts optional reload: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:4 --- --- url: /api/@warp-drive/core-types/index/interfaces/SchemaService.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [index](../index.md) / SchemaService Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:61 The SchemaService provides the ability to query for information about the structure of any resource type. Applications can provide any implementation of the SchemaService they please so long as it conforms to this interface. The design of the service means that schema information could be lazily populated, derived-on-demand, or progressively enhanced during the course of an application's runtime. The primary requirement is merely that any information the service needs to correctly respond to an inquest is available by the time it is asked. The `@ember-data/model` package provides an implementation of this service which makes use of your model classes as the source of information to respond to queries about resource schema. While this is useful, this may not be ideal for your application. For instance, Schema information could be sideloaded or pre-flighted for API calls, resulting in no need to bundle and ship potentially large and expensive JSON or large Javascript based Models to pull information from. To register a custom schema implementation, implement the store's `createSchemaService` hook to return an instance of your service. ```ts import Store from '@ember-data/store'; import CustomSchemas from './custom-schemas'; export default class extends Store { createSchemaService() { return new CustomSchemas(); } } ``` At runtime, both the `Store` and the `CacheCapabilitiesManager` provide access to this service via the `schema` property. ```ts export default class extends Component { @service store; get fields() { return this.store .schema .fields(this.args.dataType); } } ``` (Interface) SchemaService ## Methods ### ~~attributesDefinitionFor()?~~ ```ts optional attributesDefinitionFor(identifier): AttributesSchema; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:240 DEPRECATED - use `fields` instead Returns definitions for all properties of the specified resource that are considered "attributes". Generally these are properties that are not related to book-keeping state on the client and do not represent a linkage to another resource. The return value should be a dictionary of key:value pairs where the `key` is the attribute or property's name and `value` is an object with at least the property `name` which should also match `key`. Optionally, this object may also specify `type`, which should be a string reference to a `transform`, and `options` which should be dictionary in which any key:value pairs are permissable. For instance, when using `@ember-data/model`, the following attribute definition: ```ts class extends Model { @attr('string', { defaultValue: 'hello' }) greeting; @attr('date') birthday; @attr firstName; } ``` Would be returned as: ```js { greeting: { name: 'greeting', type: 'string', options: { defaultValue: 'hello' } }, birthday: { name: 'birthday', type: 'date' }, firstName: { name: 'firstName' } } ``` #### Parameters ##### identifier `ObjectWithStringTypeProperty` | `RecordIdentifier` #### Returns `AttributesSchema` #### Deprecated *** ### derivation() ```ts derivation(field): Derivation; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:134 Returns the derivation registered with the name provided by `field.type`. Validates that the field is a valid DerivedField. #### Parameters ##### field [`DerivedField`](../../schema/fields/interfaces/DerivedField.md) | `ObjectWithStringTypeProperty` #### Returns [`Derivation`](../../schema/concepts/type-aliases/Derivation.md) *** ### ~~doesTypeExist()?~~ ```ts optional doesTypeExist(type): boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:72 DEPRECATED - use `hasResource` instead Queries whether the SchemaService recognizes `type` as a resource type #### Parameters ##### type `string` #### Returns `boolean` #### Deprecated *** ### fields() ```ts fields(resource): Map; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:107 Queries for the fields of a given resource type or resource identity. Should error if the resource type is not recognized. #### Parameters ##### resource [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) | `ObjectWithStringTypeProperty` #### Returns `Map`<`string`, [`FieldSchema`](../../schema/fields/type-aliases/FieldSchema.md)> *** ### hashFn() ```ts hashFn(field): HashFn; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:125 Returns the hash function registered with the name provided by `field.type`. Validates that the field is a valid HashField. #### Parameters ##### field [`HashField`](../../schema/fields/interfaces/HashField.md) | `ObjectWithStringTypeProperty` #### Returns [`HashFn`](../../schema/concepts/type-aliases/HashFn.md) *** ### hasResource() ```ts hasResource(resource): boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:80 Queries whether the SchemaService recognizes `type` as a resource type #### Parameters ##### resource [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) | `ObjectWithStringTypeProperty` #### Returns `boolean` *** ### hasTrait() ```ts hasTrait(type): boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:88 Queries whether the SchemaService recognizes `type` as a resource trait #### Parameters ##### type `string` #### Returns `boolean` *** ### registerDerivation() ```ts registerDerivation(derivation): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:186 Enables registration of a derivation. The derivation can later be retrieved by the name attached to it's `[Type]` property. #### Type Parameters ##### R `R` ##### T `T` ##### FM `FM` *extends* `null` | [`ObjectValue`](../../json/raw/interfaces/ObjectValue.md) #### Parameters ##### derivation [`Derivation`](../../schema/concepts/type-aliases/Derivation.md)<`R`, `T`, `FM`> #### Returns `void` *** ### registerHashFn() ```ts registerHashFn(hashFn): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:196 Enables registration of a hashing function The hashing function can later be retrieved by the name attached to it's `[Type]` property. #### Parameters ##### hashFn [`HashFn`](../../schema/concepts/type-aliases/HashFn.md) #### Returns `void` *** ### registerResource() ```ts registerResource(schema): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:166 Enables registration of a single Schema representing either a resource in PolarisMode or LegacyMode or an ObjectSchema representing an embedded structure in other schemas. This can be useful for either pre-loading schema information or for registering schema information delivered by API calls or other sources just-in-time. #### Parameters ##### schema [`Schema`](../../schema/fields/type-aliases/Schema.md) #### Returns `void` *** ### registerResources() ```ts registerResources(schemas): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:153 Enables registration of multiple Schemas at once. This can be useful for either pre-loading schema information or for registering schema information delivered by API calls or other sources just-in-time. #### Parameters ##### schemas [`Schema`](../../schema/fields/type-aliases/Schema.md)\[] #### Returns `void` *** ### registerTransformation() ```ts registerTransformation(transform): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:176 Enables registration of a transformation. The transformation can later be retrieved by the name attached to it's `[Type]` property. #### Parameters ##### transform [`Transformation`](../../schema/concepts/type-aliases/Transformation.md) #### Returns `void` *** ### ~~relationshipsDefinitionFor()?~~ ```ts optional relationshipsDefinitionFor(identifier): RelationshipsSchema; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:321 DEPRECATED - use `fields` instead Returns definitions for all properties of the specified resource that are considered "relationships". Generally these are properties that represent a linkage to another resource. The return value should be a dictionary of key:value pairs where the `key` is the relationship or property's name and `value` is an object with at least the following properties: * `name` which should also match the `key` used in the dictionary. * `kind` which should be either `belongsTo` or `hasMany` * `type` which should be the related resource's string "type" * `options` which should be a dictionary allowing any key but with at least the below keys present. * `options.async` a boolean representing whether data for this relationship is typically loaded on-demand. * `options.inverse` a string or null representing the field name / key of the corresponding relationship on the inverse resource. Additionally the following options properties are optional. See [Polymorphic Relationships](https://rfcs.emberjs.com/id/0793-polymporphic-relations-without-inheritance) * `options.polymorphic` a boolean representing whether multiple resource types can be used to satisfy this relationship. * `options.as` a string representing the abstract type that the concrete side of a relationship must specify when fulfilling a polymorphic inverse. For example, the following Model using @ember-data/model would generate this relationships definition by default: ```js class User extends Model { @belongsTo('user', { async: false, inverse: null }) bestFriend; @hasMany('user', { async: true, inverse: 'friends' }) friends; @hasMany('pet', { async: false, polymorphic: true, inverse: 'owner' }) pets; } ``` Which would be returned as ```js { bestFriend: { name: 'bestFriend', kind: 'belongsTo', type: 'user', options: { async: false, inverse: null } }, friends: { name: 'friends', kind: 'hasMany', type: 'user', options: { async: true, inverse: 'friends' } }, pets: { name: 'pets', kind: 'hasMany', type: 'pet', options: { async: false, polymorphic: true, inverse: 'owner' } }, } ``` #### Parameters ##### identifier `ObjectWithStringTypeProperty` | `RecordIdentifier` #### Returns `RelationshipsSchema` #### Deprecated *** ### resource() ```ts resource(resource): Schema; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:142 Returns the schema for the provided resource type. #### Parameters ##### resource [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) | `ObjectWithStringTypeProperty` #### Returns [`Schema`](../../schema/fields/type-aliases/Schema.md) *** ### resourceHasTrait() ```ts resourceHasTrait(resource, trait): boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:97 Queries whether the given resource has the given trait #### Parameters ##### resource [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) | `ObjectWithStringTypeProperty` ##### trait `string` #### Returns `boolean` *** ### resourceTypes() ```ts resourceTypes(): readonly string[]; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:328 Returns all known resource types #### Returns readonly `string`\[] *** ### transformation() ```ts transformation(field): Transformation; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/schema-service.d.ts:116 Returns the transformation registered with the name provided by `field.type`. Validates that the field is a valid transformable. #### Parameters ##### field [`GenericField`](../../schema/fields/interfaces/GenericField.md) | [`ObjectField`](../../schema/fields/interfaces/ObjectField.md) | [`ArrayField`](../../schema/fields/interfaces/ArrayField.md) | `ObjectWithStringTypeProperty` #### Returns [`Transformation`](../../schema/concepts/type-aliases/Transformation.md) --- --- url: /api/@warp-drive/core-types/index/type-aliases/CacheCapabilitiesManager.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [index](../index.md) / CacheCapabilitiesManager ```ts type CacheCapabilitiesManager = object; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:17 CacheCapabilitiesManager provides encapsulated API access to the minimal subset of the Store's functionality that Cache implementations should interact with. It is provided to the Store's `createCache` hook. Cache implementations should not need more than this API provides. This class cannot be directly instantiated. CacheCapabilitiesManager ## Properties ### identifierCache ```ts identifierCache: IdentifierCache; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:29 Provides access to the IdentifierCache instance for this Store instance. The IdentifierCache can be used to peek, generate or retrieve a stable unique identifier for any resource. *** ### schema ```ts schema: SchemaService; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:53 Provides access to the SchemaService instance for this Store instance. The SchemaService can be used to query for information about the schema of a resource. ## Methods ### disconnectRecord() ```ts disconnectRecord(identifier): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:72 Signal to the store that the specified record may be considered fully removed from the cache. Generally this means that not only does no data exist for the identified resource, no known relationships still point to it either. #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `void` *** ### ~~getSchemaDefinitionService()~~ ```ts getSchemaDefinitionService(): SchemaService; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:42 DEPRECATED - use the schema property Provides access to the SchemaService instance for this Store instance. The SchemaService can be used to query for information about the schema of a resource. #### Returns [`SchemaService`](../interfaces/SchemaService.md) #### Deprecated *** ### hasRecord() ```ts hasRecord(identifier): boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:81 Use this method to determine if the Store has an instantiated record associated with an identifier. #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` *** ### notifyChange() #### Call Signature ```ts notifyChange( identifier, namespace, key): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:95 Notify subscribers of the NotificationManager that cache state has changed. `attributes` and `relationships` do not require a key, but if one is specified it is assumed to be the name of the attribute or relationship that has been updated. No other namespaces currently expect the `key` argument. ##### Parameters ###### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ###### namespace `"added"` | `"removed"` ###### key `null` ##### Returns `void` #### Call Signature ```ts notifyChange( identifier, namespace, key): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:96 ##### Parameters ###### identifier [`StableDocumentIdentifier`](../../identifier/type-aliases/StableDocumentIdentifier.md) ###### namespace `"added"` | `"removed"` | `"updated"` ###### key `null` ##### Returns `void` #### Call Signature ```ts notifyChange( identifier, namespace, key): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:97 ##### Parameters ###### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ###### namespace [`NotificationType`](../../../../@ember-data/store/index/type-aliases/NotificationType.md) ###### key `null` | `string` ##### Returns `void` #### Call Signature ```ts notifyChange( identifier, namespace, key): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:98 ##### Parameters ###### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) | [`StableDocumentIdentifier`](../../identifier/type-aliases/StableDocumentIdentifier.md) ###### namespace [`NotificationType`](../../../../@ember-data/store/index/type-aliases/NotificationType.md) ###### key `null` | `string` ##### Returns `void` *** ### setRecordId() ```ts setRecordId(identifier, id): void; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/cache-capabilities-manager.d.ts:62 Update the `id` for the record corresponding to the identifier This operation can only be done for records whose `id` is `null`. #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### id `string` #### Returns `void` --- --- url: /api/@warp-drive/core-types/index/type-aliases/FindAllOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [index](../index.md) / FindAllOptions ```ts type FindAllOptions = BaseFinderOptions; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:30 ## Type Parameters ### T `T` = `unknown` --- --- url: /api/@warp-drive/core-types/index/type-aliases/QueryOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [index](../index.md) / QueryOptions ```ts type QueryOptions = { [K in string | "adapterOptions"]?: K extends "adapterOptions" ? Record : unknown }; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:27 --- --- url: /api/@warp-drive/core-types/index/type-aliases/LegacyResourceQuery.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [index](../index.md) / LegacyResourceQuery ```ts type LegacyResourceQuery = object; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:31 ## Type Parameters ### T `T` = `unknown` ## Indexable ```ts [key: string]: undefined | Value ``` ## Properties ### include? ```ts optional include: T extends TypedRecordInstance ? Includes[] : string | string[]; ``` Defined in: warp-drive-packages/core/declarations/store/-types/q/store.d.ts:32 --- --- url: /api/@warp-drive/core-types/json/raw.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / json/raw ## Interfaces * [ObjectValue](interfaces/ObjectValue.md) ## Type Aliases * [ArrayValue](type-aliases/ArrayValue.md) * [PrimitiveValue](type-aliases/PrimitiveValue.md) * [Value](type-aliases/Value.md) --- --- url: /api/@warp-drive/core-types/json/raw/interfaces/ObjectValue.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [json/raw](../index.md) / ObjectValue Defined in: warp-drive-packages/core/declarations/types/json/raw.d.ts:2 ## Indexable ```ts [key: string]: Value ``` --- --- url: /api/@warp-drive/core-types/json/raw/type-aliases/Value.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [json/raw](../index.md) / Value ```ts type Value = | PrimitiveValue | ArrayValue | ObjectValue; ``` Defined in: warp-drive-packages/core/declarations/types/json/raw.d.ts:6 --- --- url: /api/@warp-drive/core-types/json/raw/type-aliases/ArrayValue.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [json/raw](../index.md) / ArrayValue ```ts type ArrayValue = Value[]; ``` Defined in: warp-drive-packages/core/declarations/types/json/raw.d.ts:5 --- --- url: /api/@warp-drive/core-types/json/raw/type-aliases/PrimitiveValue.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [json/raw](../index.md) / PrimitiveValue ```ts type PrimitiveValue = string | number | boolean | null; ``` Defined in: warp-drive-packages/core/declarations/types/json/raw.d.ts:1 --- --- url: /api/@warp-drive/core-types/params.md --- [Documentation](../../../index.md) / [@warp-drive/core-types](../index.md) / params ## Type Aliases * [QueryParamsSerializationOptions](type-aliases/QueryParamsSerializationOptions.md) * [QueryParamsSource](type-aliases/QueryParamsSource.md) * [Serializable](type-aliases/Serializable.md) * [SerializablePrimitive](type-aliases/SerializablePrimitive.md) --- --- url: >- /api/@warp-drive/core-types/params/type-aliases/QueryParamsSerializationOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [params](../index.md) / QueryParamsSerializationOptions ```ts type QueryParamsSerializationOptions = object; ``` Defined in: warp-drive-packages/core/declarations/types/params.d.ts:4 ## Properties ### arrayFormat? ```ts optional arrayFormat: "bracket" | "indices" | "repeat" | "comma"; ``` Defined in: warp-drive-packages/core/declarations/types/params.d.ts:5 --- --- url: /api/@warp-drive/core-types/params/type-aliases/Serializable.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [params](../index.md) / Serializable ```ts type Serializable = | SerializablePrimitive | SerializablePrimitive[]; ``` Defined in: warp-drive-packages/core/declarations/types/params.d.ts:3 --- --- url: /api/@warp-drive/core-types/params/type-aliases/QueryParamsSource.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [params](../index.md) / QueryParamsSource ```ts type QueryParamsSource = | object & Record, Serializable> | URLSearchParams; ``` Defined in: warp-drive-packages/core/declarations/types/params.d.ts:7 ## Type Parameters ### T `T` = `unknown` --- --- url: /api/@warp-drive/core-types/params/type-aliases/SerializablePrimitive.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [params](../index.md) / SerializablePrimitive ```ts type SerializablePrimitive = string | number | boolean | null; ``` Defined in: warp-drive-packages/core/declarations/types/params.d.ts:2 --- --- url: /api/@warp-drive/core-types/record/functions/createIncludeValidator.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [record](../index.md) / createIncludeValidator ```ts function createIncludeValidator(): (includes) => U; ``` Defined in: warp-drive-packages/core/declarations/types/record.d.ts:94 ## Type Parameters ### T `T` *extends* [`TypedRecordInstance`](../interfaces/TypedRecordInstance.md) ## Returns ```ts (includes): U; ``` ### Type Parameters #### U `U` *extends* `string` ### Parameters #### includes [`_StringSatisfiesIncludes`](../type-aliases/StringSatisfiesIncludes.md)<`U`, `Exclude`<`_ExtractUnion`<`3`, `T`, `true`, `NONE`, `NONE`, `1`>, `NONE`>> ### Returns `U` --- --- url: /api/@warp-drive/core-types/record.md --- [Documentation](../../../index.md) / [@warp-drive/core-types](../index.md) / record ## Interfaces * [TypedRecordInstance](interfaces/TypedRecordInstance.md) ## Type Aliases * [\_StringSatisfiesIncludes](type-aliases/StringSatisfiesIncludes.md) * [ExtractSuggestedCacheTypes](type-aliases/ExtractSuggestedCacheTypes.md) * [Includes](type-aliases/Includes.md) * [OpaqueRecordInstance](type-aliases/OpaqueRecordInstance.md) * [StringSatisfiesIncludes](type-aliases/StringSatisfiesIncludes-1.md) * [TypeFromInstance](type-aliases/TypeFromInstance.md) * [TypeFromInstanceOrString](type-aliases/TypeFromInstanceOrString.md) ## Functions * [createIncludeValidator](functions/createIncludeValidator.md) --- --- url: /api/@warp-drive/core-types/record/type-aliases/Includes.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [record](../index.md) / Includes ```ts type Includes = ExtractUnion; ``` Defined in: warp-drive-packages/core/declarations/types/record.d.ts:90 A utility that provides the union type of all valid include paths for the given TypedRecordInstance. Cyclical paths are filtered out. ## Type Parameters ### T `T` *extends* [`TypedRecordInstance`](../interfaces/TypedRecordInstance.md) ### MAX\_DEPTH `MAX_DEPTH` *extends* `_DEPTHCOUNT` = `DEFAULT_MAX_DEPTH` --- --- url: /api/@warp-drive/core-types/record/type-aliases/ExtractSuggestedCacheTypes.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [record](../index.md) / ExtractSuggestedCacheTypes ```ts type ExtractSuggestedCacheTypes = ExtractUnion; ``` Defined in: warp-drive-packages/core/declarations/types/record.d.ts:82 A utility that provides the union of all ResourceName for all potential includes for the given TypedRecordInstance. ## Type Parameters ### T `T` *extends* [`TypedRecordInstance`](../interfaces/TypedRecordInstance.md) ### MAX\_DEPTH `MAX_DEPTH` *extends* `_DEPTHCOUNT` = `DEFAULT_MAX_DEPTH` --- --- url: /api/@warp-drive/core-types/record/type-aliases/OpaqueRecordInstance.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [record](../index.md) / OpaqueRecordInstance ```ts type OpaqueRecordInstance = unknown; ``` Defined in: warp-drive-packages/core/declarations/types/record.d.ts:91 --- --- url: /api/@warp-drive/core-types/record/interfaces/TypedRecordInstance.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [record](../index.md) / TypedRecordInstance Defined in: warp-drive-packages/core/declarations/types/record.d.ts:13 Records may be anything, They don't even have to be objects. Whatever they are, if they have a Type property, that property will be used by WarpDrive and WarpDrive to provide better type safety and intellisense. TypedRecordInstance ## Properties ### \_\_\_(unique) Symbol($type) ```ts ___(unique) Symbol($type): string; ``` Defined in: warp-drive-packages/core/declarations/types/record.d.ts:29 The type of the resource. This is an optional feature that can be used by record implementations to provide a typescript hint for the type of the resource. When used, WarpDrive APIs can take advantage of this to provide better type safety and intellisense. --- --- url: /api/@warp-drive/core-types/record/type-aliases/StringSatisfiesIncludes-1.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [record](../index.md) / StringSatisfiesIncludes ```ts type StringSatisfiesIncludes = _StringSatisfiesIncludes; ``` Defined in: warp-drive-packages/core/declarations/types/record.d.ts:93 ## Type Parameters ### T `T` *extends* `string` ### SET `SET` *extends* `string` --- --- url: /api/@warp-drive/core-types/record/type-aliases/StringSatisfiesIncludes.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [record](../index.md) / \_StringSatisfiesIncludes ```ts type _StringSatisfiesIncludes = T extends SET ? FT : T extends `${infer U},${infer V}` ? U extends SET ? _StringSatisfiesIncludes, FT> : never : never; ``` Defined in: warp-drive-packages/core/declarations/types/record.d.ts:92 ## Type Parameters ### T `T` *extends* `string` ### SET `SET` *extends* `string` ### FT `FT` *extends* `string` --- --- url: /api/@warp-drive/core-types/record/type-aliases/TypeFromInstance.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [record](../index.md) / TypeFromInstance ```ts type TypeFromInstance = T extends TypedRecordInstance ? T[typeof Type] : never; ``` Defined in: warp-drive-packages/core/declarations/types/record.d.ts:36 A type utility that extracts the Type if available, otherwise it returns never. ## Type Parameters ### T `T` --- --- url: /api/@warp-drive/core-types/record/type-aliases/TypeFromInstanceOrString.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [record](../index.md) / TypeFromInstanceOrString ```ts type TypeFromInstanceOrString = T extends TypedRecordInstance ? T[typeof Type] : string; ``` Defined in: warp-drive-packages/core/declarations/types/record.d.ts:42 A type utility that extracts the Type if available, otherwise it returns string ## Type Parameters ### T `T` --- --- url: /api/@warp-drive/core-types/request/functions/withBrand.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / withBrand ```ts function withBrand(obj): RequestInfo & object; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:304 ## Type Parameters ### T `T` ## Parameters ### obj [`RequestInfo`](../interfaces/RequestInfo.md) ## Returns [`RequestInfo`](../interfaces/RequestInfo.md)<`T`, `unknown`> & `object` --- --- url: /api/@warp-drive/core-types/request/interfaces/ImmutableHeaders.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / ImmutableHeaders Defined in: warp-drive-packages/core/declarations/types/request.d.ts:226 ## Extends * `Headers` ## Methods ### append() ```ts append(name, value): void; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:14286 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append) #### Parameters ##### name `string` ##### value `string` #### Returns `void` #### Inherited from ```ts Headers.append ``` *** ### clone()? ```ts optional clone(): Headers; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:227 #### Returns `Headers` *** ### delete() ```ts delete(name): void; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:14288 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete) #### Parameters ##### name `string` #### Returns `void` #### Inherited from ```ts Headers.delete ``` *** ### forEach() ```ts forEach(callbackfn, thisArg?): void; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:14297 #### Parameters ##### callbackfn (`value`, `key`, `parent`) => `void` ##### thisArg? `any` #### Returns `void` #### Inherited from ```ts Headers.forEach ``` *** ### get() ```ts get(name): null | string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:14290 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get) #### Parameters ##### name `string` #### Returns `null` | `string` #### Inherited from ```ts Headers.get ``` *** ### getSetCookie() ```ts getSetCookie(): string[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:14292 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie) #### Returns `string`\[] #### Inherited from ```ts Headers.getSetCookie ``` *** ### has() ```ts has(name): boolean; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:14294 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has) #### Parameters ##### name `string` #### Returns `boolean` #### Inherited from ```ts Headers.has ``` *** ### set() ```ts set(name, value): void; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:14296 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set) #### Parameters ##### name `string` ##### value `string` #### Returns `void` #### Inherited from ```ts Headers.set ``` *** ### toJSON() ```ts toJSON(): [string, string][]; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:228 #### Returns \[`string`, `string`]\[] --- --- url: /api/@warp-drive/core-types/request.md --- [Documentation](../../../index.md) / [@warp-drive/core-types](../index.md) / request ## Interfaces * [ImmutableHeaders](interfaces/ImmutableHeaders.md) * [RequestContext](interfaces/RequestContext.md) * [RequestInfo](interfaces/RequestInfo.md) * [ResponseInfo](interfaces/ResponseInfo.md) * [StructuredDataDocument](interfaces/StructuredDataDocument.md) * [StructuredErrorDocument](interfaces/StructuredErrorDocument.md) ## Type Aliases * [CacheOptions](type-aliases/CacheOptions.md) * [ConstrainedRequestOptions](type-aliases/ConstrainedRequestOptions.md) * [CreateRequestOptions](type-aliases/CreateRequestOptions.md) * [DeleteRequestOptions](type-aliases/DeleteRequestOptions.md) * [FindRecordOptions](type-aliases/FindRecordOptions.md) * [FindRecordRequestOptions](type-aliases/FindRecordRequestOptions.md) * [HTTPMethod](type-aliases/HTTPMethod.md) * [ImmutableCreateRequestOptions](type-aliases/ImmutableCreateRequestOptions.md) * [ImmutableDeleteRequestOptions](type-aliases/ImmutableDeleteRequestOptions.md) * [ImmutableRequestInfo](type-aliases/ImmutableRequestInfo.md) * [ImmutableUpdateRequestOptions](type-aliases/ImmutableUpdateRequestOptions.md) * [PostQueryRequestOptions](type-aliases/PostQueryRequestOptions.md) * [QueryRequestOptions](type-aliases/QueryRequestOptions.md) * [RemotelyAccessibleIdentifier](type-aliases/RemotelyAccessibleIdentifier.md) * [StructuredDocument](type-aliases/StructuredDocument.md) * [UpdateRequestOptions](type-aliases/UpdateRequestOptions.md) ## Variables * [EnableHydration](variables/EnableHydration.md) * [IS\_FUTURE](variables/IS_FUTURE.md) * [SkipCache](variables/SkipCache.md) * [STRUCTURED](variables/STRUCTURED.md) ## Functions * [withBrand](functions/withBrand.md) --- --- url: /api/@warp-drive/core-types/request/interfaces/RequestContext.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / RequestContext Defined in: warp-drive-packages/core/declarations/types/request.d.ts:295 ## Extended by * [`StoreRequestContext`](../../../../@ember-data/store/index/interfaces/StoreRequestContext.md) ## Properties ### id ```ts id: number; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:300 *** ### request ```ts request: ImmutableRequestInfo; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:299 #### See [ImmutableRequestInfo](../type-aliases/ImmutableRequestInfo.md) ## Methods ### setResponse() ```ts setResponse(response): void; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:302 #### Parameters ##### response `null` | `Response` | [`ResponseInfo`](ResponseInfo.md) #### Returns `void` *** ### setStream() ```ts setStream(stream): void; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:301 #### Parameters ##### stream `ReadableStream`<`any`> | `Promise`<`null` | `ReadableStream`<`any`>> #### Returns `void` --- --- url: /api/@warp-drive/core-types/request/interfaces/RequestInfo.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / RequestInfo Defined in: warp-drive-packages/core/declarations/types/request.d.ts:235 Extends JavaScript's native Request object with additional properties specific to the RequestManager's capabilities. ## Extends * `Request` ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(EnableHydration)? ```ts optional ___(unique) Symbol(EnableHydration): boolean; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:271 *** ### \_\_\_(unique) Symbol(RequestSignature)? ```ts optional ___(unique) Symbol(RequestSignature): RT; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:270 *** ### body? ```ts optional body: null | BodyInit; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:216 Any body that you want to add to your request. Note that a GET or HEAD request may not have a body. #### Inherited from ```ts Request.body ``` *** ### cache? ```ts optional cache: RequestCache; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:174 Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching. #### Inherited from ```ts Request.cache ``` *** ### cacheOptions? ```ts optional cacheOptions: CacheOptions; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:244 #### See [CacheOptions](../type-aliases/CacheOptions.md) *** ### controller? ```ts optional controller: AbortController; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:240 If provided, used instead of the AbortController auto-configured for each request by the RequestManager *** ### credentials? ```ts optional credentials: RequestCredentials; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:177 Returns the credentials mode associated with request, which is a string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. #### Inherited from ```ts Request.credentials ``` *** ### data? ```ts optional data: Record; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:263 data that a handler should convert into the query (GET) or body (POST). Note: It is recommended that builders set query params and body directly in most scenarios. *** ### destination? ```ts optional destination: RequestDestination; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:180 Returns the kind of resource requested by request, e.g., "document" or "script". #### Inherited from ```ts Request.destination ``` *** ### disableTestWaiter? ```ts optional disableTestWaiter: boolean; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:254 *** ### duplex? ```ts optional duplex: "half"; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:224 When sending a ReadableStream as the body of a request, 'half' must be specified. [Half Duplex Further Reading](https://developer.chrome.com/docs/capabilities/web-apis/fetch-streaming-requests#half_duplex) #### Inherited from ```ts Request.duplex ``` *** ### headers? ```ts optional headers: Headers; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:183 Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header. #### Inherited from ```ts Request.headers ``` *** ### integrity? ```ts optional integrity: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:186 Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. \[SRI] #### Inherited from ```ts Request.integrity ``` *** ### keepalive? ```ts optional keepalive: boolean; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:189 Returns a boolean indicating whether or not request can outlive the global in which it was created. #### Inherited from ```ts Request.keepalive ``` *** ### method? ```ts optional method: HTTPMethod; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:192 Returns request's HTTP method, which is "GET" by default. #### Inherited from ```ts Request.method ``` *** ### mode? ```ts optional mode: RequestMode; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:198 Returns the mode associated with request, which is a string indicating whether the request will use CORS, or will be restricted to same-origin URLs. `no-cors` is not allowed for streaming request bodies. #### Inherited from ```ts Request.mode ``` *** ### op? ```ts optional op: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:246 *** ### options? ```ts optional options: Record; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:269 options specifically intended for handlers to utilize to process the request *** ### records? ```ts optional records: StableRecordIdentifier[]; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:253 The identifiers of the primary resources involved in the request (if any). This may be used by handlers to perform transactional operations on the store. *** ### redirect? ```ts optional redirect: RequestRedirect; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:201 Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default. #### Inherited from ```ts Request.redirect ``` *** ### referrer? ```ts optional referrer: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:204 Returns the referrer of request. Its value can be a same-origin URL if explicitly set in init, the empty string to indicate no referrer, and "about:client" when defaulting to the global's default. This is used during fetching to determine the value of the `Referer` header of the request being made. #### Inherited from ```ts Request.referrer ``` *** ### referrerPolicy? ```ts optional referrerPolicy: ReferrerPolicy; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:207 Returns the referrer policy associated with request. This is used during fetching to compute the value of the request's referrer. #### Inherited from ```ts Request.referrerPolicy ``` *** ### signal? ```ts optional signal: AbortSignal; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:210 Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler. #### Inherited from ```ts Request.signal ``` *** ### store? ```ts optional store: unknown; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:245 *** ### url? ```ts optional url: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:213 Returns the URL of request as a string. #### Inherited from ```ts Request.url ``` --- --- url: /api/@warp-drive/core-types/request/interfaces/ResponseInfo.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / ResponseInfo Defined in: warp-drive-packages/core/declarations/types/request.d.ts:286 ## Properties ### headers ```ts readonly headers: ImmutableHeaders; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:287 *** ### ok ```ts readonly ok: boolean; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:288 *** ### redirected ```ts readonly redirected: boolean; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:289 *** ### status ```ts readonly status: number; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:290 *** ### statusText ```ts readonly statusText: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:291 *** ### type ```ts readonly type: ResponseType; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:292 *** ### url ```ts readonly url: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:293 --- --- url: /api/@warp-drive/core-types/request/interfaces/StructuredDataDocument.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / StructuredDataDocument Defined in: warp-drive-packages/core/declarations/types/request.d.ts:148 ## Type Parameters ### T `T` ## Properties ### \_\_\_(unique) Symbol(DOC)? ```ts optional ___(unique) Symbol(DOC): true; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:149 *** ### content ```ts content: T; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:155 *** ### request ```ts request: ImmutableRequestInfo; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:153 #### See [ImmutableRequestInfo](../type-aliases/ImmutableRequestInfo.md) *** ### response ```ts response: null | Response | ResponseInfo; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:154 --- --- url: /api/@warp-drive/core-types/request/interfaces/StructuredErrorDocument.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / StructuredErrorDocument Defined in: warp-drive-packages/core/declarations/types/request.d.ts:157 ## Extends * `Error` ## Type Parameters ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(DOC)? ```ts optional ___(unique) Symbol(DOC): true; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:158 *** ### cause? ```ts optional cause: unknown; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26 #### Inherited from ```ts Error.cause ``` *** ### content? ```ts optional content: T; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:162 *** ### error ```ts error: string | object; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:161 *** ### message ```ts message: string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1077 #### Inherited from ```ts Error.message ``` *** ### name ```ts name: string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 #### Inherited from ```ts Error.name ``` *** ### request ```ts request: ImmutableRequestInfo; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:159 *** ### response ```ts response: null | Response | ResponseInfo; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:160 *** ### stack? ```ts optional stack: string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1078 #### Inherited from ```ts Error.stack ``` --- --- url: /api/@warp-drive/core-types/request/type-aliases/CacheOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / CacheOptions ```ts type CacheOptions = object; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:16 Use these options to adjust CacheHandler behavior for a request. ## Type Parameters ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(SkipCache)? ```ts optional ___(unique) Symbol(SkipCache): boolean; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:59 If true, the request will never be handled by the cache-manager and thus will never resolve from cache nor update the cache. Generally this is only used for legacy request that manage resource cache updates in a non-standard way via the LegacyNetworkHandler. *** ### backgroundReload? ```ts optional backgroundReload: boolean; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:34 If true, and a cached response is present and not expired, the request will be made in the background and the cached response will be returned. *** ### key? ```ts optional key: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:22 A key that uniquely identifies this request. If not present, the url wil be used as the key for any GET request, while all other requests will not be cached. *** ### reload? ```ts optional reload: boolean; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:28 If true, the request will be made even if a cached response is present and not expired. *** ### types? ```ts optional types: T extends TypedRecordInstance ? ExtractSuggestedCacheTypes[] : string[]; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:50 Useful for metadata around when to invalidate the cache. Typically used by strategies that invalidate requests by resource type when a new resource of that type has been created. See the CachePolicy implementation provided by `@ember-data/request-utils` for an example. It is recommended to only use this for query/queryRecord requests where new records created later would affect the results, though using it for findRecord requests is also supported if desired where it may be useful when a create may affect the result of a sideloaded relationship. Generally it is better to patch the cache directly for relationship updates than to invalidate findRecord requests for one. --- --- url: /api/@warp-drive/core-types/request/type-aliases/ConstrainedRequestOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / ConstrainedRequestOptions ```ts type ConstrainedRequestOptions = object; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:137 ## Properties ### backgroundReload? ```ts optional backgroundReload: boolean; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:139 *** ### host? ```ts optional host: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:140 *** ### namespace? ```ts optional namespace: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:141 *** ### reload? ```ts optional reload: boolean; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:138 *** ### resourcePath? ```ts optional resourcePath: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:142 *** ### urlParamsSettings? ```ts optional urlParamsSettings: QueryParamsSerializationOptions; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:143 --- --- url: /api/@warp-drive/core-types/request/type-aliases/CreateRequestOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / CreateRequestOptions ```ts type CreateRequestOptions = object; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:117 ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(RequestSignature)? ```ts optional ___(unique) Symbol(RequestSignature): RT; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:127 *** ### body? ```ts optional body: string | BodyInit | FormData; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:122 *** ### data ```ts data: object; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:123 #### record ```ts record: StableRecordIdentifier>; ``` *** ### headers ```ts headers: Headers; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:120 *** ### method ```ts method: "POST"; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:119 *** ### op ```ts op: "createRecord"; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:121 *** ### records ```ts records: [ResourceIdentifierObject>]; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:126 *** ### url ```ts url: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:118 --- --- url: /api/@warp-drive/core-types/request/type-aliases/DeleteRequestOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / DeleteRequestOptions ```ts type DeleteRequestOptions = object; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:89 ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(RequestSignature)? ```ts optional ___(unique) Symbol(RequestSignature): RT; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:99 *** ### body? ```ts optional body: string | BodyInit | FormData; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:94 *** ### data ```ts data: object; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:95 #### record ```ts record: StableRecordIdentifier>; ``` *** ### headers ```ts headers: Headers; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:92 *** ### method ```ts method: "DELETE"; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:91 *** ### op ```ts op: "deleteRecord"; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:93 *** ### records ```ts records: [ResourceIdentifierObject>]; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:98 *** ### url ```ts url: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:90 --- --- url: /api/@warp-drive/core-types/request/type-aliases/FindRecordRequestOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / FindRecordRequestOptions ```ts type FindRecordRequestOptions = object; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:61 ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(RequestSignature)? ```ts optional ___(unique) Symbol(RequestSignature): RT; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:68 *** ### cacheOptions? ```ts optional cacheOptions: CacheOptions; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:65 *** ### headers ```ts headers: Headers; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:64 *** ### method ```ts method: "GET"; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:63 *** ### op ```ts op: "findRecord"; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:66 *** ### records ```ts records: [ResourceIdentifierObject>]; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:67 *** ### url ```ts url: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:62 --- --- url: /api/@warp-drive/core-types/request/type-aliases/FindRecordOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / FindRecordOptions ```ts type FindRecordOptions = ConstrainedRequestOptions & object; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:145 ## Type declaration ### include? ```ts optional include: T extends TypedRecordInstance ? Includes[] : string | string[]; ``` ## Type Parameters ### T `T` = `unknown` --- --- url: /api/@warp-drive/core-types/request/type-aliases/HTTPMethod.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / HTTPMethod ```ts type HTTPMethod = | "QUERY" | "GET" | "OPTIONS" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "CONNECT" | "TRACE"; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:11 --- --- url: >- /api/@warp-drive/core-types/request/type-aliases/ImmutableCreateRequestOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / ImmutableCreateRequestOptions ```ts type ImmutableCreateRequestOptions = ImmutableRequest; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:131 --- --- url: >- /api/@warp-drive/core-types/request/type-aliases/ImmutableDeleteRequestOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / ImmutableDeleteRequestOptions ```ts type ImmutableDeleteRequestOptions = ImmutableRequest; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:129 --- --- url: /api/@warp-drive/core-types/request/type-aliases/ImmutableRequestInfo.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / ImmutableRequestInfo ```ts type ImmutableRequestInfo = Readonly, "controller">> & object; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:277 Immutable version of [RequestInfo](../interfaces/RequestInfo.md). This is what is passed to handlers. ## Type declaration ### bodyUsed? ```ts readonly optional bodyUsed: boolean; ``` Whether the request body has been read. ### cacheOptions? ```ts readonly optional cacheOptions: Readonly>; ``` ### data? ```ts readonly optional data: Readonly>; ``` ### headers? ```ts readonly optional headers: ImmutableHeaders; ``` ### options? ```ts readonly optional options: Readonly>; ``` ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` --- --- url: >- /api/@warp-drive/core-types/request/type-aliases/ImmutableUpdateRequestOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / ImmutableUpdateRequestOptions ```ts type ImmutableUpdateRequestOptions = ImmutableRequest; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:130 --- --- url: /api/@warp-drive/core-types/request/type-aliases/PostQueryRequestOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / PostQueryRequestOptions ```ts type PostQueryRequestOptions = object; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:78 ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(RequestSignature)? ```ts optional ___(unique) Symbol(RequestSignature): RT; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:87 *** ### body? ```ts optional body: string | BodyInit | FormData; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:82 *** ### cacheOptions ```ts cacheOptions: CacheOptions & object; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:83 #### Type declaration ##### key ```ts key: string; ``` *** ### headers ```ts headers: Headers; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:81 *** ### method ```ts method: "POST" | "QUERY"; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:80 *** ### op ```ts op: "query"; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:86 *** ### url ```ts url: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:79 --- --- url: /api/@warp-drive/core-types/request/type-aliases/QueryRequestOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / QueryRequestOptions ```ts type QueryRequestOptions = object; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:70 ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(RequestSignature)? ```ts optional ___(unique) Symbol(RequestSignature): RT; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:76 *** ### cacheOptions? ```ts optional cacheOptions: CacheOptions; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:74 *** ### headers ```ts headers: Headers; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:73 *** ### method ```ts method: "GET"; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:72 *** ### op ```ts op: "query"; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:75 *** ### url ```ts url: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:71 --- --- url: /api/@warp-drive/core-types/request/type-aliases/StructuredDocument.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / StructuredDocument ```ts type StructuredDocument = | StructuredDataDocument | StructuredErrorDocument; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:164 ## Type Parameters ### T `T` --- --- url: >- /api/@warp-drive/core-types/request/type-aliases/RemotelyAccessibleIdentifier.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / RemotelyAccessibleIdentifier ```ts type RemotelyAccessibleIdentifier = object; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:132 ## Type Parameters ### T `T` *extends* `string` = `string` ## Properties ### id ```ts id: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:133 *** ### lid? ```ts optional lid: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:135 *** ### type ```ts type: T; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:134 --- --- url: /api/@warp-drive/core-types/request/type-aliases/UpdateRequestOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / UpdateRequestOptions ```ts type UpdateRequestOptions = object; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:105 ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(RequestSignature)? ```ts optional ___(unique) Symbol(RequestSignature): RT; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:115 *** ### body? ```ts optional body: string | BodyInit | FormData; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:110 *** ### data ```ts data: object; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:111 #### record ```ts record: StableRecordIdentifier>; ``` *** ### headers ```ts headers: Headers; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:108 *** ### method ```ts method: "PATCH" | "PUT"; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:107 *** ### op ```ts op: "updateRecord"; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:109 *** ### records ```ts records: [ResourceIdentifierObject>]; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:114 *** ### url ```ts url: string; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:106 --- --- url: /api/@warp-drive/core-types/request/variables/EnableHydration.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / EnableHydration ```ts const EnableHydration: "___(unique) Symbol(EnableHydration)"; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:8 --- --- url: /api/@warp-drive/core-types/request/variables/IS_FUTURE.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / IS\_FUTURE ```ts const IS_FUTURE: "___(unique) Symbol(IS_FUTURE)"; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:9 --- --- url: /api/@warp-drive/core-types/request/variables/STRUCTURED.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / STRUCTURED ```ts const STRUCTURED: "___(unique) Symbol(DOC)"; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:10 --- --- url: /api/@warp-drive/core-types/request/variables/SkipCache.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [request](../index.md) / SkipCache ```ts const SkipCache: "___(unique) Symbol(SkipCache)"; ``` Defined in: warp-drive-packages/core/declarations/types/request.d.ts:7 --- --- url: /api/@warp-drive/core-types/runtime/functions/getRuntimeConfig.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [runtime](../index.md) / getRuntimeConfig ```ts function getRuntimeConfig(): object; ``` Defined in: warp-drive-packages/core/declarations/types/runtime.d.ts:5 ## Returns `object` ### debug ```ts debug: Partial; ``` --- --- url: /api/@warp-drive/core-types/runtime/functions/setLogging.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [runtime](../index.md) / setLogging ```ts function setLogging(config): void; ``` Defined in: warp-drive-packages/core/declarations/types/runtime.d.ts:13 Upserts the specified logging configuration into the runtime config. globalThis.setWarpDriveLogging({ LOG\_CACHE: true } }); ## Parameters ### config `Partial`<`LOG_CONFIG`> ## Returns `void` --- --- url: /api/@warp-drive/core-types/runtime.md --- [Documentation](../../../index.md) / [@warp-drive/core-types](../index.md) / runtime ## Functions * [getRuntimeConfig](functions/getRuntimeConfig.md) * [setLogging](functions/setLogging.md) --- --- url: /api/@warp-drive/core-types/schema/concepts/type-aliases/HashFn.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/concepts](../index.md) / HashFn ```ts type HashFn = object & (data, options, prop) => string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/concepts.d.ts:14 ## Type declaration ### \_\_\_(unique) Symbol($type) ```ts ___(unique) Symbol($type): string; ``` ## Type Parameters ### T `T` *extends* `object` = `object` --- --- url: /api/@warp-drive/core-types/schema/concepts.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / schema/concepts ## Type Aliases * [Derivation](type-aliases/Derivation.md) * [HashFn](type-aliases/HashFn.md) * [Transformation](type-aliases/Transformation.md) --- --- url: /api/@warp-drive/core-types/schema/concepts/type-aliases/Derivation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/concepts](../index.md) / Derivation ```ts type Derivation = object & (record, options, prop) => T; ``` Defined in: warp-drive-packages/core/declarations/types/schema/concepts.d.ts:11 ## Type declaration ### \_\_\_(unique) Symbol($type) ```ts ___(unique) Symbol($type): string; ``` ## Type Parameters ### R `R` = `unknown` ### T `T` = `unknown` ### FM `FM` *extends* [`ObjectValue`](../../../json/raw/interfaces/ObjectValue.md) | `null` = [`ObjectValue`](../../../json/raw/interfaces/ObjectValue.md) | `null` --- --- url: /api/@warp-drive/core-types/schema/concepts/type-aliases/Transformation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/concepts](../index.md) / Transformation ```ts type Transformation = object; ``` Defined in: warp-drive-packages/core/declarations/types/schema/concepts.d.ts:5 ## Type Parameters ### T `T` *extends* [`Value`](../../../json/raw/type-aliases/Value.md) = [`Value`](../../../json/raw/type-aliases/Value.md) ### PT `PT` = `unknown` ## Properties ### \_\_\_(unique) Symbol($type) ```ts ___(unique) Symbol($type): string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/concepts.d.ts:9 ## Methods ### defaultValue()? ```ts optional defaultValue(options, identifier): T; ``` Defined in: warp-drive-packages/core/declarations/types/schema/concepts.d.ts:8 #### Parameters ##### options `null` | [`ObjectValue`](../../../json/raw/interfaces/ObjectValue.md) ##### identifier [`StableRecordIdentifier`](../../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `T` *** ### hydrate() ```ts hydrate( value, options, record): PT; ``` Defined in: warp-drive-packages/core/declarations/types/schema/concepts.d.ts:7 #### Parameters ##### value `undefined` | `T` ##### options `null` | [`ObjectValue`](../../../json/raw/interfaces/ObjectValue.md) ##### record `unknown` #### Returns `PT` *** ### serialize() ```ts serialize( value, options, record): T; ``` Defined in: warp-drive-packages/core/declarations/types/schema/concepts.d.ts:6 #### Parameters ##### value `PT` ##### options `null` | [`ObjectValue`](../../../json/raw/interfaces/ObjectValue.md) ##### record `unknown` #### Returns `T` --- --- url: /api/@warp-drive/core-types/schema/fields/functions/isLegacyResourceSchema.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / isLegacyResourceSchema ```ts function isLegacyResourceSchema(schema): schema is LegacyResourceSchema; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1825 A type utility to narrow a schema to LegacyResourceSchema ## Parameters ### schema [`ObjectSchema`](../interfaces/ObjectSchema.md) | [`ResourceSchema`](../type-aliases/ResourceSchema.md) ## Returns `schema is LegacyResourceSchema` --- --- url: /api/@warp-drive/core-types/schema/fields/functions/isResourceSchema.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / isResourceSchema ```ts function isResourceSchema(schema): schema is ResourceSchema; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1817 A type utility to narrow a schema to a ResourceSchema ## Parameters ### schema [`ObjectSchema`](../interfaces/ObjectSchema.md) | [`ResourceSchema`](../type-aliases/ResourceSchema.md) ## Returns `schema is ResourceSchema` --- --- url: /api/@warp-drive/core-types/schema/fields/functions/objectSchema.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / objectSchema ```ts function objectSchema(schema): T; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1809 A no-op type utility that enables type-checking object schema definitions. Will return the passed in schema. ## Type Parameters ### T `T` *extends* [`ObjectSchema`](../interfaces/ObjectSchema.md) ## Parameters ### schema `T` ## Returns `T` the passed in schema --- --- url: /api/@warp-drive/core-types/schema/fields/functions/resourceSchema.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / resourceSchema ```ts function resourceSchema(schema): T; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1798 A no-op type utility that enables type-checking resource schema definitions. Will return the passed in schema. This will not validate relationship inverses or related types, as doing so would require a full schema graph to be passed in and no cycles in the graph to be present. ## Type Parameters ### T `T` *extends* | [`LegacyResourceSchema`](../interfaces/LegacyResourceSchema.md) | [`PolarisResourceSchema`](../interfaces/PolarisResourceSchema.md) ## Parameters ### schema [`LegacyResourceSchema`](../interfaces/LegacyResourceSchema.md) | [`PolarisResourceSchema`](../interfaces/PolarisResourceSchema.md) ## Returns `T` the passed in schema --- --- url: /api/@warp-drive/core-types/schema/fields.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / schema/fields ## Interfaces * [ArrayField](interfaces/ArrayField.md) * [CollectionField](interfaces/CollectionField.md) * [DerivedField](interfaces/DerivedField.md) * [GenericField](interfaces/GenericField.md) * [HashField](interfaces/HashField.md) * [IdentityField](interfaces/IdentityField.md) * [LegacyAliasField](interfaces/LegacyAliasField.md) * [LegacyAttributeField](interfaces/LegacyAttributeField.md) * [LegacyBelongsToField](interfaces/LegacyBelongsToField.md) * [LegacyHasManyField](interfaces/LegacyHasManyField.md) * [LegacyResourceSchema](interfaces/LegacyResourceSchema.md) * [LinksModeBelongsToField](interfaces/LinksModeBelongsToField.md) * [LinksModeHasManyField](interfaces/LinksModeHasManyField.md) * [LocalField](interfaces/LocalField.md) * [ObjectAliasField](interfaces/ObjectAliasField.md) * [ObjectField](interfaces/ObjectField.md) * [ObjectSchema](interfaces/ObjectSchema.md) * [PolarisAliasField](interfaces/PolarisAliasField.md) * [PolarisResourceSchema](interfaces/PolarisResourceSchema.md) * [ResourceField](interfaces/ResourceField.md) * [SchemaArrayField](interfaces/SchemaArrayField.md) * [SchemaObjectField](interfaces/SchemaObjectField.md) ## Type Aliases * [FieldSchema](type-aliases/FieldSchema.md) * [LegacyField](type-aliases/LegacyField.md) * [LegacyModeFieldSchema](type-aliases/LegacyModeFieldSchema.md) * [LegacyRelationshipField](type-aliases/LegacyRelationshipField.md) * [ObjectFieldSchema](type-aliases/ObjectFieldSchema.md) * [PolarisModeFieldSchema](type-aliases/PolarisModeFieldSchema.md) * [ResourceSchema](type-aliases/ResourceSchema.md) * [Schema](type-aliases/Schema.md) ## Functions * [isLegacyResourceSchema](functions/isLegacyResourceSchema.md) * [isResourceSchema](functions/isResourceSchema.md) * [objectSchema](functions/objectSchema.md) * [resourceSchema](functions/resourceSchema.md) --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/ArrayField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / ArrayField Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:537 Represents a field whose value is an array of primitive values. If the array's elements are not primitive values, use 'schema-array' instead. (Type) ArrayField ## Properties ### kind ```ts kind: "array"; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:545 The kind of field this is. *** ### name ```ts name: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:553 The name of the field. *** ### options? ```ts optional options: ObjectValue; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:574 Options to pass to the transform, if any Must comply to the specific transform's options schema. *** ### type? ```ts optional type: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:563 The name of a transform to pass each item in the array through before displaying or or serializing it. --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/CollectionField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / CollectionField Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:850 Represents a field that is a reference to a collection of other resources, potentially paginate. SUPPORT FOR THIS FEATURE IS NOT YET IMPLEMENTED BY SchemaRecord (Type) CollectionField ## Properties ### kind ```ts kind: "collection"; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:858 The kind of field this is. *** ### name ```ts name: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:866 The name of the field. *** ### options? ```ts optional options: object; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:884 Options for resources are optional. If not present, all options are presumed to be falsey #### as? ```ts optional as: string; ``` If this field is satisfying a polymorphic relationship on another resource, then this should be set to the trait or abstract type that this resource implements. #### async? ```ts optional async: boolean; ``` Whether the relationship is async If true, it is expected that the cache data for this field will contain links that can be used to fetch the related resources when needed. When false, it is expected that all related resources are loaded together with this resource, and that the cache data for this field will contain the full list of pointers. When true, it is expected that the relationship is paginated. If the relationship is not paginated, then the cache data for "page 1" would contain the full list of pointers, and loading "page 1" would load all related resources. #### inverse? ```ts optional inverse: null | string; ``` The name of the inverse field on the related resource that points back to this field on this resource to form a bidirectional relationship. If null, the relationship is unidirectional. #### polymorphic? ```ts optional polymorphic: boolean; ``` Whether this field is a polymorphic relationship, meaning that it can point to multiple types of resources so long as they implement the trait or abstract type specified in `type`. *** ### type ```ts type: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:877 The name of the resource that this field refers to. In the case of a polymorphic relationship, this should be the trait or abstract type. --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/DerivedField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / DerivedField Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:702 Represents a field whose value is derived from other fields in the schema. The value is read-only, and is not stored in the cache, nor is it sent to the server. Usage of derived fields should be minimized to scenarios where the derivation is known to be safe. For instance, derivations that required fields that are not always loaded or that require access to related resources that may not be loaded should be avoided. (Type) DerivedField ## Properties ### kind ```ts kind: "derived"; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:710 The kind of field this is. *** ### name ```ts name: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:718 The name of the field. *** ### options? ```ts optional options: ObjectValue; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:751 Options to pass to the derivation, if any Must comply to the specific derivation's options schema. *** ### type ```ts type: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:740 The name of the derivation to use. Derivations are functions that take the record, options, and the name of the field as arguments, and return the derived value. Derivations are memoized, and are only recomputed when the fields they depend on change. Derivations are not stored in the cache, and are not sent to the server. Derivation functions must be explicitly registered with the schema service. --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/GenericField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / GenericField Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:19 A generic "field" that can be used to define primitive value fields. Replaces "attribute" for primitive value fields. Can also be used to eject from deep-tracking of objects or arrays. A major difference between "field" and "attribute" is that "type" points to a legacy transform on "attribute" that a serializer *might* use, while "type" points to a new-style transform on "field" that a record implmentation *must* use. (Type) GenericField ## Properties ### kind ```ts kind: "field"; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:27 The kind of field this is. *** ### name ```ts name: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:35 The name of the field. *** ### options? ```ts optional options: ObjectValue; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:54 Options to pass to the transform, if any Must comply to the specific transform's options schema. *** ### type? ```ts optional type: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:43 the name of the transform to use, if any --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/HashField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / HashField Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:303 Represents a specialized field whose computed value will be used as the primary key of a schema-object for serializability and comparison purposes. This field functions similarly to derived fields in that it is non-settable, derived state but differs in that it is only able to compute off of cache state and is given no access to a record instance. This means that if a hashing function wants to compute its value taking into account transformations and derivations it must perform those itself. A schema-array can declare its "key" value to be `@hash` if a schema-object has such a field. Only one hash field is permittable per schema-object, and it should be placed in the `ResourceSchema`'s `@id` field in place of an `IdentityField`. (Type) HashField ## Properties ### kind ```ts kind: "@hash"; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:311 The kind of field this is. *** ### name ```ts name: null | string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:323 The name of the field that serves as the hash for the resource. Only required if access to this value by the UI is desired, it can be `null` otherwise. *** ### options? ```ts optional options: ObjectValue; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:342 Any options that should be provided to the hash function. *** ### type ```ts type: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:333 The name of a function to run to compute the hash. The function will only have access to the cached data for the record. --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/IdentityField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / IdentityField Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:260 Represents a field whose value is the primary key of the resource. This allows any field to serve as the primary key while still being able to drive identity needs within the system. This is useful for resources that use for instance 'uuid', 'urn' or 'entityUrn' or 'primaryKey' as their primary key field instead of 'id'. (Type) IdentityField ## Properties ### kind ```ts kind: "@id"; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:268 The kind of field this is. *** ### name ```ts name: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:277 The name of the field that serves as the primary key for the resource. --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/LegacyAliasField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / LegacyAliasField Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:85 A field that can be used to alias one key to another key present in the cache version of the resource. Unlike DerivedField, an AliasField may write to its source when a record is in an editable mode. AliasFields may utilize a transform, specified by type, to pre/post process the field. An AliasField may also specify a `kind` via options. `kind` may be any other valid field kind other than * `@hash` * `@id` * `@local` * `derived` This allows an AliasField to rename any field in the cache. Alias fields are generally intended to be used to support migrating between different schemas, though there are times where they are useful as a form of advanced derivation when used with a transform. For instance, an AliasField could be used to expose both a string and a Date version of the same field, with both being capable of being written to. (Type) LegacyAliasField ## Properties ### kind ```ts kind: "alias"; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:93 The kind of field this is. *** ### name ```ts name: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:101 The name of the field. *** ### options ```ts options: | GenericField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | LegacyAttributeField | LegacyBelongsToField | LegacyHasManyField; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:117 The field def for which this is an alias. *** ### type ```ts type: null; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:109 Always null (for now) --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/LegacyAttributeField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / LegacyAttributeField Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:952 > \[!CAUTION] > This Field is LEGACY > It cannot be used with PolarisMode A generic "field" that can be used to define primitive value fields. If the field points to an object or array, it will not be deep-tracked. Transforms when defined are legacy transforms that a serializer *might* use, but their usage is not guaranteed. (Type) LegacyAttributeField ## Properties ### kind ```ts kind: "attribute"; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:960 The kind of field this is. *** ### name ```ts name: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:968 The name of the field. *** ### options? ```ts optional options: ObjectValue; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:984 Options to pass to the transform, if any Must comply to the specific transform's options schema. *** ### type? ```ts optional type: null | string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:976 The name of the transform to use, if any --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/LegacyBelongsToField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / LegacyBelongsToField Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:998 > \[!CAUTION] > This Field is LEGACY Represents a field that is a reference to another resource. This is the legacy version of the `ResourceField`. (Type) LegacyBelongsToField ## Properties ### kind ```ts kind: "belongsTo"; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1006 The kind of field this is. *** ### name ```ts name: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1014 The name of the field. *** ### options ```ts options: object; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1030 Options for belongsTo are mandatory. #### as? ```ts optional as: string; ``` If this field is satisfying a polymorphic relationship on another resource, then this should be set to the trait or abstract type that this resource implements. #### async ```ts async: boolean; ``` Whether the relationship is async If true, it is expected that the cache data for this field will contain a link or a pointer that can be used to fetch the related resource when needed. Pointers are highly discouraged. #### inverse ```ts inverse: null | string; ``` The name of the inverse field on the related resource that points back to this field on this resource to form a bidirectional relationship. If null, the relationship is unidirectional. #### linksMode? ```ts optional linksMode: true; ``` Whether this field should ever make use of the legacy support infra from @ember-data/model and the LegacyNetworkMiddleware for adapters and serializers. When true, none of the legacy support will be utilized. Sync relationships will be expected to already have all their data. When reloading a sync relationship you would be expected to have a `related link` available from a prior relationship payload e.g. ```ts { data: { type: 'user', id: '2', attributes: { name: 'Chris' }, relationships: { bestFriend: { links: { related: "/users/1/bestFriend" }, data: { type: 'user', id: '1' }, } } }, included: [ { type: 'user', id: '1', attributes: { name: 'Krystan' } } ] } ``` Async relationships will be loaded via their link if needed. #### polymorphic? ```ts optional polymorphic: boolean; ``` Whether this field is a polymorphic relationship, meaning that it can point to multiple types of resources so long as they implement the trait or abstract type specified in `type`. #### resetOnRemoteUpdate? ```ts optional resetOnRemoteUpdate: false; ``` When omitted, the cache data for this field will clear local state of all changes except for the addition of records still in the "new" state any time the remote data for this field is updated. When set to `false`, the cache data for this field will instead intelligently commit any changes from local state that are present in the remote data, leaving any remaining changes in local state still. *** ### type ```ts type: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1025 The name of the resource that this field refers to. In the case of a polymorphic relationship, this should be the trait or abstract type. --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/LegacyHasManyField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / LegacyHasManyField Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1254 > \[!CAUTION] > This Field is LEGACY Represents a field that is a reference to a collection of other resources. This is the legacy version of the `CollectionField`. (Type) LegacyHasManyField ## Properties ### kind ```ts kind: "hasMany"; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1262 The kind of field this is. *** ### name ```ts name: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1270 The name of the field. *** ### options ```ts options: object; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1286 Options for hasMany are mandatory. #### as? ```ts optional as: string; ``` If this field is satisfying a polymorphic relationship on another resource, then this should be set to the trait or abstract type that this resource implements. #### async ```ts async: boolean; ``` Whether the relationship is async If true, it is expected that the cache data for this field will contain links or pointers that can be used to fetch the related resources when needed. When false, it is expected that all related resources are loaded together with this resource, and that the cache data for this field will contain the full list of pointers. hasMany relationships do not support pagination. #### inverse ```ts inverse: null | string; ``` The name of the inverse field on the related resource that points back to this field on this resource to form a bidirectional relationship. If null, the relationship is unidirectional. #### linksMode? ```ts optional linksMode: true; ``` Whether this field should ever make use of the legacy support infra from @ember-data/model and the LegacyNetworkMiddleware for adapters and serializers. When true, none of the legacy support will be utilized. Sync relationships will be expected to already have all their data. When reloading a sync relationship you would be expected to have a `related link` available from a prior relationship payload e.g. ```ts { data: { type: 'user', id: '2', attributes: { name: 'Chris' }, relationships: { bestFriends: { links: { related: "/users/1/bestFriends" }, data: [ { type: 'user', id: '1' } ], } } }, included: [ { type: 'user', id: '1', attributes: { name: 'Krystan' } } ] } ``` Async relationships will be loaded via their link if needed. #### polymorphic? ```ts optional polymorphic: boolean; ``` Whether this field is a polymorphic relationship, meaning that it can point to multiple types of resources so long as they implement the trait or abstract type specified in `type`. #### resetOnRemoteUpdate? ```ts optional resetOnRemoteUpdate: false; ``` When omitted, the cache data for this field will clear local state of all changes except for the addition of records still in the "new" state any time the remote data for this field is updated. When set to `false`, the cache data for this field will instead intelligently commit any changes from local state that are present in the remote data, leaving any remaining changes in local state still. *** ### type ```ts type: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1281 the name of the resource that this field refers to. In the case of a polymorphic relationship, this should be the trait or abstract type. --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/LegacyResourceSchema.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / LegacyResourceSchema Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1659 Represents a schema for a primary resource in LegacyMode Primary resources are objects with a unique identity of their own which may allow them to appear in relationships, or in multiple response documents. (Type) LegacyResourceSchema ## Properties ### fields ```ts fields: LegacyModeFieldSchema[]; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1708 The fields that make up the shape of the resource *** ### identity ```ts identity: IdentityField; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1679 This should be an IdentityField. To maximize compatibility with Model where `id` was the name of the identity field, we recommend using `{ kind: '@id', name: 'id' }` for records in legacy mode, but this is not required. *** ### legacy ```ts legacy: true; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1667 A flag indicating that this is a legacy resource schema *** ### traits? ```ts optional traits: string[]; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1721 A list of traits that this resource implements. The fields for these traits should still be defined in the fields array. Each trait should be a string that matches the `type` of another resource schema. The trait can be abstract and reference a resource type that is never defined as a schema. *** ### type ```ts type: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1700 The name of the schema For cacheable resources, this should be the primary resource type. The names of object and resource schemas share a single namespace and must not conflict. We recommend a naming convention for object schemas such as below for ensuring uniqueness: * for globally shared objects: The pattern `$field:${KlassName}` e.g. `$field:AddressObject` * for resource-specific objects: The pattern `$${ResourceKlassName}:$field:${KlassName}` e.g. `$User:$field:ReusableAddress` * for inline objects: The pattern `$${ResourceKlassName}.${fieldPath}:$field:anonymous` e.g. `$User.shippingAddress:$field:anonymous` --- --- url: >- /api/@warp-drive/core-types/schema/fields/interfaces/LinksModeBelongsToField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / LinksModeBelongsToField Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1128 > \[!CAUTION] > This Field is LEGACY Represents a field that is a reference to another resource. This is the legacy version of the `ResourceField`. (Type) LinksModeBelongsToField ## Properties ### kind ```ts kind: "belongsTo"; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1136 The kind of field this is. *** ### name ```ts name: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1144 The name of the field. *** ### options ```ts options: object; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1160 Options for belongsTo are mandatory. #### as? ```ts optional as: string; ``` If this field is satisfying a polymorphic relationship on another resource, then this should be set to the trait or abstract type that this resource implements. #### async ```ts async: false; ``` Whether the relationship is async MUST be false for PolarisMode + LinksMode #### inverse ```ts inverse: null | string; ``` The name of the inverse field on the related resource that points back to this field on this resource to form a bidirectional relationship. If null, the relationship is unidirectional. #### linksMode ```ts linksMode: true; ``` Whether this field should ever make use of the legacy support infra from @ember-data/model and the LegacyNetworkMiddleware for adapters and serializers. MUST be true for PolarisMode + LinksMode When true, none of the legacy support will be utilized. Sync relationships will be expected to already have all their data. When reloading a sync relationship you would be expected to have a `related link` available from a prior relationship payload e.g. ```ts { data: { type: 'user', id: '2', attributes: { name: 'Chris' }, relationships: { bestFriend: { links: { related: "/users/1/bestFriend" }, data: { type: 'user', id: '1' }, } } }, included: [ { type: 'user', id: '1', attributes: { name: 'Krystan' } } ] } ``` Async relationships will be loaded via their link if needed. Activating LinksMode will *also* deactivate the deprecated `resetOnRemoteUpdate` behavior for this field. This means that when new remote state is received, the cache will intelligently commit any changes from local state that are present in the remote data for this field, leaving any remaining changes in local state still. Previously, the cache would clear local state of all changes except for the addition of records still in the "new" state any time the remote data for this field was updated. #### polymorphic? ```ts optional polymorphic: boolean; ``` Whether this field is a polymorphic relationship, meaning that it can point to multiple types of resources so long as they implement the trait or abstract type specified in `type`. *** ### type ```ts type: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1155 The name of the resource that this field refers to. In the case of a polymorphic relationship, this should be the trait or abstract type. --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/LinksModeHasManyField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / LinksModeHasManyField Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1389 > \[!CAUTION] > This Field is LEGACY Represents a field that is a reference to a collection of other resources. This is the legacy version of the `CollectionField`. (Type) LinksModeHasManyField ## Properties ### kind ```ts kind: "hasMany"; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1397 The kind of field this is. *** ### name ```ts name: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1405 The name of the field. *** ### options ```ts options: object; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1421 Options for hasMany are mandatory. #### as? ```ts optional as: string; ``` If this field is satisfying a polymorphic relationship on another resource, then this should be set to the trait or abstract type that this resource implements. #### async ```ts async: false; ``` Whether the relationship is async MUST be false for PolarisMode + LinksMode If true, it is expected that the cache data for this field will contain links or pointers that can be used to fetch the related resources when needed. When false, it is expected that all related resources are loaded together with this resource, and that the cache data for this field will contain the full list of pointers. hasMany relationships do not support pagination. #### inverse ```ts inverse: null | string; ``` The name of the inverse field on the related resource that points back to this field on this resource to form a bidirectional relationship. If null, the relationship is unidirectional. #### linksMode ```ts linksMode: true; ``` Whether this field should ever make use of the legacy support infra from @ember-data/model and the LegacyNetworkMiddleware for adapters and serializers. MUST be true for PolarisMode + LinksMode When true, none of the legacy support will be utilized. Sync relationships will be expected to already have all their data. When reloading a sync relationship you would be expected to have a `related link` available from a prior relationship payload e.g. ```ts { data: { type: 'user', id: '2', attributes: { name: 'Chris' }, relationships: { bestFriends: { links: { related: "/users/1/bestFriends" }, data: [ { type: 'user', id: '1' } ], } } }, included: [ { type: 'user', id: '1', attributes: { name: 'Krystan' } } ] } ``` Async relationships will be loaded via their link if needed. Activating LinksMode will *also* deactivate the deprecated `resetOnRemoteUpdate` behavior for this field. This means that when new remote state is received, the cache will intelligently commit any changes from local state that are present in the remote data for this field, leaving any remaining changes in local state still. Previously, the cache would clear local state of all changes except for the addition of records still in the "new" state any time the remote data for this field was updated. #### polymorphic? ```ts optional polymorphic: boolean; ``` Whether this field is a polymorphic relationship, meaning that it can point to multiple types of resources so long as they implement the trait or abstract type specified in `type`. *** ### type ```ts type: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1416 the name of the resource that this field refers to. In the case of a polymorphic relationship, this should be the trait or abstract type. --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/LocalField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / LocalField Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:374 Represents a field whose value is a local value that is not stored in the cache, nor is it sent to the server. Local fields can be written to, and their value is both memoized and reactive (though not deep-tracked). Because their state is not derived from the cache data or the server, they represent a divorced uncanonical source of state. For this reason Local fields should be used sparingly. Currently, while we document this feature here, only allow our own SchemaRecord default fields to utilize them and the feature should be considered private. Example use cases that drove the creation of local fields are states like `isDestroying` and `isDestroyed` which are specific to a record instance but not stored in the cache. We wanted to be able to drive these fields from schema the same as all other fields. Don't make us regret this decision. (Type) LocalField ## Properties ### kind ```ts kind: "@local"; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:382 The kind of field this is. *** ### name ```ts name: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:390 The name of the field. *** ### options? ```ts optional options: object; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:407 Options for the field. #### defaultValue? ```ts optional defaultValue: PrimitiveValue; ``` *** ### type? ```ts optional type: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:399 Not currently utilized, we are considering allowing transforms to operate on local fields --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/ObjectAliasField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / ObjectAliasField Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:211 A field that can be used to alias one key to another key present in the cache version of the resource. Unlike DerivedField, an AliasField may write to its source when a record is in an editable mode. AliasFields may utilize a transform, specified by type, to pre/post process the field. An AliasField may also specify a `kind` via options. `kind` may be any other valid field kind other than * `@hash` * `@id` * `@local` * `derived` This allows an AliasField to rename any field in the cache. Alias fields are generally intended to be used to support migrating between different schemas, though there are times where they are useful as a form of advanced derivation when used with a transform. For instance, an AliasField could be used to expose both a string and a Date version of the same field, with both being capable of being written to. (Type) ObjectAliasField ## Properties ### kind ```ts kind: "alias"; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:219 The kind of field this is. *** ### name ```ts name: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:227 The name of the field. *** ### options ```ts options: | GenericField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:243 The field def for which this is an alias. *** ### type ```ts type: null; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:235 Always null (for now) --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/ObjectField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / ObjectField Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:423 Represents a field whose value is an object with keys pointing to values that are primitive values. If values of the keys are not primitives, or if the key/value pairs have well-defined shape, use 'schema-object' instead. (Type) ObjectField ## Properties ### kind ```ts kind: "object"; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:431 The kind of field this is. *** ### name ```ts name: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:439 The name of the field. *** ### options? ```ts optional options: ObjectValue; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:459 Options to pass to the transform, if any Must comply to the specific transform's options schema. *** ### type? ```ts optional type: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:448 The name of a transform to pass the entire object through before displaying or serializing it. --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/ObjectSchema.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / ObjectSchema Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1743 Represents a schema for an object that is not a primary resource (has no unique identity of its own). ObjectSchemas may not currently contain relationships. (Type) ObjectSchema ## Properties ### fields ```ts fields: ObjectFieldSchema[]; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1781 The fields that make up the shape of the object *** ### identity ```ts identity: null | HashField; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1755 Either a HashField from which to calculate an identity or null In the case of `null`, the object's identity will be based on the referential identity of the object in the cache itself when an identity is needed. *** ### type ```ts type: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1773 The name of the schema The names of object and resource schemas share a single namespace and must not conflict. We recommend a naming convention for object schemas such as below for ensuring uniqueness: * for globally shared objects: The pattern `$field:${KlassName}` e.g. `$field:AddressObject` * for resource-specific objects: The pattern `$${ResourceKlassName}:$field:${KlassName}` e.g. `$User:$field:ReusableAddress` * for inline objects: The pattern `$${ResourceKlassName}.${fieldPath}:$field:anonymous` e.g. `$User.shippingAddress:$field:anonymous` --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/PolarisAliasField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / PolarisAliasField Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:148 A field that can be used to alias one key to another key present in the cache version of the resource. Unlike DerivedField, an AliasField may write to its source when a record is in an editable mode. AliasFields may utilize a transform, specified by type, to pre/post process the field. An AliasField may also specify a `kind` via options. `kind` may be any other valid field kind other than * `@hash` * `@id` * `@local` * `derived` This allows an AliasField to rename any field in the cache. Alias fields are generally intended to be used to support migrating between different schemas, though there are times where they are useful as a form of advanced derivation when used with a transform. For instance, an AliasField could be used to expose both a string and a Date version of the same field, with both being capable of being written to. (Type) PolarisAliasField ## Properties ### kind ```ts kind: "alias"; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:156 The kind of field this is. *** ### name ```ts name: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:164 The name of the field. *** ### options ```ts options: | GenericField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | LinksModeBelongsToField | LinksModeHasManyField; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:180 The field def for which this is an alias. *** ### type ```ts type: null; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:172 Always null (for now) --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/PolarisResourceSchema.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / PolarisResourceSchema Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1591 Represents a schema for a primary resource in PolarisMode. Primary resources are objects with a unique identity of their own which may allow them to appear in relationships, or in multiple response documents. (Type) PolarisResourceSchema ## Properties ### fields ```ts fields: PolarisModeFieldSchema[]; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1634 The fields that make up the shape of the resource *** ### identity ```ts identity: IdentityField; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1602 For primary resources, this should be an IdentityField for schema-objects, this should be either a HashField or null *** ### legacy? ```ts optional legacy: false; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1592 *** ### traits? ```ts optional traits: string[]; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1647 A list of traits that this resource implements. The fields for these traits should still be defined in the fields array. Each trait should be a string that matches the `type` of another resource schema. The trait can be abstract and reference a resource type that is never defined as a schema. *** ### type ```ts type: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1626 The name of the schema For cacheable resources, this should be the primary resource type. For object schemas, this should be the name of the object schema. The names of object and resource schemas share a single namespace and must not conflict. We recommend a naming convention for object schemas such as below for ensuring uniqueness: * for globally shared objects: The pattern `$field:${KlassName}` e.g. `$field:AddressObject` * for resource-specific objects: The pattern `$${ResourceKlassName}:$field:${KlassName}` e.g. `$User:$field:ReusableAddress` * for inline objects: The pattern `$${ResourceKlassName}.${fieldPath}:$field:anonymous` e.g. `$User.shippingAddress:$field:anonymous` --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/ResourceField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / ResourceField Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:763 Represents a field that is a reference to another resource. SUPPORT FOR THIS FEATURE IS NOT YET IMPLEMENTED BY SchemaRecord (Type) ResourceField ## Properties ### kind ```ts kind: "resource"; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:771 The kind of field this is. *** ### name ```ts name: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:779 The name of the field. *** ### options? ```ts optional options: object; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:800 Options for resources are optional. If not present, all options are presumed to be falsey #### as? ```ts optional as: string; ``` If this field is satisfying a polymorphic relationship on another resource, then this should be set to the trait or abstract type that this resource implements. #### async? ```ts optional async: boolean; ``` Whether the relationship is async If true, it is expected that the cache data for this field will contain a link that can be used to fetch the related resource when needed. #### inverse? ```ts optional inverse: null | string; ``` The name of the inverse field on the related resource that points back to this field on this resource to form a bidirectional relationship. If null, the relationship is unidirectional. #### polymorphic? ```ts optional polymorphic: boolean; ``` Whether this field is a polymorphic relationship, meaning that it can point to multiple types of resources so long as they implement the trait or abstract type specified in `type`. *** ### type ```ts type: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:790 The name of the resource that this field refers to. In the case of a polymorphic relationship, this should be the trait or abstract type. --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/SchemaArrayField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / SchemaArrayField Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:587 Represents a field whose value is an array of objects with a well-defined structure described by a non-resource schema. If the array's elements are not well-defined, use 'array' instead. (Type) SchemaArrayField ## Properties ### kind ```ts kind: "schema-array"; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:595 The kind of field this is. *** ### name ```ts name: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:603 The name of the field. *** ### options? ```ts optional options: object; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:644 Options for configuring the behavior of the SchemaArray. * `key` Configures how the SchemaArray determines whether an object in the cache is the same as an object previously used to instantiate one of the schema-objects it contains. The default is `'@identity'`. Valid options are: * `'@identity'` (default) : the cached object's referential identity will be used. This may result in significant instability when resource data is updated from the API * `'@index'` : the cached object's index in the array will be used. This is only a good choice for arrays that rarely if ever change membership * `'@hash'` : will lookup the `@hash` function supplied in the ResourceSchema for The contained schema-object and use the computed result to determine and compare identity. * \ (string) : the name of a field to use as the key, only GenericFields (kind `field`) Are valid field names for this purpose. The cache state without transforms applied will be used when comparing values. The field value should be unique enough to guarantee two schema-objects of the same type will not collide. * `polymorphic` : Whether this SchemaArray is Polymorphic. * `type` : If the SchemaArray is Polymorphic, the key on the raw cache data to use as the "resource-type" value for the schema-object. #### key? ```ts optional key: string; ``` Configures how the SchemaArray determines whether an object in the cache is the same as an object previously used to instantiate one of the schema-objects it contains. The default is `'@identity'`. Valid options are: * `'@identity'` (default) : the cached object's referential identity will be used. This may result in significant instability when resource data is updated from the API * `'@index'` : the cached object's index in the array will be used. This is only a good choice for arrays that rarely if ever change membership * `'@hash'` : will lookup the `@hash` function supplied in the ResourceSchema for The contained schema-object and use the computed result to determine and compare identity. * \ (string) : the name of a field to use as the key, only GenericFields (kind `field`) Are valid field names for this purpose. The cache state without transforms applied will be used when comparing values. The field value should be unique enough to guarantee two schema-objects of the same type will not collide. #### polymorphic? ```ts optional polymorphic: boolean; ``` Whether this SchemaArray is Polymorphic. If the SchemaArray is polymorphic, `options.type` must also be supplied. #### type? ```ts optional type: string; ``` If the SchemaArray is Polymorphic, the key on the raw cache data to use as the "resource-type" value for the schema-object. Defaults to "type". *** ### type ```ts type: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:612 The name of the ObjectSchema that describes the structure of the objects in the array. --- --- url: /api/@warp-drive/core-types/schema/fields/interfaces/SchemaObjectField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / SchemaObjectField Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:472 Represents a field whose value is an object with a well-defined structure described by a non-resource schema. If the object's structure is not well-defined, use 'object' instead. (Type) SchemaObjectField ## Properties ### kind ```ts kind: "schema-object"; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:480 The kind of field this is. *** ### name ```ts name: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:488 The name of the field. *** ### options? ```ts optional options: object; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:509 Options for configuring the behavior of the SchemaObject. * `polymorphic` : Whether this SchemaObject is Polymorphic. * `type` : If the SchemaObject is Polymorphic, the key on the raw cache data to use as the "resource-type" value for the schema-object. #### polymorphic? ```ts optional polymorphic: boolean; ``` Whether this SchemaObject is Polymorphic. If the SchemaObject is polymorphic, `options.type` must also be supplied. #### type? ```ts optional type: string; ``` If the SchemaObject is Polymorphic, the key on the raw cache data to use as the "resource-type" value for the schema-object. Defaults to "type". *** ### type ```ts type: string; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:497 The name of the ObjectSchema that describes the structure of the object. --- --- url: /api/@warp-drive/core-types/schema/fields/type-aliases/FieldSchema.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / FieldSchema ```ts type FieldSchema = | GenericField | LegacyAliasField | PolarisAliasField | LocalField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | DerivedField | ResourceField | CollectionField | LegacyAttributeField | LegacyBelongsToField | LegacyHasManyField | LinksModeBelongsToField | LinksModeHasManyField; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1572 A union of all possible LegacyMode and PolarisMode field schemas. You likely will want to use PolarisModeFieldSchema, LegacyModeFieldSchema, or ObjectFieldSchema instead as appropriate as they are more specific and will provide better guidance around what is valid. (Type) FieldSchema --- --- url: /api/@warp-drive/core-types/schema/fields/type-aliases/LegacyField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / LegacyField ```ts type LegacyField = | LegacyAttributeField | LegacyBelongsToField | LegacyHasManyField | LinksModeBelongsToField | LinksModeHasManyField; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1826 --- --- url: >- /api/@warp-drive/core-types/schema/fields/type-aliases/LegacyModeFieldSchema.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / LegacyModeFieldSchema ```ts type LegacyModeFieldSchema = | GenericField | LegacyAliasField | LocalField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | DerivedField | LegacyAttributeField | LegacyBelongsToField | LegacyHasManyField; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1537 A union of all possible LegacyMode field schemas. Available field schemas are: * [GenericField](../interfaces/GenericField.md) * [LegacyAliasField](../interfaces/LegacyAliasField.md) * [LocalField](../interfaces/LocalField.md) * [ObjectField](../interfaces/ObjectField.md) * [SchemaObjectField](../interfaces/SchemaObjectField.md) * [ArrayField](../interfaces/ArrayField.md) * [SchemaArrayField](../interfaces/SchemaArrayField.md) * [DerivedField](../interfaces/DerivedField.md) * [ResourceField (not yet implemented)](../interfaces/ResourceField.md) * [CollectionField (not yet implemented)](../interfaces/CollectionField.md) * [LegacyAttributeField](../interfaces/LegacyAttributeField.md) * [LegacyBelongsToField](../interfaces/LegacyBelongsToField.md) * [LegacyHasManyField](../interfaces/LegacyHasManyField.md) (Type) LegacyModeFieldSchema --- --- url: >- /api/@warp-drive/core-types/schema/fields/type-aliases/LegacyRelationshipField.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / LegacyRelationshipField ```ts type LegacyRelationshipField = | LegacyBelongsToField | LegacyHasManyField | LinksModeBelongsToField | LinksModeHasManyField; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1827 --- --- url: /api/@warp-drive/core-types/schema/fields/type-aliases/ObjectFieldSchema.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / ObjectFieldSchema ```ts type ObjectFieldSchema = | GenericField | ObjectAliasField | LocalField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | DerivedField; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1580 A union of all possible field schemas that can be used in an ObjectSchema. (Type) ObjectFieldSchema --- --- url: >- /api/@warp-drive/core-types/schema/fields/type-aliases/PolarisModeFieldSchema.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / PolarisModeFieldSchema ```ts type PolarisModeFieldSchema = | GenericField | PolarisAliasField | LocalField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | DerivedField | LinksModeBelongsToField | LinksModeHasManyField; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1559 A union of all possible PolarisMode field schemas. Available field schemas are: * [GenericField](../interfaces/GenericField.md) * [PolarisAliasField](../interfaces/PolarisAliasField.md) * [LocalField](../interfaces/LocalField.md) * [ObjectField](../interfaces/ObjectField.md) * [SchemaObjectField](../interfaces/SchemaObjectField.md) * [ArrayField](../interfaces/ArrayField.md) * [SchemaArrayField](../interfaces/SchemaArrayField.md) * [DerivedField](../interfaces/DerivedField.md) * [ResourceField (not yet implemented)](../interfaces/ResourceField.md) * [CollectionField (not yet implemented)](../interfaces/CollectionField.md) * [LinksModeBelongsToField](../interfaces/LinksModeBelongsToField.md) * [LinksModeHasManyField](../interfaces/LinksModeHasManyField.md) (Type) PolarisModeFieldSchema --- --- url: /api/@warp-drive/core-types/schema/fields/type-aliases/ResourceSchema.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / ResourceSchema ```ts type ResourceSchema = | PolarisResourceSchema | LegacyResourceSchema; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1733 A type which represents a valid JSON schema definition for either a PolarisMode or a LegacyMode resource. Note, this is separate from the type returned by the SchemaService which provides fields as a Map instead of as an Array. --- --- url: /api/@warp-drive/core-types/spec/document.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / spec/document ## Interfaces * [CollectionResourceDataDocument](interfaces/CollectionResourceDataDocument.md) * [ResourceErrorDocument](interfaces/ResourceErrorDocument.md) * [ResourceMetaDocument](interfaces/ResourceMetaDocument.md) * [SingleResourceDataDocument](interfaces/SingleResourceDataDocument.md) ## Type Aliases * [ResourceDataDocument](type-aliases/ResourceDataDocument.md) * [ResourceDocument](type-aliases/ResourceDocument.md) --- --- url: /api/@warp-drive/core-types/schema/fields/type-aliases/Schema.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [schema/fields](../index.md) / Schema ```ts type Schema = | ResourceSchema | ObjectSchema; ``` Defined in: warp-drive-packages/core/declarations/types/schema/fields.d.ts:1783 --- --- url: >- /api/@warp-drive/core-types/spec/document/interfaces/CollectionResourceDataDocument.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/document](../index.md) / CollectionResourceDataDocument Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:16 ## Type Parameters ### T `T` = `StableExistingRecordIdentifier` ## Properties ### data ```ts data: T[]; ``` Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:20 *** ### included? ```ts optional included: T[]; ``` Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:21 *** ### lid? ```ts optional lid: string; ``` Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:17 *** ### links? ```ts optional links: | Links | PaginationLinks; ``` Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:18 *** ### meta? ```ts optional meta: ObjectValue; ``` Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:19 --- --- url: /api/@warp-drive/core-types/spec/document/interfaces/ResourceErrorDocument.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/document](../index.md) / ResourceErrorDocument Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:24 ## Properties ### errors ```ts errors: ApiError[]; ``` Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:28 *** ### lid? ```ts optional lid: string; ``` Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:25 *** ### links? ```ts optional links: | Links | PaginationLinks; ``` Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:26 *** ### meta? ```ts optional meta: ObjectValue; ``` Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:27 --- --- url: /api/@warp-drive/core-types/spec/document/interfaces/ResourceMetaDocument.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/document](../index.md) / ResourceMetaDocument Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:4 ## Properties ### lid? ```ts optional lid: string; ``` Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:5 *** ### links? ```ts optional links: | Links | PaginationLinks; ``` Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:7 *** ### meta ```ts meta: ObjectValue; ``` Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:6 --- --- url: >- /api/@warp-drive/core-types/spec/document/interfaces/SingleResourceDataDocument.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/document](../index.md) / SingleResourceDataDocument Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:9 ## Type Parameters ### T `T` = `StableExistingRecordIdentifier` ### R `R` = `StableExistingRecordIdentifier` ## Properties ### data ```ts data: null | T; ``` Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:13 *** ### included? ```ts optional included: R[]; ``` Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:14 *** ### lid? ```ts optional lid: string; ``` Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:10 *** ### links? ```ts optional links: | Links | PaginationLinks; ``` Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:11 *** ### meta? ```ts optional meta: ObjectValue; ``` Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:12 --- --- url: /api/@warp-drive/core-types/spec/document/type-aliases/ResourceDataDocument.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/document](../index.md) / ResourceDataDocument ```ts type ResourceDataDocument = | SingleResourceDataDocument | CollectionResourceDataDocument; ``` Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:23 ## Type Parameters ### T `T` = `StableExistingRecordIdentifier` --- --- url: /api/@warp-drive/core-types/spec/document/type-aliases/ResourceDocument.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/document](../index.md) / ResourceDocument ```ts type ResourceDocument = | ResourceMetaDocument | SingleResourceDataDocument | CollectionResourceDataDocument | ResourceErrorDocument; ``` Defined in: warp-drive-packages/core/declarations/types/spec/document.d.ts:30 ## Type Parameters ### T `T` = `StableExistingRecordIdentifier` --- --- url: /api/@warp-drive/core-types/spec/error.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / spec/error ## Interfaces * [ApiError](interfaces/ApiError.md) --- --- url: /api/@warp-drive/core-types/spec/error/interfaces/ApiError.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/error](../index.md) / ApiError Defined in: warp-drive-packages/core/declarations/types/spec/error.d.ts:2 ## Properties ### code? ```ts optional code: string; ``` Defined in: warp-drive-packages/core/declarations/types/spec/error.d.ts:11 *** ### detail? ```ts optional detail: string; ``` Defined in: warp-drive-packages/core/declarations/types/spec/error.d.ts:5 *** ### id? ```ts optional id: string; ``` Defined in: warp-drive-packages/core/declarations/types/spec/error.d.ts:3 *** ### links? ```ts optional links: object; ``` Defined in: warp-drive-packages/core/declarations/types/spec/error.d.ts:6 #### about? ```ts optional about: Link; ``` #### type? ```ts optional type: Link; ``` *** ### meta? ```ts optional meta: ObjectValue; ``` Defined in: warp-drive-packages/core/declarations/types/spec/error.d.ts:17 *** ### source? ```ts optional source: object; ``` Defined in: warp-drive-packages/core/declarations/types/spec/error.d.ts:12 #### header? ```ts optional header: string; ``` #### parameter? ```ts optional parameter: string; ``` #### pointer ```ts pointer: string; ``` *** ### status? ```ts optional status: string; ``` Defined in: warp-drive-packages/core/declarations/types/spec/error.d.ts:10 *** ### title? ```ts optional title: string; ``` Defined in: warp-drive-packages/core/declarations/types/spec/error.d.ts:4 --- --- url: /api/@warp-drive/core-types/spec/json-api-raw.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / spec/json-api-raw ## Interfaces * [CollectionResourceRelationship](interfaces/CollectionResourceRelationship.md) * [Links](interfaces/Links.md) * [PaginationLinks](interfaces/PaginationLinks.md) * [ResourceIdentifier](interfaces/ResourceIdentifier.md) * [SingleResourceRelationship](interfaces/SingleResourceRelationship.md) ## Type Aliases * [CollectionResourceDocument](type-aliases/CollectionResourceDocument.md) * [EmptyResourceDocument](type-aliases/EmptyResourceDocument.md) * [InnerRelationshipDocument](type-aliases/InnerRelationshipDocument.md) * [Link](type-aliases/Link.md) * [LinkObject](type-aliases/LinkObject.md) * [Meta](type-aliases/Meta.md) * [NewResourceObject](type-aliases/NewResourceObject.md) * [ResourceIdentifierObject](type-aliases/ResourceIdentifierObject.md) * [ResourceObject](type-aliases/ResourceObject.md) * [ResourceRelationshipsObject](type-aliases/ResourceRelationshipsObject.md) * [SingleResourceDocument](type-aliases/SingleResourceDocument.md) --- --- url: >- /api/@warp-drive/core-types/spec/json-api-raw/interfaces/CollectionResourceRelationship.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/json-api-raw](../index.md) / CollectionResourceRelationship Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:91 ## Type Parameters ### T `T` = `ExistingResourceIdentifierObject` | `NewResourceIdentifierObject` ## Properties ### data? ```ts optional data: T[]; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:92 *** ### links? ```ts optional links: PaginationLinks; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:94 *** ### meta? ```ts optional meta: ObjectValue; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:93 --- --- url: /api/@warp-drive/core-types/spec/json-api-raw/interfaces/Links.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/json-api-raw](../index.md) / Links Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:8 ## Extended by * [`PaginationLinks`](PaginationLinks.md) ## Properties ### related? ```ts optional related: null | Link; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:9 *** ### self? ```ts optional self: null | Link; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:10 --- --- url: /api/@warp-drive/core-types/spec/json-api-raw/interfaces/PaginationLinks.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/json-api-raw](../index.md) / PaginationLinks Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:12 ## Extends * [`Links`](Links.md) ## Properties ### first? ```ts optional first: null | Link; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:13 *** ### last? ```ts optional last: null | Link; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:14 *** ### next? ```ts optional next: null | Link; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:16 *** ### prev? ```ts optional prev: null | Link; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:15 *** ### related? ```ts optional related: null | Link; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:9 #### Inherited from [`Links`](Links.md).[`related`](Links.md#related) *** ### self? ```ts optional self: null | Link; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:10 #### Inherited from [`Links`](Links.md).[`self`](Links.md#self) --- --- url: /api/@warp-drive/core-types/spec/json-api-raw/interfaces/ResourceIdentifier.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/json-api-raw](../index.md) / ResourceIdentifier Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:82 ## Properties ### lid ```ts lid: string; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:83 --- --- url: >- /api/@warp-drive/core-types/spec/json-api-raw/interfaces/SingleResourceRelationship.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/json-api-raw](../index.md) / SingleResourceRelationship Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:86 ## Type Parameters ### T `T` = `ExistingResourceIdentifierObject` | `NewResourceIdentifierObject` ## Properties ### data? ```ts optional data: null | T; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:87 *** ### links? ```ts optional links: Links; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:89 *** ### meta? ```ts optional meta: ObjectValue; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:88 --- --- url: >- /api/@warp-drive/core-types/spec/json-api-raw/type-aliases/CollectionResourceDocument.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/json-api-raw](../index.md) / CollectionResourceDocument ```ts type CollectionResourceDocument = Document & object; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:129 ## Type declaration ### data ```ts data: ExistingResourceObject[]; ``` ## Type Parameters ### T `T` *extends* `string` = `string` --- --- url: >- /api/@warp-drive/core-types/spec/json-api-raw/type-aliases/EmptyResourceDocument.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/json-api-raw](../index.md) / EmptyResourceDocument ```ts type EmptyResourceDocument = Document & object; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:123 ## Type declaration ### data ```ts data: null; ``` --- --- url: >- /api/@warp-drive/core-types/spec/json-api-raw/type-aliases/InnerRelationshipDocument.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/json-api-raw](../index.md) / InnerRelationshipDocument ```ts type InnerRelationshipDocument = | SingleResourceRelationship | CollectionResourceRelationship; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:96 ## Type Parameters ### T `T` = `ExistingResourceIdentifierObject` | `NewResourceIdentifierObject` --- --- url: /api/@warp-drive/core-types/spec/json-api-raw/type-aliases/Link.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/json-api-raw](../index.md) / Link ```ts type Link = string | LinkObject; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:7 --- --- url: /api/@warp-drive/core-types/spec/json-api-raw/type-aliases/LinkObject.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/json-api-raw](../index.md) / LinkObject ```ts type LinkObject = object; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:3 ## Properties ### href ```ts href: string; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:4 *** ### meta? ```ts optional meta: Meta; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:5 --- --- url: /api/@warp-drive/core-types/spec/json-api-raw/type-aliases/Meta.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/json-api-raw](../index.md) / Meta ```ts type Meta = ObjectValue; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:2 --- --- url: >- /api/@warp-drive/core-types/spec/json-api-raw/type-aliases/ResourceIdentifierObject.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/json-api-raw](../index.md) / ResourceIdentifierObject ```ts type ResourceIdentifierObject = | ResourceIdentifier | ExistingResourceIdentifierObject | NewResourceIdentifierObject; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:85 ## Type Parameters ### T `T` *extends* `string` = `string` --- --- url: >- /api/@warp-drive/core-types/spec/json-api-raw/type-aliases/NewResourceObject.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/json-api-raw](../index.md) / NewResourceObject ```ts type NewResourceObject = NewResourceIdentifierObject & object; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:108 ## Type declaration ### attributes? ```ts optional attributes: ObjectValue; ``` ### links? ```ts optional links: Links; ``` ### meta? ```ts optional meta: Meta; ``` ### relationships? ```ts optional relationships: ResourceRelationshipsObject; ``` ## Type Parameters ### T `T` *extends* `string` = `string` --- --- url: /api/@warp-drive/core-types/spec/json-api-raw/type-aliases/ResourceObject.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/json-api-raw](../index.md) / ResourceObject ```ts type ResourceObject = | ExistingResourceObject | NewResourceObject; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:114 ## Type Parameters ### T `T` *extends* `string` = `string` --- --- url: >- /api/@warp-drive/core-types/spec/json-api-raw/type-aliases/ResourceRelationshipsObject.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/json-api-raw](../index.md) / ResourceRelationshipsObject ```ts type ResourceRelationshipsObject = Record>; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:97 ## Type Parameters ### T `T` = `ExistingResourceIdentifierObject` | `NewResourceIdentifierObject` --- --- url: >- /api/@warp-drive/core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md --- [Documentation](../../../../../index.md) / [@warp-drive/core-types](../../../index.md) / [spec/json-api-raw](../index.md) / SingleResourceDocument ```ts type SingleResourceDocument = Document & object; ``` Defined in: warp-drive-packages/core/declarations/types/spec/json-api-raw.d.ts:126 ## Type declaration ### data ```ts data: ExistingResourceObject; ``` ## Type Parameters ### T `T` *extends* `string` = `string` --- --- url: /api/@warp-drive/core-types/symbols.md --- [Documentation](../../../index.md) / [@warp-drive/core-types](../index.md) / symbols ## Variables * [RecordStore](variables/RecordStore.md) * [RequestSignature](variables/RequestSignature.md) * [ResourceType](variables/ResourceType.md) * [TransformName](variables/TransformName.md) * [Type](variables/Type.md) --- --- url: /api/@warp-drive/core-types/symbols/variables/RecordStore.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [symbols](../index.md) / RecordStore ```ts const RecordStore: "___(unique) Symbol(Store)"; ``` Defined in: warp-drive-packages/core/declarations/types/symbols.d.ts:1 --- --- url: /api/@warp-drive/core-types/symbols/variables/RequestSignature.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [symbols](../index.md) / RequestSignature ```ts const RequestSignature: "___(unique) Symbol(RequestSignature)"; ``` Defined in: warp-drive-packages/core/declarations/types/symbols.d.ts:78 Symbol for use by builders to indicate the return type generic to use for store.request() --- --- url: /api/@warp-drive/core-types/symbols/variables/ResourceType.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [symbols](../index.md) / ResourceType ```ts const ResourceType: "___(unique) Symbol($type)"; ``` Defined in: warp-drive-packages/core/declarations/types/symbols.d.ts:54 Symbol for the type of a resource. This is an optional feature that can be used by record implementations to provide a typescript hint for the type of the resource. When used, EmberData/WarpDrive APIs can take advantage of this to provide better type safety and intellisense. --- --- url: /api/@warp-drive/core-types/symbols/variables/TransformName.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [symbols](../index.md) / TransformName ```ts const TransformName: "___(unique) Symbol($type)"; ``` Defined in: warp-drive-packages/core/declarations/types/symbols.d.ts:71 Symbol for the name of a transform. This is an optional feature that can be used by transform implementations to provide a typescript hint for the name of the transform. If not used, `attr('name')` will allow any string name. `attr('name')` will always allow any string name. If used, `attr('name')` will enforce that the name is the same as the transform name. --- --- url: /api/@warp-drive/core-types/symbols/variables/Type.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [symbols](../index.md) / Type ```ts const Type: "___(unique) Symbol($type)"; ``` Defined in: warp-drive-packages/core/declarations/types/symbols.d.ts:40 Symbol for the name of a resource, transformation or derivation. ### With Resources This is an optional feature that can be used by record implementations to provide a typescript hint for the type of the resource. When used, EmberData/WarpDrive APIs can take advantage of this to provide better type safety and intellisense. ### With Derivations Required for derivations registered with `store.registerDerivation(derivation)`. ```ts function concat(record: object, options: ObjectValue | null, prop: string): string {} concat[Name] = 'concat'; ``` ### With Transforms Required for new-style transformations registered with `store.registerTransform(transform)`. For legacy transforms, if not used, `attr('name')` will allow any string name. `attr('name')` will always allow any string name. If used, `attr('name')` will enforce that the name is the same as the transform name. --- --- url: /api/@warp-drive/core-types/utils.md --- [Documentation](../../../index.md) / [@warp-drive/core-types](../index.md) / utils ## Type Aliases * [Mutable](type-aliases/Mutable.md) * [WithPartial](type-aliases/WithPartial.md) --- --- url: /api/@warp-drive/core-types/utils/type-aliases/Mutable.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [utils](../index.md) / Mutable ```ts type Mutable = { -readonly [P in keyof T]: T[P] }; ``` Defined in: warp-drive-packages/core/declarations/types/utils.d.ts:2 ## Type Parameters ### T `T` --- --- url: /api/@warp-drive/core-types/utils/type-aliases/WithPartial.md --- [Documentation](../../../../index.md) / [@warp-drive/core-types](../../index.md) / [utils](../index.md) / WithPartial ```ts type WithPartial = Omit & Partial>; ``` Defined in: warp-drive-packages/core/declarations/types/utils.d.ts:1 ## Type Parameters ### T `T` ### K `K` *extends* keyof `T` --- --- url: /api/@warp-drive/core/build-config/babel-macros/functions/macros.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/babel-macros](../index.md) / macros ```ts function macros(): BabelPlugin[]; ``` Defined in: warp-drive-packages/build-config/declarations/babel-macros.d.ts:12 ## Returns `BabelPlugin`\[] an array of Babel plugins that can be used for code-stripping based on the configuration supplied to `setConfig` and the current ENV. * deprecation constants imported from `@warp-drive/build-config/deprecations` * feature flags imported from `@warp-drive/build-config/canary-features` * debug logging constants imported from `@warp-drive/build-config/debugging` * environment constants imported from `@warp-drive/build-config/env` * expressionts imported from `@warp-drive/build-config/macros` --- --- url: /api/@warp-drive/core/build-config/babel-macros.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / build-config/babel-macros ## Functions * [macros](functions/macros.md) --- --- url: /api/@warp-drive/core/build-config/canary-features.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / build-config/canary-features ## Variables * [JSON\_API\_CACHE\_VALIDATION\_ERRORS](variables/JSON_API_CACHE_VALIDATION_ERRORS.md) --- --- url: >- /api/@warp-drive/core/build-config/canary-features/variables/JSON_API_CACHE_VALIDATION_ERRORS.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/canary-features](../index.md) / JSON\_API\_CACHE\_VALIDATION\_ERRORS ```ts const JSON_API_CACHE_VALIDATION_ERRORS: boolean | null; ``` Defined in: warp-drive-packages/build-config/declarations/canary-features.d.ts:159 This upcoming feature adds a validation step to payloads received by the JSONAPICache implementation. When a request completes and the result is given to the cache via `cache.put`, the cache will validate the payload against registered schemas as well as the JSON:API spec. ## Since 5.4 --- --- url: /api/@warp-drive/core/build-config/debugging.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / build-config/debugging ## Variables * [DEBUG\_RELATIONSHIP\_NOTIFICATIONS](variables/DEBUG_RELATIONSHIP_NOTIFICATIONS.md) * [LOG\_CACHE](variables/LOG_CACHE.md) * [LOG\_CACHE\_POLICY](variables/LOG_CACHE_POLICY.md) * [LOG\_GRAPH](variables/LOG_GRAPH.md) * [LOG\_IDENTIFIERS](variables/LOG_IDENTIFIERS.md) * [LOG\_INSTANCE\_CACHE](variables/LOG_INSTANCE_CACHE.md) * [LOG\_METRIC\_COUNTS](variables/LOG_METRIC_COUNTS.md) * [~~LOG\_MUTATIONS~~](variables/LOG_MUTATIONS.md) * [LOG\_NOTIFICATIONS](variables/LOG_NOTIFICATIONS.md) * [~~LOG\_OPERATIONS~~](variables/LOG_OPERATIONS.md) * [~~LOG\_PAYLOADS~~](variables/LOG_PAYLOADS.md) * [LOG\_REQUEST\_STATUS](variables/LOG_REQUEST_STATUS.md) * [LOG\_REQUESTS](variables/LOG_REQUESTS.md) --- --- url: >- /api/@warp-drive/core/build-config/debugging/variables/DEBUG_RELATIONSHIP_NOTIFICATIONS.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/debugging](../index.md) / DEBUG\_RELATIONSHIP\_NOTIFICATIONS ```ts const DEBUG_RELATIONSHIP_NOTIFICATIONS: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/debugging.d.ts:161 Helps when debugging causes of a change notification when processing an update to a hasMany relationship. --- --- url: /api/@warp-drive/core/build-config/debugging/variables/LOG_CACHE.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/debugging](../index.md) / LOG\_CACHE ```ts const LOG_CACHE: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/debugging.d.ts:68 log cache updates for both local and remote state. Note in some older versions this was called `LOG_PAYLOADS` and was one of three flags that controlled logging of cache updates. This is now the only flag. The others were `LOG_OPERATIONS` and `LOG_MUTATIONS`. ## Since 5.5 --- --- url: /api/@warp-drive/core/build-config/debugging/variables/LOG_GRAPH.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/debugging](../index.md) / LOG\_GRAPH ```ts const LOG_GRAPH: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/debugging.d.ts:140 log updates received by the graph (relationship pointer storage) --- --- url: /api/@warp-drive/core/build-config/debugging/variables/LOG_CACHE_POLICY.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/debugging](../index.md) / LOG\_CACHE\_POLICY ```ts const LOG_CACHE_POLICY: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/debugging.d.ts:107 Log decisions made by the Basic CachePolicy --- --- url: /api/@warp-drive/core/build-config/debugging/variables/LOG_IDENTIFIERS.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/debugging](../index.md) / LOG\_IDENTIFIERS ```ts const LOG_IDENTIFIERS: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/debugging.d.ts:134 log peek, generation and updates to Record Identifiers. --- --- url: /api/@warp-drive/core/build-config/debugging/variables/LOG_INSTANCE_CACHE.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/debugging](../index.md) / LOG\_INSTANCE\_CACHE ```ts const LOG_INSTANCE_CACHE: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/debugging.d.ts:147 log creation/removal of RecordData and Record instances. --- --- url: /api/@warp-drive/core/build-config/debugging/variables/LOG_METRIC_COUNTS.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/debugging](../index.md) / LOG\_METRIC\_COUNTS ```ts const LOG_METRIC_COUNTS: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/debugging.d.ts:154 Log key count metrics, useful for performance debugging. --- --- url: /api/@warp-drive/core/build-config/debugging/variables/LOG_MUTATIONS.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/debugging](../index.md) / LOG\_MUTATIONS ```ts const LOG_MUTATIONS: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/debugging.d.ts:101 This flag no longer has any effect. Use [LOG\_CACHE](LOG_CACHE.md) instead. ## Deprecated removed in version 5.5 --- --- url: /api/@warp-drive/core/build-config/debugging/variables/LOG_NOTIFICATIONS.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/debugging](../index.md) / LOG\_NOTIFICATIONS ```ts const LOG_NOTIFICATIONS: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/debugging.d.ts:113 log notifications received by the NotificationManager --- --- url: /api/@warp-drive/core/build-config/debugging/variables/LOG_OPERATIONS.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/debugging](../index.md) / LOG\_OPERATIONS ```ts const LOG_OPERATIONS: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/debugging.d.ts:90 This flag no longer has any effect. Use [LOG\_CACHE](LOG_CACHE.md) instead. ## Deprecated removed in version 5.5 --- --- url: /api/@warp-drive/core/build-config/debugging/variables/LOG_PAYLOADS.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/debugging](../index.md) / LOG\_PAYLOADS ```ts const LOG_PAYLOADS: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/debugging.d.ts:79 This flag no longer has any effect. Use [LOG\_CACHE](LOG_CACHE.md) instead. ## Deprecated removed in version 5.5 --- --- url: /api/@warp-drive/core/build-config/debugging/variables/LOG_REQUEST_STATUS.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/debugging](../index.md) / LOG\_REQUEST\_STATUS ```ts const LOG_REQUEST_STATUS: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/debugging.d.ts:126 log updates to requests the store has issued to the network (adapter) to fulfill. --- --- url: /api/@warp-drive/core/build-config/deprecations.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / build-config/deprecations ## Variables * [DEPRECATE\_COMPUTED\_CHAINS](variables/DEPRECATE_COMPUTED_CHAINS.md) * [DEPRECATE\_EMBER\_INFLECTOR](variables/DEPRECATE_EMBER_INFLECTOR.md) * [DEPRECATE\_LEGACY\_IMPORTS](variables/DEPRECATE_LEGACY_IMPORTS.md) * [DEPRECATE\_MANY\_ARRAY\_DUPLICATES](variables/DEPRECATE_MANY_ARRAY_DUPLICATES.md) * [DEPRECATE\_NON\_STRICT\_ID](variables/DEPRECATE_NON_STRICT_ID.md) * [DEPRECATE\_NON\_STRICT\_TYPES](variables/DEPRECATE_NON_STRICT_TYPES.md) * [DEPRECATE\_NON\_UNIQUE\_PAYLOADS](variables/DEPRECATE_NON_UNIQUE_PAYLOADS.md) * [DEPRECATE\_RELATIONSHIP\_REMOTE\_UPDATE\_CLEARING\_LOCAL\_STATE](variables/DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE.md) * [DEPRECATE\_STORE\_EXTENDS\_EMBER\_OBJECT](variables/DEPRECATE_STORE_EXTENDS_EMBER_OBJECT.md) * [DEPRECATE\_TRACKING\_PACKAGE](variables/DEPRECATE_TRACKING_PACKAGE.md) * [DISABLE\_7X\_DEPRECATIONS](variables/DISABLE_7X_DEPRECATIONS.md) * [ENABLE\_LEGACY\_SCHEMA\_SERVICE](variables/ENABLE_LEGACY_SCHEMA_SERVICE.md) --- --- url: /api/@warp-drive/core/build-config/debugging/variables/LOG_REQUESTS.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/debugging](../index.md) / LOG\_REQUESTS ```ts const LOG_REQUESTS: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/debugging.d.ts:119 log requests issued by the RequestManager --- --- url: >- /api/@warp-drive/core/build-config/deprecations/variables/DEPRECATE_COMPUTED_CHAINS.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/deprecations](../index.md) / DEPRECATE\_COMPUTED\_CHAINS ```ts const DEPRECATE_COMPUTED_CHAINS: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/deprecations.d.ts:127 This is a planned deprecation which will trigger when observer or computed chains are used to watch for changes on any WarpDrive LiveArray, CollectionRecordArray, ManyArray or PromiseManyArray. Support for these chains is currently guarded by the deprecation flag listed here, enabling removal of the behavior if desired. The instrumentation was added in 5.0 but the version number is set to 7.0 as we do not want to strip support without adding a deprecation message. Once we've added the deprecation message, we will update this version number to the proper version. ## Since 5.0 ## Until 8.0 --- --- url: >- /api/@warp-drive/core/build-config/deprecations/variables/DEPRECATE_EMBER_INFLECTOR.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/deprecations](../index.md) / DEPRECATE\_EMBER\_INFLECTOR ```ts const DEPRECATE_EMBER_INFLECTOR: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/deprecations.d.ts:464 Deprecates the use of ember-inflector for pluralization and singularization in favor of the `@ember-data/request-utils` package. Rule configuration methods (singular, plural, uncountable, irregular) and usage methods (singularize, pluralize) are are available as imports from `@ember-data/request-utils/string` Notable differences with ember-inflector: * there cannot be multiple inflector instances with separate rules * pluralization does not support a count argument * string caches now default to 10k entries instead of 1k, and this size is now configurable. Additionally, the cache is now a LRU cache instead of a first-N cache. This deprecation can be resolved by removing usage of ember-inflector or by using both ember-inflector and @ember-data/request-utils in parallel and updating your EmberData/WarpDrive build config to mark the deprecation as resolved in ember-cli-build ```js setConfig(app, __dirname, { deprecations: { DEPRECATE_EMBER_INFLECTOR: false }}); ``` ## Since 5.3 ## Until 6.0 --- --- url: >- /api/@warp-drive/core/build-config/deprecations/variables/DEPRECATE_LEGACY_IMPORTS.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/deprecations](../index.md) / DEPRECATE\_LEGACY\_IMPORTS ```ts const DEPRECATE_LEGACY_IMPORTS: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/deprecations.d.ts:198 Deprecates when importing from `ember-data/*` instead of `@ember-data/*` in order to prepare for the eventual removal of the legacy `ember-data/*` All imports from `ember-data/*` should be updated to `@ember-data/*` except for `ember-data/store`. When you are using `ember-data` (as opposed to installing the indivudal packages) you should import from `ember-data/store` instead of `@ember-data/store` in order to receive the appropriate configuration of defaults. ## Since 5.3 ## Until 6.0 --- --- url: >- /api/@warp-drive/core/build-config/deprecations/variables/DEPRECATE_NON_STRICT_ID.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/deprecations](../index.md) / DEPRECATE\_NON\_STRICT\_ID ```ts const DEPRECATE_NON_STRICT_ID: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/deprecations.d.ts:181 Currently, WarpDrive expects that the `id` property associated with a resource is a string. However, for legacy support in many locations we would accept a number which would then immediately be coerced into a string. We are deprecating this legacy support for numeric IDs. The goal is that in the future, you will be able to use any ID format so long as everywhere you refer to the ID you use the same format. However, for identifiers we will always use string IDs and so any custom identifier configuration should provide a string ID. ## Since 5.3 ## Until 6.0 --- --- url: >- /api/@warp-drive/core/build-config/deprecations/variables/DEPRECATE_MANY_ARRAY_DUPLICATES.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/deprecations](../index.md) / DEPRECATE\_MANY\_ARRAY\_DUPLICATES ```ts const DEPRECATE_MANY_ARRAY_DUPLICATES: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/deprecations.d.ts:399 When the flag is `true` (default), adding duplicate records to a `ManyArray` is deprecated in non-production environments. In production environments, duplicate records added to a `ManyArray` will be deduped and no error will be thrown. When the flag is `false`, an error will be thrown when duplicates are added. ## Since 5.3 ## Until 6.0 --- --- url: >- /api/@warp-drive/core/build-config/deprecations/variables/DEPRECATE_NON_STRICT_TYPES.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/deprecations](../index.md) / DEPRECATE\_NON\_STRICT\_TYPES ```ts const DEPRECATE_NON_STRICT_TYPES: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/deprecations.d.ts:159 Currently, ***Warp*Drive** expects that the `type` property associated with a resource follows several conventions. * The `type` property must be a non-empty string * The `type` property must be singular * The `type` property must be dasherized We are deprecating support for types that do not match this pattern in order to unlock future improvements in which we can support `type` being any string of your choosing. The goal is that in the future, you will be able to use any string so long as it matches what your configured cache, identifier generation, and schemas expect. E.G. It will matter not that your string is in a specific format like singular, dasherized, etc. so long as everywhere you refer to the type you use the same string. If using @ember-data/model, there will always be a restriction that the `type` must match the path on disk where the model is defined. e.g. `app/models/foo/bar-bem.js` must have a type of `foo/bar-bem` ## Since 5.3 ## Until 6.0 --- --- url: >- /api/@warp-drive/core/build-config/deprecations/variables/DEPRECATE_NON_UNIQUE_PAYLOADS.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/deprecations](../index.md) / DEPRECATE\_NON\_UNIQUE\_PAYLOADS ```ts const DEPRECATE_NON_UNIQUE_PAYLOADS: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/deprecations.d.ts:239 Deprecates when the data for a hasMany relationship contains duplicate identifiers. Previously, relationships would silently de-dupe the data when received, but this behavior is being removed in favor of erroring if the same related record is included multiple times. For instance, in JSON:API the below relationship data would be considered invalid: ```json { "data": { "type": "article", "id": "1", "relationships": { "comments": { "data": [ { "type": "comment", "id": "1" }, { "type": "comment", "id": "2" }, { "type": "comment", "id": "1" } // duplicate ] } } } ``` To resolve this deprecation, either update your server to not include duplicate data, or implement normalization logic in either a request handler or serializer which removes duplicate data from relationship payloads. ## Since 5.3 ## Until 6.0 --- --- url: >- /api/@warp-drive/core/build-config/deprecations/variables/DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/deprecations](../index.md) / DEPRECATE\_RELATIONSHIP\_REMOTE\_UPDATE\_CLEARING\_LOCAL\_STATE ```ts const DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/deprecations.d.ts:384 Deprecates when a relationship is updated remotely and the local state is cleared of all changes except for "new" records. Instead, any records not present in the new payload will be considered "removed" while any records present in the new payload will be considered "added". This allows us to "commit" local additions and removals, preserving any additions or removals that are not yet reflected in the remote state. For instance, given the following initial state: remote: A, B, C local: add D, E remove B, C \=> A, D, E If after an update, the remote state is now A, B, D, F then the new state will be remote: A, B, D, F local: add E remove B \=> A, D, E, F Under the old behavior the updated local state would instead have been \=> A, B, D, F Similarly, if a belongsTo remote State was A while its local state was B, then under the old behavior if the remote state changed to C, the local state would be updated to C. Under the new behavior, the local state would remain B. If the remote state was A while its local state was `null`, then under the old behavior if the remote state changed to C, the local state would be updated to C. Under the new behavior, the local state would remain `null`. Thus the new correct mental model is that the state of the relationship at any point in time is whatever the most recent remote state is, plus any local additions or removals you have made that have not yet been reflected by the remote state. > Note: The old behavior extended to modifying the inverse of a relationship. So if > you had local state not reflected in the new remote state, inverses would be notified > and their state reverted as well when "resetting" the relationship. > Under the new behavior, since the local state is preserved the inverses will also > not be reverted. ### Resolving this deprecation Resolving this deprecation can be done individually for each relationship or globally for all relationships. To resolve it globally, set the `DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE` to `false` in ember-cli-build.js ```js const { setConfig } = await import('@warp-drive/build-config'); let app = new EmberApp(defaults, {}); setConfig(app, __dirname, { deprecations: { // set to false to strip the deprecated code (thereby opting into the new behavior) DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE: false } }); ``` To resolve this deprecation on an individual relationship, adjust the `options` passed to the relationship. For relationships with inverses, both sides MUST be migrated to the new behavior at the same time. ```js class Person extends Model { @hasMany('person', { async: false, inverse: null, resetOnRemoteUpdate: false }) children; @belongsTo('person', { async: false, inverse: null, resetOnRemoteUpdate: false }) parent; } ``` > Note: false is the only valid value here, all other values (including missing) > will be treated as true, where `true` is the legacy behavior that is now deprecated. Once you have migrated all relationships, you can remove the the resetOnRemoteUpdate option and set the deprecation flag to false in ember-cli-build. ### What if I don't want the new behavior? WarpDrive's philosophy is to not make assumptions about your application. Where possible we seek out "100%" solutions – solutions that work for all use cases - and where that is not possible we default to "90%" solutions – solutions that work for the vast majority of use cases. In the case of "90%" solutions we look for primitives that allow you to resolve the 10% case in your application. If no such primitives exist, we provide an escape hatch that ensures you can build the behavior you need without adopting the cost of the default solution. In this case, the old behavior was a "40%" solution. The inability for an application developer to determine what changes were made locally, and thus what changes should be preserved, made it impossible to build certain features easily, or in some cases at all. The proliferation of feature requests, bug reports (from folks surprised by the prior behavior) and addon attempts in this space are all evidence of this. We believe the new behavior is a "90%" solution. It works for the vast majority of use cases, often without noticeable changes to existing application behavior, and provides primitives that allow you to build the behavior you need for the remaining 10%. The great news is that this behavior defaults to trusting your API similar to the old behavior. If your API is correct, you will not need to make any changes to your application to adopt the new behavior. This means the 10% cases are those where you can't trust your API to provide the correct information. In these cases, because you now have cheap access to a diff of the relationship state, there are a few options that weren't available before: * you can adjust returned API payloads to contain the expected changes that it doesn't include * you can modify local state by adding or removing records on the HasMany record array to remove any local changes that were not returned by the API. * you can use `.mutate(mutation)` to directly modify the local cache state of the relationship to match the expected state. What this version (5.3) does not yet provide is a way to directly modify the cache's remote state for the relationship via public APIs other than via the broader action of upserting a response via `.put(document)`. However, such an API was sketched in the Cache 2.1 RFC `.patch(operation)` and is likely to be added in a future 5.x release of WarpDrive. This version (5.3) also does not yet provide a way to directly modify the graph (a general purpose subset of cache behaviors specific to relationships) via public APIs. However, during the 5.x release series we will be working on finalizing the Graph API and making it public. If none of these options work for you, you can always opt-out more broadly by implementing a custom Cache with the relationship behaviors you need. ## Since 5.3 ## Until 6.0 --- --- url: >- /api/@warp-drive/core/build-config/deprecations/variables/DEPRECATE_STORE_EXTENDS_EMBER_OBJECT.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/deprecations](../index.md) / DEPRECATE\_STORE\_EXTENDS\_EMBER\_OBJECT ```ts const DEPRECATE_STORE_EXTENDS_EMBER_OBJECT: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/deprecations.d.ts:411 When the flag is `true` (default), the Store class will extend from `@ember/object`. When the flag is `false` or `ember-source` is not present, the Store will not extend from EmberObject. ## Since 5.4 ## Until 6.0 --- --- url: >- /api/@warp-drive/core/build-config/deprecations/variables/DEPRECATE_TRACKING_PACKAGE.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/deprecations](../index.md) / DEPRECATE\_TRACKING\_PACKAGE ```ts const DEPRECATE_TRACKING_PACKAGE: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/deprecations.d.ts:501 Deprecates the use of the @ember-data/tracking package which historically provided bindings into Ember's reactivity system. This package is no longer needed as the configuration is now provided by the @warp-drive/ember package. This deprecation can be resolved by removing the @ember-data/tracking package from your project and ensuring that your app.js file has the following import: ```js import '@warp-drive/ember/install'; ``` Once this import is present, you can remove the deprecation by setting the deprecation to `false` in your build config: ```js // inside of ember-cli-build.js const { setConfig } = await import('@warp-drive/build-config'); setConfig(app, __dirname, { deprecations: { DEPRECATE_TRACKING_PACKAGE: false } }); ``` ## Since 5.5 ## Until 6.0 --- --- url: >- /api/@warp-drive/core/build-config/deprecations/variables/DISABLE_7X_DEPRECATIONS.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/deprecations](../index.md) / DISABLE\_7X\_DEPRECATIONS ```ts const DISABLE_7X_DEPRECATIONS: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/deprecations.d.ts:516 This is a special flag that can be used to opt-in early to receiving deprecations introduced in 6.x which have had their infra backported to 5.x versions of ***Warp*Drive**. When this flag is not present or set to `true`, the deprecations from the 6.x branch will not print their messages and the deprecation cannot be resolved. When this flag is present and set to `false`, the deprecations from the 6.x branch will print and can be resolved. ## Since 5.3 ## Until 7.0 --- --- url: >- /api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_SCHEMA_SERVICE.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [build-config/deprecations](../index.md) / ENABLE\_LEGACY\_SCHEMA\_SERVICE ```ts const ENABLE_LEGACY_SCHEMA_SERVICE: boolean; ``` Defined in: warp-drive-packages/build-config/declarations/deprecations.d.ts:433 When the flag is `true` (default), the legacy schema service features will be enabled on the store and the service, and deprecations will be thrown when they are used. Deprecated features include: * `Store.registerSchema` method is deprecated in favor of the `Store.createSchemaService` hook * `Store.registerSchemaDefinitionService` method is deprecated in favor of the `Store.createSchemaService` hook * `Store.getSchemaDefinitionService` method is deprecated in favor of `Store.schema` property * `SchemaService.doesTypeExist` method is deprecated in favor of the `SchemaService.hasResource` method * `SchemaService.attributesDefinitionFor` method is deprecated in favor of the `SchemaService.fields` method * `SchemaService.relationshipsDefinitionFor` method is deprecated in favor of the `SchemaService.fields` method ## Since 5.4 ## Until 6.0 --- --- url: /api/@warp-drive/core/build-config/env.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / build-config/env --- --- url: /api/@warp-drive/core/build-config/functions/setConfig.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [build-config](../index.md) / setConfig ## Call Signature ```ts function setConfig(macros, config): void; ``` Defined in: warp-drive-packages/build-config/declarations/index.d.ts:95 ### Parameters #### macros `object` #### config [`WarpDriveConfig`](../../../build-config/index/type-aliases/WarpDriveConfig.md) ### Returns `void` ## Call Signature ```ts function setConfig( context, appRoot, config): void; ``` Defined in: warp-drive-packages/build-config/declarations/index.d.ts:96 ### Parameters #### context `object` #### appRoot `string` #### config [`WarpDriveConfig`](../../../build-config/index/type-aliases/WarpDriveConfig.md) ### Returns `void` --- --- url: /api/@warp-drive/core/build-config.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / build-config ## Functions * [setConfig](functions/setConfig.md) --- --- url: /api/@warp-drive/core/build-config/macros.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / build-config/macros --- --- url: /api/@warp-drive/core/classes/Document.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / Document Defined in: [warp-drive-packages/core/src/store/-private/document.ts:32](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/document.ts#L32) A Document is a class that wraps the response content from a request to the API returned by `Cache.put` or `Cache.peek`, converting resource-identifiers into record instances. It is not directly instantiated by the user, and its properties should not be directly modified. Whether individual properties are mutable or not is determined by the record instance itself. ReactiveDocument ## Type Parameters ### T `T` ## Constructors ### Constructor ```ts new Document( store, identifier, localCache): ReactiveDocument; ``` Defined in: [warp-drive-packages/core/src/store/-private/document.ts:94](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/document.ts#L94) #### Parameters ##### store [`Store`](Store.md) ##### identifier `null` | [`StableDocumentIdentifier`](../types/identifier/type-aliases/StableDocumentIdentifier.md) ##### localCache `null` | { `document`: [`ResourceDocument`](../types/spec/document/type-aliases/ResourceDocument.md); `request`: [`ImmutableRequestInfo`](../types/request/type-aliases/ImmutableRequestInfo.md); } #### Returns `ReactiveDocument`<`T`> ## Properties ### \_localCache ```ts protected readonly _localCache: | null | { document: ResourceDocument; request: ImmutableRequestInfo; }; ``` Defined in: [warp-drive-packages/core/src/store/-private/document.ts:92](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/document.ts#L92) *** ### \_store ```ts protected readonly _store: Store; ``` Defined in: [warp-drive-packages/core/src/store/-private/document.ts:91](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/document.ts#L91) *** ### data? ```ts readonly optional data: T; ``` Defined in: [warp-drive-packages/core/src/store/-private/document.ts:62](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/document.ts#L62) The primary data for this document, if any. If this document has no primary data (e.g. because it is an error document) this property will be `undefined`. For collections this will be an array of record instances, for single resource requests it will be a single record instance or null. *** ### errors? ```ts readonly optional errors: object[]; ``` Defined in: [warp-drive-packages/core/src/store/-private/document.ts:71](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/document.ts#L71) The errors returned by the API for this request, if any *** ### identifier ```ts readonly identifier: | null | StableDocumentIdentifier; ``` Defined in: [warp-drive-packages/core/src/store/-private/document.ts:89](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/document.ts#L89) The identifier associated with this document, if any *** ### links? ```ts readonly optional links: PaginationLinks; ``` Defined in: [warp-drive-packages/core/src/store/-private/document.ts:48](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/document.ts#L48) The links object for this document, if any e.g. ``` { self: '/articles?page[number]=3', } ``` *** ### meta? ```ts readonly optional meta: ObjectValue; ``` Defined in: [warp-drive-packages/core/src/store/-private/document.ts:80](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/document.ts#L80) The meta object for this document, if any ## Methods ### fetch() ```ts fetch(options): Promise>; ``` Defined in: [warp-drive-packages/core/src/store/-private/document.ts:155](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/document.ts#L155) Fetches the related link for this document, returning a promise that resolves with the document when the request completes. If no related link is present, will fallback to the self link if present #### Parameters ##### options [`RequestInfo`](../types/request/interfaces/RequestInfo.md)<`ReactiveDocument`<`T`>, `T`> = `...` #### Returns `Promise`<`ReactiveDocument`<`T`>> *** ### first() ```ts first(options): Promise>; ``` Defined in: [warp-drive-packages/core/src/store/-private/document.ts:199](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/document.ts#L199) Fetches the first link for this document, returning a promise that resolves with the new document when the request completes, or null if there is no first link. #### Parameters ##### options [`RequestInfo`](../types/request/interfaces/RequestInfo.md)<`ReactiveDocument`<`T`>, `T`> #### Returns `Promise`<`null` | `ReactiveDocument`<`T`>> *** ### last() ```ts last(options): Promise>; ``` Defined in: [warp-drive-packages/core/src/store/-private/document.ts:212](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/document.ts#L212) Fetches the last link for this document, returning a promise that resolves with the new document when the request completes, or null if there is no last link. #### Parameters ##### options [`RequestInfo`](../types/request/interfaces/RequestInfo.md)<`ReactiveDocument`<`T`>, `T`> #### Returns `Promise`<`null` | `ReactiveDocument`<`T`>> *** ### next() ```ts next(options?): Promise>; ``` Defined in: [warp-drive-packages/core/src/store/-private/document.ts:173](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/document.ts#L173) Fetches the next link for this document, returning a promise that resolves with the new document when the request completes, or null if there is no next link. #### Parameters ##### options? [`RequestInfo`](../types/request/interfaces/RequestInfo.md)<`ReactiveDocument`<`T`>, `T`> #### Returns `Promise`<`null` | `ReactiveDocument`<`T`>> *** ### prev() ```ts prev(options): Promise>; ``` Defined in: [warp-drive-packages/core/src/store/-private/document.ts:186](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/document.ts#L186) Fetches the prev link for this document, returning a promise that resolves with the new document when the request completes, or null if there is no prev link. #### Parameters ##### options [`RequestInfo`](../types/request/interfaces/RequestInfo.md)<`ReactiveDocument`<`T`>, `T`> #### Returns `Promise`<`null` | `ReactiveDocument`<`T`>> *** ### toJSON() ```ts toJSON(): object; ``` Defined in: [warp-drive-packages/core/src/store/-private/document.ts:228](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/document.ts#L228) Implemented for `JSON.stringify` support. Returns the JSON representation of the document wrapper. This is a shallow serialization, it does not deeply serialize the document's contents, leaving that to the individual record instances to determine how to do, if at all. #### Returns `object` --- --- url: /api/@warp-drive/core/classes/Fetch.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / Fetch Defined in: [warp-drive-packages/core/src/request/-private/fetch.ts:118](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/fetch.ts#L118) A basic handler which converts a request into a `fetch` call presuming the response to be `json`. ```ts import Fetch from '@ember-data/request/fetch'; manager.use([Fetch]); ``` Fetch ## Methods ### request() ```ts static request(context): Promise; ``` Defined in: [warp-drive-packages/core/src/request/-private/fetch.ts:119](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/fetch.ts#L119) #### Type Parameters ##### T `T` #### Parameters ##### context [`Context`](../request/classes/Context.md) #### Returns `Promise`<`T`> --- --- url: /api/@warp-drive/core/classes/RequestManager.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / RequestManager Defined in: [warp-drive-packages/core/src/request/-private/manager.ts:88](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/manager.ts#L88) ```js import RequestManager from '@ember-data/request'; ``` A RequestManager provides a request/response flow in which configured handlers are successively given the opportunity to handle, modify, or pass-along a request. ```ts interface RequestManager { request(req: RequestInfo): Future; } ``` For example: ```ts import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; import Auth from 'ember-simple-auth/ember-data-handler'; import Config from './config'; const { apiUrl } = Config; // ... create manager const manager = new RequestManager().use([Auth, Fetch]); // ... execute a request const response = await manager.request({ url: `${apiUrl}/users` }); ``` ### Futures The return value of `manager.request` is a `Future`, which allows access to limited information about the request while it is still pending and fulfills with the final state when the request completes. A `Future` is cancellable via `abort`. Handlers may optionally expose a `ReadableStream` to the `Future` for streaming data; however, when doing so the future should not resolve until the response stream is fully read. ```ts interface Future extends Promise> { abort(): void; async getStream(): ReadableStream | null; } ``` ### StructuredDocuments A Future resolves with a `StructuredDataDocument` or rejects with a `StructuredErrorDocument`. ```ts interface StructuredDataDocument { request: ImmutableRequestInfo; response: ImmutableResponseInfo; content: T; } interface StructuredErrorDocument extends Error { request: ImmutableRequestInfo; response: ImmutableResponseInfo; error: string | object; } type StructuredDocument = StructuredDataDocument | StructuredErrorDocument; ``` RequestManager ## Constructors ### Constructor ```ts new RequestManager(options?): RequestManager; ``` Defined in: [warp-drive-packages/core/src/request/-private/manager.ts:102](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/manager.ts#L102) #### Parameters ##### options? `GenericCreateArgs` #### Returns `RequestManager` ## Properties ### \_deduped ```ts _deduped: Map; }>; ``` Defined in: [warp-drive-packages/core/src/request/-private/manager.ts:100](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/manager.ts#L100) *** ### \_hasCacheHandler ```ts _hasCacheHandler: boolean; ``` Defined in: [warp-drive-packages/core/src/request/-private/manager.ts:90](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/manager.ts#L90) ## Methods ### request() ```ts request(request): Future; ``` Defined in: [warp-drive-packages/core/src/request/-private/manager.ts:183](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/manager.ts#L183) Issue a Request. Returns a Future that fulfills with a StructuredDocument #### Type Parameters ##### RT `RT` ##### T `T` = `unknown` #### Parameters ##### request [`RequestInfo`](../types/request/interfaces/RequestInfo.md)<`RT`, `T`> #### Returns [`Future`](../request/interfaces/Future.md)<`RT`> *** ### use() ```ts use(newHandlers): this; ``` Defined in: [warp-drive-packages/core/src/request/-private/manager.ts:147](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/manager.ts#L147) Register handler(s) to use when a request is issued. Handlers will be invoked in the order they are registered. Each Handler is given the opportunity to handle the request, curry the request, or pass along a modified request. #### Parameters ##### newHandlers [`Handler`](../request/interfaces/Handler.md)\[] #### Returns `this` *** ### useCache() ```ts useCache(cacheHandler): this; ``` Defined in: [warp-drive-packages/core/src/request/-private/manager.ts:119](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/manager.ts#L119) Register a handler to use for primary cache intercept. Only one such handler may exist. If using the same RequestManager as the Store instance the Store registers itself as a Cache handler. #### Parameters ##### cacheHandler [`CacheHandler`](../request/interfaces/CacheHandler.md) & `object` #### Returns `this` *** ### create() ```ts static create(options?): RequestManager; ``` Defined in: [warp-drive-packages/core/src/request/-private/manager.ts:270](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/manager.ts#L270) #### Parameters ##### options? `GenericCreateArgs` #### Returns `RequestManager` --- --- url: /api/@warp-drive/core/configure.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / configure Provides a configuration API for the reactivity system that WarpDrive should use. --- --- url: /api/@warp-drive/core/classes/Store.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / Store Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:345](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L345) ## Extends * `BaseClass` ## Properties ### identifierCache ```ts identifierCache: IdentifierCache; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:596](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L596) Provides access to the IdentifierCache instance for this store. The IdentifierCache can be used to generate or retrieve a stable unique identifier for any resource. *** ### lifetimes? ```ts optional lifetimes: CachePolicy; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:654](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L654) A Property which an App may set to provide a CachePolicy to control when a cached request becomes stale. Note, when defined, these methods will only be invoked if a cache key exists for the request, either because the request contains `cacheOptions.key` or because the [IdentifierCache](/ember-data/release/classes/IdentifierCache) was able to generate a key for the request using the configured [generation method](/ember-data/release/functions/@ember-data%2Fstore/setIdentifierGenerationMethod). `isSoftExpired` will only be invoked if `isHardExpired` returns `false`. ```ts store.lifetimes = { // make the request and ignore the current cache state isHardExpired(identifier: StableDocumentIdentifier): boolean { return false; } // make the request in the background if true, return cache state isSoftExpired(identifier: StableDocumentIdentifier): boolean { return false; } } ``` *** ### notifications ```ts notifications: NotificationManager; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:563](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L563) Provides access to the NotificationManager associated with this Store instance. The NotificationManager can be used to subscribe to changes to the cache. *** ### requestManager ```ts requestManager: RequestManager; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:622](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L622) Provides access to the requestManager instance associated with this Store instance. When using `ember-data` this property is automatically set to an instance of `RequestManager`. When not using `ember-data` you must configure this property yourself, either by declaring it as a service or by initializing it. ```ts import Store, { CacheHandler } from '@ember-data/store'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; class extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); } ``` ## Accessors ### cache #### Get Signature ```ts get cache(): ReturnType; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:2454](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L2454) Returns the cache instance associated to this Store, instantiates the Cache if necessary via `Store.createCache` ##### Returns `ReturnType`<`this`\[`"createCache"`]> *** ### isDestroyed #### Set Signature ```ts set isDestroyed(value): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:698](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L698) ##### Parameters ###### value `boolean` ##### Returns `void` *** ### isDestroying #### Set Signature ```ts set isDestroying(value): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:691](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L691) ##### Parameters ###### value `boolean` ##### Returns `void` *** ### schema #### Get Signature ```ts get schema(): ReturnType; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:576](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L576) Provides access to the SchemaService instance for this Store instance. The SchemaService can be used to query for information about the schema of a resource. ##### Returns `ReturnType`<`this`\[`"createSchemaService"`]> ## Methods ### createCache() ```ts createCache(capabilities): Cache; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:346](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L346) #### Parameters ##### capabilities [`CacheCapabilitiesManager`](../types/type-aliases/CacheCapabilitiesManager.md) #### Returns [`Cache`](../types/cache/interfaces/Cache.md) *** ### createRecord() #### Call Signature ```ts createRecord(type, inputProperties): T; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:1022](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L1022) Create a new record in the current store. The properties passed to this method are set on the newly created record. To create a new instance of a `Post`: ```js store.createRecord('post', { title: 'Ember is awesome!' }); ``` To create a new instance of a `Post` that has a relationship with a `User` record: ```js let user = this.store.peekRecord('user', '1'); store.createRecord('post', { title: 'Ember is awesome!', user: user }); ``` ##### Type Parameters ###### T `T` ##### Parameters ###### type [`TypeFromInstance`](../types/record/type-aliases/TypeFromInstance.md)<`T`> the name of the resource ###### inputProperties `CreateRecordProperties`<`T`> a hash of properties to set on the newly created record. ##### Returns `T` record #### Call Signature ```ts createRecord(type, inputProperties): unknown; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:1023](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L1023) Create a new record in the current store. The properties passed to this method are set on the newly created record. To create a new instance of a `Post`: ```js store.createRecord('post', { title: 'Ember is awesome!' }); ``` To create a new instance of a `Post` that has a relationship with a `User` record: ```js let user = this.store.peekRecord('user', '1'); store.createRecord('post', { title: 'Ember is awesome!', user: user }); ``` ##### Parameters ###### type `string` the name of the resource ###### inputProperties `MaybeHasId` & `Partial`<`FilteredKeys`<`MaybeHasId` & `Record`<`string`, `unknown`>>> a hash of properties to set on the newly created record. ##### Returns `unknown` record *** ### createSchemaService() ```ts createSchemaService(): SchemaService; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:421](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L421) This hook enables an app to supply a SchemaService for use when information about a resource's schema needs to be queried. This method will only be called once to instantiate the singleton service, which can then be accessed via `store.schema`. For Example, to use the default SchemaService for SchemaRecord ```ts import { SchemaService } from '@warp-drive/schema-record'; class extends Store { createSchemaService() { return new SchemaService(); } } ``` Or to use the SchemaService for @ember-data/model ```ts import { buildSchema } from '@ember-data/model'; class extends Store { createSchemaService() { return buildSchema(this); } } ``` If you wish to chain services, you must either instantiate each schema source directly or super to retrieve an existing service. For convenience, when migrating from `@ember-data/model` to `@warp-drive/schema-record` a SchemaService is provided that handles this transition for you: ```ts import { DelegatingSchemaService } from '@ember-data/model/migration-support'; import { SchemaService } from '@warp-drive/schema-record'; class extends Store { createSchemaService() { const schema = new SchemaService(); return new DelegatingSchemaService(this, schema); } } ``` When using the DelegateSchemaService, the schema will first be sourced from directly registered schemas, then will fallback to sourcing a schema from available models if no schema is found. #### Returns [`SchemaService`](../types/interfaces/SchemaService.md) *** ### deleteRecord() ```ts deleteRecord(record): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:1101](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L1101) For symmetry, a record can be deleted via the store. Example ```javascript let post = store.createRecord('post', { title: 'Ember is awesome!' }); store.deleteRecord(post); ``` #### Type Parameters ##### T `T` #### Parameters ##### record `T` #### Returns `void` *** ### destroy() ```ts destroy(): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:2466](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L2466) #### Returns `void` *** ### findAll() #### Call Signature ```ts findAll(type, options?): Promise>; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:2075](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L2075) `findAll` asks the adapter's `findAll` method to find the records for the given type, and returns a promise which will resolve with all records of this type present in the store, even if the adapter only returns a subset of them. ```js [app/routes/authors.js] export default class AuthorsRoute extends Route { model(params) { return this.store.findAll('author'); } } ``` *When* the returned promise resolves depends on the reload behavior, configured via the passed `options` hash and the result of the adapter's `shouldReloadAll` method. ### Reloading If `{ reload: true }` is passed or `adapter.shouldReloadAll` evaluates to `true`, then the returned promise resolves once the adapter returns data, regardless if there are already records in the store: ```js store.push({ data: { id: 'first', type: 'author' } }); // adapter#findAll resolves with // [ // { // id: 'second', // type: 'author' // } // ] store.findAll('author', { reload: true }).then(function(authors) { authors.getEach('id'); // ['first', 'second'] }); ``` If no reload is indicated via the above mentioned ways, then the promise immediately resolves with all the records currently loaded in the store. ### Background Reloading Optionally, if `adapter.shouldBackgroundReloadAll` evaluates to `true`, then a background reload is started. Once this resolves, the array with which the promise resolves, is updated automatically so it contains all the records in the store: ```js [app/adapters/application.js] import Adapter from '@ember-data/adapter'; export default class ApplicationAdapter extends Adapter { shouldReloadAll(store, snapshotsArray) { return false; }, shouldBackgroundReloadAll(store, snapshotsArray) { return true; } }); // ... store.push({ data: { id: 'first', type: 'author' } }); let allAuthors; store.findAll('author').then(function(authors) { authors.getEach('id'); // ['first'] allAuthors = authors; }); // later, once adapter#findAll resolved with // [ // { // id: 'second', // type: 'author' // } // ] allAuthors.getEach('id'); // ['first', 'second'] ``` If you would like to force or prevent background reloading, you can set a boolean value for `backgroundReload` in the options object for `findAll`. ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model() { return this.store.findAll('post', { backgroundReload: false }); } } ``` If you pass an object on the `adapterOptions` property of the options argument it will be passed to you adapter via the `snapshotRecordArray` ```js [app/routes/posts.js] export default class PostsRoute extends Route { model(params) { return this.store.findAll('post', { adapterOptions: { subscribe: false } }); } } ``` ```js [app/adapters/post.js] import MyCustomAdapter from './custom-adapter'; export default class UserAdapter extends MyCustomAdapter { findAll(store, type, sinceToken, snapshotRecordArray) { if (snapshotRecordArray.adapterOptions.subscribe) { // ... } // ... } } ``` See [peekAll](../methods/peekAll?anchor=peekAll) to get an array of current records in the store, without waiting until a reload is finished. ### Retrieving Related Model Records If you use an adapter such as Ember's default [`JSONAPIAdapter`](/ember-data/release/classes/JSONAPIAdapter) that supports the [JSON API specification](http://jsonapi.org/) and if your server endpoint supports the use of an ['include' query parameter](http://jsonapi.org/format/#fetching-includes), you can use `findAll()` to automatically retrieve additional records related to those requested by supplying an `include` parameter in the `options` object. For example, given a `post` model that has a `hasMany` relationship with a `comment` model, when we retrieve all of the post records we can have the server also return all of the posts' comments in the same request: ```js [app/routes/posts.js] export default class PostsRoute extends Route { model() { return this.store.findAll('post', { include: ['comments'] }); } } ``` Multiple relationships can be requested using an `include` parameter consisting of a list or relationship names, while nested relationships can be specified using a dot-separated sequence of relationship names. So to request both the posts' comments and the authors of those comments the request would look like this: ```js [app/routes/posts.js] export default class PostsRoute extends Route { model() { return this.store.findAll('post', { include: ['comments','comments.author'] }); } } ``` See [query](../methods/query?anchor=query) to only get a subset of records from the server. ##### Type Parameters ###### T `T` ##### Parameters ###### type [`TypeFromInstance`](../types/record/type-aliases/TypeFromInstance.md)<`T`> the name of the resource ###### options? [`FindAllOptions`](../types/type-aliases/FindAllOptions.md)<`T`> ##### Returns `Promise`<`IdentifierArray`<`T`>> promise ##### Since 1.13.0 #### Call Signature ```ts findAll(type, options?): Promise>; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:2076](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L2076) `findAll` asks the adapter's `findAll` method to find the records for the given type, and returns a promise which will resolve with all records of this type present in the store, even if the adapter only returns a subset of them. ```js [app/routes/authors.js] export default class AuthorsRoute extends Route { model(params) { return this.store.findAll('author'); } } ``` *When* the returned promise resolves depends on the reload behavior, configured via the passed `options` hash and the result of the adapter's `shouldReloadAll` method. ### Reloading If `{ reload: true }` is passed or `adapter.shouldReloadAll` evaluates to `true`, then the returned promise resolves once the adapter returns data, regardless if there are already records in the store: ```js store.push({ data: { id: 'first', type: 'author' } }); // adapter#findAll resolves with // [ // { // id: 'second', // type: 'author' // } // ] store.findAll('author', { reload: true }).then(function(authors) { authors.getEach('id'); // ['first', 'second'] }); ``` If no reload is indicated via the above mentioned ways, then the promise immediately resolves with all the records currently loaded in the store. ### Background Reloading Optionally, if `adapter.shouldBackgroundReloadAll` evaluates to `true`, then a background reload is started. Once this resolves, the array with which the promise resolves, is updated automatically so it contains all the records in the store: ```js [app/adapters/application.js] import Adapter from '@ember-data/adapter'; export default class ApplicationAdapter extends Adapter { shouldReloadAll(store, snapshotsArray) { return false; }, shouldBackgroundReloadAll(store, snapshotsArray) { return true; } }); // ... store.push({ data: { id: 'first', type: 'author' } }); let allAuthors; store.findAll('author').then(function(authors) { authors.getEach('id'); // ['first'] allAuthors = authors; }); // later, once adapter#findAll resolved with // [ // { // id: 'second', // type: 'author' // } // ] allAuthors.getEach('id'); // ['first', 'second'] ``` If you would like to force or prevent background reloading, you can set a boolean value for `backgroundReload` in the options object for `findAll`. ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model() { return this.store.findAll('post', { backgroundReload: false }); } } ``` If you pass an object on the `adapterOptions` property of the options argument it will be passed to you adapter via the `snapshotRecordArray` ```js [app/routes/posts.js] export default class PostsRoute extends Route { model(params) { return this.store.findAll('post', { adapterOptions: { subscribe: false } }); } } ``` ```js [app/adapters/post.js] import MyCustomAdapter from './custom-adapter'; export default class UserAdapter extends MyCustomAdapter { findAll(store, type, sinceToken, snapshotRecordArray) { if (snapshotRecordArray.adapterOptions.subscribe) { // ... } // ... } } ``` See [peekAll](../methods/peekAll?anchor=peekAll) to get an array of current records in the store, without waiting until a reload is finished. ### Retrieving Related Model Records If you use an adapter such as Ember's default [`JSONAPIAdapter`](/ember-data/release/classes/JSONAPIAdapter) that supports the [JSON API specification](http://jsonapi.org/) and if your server endpoint supports the use of an ['include' query parameter](http://jsonapi.org/format/#fetching-includes), you can use `findAll()` to automatically retrieve additional records related to those requested by supplying an `include` parameter in the `options` object. For example, given a `post` model that has a `hasMany` relationship with a `comment` model, when we retrieve all of the post records we can have the server also return all of the posts' comments in the same request: ```js [app/routes/posts.js] export default class PostsRoute extends Route { model() { return this.store.findAll('post', { include: ['comments'] }); } } ``` Multiple relationships can be requested using an `include` parameter consisting of a list or relationship names, while nested relationships can be specified using a dot-separated sequence of relationship names. So to request both the posts' comments and the authors of those comments the request would look like this: ```js [app/routes/posts.js] export default class PostsRoute extends Route { model() { return this.store.findAll('post', { include: ['comments','comments.author'] }); } } ``` See [query](../methods/query?anchor=query) to only get a subset of records from the server. ##### Parameters ###### type `string` the name of the resource ###### options? [`FindAllOptions`](../types/type-aliases/FindAllOptions.md) ##### Returns `Promise`<`IdentifierArray`<`unknown`>> promise ##### Since 1.13.0 *** ### findRecord() #### Call Signature ```ts findRecord( type, id, options?): Promise; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:1494](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L1494) This method returns a record for a given identifier or type and id combination. The `findRecord` method will always resolve its promise with the same object for a given identifier or type and `id`. The `findRecord` method will always return a **promise** that will be resolved with the record. **Example 1** ```js [app/routes/post.js] export default class PostRoute extends Route { model({ post_id }) { return this.store.findRecord('post', post_id); } } ``` **Example 2** `findRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) ```js [app/routes/post.js] export default class PostRoute extends Route { model({ post_id: id }) { return this.store.findRecord({ type: 'post', id }); } } ``` **Example 3** If you have previously received an lid via an Identifier for this record, and the record has already been assigned an id, you can find the record again using just the lid. ```js [app/routes/post.js] store.findRecord({ lid }); ``` If the record is not yet available, the store will ask the adapter's `findRecord` method to retrieve and supply the necessary data. If the record is already present in the store, it depends on the reload behavior *when* the returned promise resolves. ### Preloading You can optionally `preload` specific attributes and relationships that you know of by passing them via the passed `options`. For example, if your Ember route looks like `/posts/1/comments/2` and your API route for the comment also looks like `/posts/1/comments/2` if you want to fetch the comment without also fetching the post you can pass in the post to the `findRecord` call: ```js [app/routes/post-comments.js] export default class PostRoute extends Route { model({ post_id, comment_id: id }) { return this.store.findRecord({ type: 'comment', id, { preload: { post: post_id }} }); } } ``` In your adapter you can then access this id without triggering a network request via the snapshot: ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'comment') let postId = snapshot.belongsTo('post', { id: true }); return fetch(`./posts/${postId}/comments/${id}`) .then(response => response.json()) } } static create() { return new this(); } } ``` This could also be achieved by supplying the post id to the adapter via the adapterOptions property on the options hash. ```js [app/routes/post-comments.js] export default class PostRoute extends Route { model({ post_id, comment_id: id }) { return this.store.findRecord({ type: 'comment', id, { adapterOptions: { post: post_id }} }); } } ``` ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'comment') let postId = snapshot.adapterOptions.post; return fetch(`./posts/${postId}/comments/${id}`) .then(response => response.json()) } } static create() { return new this(); } } ``` If you have access to the post model you can also pass the model itself to preload: ```javascript let post = await store.findRecord('post', '1'); let comment = await store.findRecord('comment', '2', { post: myPostModel }); ``` ### Reloading The reload behavior is configured either via the passed `options` hash or the result of the adapter's `shouldReloadRecord`. If `{ reload: true }` is passed or `adapter.shouldReloadRecord` evaluates to `true`, then the returned promise resolves once the adapter returns data, regardless if the requested record is already in the store: ```js store.push({ data: { id: 1, type: 'post', revision: 1 } }); // adapter#findRecord resolves with // [ // { // id: 1, // type: 'post', // revision: 2 // } // ] store.findRecord('post', '1', { reload: true }).then(function(post) { post.revision; // 2 }); ``` If no reload is indicated via the above mentioned ways, then the promise immediately resolves with the cached version in the store. ### Background Reloading Optionally, if `adapter.shouldBackgroundReloadRecord` evaluates to `true`, then a background reload is started, which updates the records' data, once it is available: ```js // app/adapters/post.js import ApplicationAdapter from "./application"; export default class PostAdapter extends ApplicationAdapter { shouldReloadRecord(store, snapshot) { return false; }, shouldBackgroundReloadRecord(store, snapshot) { return true; } }); // ... store.push({ data: { id: 1, type: 'post', revision: 1 } }); let blogPost = store.findRecord('post', '1').then(function(post) { post.revision; // 1 }); // later, once adapter#findRecord resolved with // [ // { // id: 1, // type: 'post', // revision: 2 // } // ] blogPost.revision; // 2 ``` If you would like to force or prevent background reloading, you can set a boolean value for `backgroundReload` in the options object for `findRecord`. ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { backgroundReload: false }); } } ``` If you pass an object on the `adapterOptions` property of the options argument it will be passed to your adapter via the snapshot ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { subscribe: false } }); } } ``` ```js [app/adapters/post.js] import MyCustomAdapter from './custom-adapter'; export default class PostAdapter extends MyCustomAdapter { findRecord(store, type, id, snapshot) { if (snapshot.adapterOptions.subscribe) { // ... } // ... } } ``` See [peekRecord](../methods/peekRecord?anchor=peekRecord) to get the cached version of a record. ### Retrieving Related Model Records If you use an adapter such as Ember's default [`JSONAPIAdapter`](/ember-data/release/classes/JSONAPIAdapter) that supports the [JSON API specification](http://jsonapi.org/) and if your server endpoint supports the use of an ['include' query parameter](http://jsonapi.org/format/#fetching-includes), you can use `findRecord()` or `findAll()` to automatically retrieve additional records related to the one you request by supplying an `include` parameter in the `options` object. For example, given a `post` model that has a `hasMany` relationship with a `comment` model, when we retrieve a specific post we can have the server also return that post's comments in the same request: ```js [app/routes/post.js] export default class PostRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { include: ['comments'] }); } } ``` ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'post') let includes = snapshot.adapterOptions.include; return fetch(`./posts/${postId}?include=${includes}`) .then(response => response.json()) } } static create() { return new this(); } } ``` In this case, the post's comments would then be available in your template as `model.comments`. Multiple relationships can be requested using an `include` parameter consisting of a list of relationship names, while nested relationships can be specified using a dot-separated sequence of relationship names. So to request both the post's comments and the authors of those comments the request would look like this: ```js [app/routes/post.js] export default class PostRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { include: ['comments','comments.author'] }); } } ``` ### Retrieving Specific Fields by Type If your server endpoint supports the use of a ['fields' query parameter](https://jsonapi.org/format/#fetching-sparse-fieldsets), you can use pass those fields through to your server. At this point in time, this requires a few manual steps on your part. 1. Implement `buildQuery` in your adapter. ```js [app/adapters/application.js] buildQuery(snapshot) { let query = super.buildQuery(...arguments); let { fields } = snapshot.adapterOptions; if (fields) { query.fields = fields; } return query; } ``` 2. Then pass through the applicable fields to your `findRecord` request. Given a `post` model with attributes body, title, publishDate and meta, you can retrieve a filtered list of attributes. ```js [app/routes/post.js] export default class extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title' } }); } } ``` Moreover, you can filter attributes on related models as well. If a `post` has a `belongsTo` relationship to a user, just include the relationship key and attributes. ```js [app/routes/post.js] export default class extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title', user: 'name,email' } }); } } ``` ##### Type Parameters ###### T `T` ##### Parameters ###### type [`TypeFromInstance`](../types/record/type-aliases/TypeFromInstance.md)<`T`> either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record ###### id optional object with options for the request only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved `string` | `number` ###### options? [`FindRecordOptions`](../types/interfaces/FindRecordOptions.md)<`T`> if the first param is a string this will be the optional options for the request. See examples for available options. ##### Returns `Promise`<`T`> promise ##### Since 1.13.0 #### Call Signature ```ts findRecord( type, id, options?): Promise; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:1495](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L1495) This method returns a record for a given identifier or type and id combination. The `findRecord` method will always resolve its promise with the same object for a given identifier or type and `id`. The `findRecord` method will always return a **promise** that will be resolved with the record. **Example 1** ```js [app/routes/post.js] export default class PostRoute extends Route { model({ post_id }) { return this.store.findRecord('post', post_id); } } ``` **Example 2** `findRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) ```js [app/routes/post.js] export default class PostRoute extends Route { model({ post_id: id }) { return this.store.findRecord({ type: 'post', id }); } } ``` **Example 3** If you have previously received an lid via an Identifier for this record, and the record has already been assigned an id, you can find the record again using just the lid. ```js [app/routes/post.js] store.findRecord({ lid }); ``` If the record is not yet available, the store will ask the adapter's `findRecord` method to retrieve and supply the necessary data. If the record is already present in the store, it depends on the reload behavior *when* the returned promise resolves. ### Preloading You can optionally `preload` specific attributes and relationships that you know of by passing them via the passed `options`. For example, if your Ember route looks like `/posts/1/comments/2` and your API route for the comment also looks like `/posts/1/comments/2` if you want to fetch the comment without also fetching the post you can pass in the post to the `findRecord` call: ```js [app/routes/post-comments.js] export default class PostRoute extends Route { model({ post_id, comment_id: id }) { return this.store.findRecord({ type: 'comment', id, { preload: { post: post_id }} }); } } ``` In your adapter you can then access this id without triggering a network request via the snapshot: ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'comment') let postId = snapshot.belongsTo('post', { id: true }); return fetch(`./posts/${postId}/comments/${id}`) .then(response => response.json()) } } static create() { return new this(); } } ``` This could also be achieved by supplying the post id to the adapter via the adapterOptions property on the options hash. ```js [app/routes/post-comments.js] export default class PostRoute extends Route { model({ post_id, comment_id: id }) { return this.store.findRecord({ type: 'comment', id, { adapterOptions: { post: post_id }} }); } } ``` ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'comment') let postId = snapshot.adapterOptions.post; return fetch(`./posts/${postId}/comments/${id}`) .then(response => response.json()) } } static create() { return new this(); } } ``` If you have access to the post model you can also pass the model itself to preload: ```javascript let post = await store.findRecord('post', '1'); let comment = await store.findRecord('comment', '2', { post: myPostModel }); ``` ### Reloading The reload behavior is configured either via the passed `options` hash or the result of the adapter's `shouldReloadRecord`. If `{ reload: true }` is passed or `adapter.shouldReloadRecord` evaluates to `true`, then the returned promise resolves once the adapter returns data, regardless if the requested record is already in the store: ```js store.push({ data: { id: 1, type: 'post', revision: 1 } }); // adapter#findRecord resolves with // [ // { // id: 1, // type: 'post', // revision: 2 // } // ] store.findRecord('post', '1', { reload: true }).then(function(post) { post.revision; // 2 }); ``` If no reload is indicated via the above mentioned ways, then the promise immediately resolves with the cached version in the store. ### Background Reloading Optionally, if `adapter.shouldBackgroundReloadRecord` evaluates to `true`, then a background reload is started, which updates the records' data, once it is available: ```js // app/adapters/post.js import ApplicationAdapter from "./application"; export default class PostAdapter extends ApplicationAdapter { shouldReloadRecord(store, snapshot) { return false; }, shouldBackgroundReloadRecord(store, snapshot) { return true; } }); // ... store.push({ data: { id: 1, type: 'post', revision: 1 } }); let blogPost = store.findRecord('post', '1').then(function(post) { post.revision; // 1 }); // later, once adapter#findRecord resolved with // [ // { // id: 1, // type: 'post', // revision: 2 // } // ] blogPost.revision; // 2 ``` If you would like to force or prevent background reloading, you can set a boolean value for `backgroundReload` in the options object for `findRecord`. ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { backgroundReload: false }); } } ``` If you pass an object on the `adapterOptions` property of the options argument it will be passed to your adapter via the snapshot ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { subscribe: false } }); } } ``` ```js [app/adapters/post.js] import MyCustomAdapter from './custom-adapter'; export default class PostAdapter extends MyCustomAdapter { findRecord(store, type, id, snapshot) { if (snapshot.adapterOptions.subscribe) { // ... } // ... } } ``` See [peekRecord](../methods/peekRecord?anchor=peekRecord) to get the cached version of a record. ### Retrieving Related Model Records If you use an adapter such as Ember's default [`JSONAPIAdapter`](/ember-data/release/classes/JSONAPIAdapter) that supports the [JSON API specification](http://jsonapi.org/) and if your server endpoint supports the use of an ['include' query parameter](http://jsonapi.org/format/#fetching-includes), you can use `findRecord()` or `findAll()` to automatically retrieve additional records related to the one you request by supplying an `include` parameter in the `options` object. For example, given a `post` model that has a `hasMany` relationship with a `comment` model, when we retrieve a specific post we can have the server also return that post's comments in the same request: ```js [app/routes/post.js] export default class PostRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { include: ['comments'] }); } } ``` ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'post') let includes = snapshot.adapterOptions.include; return fetch(`./posts/${postId}?include=${includes}`) .then(response => response.json()) } } static create() { return new this(); } } ``` In this case, the post's comments would then be available in your template as `model.comments`. Multiple relationships can be requested using an `include` parameter consisting of a list of relationship names, while nested relationships can be specified using a dot-separated sequence of relationship names. So to request both the post's comments and the authors of those comments the request would look like this: ```js [app/routes/post.js] export default class PostRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { include: ['comments','comments.author'] }); } } ``` ### Retrieving Specific Fields by Type If your server endpoint supports the use of a ['fields' query parameter](https://jsonapi.org/format/#fetching-sparse-fieldsets), you can use pass those fields through to your server. At this point in time, this requires a few manual steps on your part. 1. Implement `buildQuery` in your adapter. ```js [app/adapters/application.js] buildQuery(snapshot) { let query = super.buildQuery(...arguments); let { fields } = snapshot.adapterOptions; if (fields) { query.fields = fields; } return query; } ``` 2. Then pass through the applicable fields to your `findRecord` request. Given a `post` model with attributes body, title, publishDate and meta, you can retrieve a filtered list of attributes. ```js [app/routes/post.js] export default class extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title' } }); } } ``` Moreover, you can filter attributes on related models as well. If a `post` has a `belongsTo` relationship to a user, just include the relationship key and attributes. ```js [app/routes/post.js] export default class extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title', user: 'name,email' } }); } } ``` ##### Parameters ###### type `string` either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record ###### id optional object with options for the request only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved `string` | `number` ###### options? [`FindRecordOptions`](../types/interfaces/FindRecordOptions.md)<`unknown`> if the first param is a string this will be the optional options for the request. See examples for available options. ##### Returns `Promise`<`unknown`> promise ##### Since 1.13.0 #### Call Signature ```ts findRecord(resource, options?): Promise; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:1496](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L1496) This method returns a record for a given identifier or type and id combination. The `findRecord` method will always resolve its promise with the same object for a given identifier or type and `id`. The `findRecord` method will always return a **promise** that will be resolved with the record. **Example 1** ```js [app/routes/post.js] export default class PostRoute extends Route { model({ post_id }) { return this.store.findRecord('post', post_id); } } ``` **Example 2** `findRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) ```js [app/routes/post.js] export default class PostRoute extends Route { model({ post_id: id }) { return this.store.findRecord({ type: 'post', id }); } } ``` **Example 3** If you have previously received an lid via an Identifier for this record, and the record has already been assigned an id, you can find the record again using just the lid. ```js [app/routes/post.js] store.findRecord({ lid }); ``` If the record is not yet available, the store will ask the adapter's `findRecord` method to retrieve and supply the necessary data. If the record is already present in the store, it depends on the reload behavior *when* the returned promise resolves. ### Preloading You can optionally `preload` specific attributes and relationships that you know of by passing them via the passed `options`. For example, if your Ember route looks like `/posts/1/comments/2` and your API route for the comment also looks like `/posts/1/comments/2` if you want to fetch the comment without also fetching the post you can pass in the post to the `findRecord` call: ```js [app/routes/post-comments.js] export default class PostRoute extends Route { model({ post_id, comment_id: id }) { return this.store.findRecord({ type: 'comment', id, { preload: { post: post_id }} }); } } ``` In your adapter you can then access this id without triggering a network request via the snapshot: ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'comment') let postId = snapshot.belongsTo('post', { id: true }); return fetch(`./posts/${postId}/comments/${id}`) .then(response => response.json()) } } static create() { return new this(); } } ``` This could also be achieved by supplying the post id to the adapter via the adapterOptions property on the options hash. ```js [app/routes/post-comments.js] export default class PostRoute extends Route { model({ post_id, comment_id: id }) { return this.store.findRecord({ type: 'comment', id, { adapterOptions: { post: post_id }} }); } } ``` ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'comment') let postId = snapshot.adapterOptions.post; return fetch(`./posts/${postId}/comments/${id}`) .then(response => response.json()) } } static create() { return new this(); } } ``` If you have access to the post model you can also pass the model itself to preload: ```javascript let post = await store.findRecord('post', '1'); let comment = await store.findRecord('comment', '2', { post: myPostModel }); ``` ### Reloading The reload behavior is configured either via the passed `options` hash or the result of the adapter's `shouldReloadRecord`. If `{ reload: true }` is passed or `adapter.shouldReloadRecord` evaluates to `true`, then the returned promise resolves once the adapter returns data, regardless if the requested record is already in the store: ```js store.push({ data: { id: 1, type: 'post', revision: 1 } }); // adapter#findRecord resolves with // [ // { // id: 1, // type: 'post', // revision: 2 // } // ] store.findRecord('post', '1', { reload: true }).then(function(post) { post.revision; // 2 }); ``` If no reload is indicated via the above mentioned ways, then the promise immediately resolves with the cached version in the store. ### Background Reloading Optionally, if `adapter.shouldBackgroundReloadRecord` evaluates to `true`, then a background reload is started, which updates the records' data, once it is available: ```js // app/adapters/post.js import ApplicationAdapter from "./application"; export default class PostAdapter extends ApplicationAdapter { shouldReloadRecord(store, snapshot) { return false; }, shouldBackgroundReloadRecord(store, snapshot) { return true; } }); // ... store.push({ data: { id: 1, type: 'post', revision: 1 } }); let blogPost = store.findRecord('post', '1').then(function(post) { post.revision; // 1 }); // later, once adapter#findRecord resolved with // [ // { // id: 1, // type: 'post', // revision: 2 // } // ] blogPost.revision; // 2 ``` If you would like to force or prevent background reloading, you can set a boolean value for `backgroundReload` in the options object for `findRecord`. ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { backgroundReload: false }); } } ``` If you pass an object on the `adapterOptions` property of the options argument it will be passed to your adapter via the snapshot ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { subscribe: false } }); } } ``` ```js [app/adapters/post.js] import MyCustomAdapter from './custom-adapter'; export default class PostAdapter extends MyCustomAdapter { findRecord(store, type, id, snapshot) { if (snapshot.adapterOptions.subscribe) { // ... } // ... } } ``` See [peekRecord](../methods/peekRecord?anchor=peekRecord) to get the cached version of a record. ### Retrieving Related Model Records If you use an adapter such as Ember's default [`JSONAPIAdapter`](/ember-data/release/classes/JSONAPIAdapter) that supports the [JSON API specification](http://jsonapi.org/) and if your server endpoint supports the use of an ['include' query parameter](http://jsonapi.org/format/#fetching-includes), you can use `findRecord()` or `findAll()` to automatically retrieve additional records related to the one you request by supplying an `include` parameter in the `options` object. For example, given a `post` model that has a `hasMany` relationship with a `comment` model, when we retrieve a specific post we can have the server also return that post's comments in the same request: ```js [app/routes/post.js] export default class PostRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { include: ['comments'] }); } } ``` ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'post') let includes = snapshot.adapterOptions.include; return fetch(`./posts/${postId}?include=${includes}`) .then(response => response.json()) } } static create() { return new this(); } } ``` In this case, the post's comments would then be available in your template as `model.comments`. Multiple relationships can be requested using an `include` parameter consisting of a list of relationship names, while nested relationships can be specified using a dot-separated sequence of relationship names. So to request both the post's comments and the authors of those comments the request would look like this: ```js [app/routes/post.js] export default class PostRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { include: ['comments','comments.author'] }); } } ``` ### Retrieving Specific Fields by Type If your server endpoint supports the use of a ['fields' query parameter](https://jsonapi.org/format/#fetching-sparse-fieldsets), you can use pass those fields through to your server. At this point in time, this requires a few manual steps on your part. 1. Implement `buildQuery` in your adapter. ```js [app/adapters/application.js] buildQuery(snapshot) { let query = super.buildQuery(...arguments); let { fields } = snapshot.adapterOptions; if (fields) { query.fields = fields; } return query; } ``` 2. Then pass through the applicable fields to your `findRecord` request. Given a `post` model with attributes body, title, publishDate and meta, you can retrieve a filtered list of attributes. ```js [app/routes/post.js] export default class extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title' } }); } } ``` Moreover, you can filter attributes on related models as well. If a `post` has a `belongsTo` relationship to a user, just include the relationship key and attributes. ```js [app/routes/post.js] export default class extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title', user: 'name,email' } }); } } ``` ##### Type Parameters ###### T `T` ##### Parameters ###### resource [`ResourceIdentifierObject`](../types/spec/json-api-raw/type-aliases/ResourceIdentifierObject.md)<[`TypeFromInstance`](../types/record/type-aliases/TypeFromInstance.md)<`T`>> ###### options? [`FindRecordOptions`](../types/interfaces/FindRecordOptions.md)<`T`> if the first param is a string this will be the optional options for the request. See examples for available options. ##### Returns `Promise`<`T`> promise ##### Since 1.13.0 #### Call Signature ```ts findRecord(resource, options?): Promise; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:1497](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L1497) This method returns a record for a given identifier or type and id combination. The `findRecord` method will always resolve its promise with the same object for a given identifier or type and `id`. The `findRecord` method will always return a **promise** that will be resolved with the record. **Example 1** ```js [app/routes/post.js] export default class PostRoute extends Route { model({ post_id }) { return this.store.findRecord('post', post_id); } } ``` **Example 2** `findRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) ```js [app/routes/post.js] export default class PostRoute extends Route { model({ post_id: id }) { return this.store.findRecord({ type: 'post', id }); } } ``` **Example 3** If you have previously received an lid via an Identifier for this record, and the record has already been assigned an id, you can find the record again using just the lid. ```js [app/routes/post.js] store.findRecord({ lid }); ``` If the record is not yet available, the store will ask the adapter's `findRecord` method to retrieve and supply the necessary data. If the record is already present in the store, it depends on the reload behavior *when* the returned promise resolves. ### Preloading You can optionally `preload` specific attributes and relationships that you know of by passing them via the passed `options`. For example, if your Ember route looks like `/posts/1/comments/2` and your API route for the comment also looks like `/posts/1/comments/2` if you want to fetch the comment without also fetching the post you can pass in the post to the `findRecord` call: ```js [app/routes/post-comments.js] export default class PostRoute extends Route { model({ post_id, comment_id: id }) { return this.store.findRecord({ type: 'comment', id, { preload: { post: post_id }} }); } } ``` In your adapter you can then access this id without triggering a network request via the snapshot: ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'comment') let postId = snapshot.belongsTo('post', { id: true }); return fetch(`./posts/${postId}/comments/${id}`) .then(response => response.json()) } } static create() { return new this(); } } ``` This could also be achieved by supplying the post id to the adapter via the adapterOptions property on the options hash. ```js [app/routes/post-comments.js] export default class PostRoute extends Route { model({ post_id, comment_id: id }) { return this.store.findRecord({ type: 'comment', id, { adapterOptions: { post: post_id }} }); } } ``` ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'comment') let postId = snapshot.adapterOptions.post; return fetch(`./posts/${postId}/comments/${id}`) .then(response => response.json()) } } static create() { return new this(); } } ``` If you have access to the post model you can also pass the model itself to preload: ```javascript let post = await store.findRecord('post', '1'); let comment = await store.findRecord('comment', '2', { post: myPostModel }); ``` ### Reloading The reload behavior is configured either via the passed `options` hash or the result of the adapter's `shouldReloadRecord`. If `{ reload: true }` is passed or `adapter.shouldReloadRecord` evaluates to `true`, then the returned promise resolves once the adapter returns data, regardless if the requested record is already in the store: ```js store.push({ data: { id: 1, type: 'post', revision: 1 } }); // adapter#findRecord resolves with // [ // { // id: 1, // type: 'post', // revision: 2 // } // ] store.findRecord('post', '1', { reload: true }).then(function(post) { post.revision; // 2 }); ``` If no reload is indicated via the above mentioned ways, then the promise immediately resolves with the cached version in the store. ### Background Reloading Optionally, if `adapter.shouldBackgroundReloadRecord` evaluates to `true`, then a background reload is started, which updates the records' data, once it is available: ```js // app/adapters/post.js import ApplicationAdapter from "./application"; export default class PostAdapter extends ApplicationAdapter { shouldReloadRecord(store, snapshot) { return false; }, shouldBackgroundReloadRecord(store, snapshot) { return true; } }); // ... store.push({ data: { id: 1, type: 'post', revision: 1 } }); let blogPost = store.findRecord('post', '1').then(function(post) { post.revision; // 1 }); // later, once adapter#findRecord resolved with // [ // { // id: 1, // type: 'post', // revision: 2 // } // ] blogPost.revision; // 2 ``` If you would like to force or prevent background reloading, you can set a boolean value for `backgroundReload` in the options object for `findRecord`. ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { backgroundReload: false }); } } ``` If you pass an object on the `adapterOptions` property of the options argument it will be passed to your adapter via the snapshot ```js [app/routes/post/edit.js] export default class PostEditRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { subscribe: false } }); } } ``` ```js [app/adapters/post.js] import MyCustomAdapter from './custom-adapter'; export default class PostAdapter extends MyCustomAdapter { findRecord(store, type, id, snapshot) { if (snapshot.adapterOptions.subscribe) { // ... } // ... } } ``` See [peekRecord](../methods/peekRecord?anchor=peekRecord) to get the cached version of a record. ### Retrieving Related Model Records If you use an adapter such as Ember's default [`JSONAPIAdapter`](/ember-data/release/classes/JSONAPIAdapter) that supports the [JSON API specification](http://jsonapi.org/) and if your server endpoint supports the use of an ['include' query parameter](http://jsonapi.org/format/#fetching-includes), you can use `findRecord()` or `findAll()` to automatically retrieve additional records related to the one you request by supplying an `include` parameter in the `options` object. For example, given a `post` model that has a `hasMany` relationship with a `comment` model, when we retrieve a specific post we can have the server also return that post's comments in the same request: ```js [app/routes/post.js] export default class PostRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { include: ['comments'] }); } } ``` ```js [app/adapters/application.js] export default class Adapter { findRecord(store, schema, id, snapshot) { let type = schema.modelName; if (type === 'post') let includes = snapshot.adapterOptions.include; return fetch(`./posts/${postId}?include=${includes}`) .then(response => response.json()) } } static create() { return new this(); } } ``` In this case, the post's comments would then be available in your template as `model.comments`. Multiple relationships can be requested using an `include` parameter consisting of a list of relationship names, while nested relationships can be specified using a dot-separated sequence of relationship names. So to request both the post's comments and the authors of those comments the request would look like this: ```js [app/routes/post.js] export default class PostRoute extends Route { model(params) { return this.store.findRecord('post', params.post_id, { include: ['comments','comments.author'] }); } } ``` ### Retrieving Specific Fields by Type If your server endpoint supports the use of a ['fields' query parameter](https://jsonapi.org/format/#fetching-sparse-fieldsets), you can use pass those fields through to your server. At this point in time, this requires a few manual steps on your part. 1. Implement `buildQuery` in your adapter. ```js [app/adapters/application.js] buildQuery(snapshot) { let query = super.buildQuery(...arguments); let { fields } = snapshot.adapterOptions; if (fields) { query.fields = fields; } return query; } ``` 2. Then pass through the applicable fields to your `findRecord` request. Given a `post` model with attributes body, title, publishDate and meta, you can retrieve a filtered list of attributes. ```js [app/routes/post.js] export default class extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title' } }); } } ``` Moreover, you can filter attributes on related models as well. If a `post` has a `belongsTo` relationship to a user, just include the relationship key and attributes. ```js [app/routes/post.js] export default class extends Route { model(params) { return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title', user: 'name,email' } }); } } ``` ##### Parameters ###### resource [`ResourceIdentifierObject`](../types/spec/json-api-raw/type-aliases/ResourceIdentifierObject.md) ###### options? [`FindRecordOptions`](../types/interfaces/FindRecordOptions.md)<`unknown`> if the first param is a string this will be the optional options for the request. See examples for available options. ##### Returns `Promise`<`unknown`> promise ##### Since 1.13.0 *** ### getReference() ```ts getReference(resource, id): RecordReference; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:1590](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L1590) Get the reference for the specified record. Example ```javascript let userRef = store.getReference('user', '1'); // check if the user is loaded let isLoaded = userRef.value() !== null; // get the record of the reference (null if not yet available) let user = userRef.value(); // get the identifier of the reference if (userRef.remoteType() === 'id') { let id = userRef.id(); } // load user (via store.find) userRef.load().then(...) // or trigger a reload userRef.reload().then(...) // provide data for reference userRef.push({ id: 1, username: '@user' }).then(function(user) { userRef.value() === user; }); ``` #### Parameters ##### resource modelName (string) or Identifier (object) `string` | [`ResourceIdentifierObject`](../types/spec/json-api-raw/type-aliases/ResourceIdentifierObject.md) ##### id `string` | `number` #### Returns `RecordReference` #### Since 2.5.0 *** ### getRequestStateService() ```ts getRequestStateService(): RequestStateService; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:793](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L793) Retrieve the RequestStateService instance associated with this Store. This can be used to query the status of requests that have been initiated for a given identifier. #### Returns `RequestStateService` *** ### ~~getSchemaDefinitionService()~~ ```ts getSchemaDefinitionService(): SchemaService; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:435](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L435) DEPRECATED - Use the property `store.schema` instead. Provides access to the SchemaDefinitionService instance for this Store instance. The SchemaDefinitionService can be used to query for information about the schema of a resource. #### Returns [`SchemaService`](../types/interfaces/SchemaService.md) #### Deprecated *** ### instantiateRecord() ```ts instantiateRecord(identifier, createRecordArgs): unknown; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:353](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L353) This is the hook WarpDrive uses to create a record instance to give reactive access to a resource in the cache. #### Type Parameters ##### T `T` #### Parameters ##### identifier [`StableRecordIdentifier`](../types/identifier/type-aliases/StableRecordIdentifier.md) ##### createRecordArgs #### Returns `unknown` *** ### ~~modelFor()~~ #### Call Signature ```ts modelFor(type): ModelSchema; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:980](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L980) Returns the schema for a particular resource type (modelName). When used with Model from @ember-data/model the return is the model class, but this is not guaranteed. If looking to query attribute or relationship information it is recommended to use `getSchemaDefinitionService` instead. This method should be considered legacy and exists primarily to continue to support Adapter/Serializer APIs which expect it's return value in their method signatures. The class of a model might be useful if you want to get a list of all the relationship names of the model, see [`relationshipNames`](/ember-data/release/classes/Model?anchor=relationshipNames) for example. ##### Type Parameters ###### T `T` ##### Parameters ###### type [`TypeFromInstance`](../types/record/type-aliases/TypeFromInstance.md)<`T`> ##### Returns [`ModelSchema`](../types/interfaces/ModelSchema.md)<`T`> ##### Deprecated #### Call Signature ```ts modelFor(type): ModelSchema; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:981](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L981) Returns the schema for a particular resource type (modelName). When used with Model from @ember-data/model the return is the model class, but this is not guaranteed. If looking to query attribute or relationship information it is recommended to use `getSchemaDefinitionService` instead. This method should be considered legacy and exists primarily to continue to support Adapter/Serializer APIs which expect it's return value in their method signatures. The class of a model might be useful if you want to get a list of all the relationship names of the model, see [`relationshipNames`](/ember-data/release/classes/Model?anchor=relationshipNames) for example. ##### Parameters ###### type `string` ##### Returns [`ModelSchema`](../types/interfaces/ModelSchema.md) ##### Deprecated *** ### peekAll() #### Call Signature ```ts peekAll(type): IdentifierArray; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:2123](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L2123) This method returns a filtered array that contains all of the known records for a given type in the store. Note that because it's just a filter, the result will contain any locally created records of the type, however, it will not make a request to the backend to retrieve additional records. If you would like to request all the records from the backend please use [store.findAll](../methods/findAll?anchor=findAll). Also note that multiple calls to `peekAll` for a given type will always return the same `RecordArray`. Example ```javascript let localPosts = store.peekAll('post'); ``` ##### Type Parameters ###### T `T` ##### Parameters ###### type [`TypeFromInstance`](../types/record/type-aliases/TypeFromInstance.md)<`T`> the name of the resource ##### Returns `IdentifierArray`<`T`> ##### Since 1.13.0 #### Call Signature ```ts peekAll(type): IdentifierArray; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:2124](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L2124) This method returns a filtered array that contains all of the known records for a given type in the store. Note that because it's just a filter, the result will contain any locally created records of the type, however, it will not make a request to the backend to retrieve additional records. If you would like to request all the records from the backend please use [store.findAll](../methods/findAll?anchor=findAll). Also note that multiple calls to `peekAll` for a given type will always return the same `RecordArray`. Example ```javascript let localPosts = store.peekAll('post'); ``` ##### Parameters ###### type `string` the name of the resource ##### Returns `IdentifierArray` ##### Since 1.13.0 *** ### peekRecord() #### Call Signature ```ts peekRecord(type, id): null | T; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:1661](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L1661) Get a record by a given type and ID without triggering a fetch. This method will synchronously return the record if it is available in the store, otherwise it will return `null`. A record is available if it has been fetched earlier, or pushed manually into the store. See [findRecord](../methods/findRecord?anchor=findRecord) if you would like to request this record from the backend. *Note: This is a synchronous method and does not return a promise.* **Example 1** ```js let post = store.peekRecord('post', '1'); post.id; // '1' ``` `peekRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) **Example 2** ```js let post = store.peekRecord({ type: 'post', id }); post.id; // '1' ``` If you have previously received an lid from an Identifier for this record, you can lookup the record again using just the lid. **Example 3** ```js let post = store.peekRecord({ lid }); post.id; // '1' ``` ##### Type Parameters ###### T `T` ##### Parameters ###### type [`TypeFromInstance`](../types/record/type-aliases/TypeFromInstance.md)<`T`> ###### id optional only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved. `string` | `number` ##### Returns `null` | `T` record ##### Since 1.13.0 #### Call Signature ```ts peekRecord(type, id): unknown; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:1662](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L1662) Get a record by a given type and ID without triggering a fetch. This method will synchronously return the record if it is available in the store, otherwise it will return `null`. A record is available if it has been fetched earlier, or pushed manually into the store. See [findRecord](../methods/findRecord?anchor=findRecord) if you would like to request this record from the backend. *Note: This is a synchronous method and does not return a promise.* **Example 1** ```js let post = store.peekRecord('post', '1'); post.id; // '1' ``` `peekRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) **Example 2** ```js let post = store.peekRecord({ type: 'post', id }); post.id; // '1' ``` If you have previously received an lid from an Identifier for this record, you can lookup the record again using just the lid. **Example 3** ```js let post = store.peekRecord({ lid }); post.id; // '1' ``` ##### Parameters ###### type `string` ###### id optional only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved. `string` | `number` ##### Returns `unknown` record ##### Since 1.13.0 #### Call Signature ```ts peekRecord(identifier): null | T; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:1663](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L1663) Get a record by a given type and ID without triggering a fetch. This method will synchronously return the record if it is available in the store, otherwise it will return `null`. A record is available if it has been fetched earlier, or pushed manually into the store. See [findRecord](../methods/findRecord?anchor=findRecord) if you would like to request this record from the backend. *Note: This is a synchronous method and does not return a promise.* **Example 1** ```js let post = store.peekRecord('post', '1'); post.id; // '1' ``` `peekRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) **Example 2** ```js let post = store.peekRecord({ type: 'post', id }); post.id; // '1' ``` If you have previously received an lid from an Identifier for this record, you can lookup the record again using just the lid. **Example 3** ```js let post = store.peekRecord({ lid }); post.id; // '1' ``` ##### Type Parameters ###### T `T` ##### Parameters ###### identifier [`ResourceIdentifierObject`](../types/spec/json-api-raw/type-aliases/ResourceIdentifierObject.md)<[`TypeFromInstance`](../types/record/type-aliases/TypeFromInstance.md)<`T`>> ##### Returns `null` | `T` record ##### Since 1.13.0 #### Call Signature ```ts peekRecord(identifier): unknown; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:1664](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L1664) Get a record by a given type and ID without triggering a fetch. This method will synchronously return the record if it is available in the store, otherwise it will return `null`. A record is available if it has been fetched earlier, or pushed manually into the store. See [findRecord](../methods/findRecord?anchor=findRecord) if you would like to request this record from the backend. *Note: This is a synchronous method and does not return a promise.* **Example 1** ```js let post = store.peekRecord('post', '1'); post.id; // '1' ``` `peekRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) **Example 2** ```js let post = store.peekRecord({ type: 'post', id }); post.id; // '1' ``` If you have previously received an lid from an Identifier for this record, you can lookup the record again using just the lid. **Example 3** ```js let post = store.peekRecord({ lid }); post.id; // '1' ``` ##### Parameters ###### identifier [`ResourceIdentifierObject`](../types/spec/json-api-raw/type-aliases/ResourceIdentifierObject.md) ##### Returns `unknown` record ##### Since 1.13.0 *** ### push() #### Call Signature ```ts push(data): null; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:2328](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L2328) Push some data for a given type into the store. This method expects normalized [JSON API](http://jsonapi.org/) document. This means you have to follow [JSON API specification](http://jsonapi.org/format/) with few minor adjustments: * record's `type` should always be in singular, dasherized form * members (properties) should be camelCased [Your primary data should be wrapped inside `data` property](http://jsonapi.org/format/#document-top-level): ```js store.push({ data: { // primary data for single record of type `Person` id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } } }); ``` [Demo.](http://ember-twiddle.com/fb99f18cd3b4d3e2a4c7) `data` property can also hold an array (of records): ```js store.push({ data: [ // an array of records { id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } }, { id: '2', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' } } ] }); ``` [Demo.](http://ember-twiddle.com/69cdbeaa3702159dc355) There are some typical properties for `JSONAPI` payload: * `id` - mandatory, unique record's key * `type` - mandatory string which matches `model`'s dasherized name in singular form * `attributes` - object which holds data for record attributes - `attr`'s declared in model * `relationships` - object which must contain any of the following properties under each relationships' respective key (example path is `relationships.achievements.data`): * [`links`](http://jsonapi.org/format/#document-links) * [`data`](http://jsonapi.org/format/#document-resource-object-linkage) - place for primary data * [`meta`](http://jsonapi.org/format/#document-meta) - object which contains meta-information about relationship For this model: ```js [app/models/person.js] import Model, { attr, hasMany } from '@ember-data/model'; export default class PersonRoute extends Route { @attr('string') firstName; @attr('string') lastName; @hasMany('person') children; } ``` To represent the children as IDs: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { data: [ { id: '2', type: 'person' }, { id: '3', type: 'person' }, { id: '4', type: 'person' } ] } } } } ``` [Demo.](http://ember-twiddle.com/343e1735e034091f5bde) To represent the children relationship as a URL: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { links: { related: '/people/1/children' } } } } } ``` If you're streaming data or implementing an adapter, make sure that you have converted the incoming data into this form. The store's [normalize](../methods/normalize?anchor=normalize) method is a convenience helper for converting a json payload into the form Ember Data expects. ```js store.push(store.normalize('person', data)); ``` This method can be used both to push in brand new records, as well as to update existing records. ##### Parameters ###### data [`EmptyResourceDocument`](../types/spec/json-api-raw/type-aliases/EmptyResourceDocument.md) ##### Returns `null` the record(s) that was created or updated. #### Call Signature ```ts push(data): T; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:2329](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L2329) Push some data for a given type into the store. This method expects normalized [JSON API](http://jsonapi.org/) document. This means you have to follow [JSON API specification](http://jsonapi.org/format/) with few minor adjustments: * record's `type` should always be in singular, dasherized form * members (properties) should be camelCased [Your primary data should be wrapped inside `data` property](http://jsonapi.org/format/#document-top-level): ```js store.push({ data: { // primary data for single record of type `Person` id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } } }); ``` [Demo.](http://ember-twiddle.com/fb99f18cd3b4d3e2a4c7) `data` property can also hold an array (of records): ```js store.push({ data: [ // an array of records { id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } }, { id: '2', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' } } ] }); ``` [Demo.](http://ember-twiddle.com/69cdbeaa3702159dc355) There are some typical properties for `JSONAPI` payload: * `id` - mandatory, unique record's key * `type` - mandatory string which matches `model`'s dasherized name in singular form * `attributes` - object which holds data for record attributes - `attr`'s declared in model * `relationships` - object which must contain any of the following properties under each relationships' respective key (example path is `relationships.achievements.data`): * [`links`](http://jsonapi.org/format/#document-links) * [`data`](http://jsonapi.org/format/#document-resource-object-linkage) - place for primary data * [`meta`](http://jsonapi.org/format/#document-meta) - object which contains meta-information about relationship For this model: ```js [app/models/person.js] import Model, { attr, hasMany } from '@ember-data/model'; export default class PersonRoute extends Route { @attr('string') firstName; @attr('string') lastName; @hasMany('person') children; } ``` To represent the children as IDs: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { data: [ { id: '2', type: 'person' }, { id: '3', type: 'person' }, { id: '4', type: 'person' } ] } } } } ``` [Demo.](http://ember-twiddle.com/343e1735e034091f5bde) To represent the children relationship as a URL: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { links: { related: '/people/1/children' } } } } } ``` If you're streaming data or implementing an adapter, make sure that you have converted the incoming data into this form. The store's [normalize](../methods/normalize?anchor=normalize) method is a convenience helper for converting a json payload into the form Ember Data expects. ```js store.push(store.normalize('person', data)); ``` This method can be used both to push in brand new records, as well as to update existing records. ##### Type Parameters ###### T `T` ##### Parameters ###### data [`SingleResourceDocument`](../types/spec/json-api-raw/type-aliases/SingleResourceDocument.md)<[`TypeFromInstance`](../types/record/type-aliases/TypeFromInstance.md)<`T`>> ##### Returns `T` the record(s) that was created or updated. #### Call Signature ```ts push(data): unknown; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:2330](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L2330) Push some data for a given type into the store. This method expects normalized [JSON API](http://jsonapi.org/) document. This means you have to follow [JSON API specification](http://jsonapi.org/format/) with few minor adjustments: * record's `type` should always be in singular, dasherized form * members (properties) should be camelCased [Your primary data should be wrapped inside `data` property](http://jsonapi.org/format/#document-top-level): ```js store.push({ data: { // primary data for single record of type `Person` id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } } }); ``` [Demo.](http://ember-twiddle.com/fb99f18cd3b4d3e2a4c7) `data` property can also hold an array (of records): ```js store.push({ data: [ // an array of records { id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } }, { id: '2', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' } } ] }); ``` [Demo.](http://ember-twiddle.com/69cdbeaa3702159dc355) There are some typical properties for `JSONAPI` payload: * `id` - mandatory, unique record's key * `type` - mandatory string which matches `model`'s dasherized name in singular form * `attributes` - object which holds data for record attributes - `attr`'s declared in model * `relationships` - object which must contain any of the following properties under each relationships' respective key (example path is `relationships.achievements.data`): * [`links`](http://jsonapi.org/format/#document-links) * [`data`](http://jsonapi.org/format/#document-resource-object-linkage) - place for primary data * [`meta`](http://jsonapi.org/format/#document-meta) - object which contains meta-information about relationship For this model: ```js [app/models/person.js] import Model, { attr, hasMany } from '@ember-data/model'; export default class PersonRoute extends Route { @attr('string') firstName; @attr('string') lastName; @hasMany('person') children; } ``` To represent the children as IDs: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { data: [ { id: '2', type: 'person' }, { id: '3', type: 'person' }, { id: '4', type: 'person' } ] } } } } ``` [Demo.](http://ember-twiddle.com/343e1735e034091f5bde) To represent the children relationship as a URL: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { links: { related: '/people/1/children' } } } } } ``` If you're streaming data or implementing an adapter, make sure that you have converted the incoming data into this form. The store's [normalize](../methods/normalize?anchor=normalize) method is a convenience helper for converting a json payload into the form Ember Data expects. ```js store.push(store.normalize('person', data)); ``` This method can be used both to push in brand new records, as well as to update existing records. ##### Parameters ###### data [`SingleResourceDocument`](../types/spec/json-api-raw/type-aliases/SingleResourceDocument.md) ##### Returns `unknown` the record(s) that was created or updated. #### Call Signature ```ts push(data): T[]; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:2331](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L2331) Push some data for a given type into the store. This method expects normalized [JSON API](http://jsonapi.org/) document. This means you have to follow [JSON API specification](http://jsonapi.org/format/) with few minor adjustments: * record's `type` should always be in singular, dasherized form * members (properties) should be camelCased [Your primary data should be wrapped inside `data` property](http://jsonapi.org/format/#document-top-level): ```js store.push({ data: { // primary data for single record of type `Person` id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } } }); ``` [Demo.](http://ember-twiddle.com/fb99f18cd3b4d3e2a4c7) `data` property can also hold an array (of records): ```js store.push({ data: [ // an array of records { id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } }, { id: '2', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' } } ] }); ``` [Demo.](http://ember-twiddle.com/69cdbeaa3702159dc355) There are some typical properties for `JSONAPI` payload: * `id` - mandatory, unique record's key * `type` - mandatory string which matches `model`'s dasherized name in singular form * `attributes` - object which holds data for record attributes - `attr`'s declared in model * `relationships` - object which must contain any of the following properties under each relationships' respective key (example path is `relationships.achievements.data`): * [`links`](http://jsonapi.org/format/#document-links) * [`data`](http://jsonapi.org/format/#document-resource-object-linkage) - place for primary data * [`meta`](http://jsonapi.org/format/#document-meta) - object which contains meta-information about relationship For this model: ```js [app/models/person.js] import Model, { attr, hasMany } from '@ember-data/model'; export default class PersonRoute extends Route { @attr('string') firstName; @attr('string') lastName; @hasMany('person') children; } ``` To represent the children as IDs: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { data: [ { id: '2', type: 'person' }, { id: '3', type: 'person' }, { id: '4', type: 'person' } ] } } } } ``` [Demo.](http://ember-twiddle.com/343e1735e034091f5bde) To represent the children relationship as a URL: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { links: { related: '/people/1/children' } } } } } ``` If you're streaming data or implementing an adapter, make sure that you have converted the incoming data into this form. The store's [normalize](../methods/normalize?anchor=normalize) method is a convenience helper for converting a json payload into the form Ember Data expects. ```js store.push(store.normalize('person', data)); ``` This method can be used both to push in brand new records, as well as to update existing records. ##### Type Parameters ###### T `T` ##### Parameters ###### data [`CollectionResourceDocument`](../types/spec/json-api-raw/type-aliases/CollectionResourceDocument.md)<[`TypeFromInstance`](../types/record/type-aliases/TypeFromInstance.md)<`T`>> ##### Returns `T`\[] the record(s) that was created or updated. #### Call Signature ```ts push(data): unknown[]; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:2332](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L2332) Push some data for a given type into the store. This method expects normalized [JSON API](http://jsonapi.org/) document. This means you have to follow [JSON API specification](http://jsonapi.org/format/) with few minor adjustments: * record's `type` should always be in singular, dasherized form * members (properties) should be camelCased [Your primary data should be wrapped inside `data` property](http://jsonapi.org/format/#document-top-level): ```js store.push({ data: { // primary data for single record of type `Person` id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } } }); ``` [Demo.](http://ember-twiddle.com/fb99f18cd3b4d3e2a4c7) `data` property can also hold an array (of records): ```js store.push({ data: [ // an array of records { id: '1', type: 'person', attributes: { firstName: 'Daniel', lastName: 'Kmak' } }, { id: '2', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' } } ] }); ``` [Demo.](http://ember-twiddle.com/69cdbeaa3702159dc355) There are some typical properties for `JSONAPI` payload: * `id` - mandatory, unique record's key * `type` - mandatory string which matches `model`'s dasherized name in singular form * `attributes` - object which holds data for record attributes - `attr`'s declared in model * `relationships` - object which must contain any of the following properties under each relationships' respective key (example path is `relationships.achievements.data`): * [`links`](http://jsonapi.org/format/#document-links) * [`data`](http://jsonapi.org/format/#document-resource-object-linkage) - place for primary data * [`meta`](http://jsonapi.org/format/#document-meta) - object which contains meta-information about relationship For this model: ```js [app/models/person.js] import Model, { attr, hasMany } from '@ember-data/model'; export default class PersonRoute extends Route { @attr('string') firstName; @attr('string') lastName; @hasMany('person') children; } ``` To represent the children as IDs: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { data: [ { id: '2', type: 'person' }, { id: '3', type: 'person' }, { id: '4', type: 'person' } ] } } } } ``` [Demo.](http://ember-twiddle.com/343e1735e034091f5bde) To represent the children relationship as a URL: ```js { data: { id: '1', type: 'person', attributes: { firstName: 'Tom', lastName: 'Dale' }, relationships: { children: { links: { related: '/people/1/children' } } } } } ``` If you're streaming data or implementing an adapter, make sure that you have converted the incoming data into this form. The store's [normalize](../methods/normalize?anchor=normalize) method is a convenience helper for converting a json payload into the form Ember Data expects. ```js store.push(store.normalize('person', data)); ``` This method can be used both to push in brand new records, as well as to update existing records. ##### Parameters ###### data [`CollectionResourceDocument`](../types/spec/json-api-raw/type-aliases/CollectionResourceDocument.md) ##### Returns `unknown`\[] the record(s) that was created or updated. *** ### query() #### Call Signature ```ts query( type, query, options?): Promise>; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:1745](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L1745) This method delegates a query to the adapter. This is the one place where adapter-level semantics are exposed to the application. Each time this method is called a new request is made through the adapter. Exposing queries this way seems preferable to creating an abstract query language for all server-side queries, and then require all adapters to implement them. *** If you do something like this: ```javascript store.query('person', { page: 1 }); ``` The request made to the server will look something like this: ``` GET "/api/v1/person?page=1" ``` *** If you do something like this: ```javascript store.query('person', { ids: ['1', '2', '3'] }); ``` The request made to the server will look something like this: ``` GET "/api/v1/person?ids%5B%5D=1&ids%5B%5D=2&ids%5B%5D=3" decoded: "/api/v1/person?ids[]=1&ids[]=2&ids[]=3" ``` This method returns a promise, which is resolved with a [`Collection`](/ember-data/release/classes/Collection) once the server returns. ##### Type Parameters ###### T `T` ##### Parameters ###### type [`TypeFromInstance`](../types/record/type-aliases/TypeFromInstance.md)<`T`> the name of the resource ###### query [`LegacyResourceQuery`](../types/type-aliases/LegacyResourceQuery.md)<`T`> a query to be used by the adapter ###### options? [`QueryOptions`](../types/type-aliases/QueryOptions.md) optional, may include `adapterOptions` hash which will be passed to adapter.query ##### Returns `Promise`<`Collection`<`T`>> promise ##### Since 1.13.0 #### Call Signature ```ts query( type, query, options?): Promise>; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:1746](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L1746) This method delegates a query to the adapter. This is the one place where adapter-level semantics are exposed to the application. Each time this method is called a new request is made through the adapter. Exposing queries this way seems preferable to creating an abstract query language for all server-side queries, and then require all adapters to implement them. *** If you do something like this: ```javascript store.query('person', { page: 1 }); ``` The request made to the server will look something like this: ``` GET "/api/v1/person?page=1" ``` *** If you do something like this: ```javascript store.query('person', { ids: ['1', '2', '3'] }); ``` The request made to the server will look something like this: ``` GET "/api/v1/person?ids%5B%5D=1&ids%5B%5D=2&ids%5B%5D=3" decoded: "/api/v1/person?ids[]=1&ids[]=2&ids[]=3" ``` This method returns a promise, which is resolved with a [`Collection`](/ember-data/release/classes/Collection) once the server returns. ##### Parameters ###### type `string` the name of the resource ###### query [`LegacyResourceQuery`](../types/type-aliases/LegacyResourceQuery.md) a query to be used by the adapter ###### options? [`QueryOptions`](../types/type-aliases/QueryOptions.md) optional, may include `adapterOptions` hash which will be passed to adapter.query ##### Returns `Promise`<`Collection`<`unknown`>> promise ##### Since 1.13.0 *** ### queryRecord() #### Call Signature ```ts queryRecord( type, query, options?): Promise; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:1868](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L1868) This method makes a request for one record, where the `id` is not known beforehand (if the `id` is known, use [`findRecord`](../methods/findRecord?anchor=findRecord) instead). This method can be used when it is certain that the server will return a single object for the primary data. Each time this method is called a new request is made through the adapter. Let's assume our API provides an endpoint for the currently logged in user via: ``` // GET /api/current_user { user: { id: 1234, username: 'admin' } } ``` Since the specific `id` of the `user` is not known beforehand, we can use `queryRecord` to get the user: ```javascript store.queryRecord('user', {}).then(function(user) { let username = user.username; // do thing }); ``` The request is made through the adapters' `queryRecord`: ```js [app/adapters/user.js] import Adapter from '@ember-data/adapter'; import $ from 'jquery'; export default class UserAdapter extends Adapter { queryRecord(modelName, query) { return $.getJSON('/api/current_user'); } } ``` Note: the primary use case for `store.queryRecord` is when a single record is queried and the `id` is not known beforehand. In all other cases `store.query` and using the first item of the array is likely the preferred way: ``` // GET /users?username=unique { data: [{ id: 1234, type: 'user', attributes: { username: "unique" } }] } ``` ```javascript store.query('user', { username: 'unique' }).then(function(users) { return users.firstObject; }).then(function(user) { let id = user.id; }); ``` This method returns a promise, which resolves with the found record. If the adapter returns no data for the primary data of the payload, then `queryRecord` resolves with `null`: ``` // GET /users?username=unique { data: null } ``` ```javascript store.queryRecord('user', { username: 'unique' }).then(function(user) { // user is null }); ``` ##### Type Parameters ###### T `T` ##### Parameters ###### type [`TypeFromInstance`](../types/record/type-aliases/TypeFromInstance.md)<`T`> ###### query [`LegacyResourceQuery`](../types/type-aliases/LegacyResourceQuery.md)<`T`> an opaque query to be used by the adapter ###### options? [`QueryOptions`](../types/type-aliases/QueryOptions.md) optional, may include `adapterOptions` hash which will be passed to adapter.queryRecord ##### Returns `Promise`<`null` | `T`> promise which resolves with the found record or `null` ##### Since 1.13.0 #### Call Signature ```ts queryRecord( type, query, options?): Promise; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:1869](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L1869) This method makes a request for one record, where the `id` is not known beforehand (if the `id` is known, use [`findRecord`](../methods/findRecord?anchor=findRecord) instead). This method can be used when it is certain that the server will return a single object for the primary data. Each time this method is called a new request is made through the adapter. Let's assume our API provides an endpoint for the currently logged in user via: ``` // GET /api/current_user { user: { id: 1234, username: 'admin' } } ``` Since the specific `id` of the `user` is not known beforehand, we can use `queryRecord` to get the user: ```javascript store.queryRecord('user', {}).then(function(user) { let username = user.username; // do thing }); ``` The request is made through the adapters' `queryRecord`: ```js [app/adapters/user.js] import Adapter from '@ember-data/adapter'; import $ from 'jquery'; export default class UserAdapter extends Adapter { queryRecord(modelName, query) { return $.getJSON('/api/current_user'); } } ``` Note: the primary use case for `store.queryRecord` is when a single record is queried and the `id` is not known beforehand. In all other cases `store.query` and using the first item of the array is likely the preferred way: ``` // GET /users?username=unique { data: [{ id: 1234, type: 'user', attributes: { username: "unique" } }] } ``` ```javascript store.query('user', { username: 'unique' }).then(function(users) { return users.firstObject; }).then(function(user) { let id = user.id; }); ``` This method returns a promise, which resolves with the found record. If the adapter returns no data for the primary data of the payload, then `queryRecord` resolves with `null`: ``` // GET /users?username=unique { data: null } ``` ```javascript store.queryRecord('user', { username: 'unique' }).then(function(user) { // user is null }); ``` ##### Parameters ###### type `string` ###### query [`LegacyResourceQuery`](../types/type-aliases/LegacyResourceQuery.md) an opaque query to be used by the adapter ###### options? [`QueryOptions`](../types/type-aliases/QueryOptions.md) optional, may include `adapterOptions` hash which will be passed to adapter.queryRecord ##### Returns `Promise`<`unknown`> promise which resolves with the found record or `null` ##### Since 1.13.0 *** ### ~~registerSchema()~~ ```ts registerSchema(schema): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:545](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L545) DEPRECATED - Use `createSchemaService` instead. Allows an app to register a custom SchemaService for use when information about a resource's schema needs to be queried. This method can only be called more than once, but only one schema definition service may exist. Therefore if you wish to chain services you must lookup the existing service and close over it with the new service by accessing `store.schema` prior to registration. For Example: ```ts import Store from '@ember-data/store'; class SchemaDelegator { constructor(schema) { this._schema = schema; } hasResource(resource: { type: string }): boolean { if (AbstractSchemas.has(resource.type)) { return true; } return this._schema.hasResource(resource); } attributesDefinitionFor(identifier: RecordIdentifier | { type: string }): AttributesSchema { return this._schema.attributesDefinitionFor(identifier); } relationshipsDefinitionFor(identifier: RecordIdentifier | { type: string }): RelationshipsSchema { const schema = AbstractSchemas.get(identifier.type); return schema || this._schema.relationshipsDefinitionFor(identifier); } } export default class extends Store { constructor(...args) { super(...args); const schema = this.schema; this.registerSchema(new SchemaDelegator(schema)); } } ``` #### Parameters ##### schema [`SchemaService`](../types/interfaces/SchemaService.md) #### Returns `void` #### Deprecated *** ### ~~registerSchemaDefinitionService()~~ ```ts registerSchemaDefinitionService(schema): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:490](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L490) DEPRECATED - Use `createSchemaService` instead. Allows an app to register a custom SchemaService for use when information about a resource's schema needs to be queried. This method can only be called more than once, but only one schema definition service may exist. Therefore if you wish to chain services you must lookup the existing service and close over it with the new service by accessing `store.schema` prior to registration. For Example: ```ts import Store from '@ember-data/store'; class SchemaDelegator { constructor(schema) { this._schema = schema; } hasResource(resource: { type: string }): boolean { if (AbstractSchemas.has(resource.type)) { return true; } return this._schema.hasResource(resource); } attributesDefinitionFor(identifier: RecordIdentifier | { type: string }): AttributesSchema { return this._schema.attributesDefinitionFor(identifier); } relationshipsDefinitionFor(identifier: RecordIdentifier | { type: string }): RelationshipsSchema { const schema = AbstractSchemas.get(identifier.type); return schema || this._schema.relationshipsDefinitionFor(identifier); } } export default class extends Store { constructor(...args) { super(...args); const schema = this.createSchemaService(); this.registerSchemaDefinitionService(new SchemaDelegator(schema)); } } ``` #### Parameters ##### schema [`SchemaService`](../types/interfaces/SchemaService.md) #### Returns `void` #### Deprecated *** ### request() ```ts request(requestConfig): Future; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:867](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L867) Issue a request via the configured RequestManager, inserting the response into the cache and handing back a Future which resolves to a ResponseDocument ## Cache Keys Only GET requests with a url or requests with an explicit cache key (`cacheOptions.key`) will have the request result and document cached. The cache key used is `requestConfig.cacheOptions.key` if present, falling back to `requestConfig.url`. Params are not serialized as part of the cache-key, so either ensure they are already in the url or utilize `requestConfig.cacheOptions.key`. For queries issued via the `POST` method `requestConfig.cacheOptions.key` MUST be supplied for the document to be cached. ## Requesting Without a Cache Key Resource data within the request is always updated in the cache, regardless of whether a cache key is present for the request. ## Fulfilling From Cache When a cache-key is determined, the request may fulfill from cache provided the cache is not stale. Cache staleness is determined by the configured CachePolicy with priority given to the `cacheOptions.reload` and `cacheOptions.backgroundReload` on the request if present. If the cache data has soft expired or the request asks for a background reload, the request will fulfill from cache if possible and make a non-blocking request in the background to update the cache. If the cache data has hard expired or the request asks for a reload, the request will not fulfill from cache and will make a blocking request to update the cache. ## The Response The primary difference between `requestManager.request` and `store.request` is that `store.request` will attempt to hydrate the response content into a response Document containing RecordInstances. #### Type Parameters ##### RT `RT` ##### T `T` = `unknown` #### Parameters ##### requestConfig [`StoreRequestInput`](../type-aliases/StoreRequestInput.md)<`RT`, `T`> #### Returns [`Future`](../request/interfaces/Future.md)<`RT`> *** ### saveRecord() ```ts saveRecord(record, options): Promise; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:2389](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L2389) Trigger a save for a Record. Returns a promise resolving with the same record when the save is complete. #### Type Parameters ##### T `T` #### Parameters ##### record `T` ##### options `Record`<`string`, `unknown`> = `{}` #### Returns `Promise`<`T`> *** ### teardownRecord() ```ts teardownRecord(record): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:361](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L361) This is the hook WarpDrive uses to remove a record instance that is no longer needed #### Parameters ##### record `unknown` #### Returns `void` *** ### unloadAll() #### Call Signature ```ts unloadAll(type): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:2152](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L2152) This method unloads all records in the store. It schedules unloading to happen during the next run loop. Optionally you can pass a type which unload all records for a given type. ```javascript store.unloadAll(); store.unloadAll('post'); ``` ##### Type Parameters ###### T `T` ##### Parameters ###### type [`TypeFromInstance`](../types/record/type-aliases/TypeFromInstance.md)<`T`> the name of the resource ##### Returns `void` #### Call Signature ```ts unloadAll(type?): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:2153](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L2153) This method unloads all records in the store. It schedules unloading to happen during the next run loop. Optionally you can pass a type which unload all records for a given type. ```javascript store.unloadAll(); store.unloadAll('post'); ``` ##### Parameters ###### type? `string` the name of the resource ##### Returns `void` *** ### unloadRecord() ```ts unloadRecord(record): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:1132](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L1132) For symmetry, a record can be unloaded via the store. This will cause the record to be destroyed and freed up for garbage collection. Example ```javascript const { content: { data: post } } = await store.request(findRecord({ type: 'post', id: '1' })); store.unloadRecord(post); ``` #### Type Parameters ##### T `T` #### Parameters ##### record `T` #### Returns `void` *** ### create() ```ts static create(args?): Store; ``` Defined in: [warp-drive-packages/core/src/store/-private/store-service.ts:2484](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/store-service.ts#L2484) #### Parameters ##### args? `Record`<`string`, `unknown`> #### Returns `Store` --- --- url: /api/@warp-drive/core/functions/recordIdentifierFor.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / recordIdentifierFor ## Call Signature ```ts function recordIdentifierFor(record): StableRecordIdentifier>; ``` Defined in: [warp-drive-packages/core/src/store/-private/caches/instance-cache.ts:62](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/caches/instance-cache.ts#L62) Retrieves the unique referentially-stable [RecordIdentifier](/ember-data/release/classes/StableRecordIdentifier) assigned to the given record instance. ```js import { recordIdentifierFor } from "@ember-data/store"; // ... gain access to a record, for instance with peekRecord or findRecord const record = store.peekRecord("user", "1"); // get the identifier for the record (see docs for StableRecordIdentifier) const identifier = recordIdentifierFor(record); // access the identifier's properties. const { id, type, lid } = identifier; ``` ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../types/record/interfaces/TypedRecordInstance.md) ### Parameters #### record `T` a record instance previously obstained from the store. ### Returns [`StableRecordIdentifier`](../types/identifier/type-aliases/StableRecordIdentifier.md)<[`TypeFromInstance`](../types/record/type-aliases/TypeFromInstance.md)<`T`>> ## Call Signature ```ts function recordIdentifierFor(record): StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/store/-private/caches/instance-cache.ts:65](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/caches/instance-cache.ts#L65) Retrieves the unique referentially-stable [RecordIdentifier](/ember-data/release/classes/StableRecordIdentifier) assigned to the given record instance. ```js import { recordIdentifierFor } from "@ember-data/store"; // ... gain access to a record, for instance with peekRecord or findRecord const record = store.peekRecord("user", "1"); // get the identifier for the record (see docs for StableRecordIdentifier) const identifier = recordIdentifierFor(record); // access the identifier's properties. const { id, type, lid } = identifier; ``` ### Parameters #### record `unknown` a record instance previously obstained from the store. ### Returns [`StableRecordIdentifier`](../types/identifier/type-aliases/StableRecordIdentifier.md) --- --- url: /api/@warp-drive/core/functions/setIdentifierForgetMethod.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / setIdentifierForgetMethod ```ts function setIdentifierForgetMethod(method): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/caches/identifier-cache.ts:113](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/caches/identifier-cache.ts#L113) ## Parameters ### method `null` | `ForgetMethod` ## Returns `void` --- --- url: /api/@warp-drive/core/functions/setIdentifierGenerationMethod.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / setIdentifierGenerationMethod ```ts function setIdentifierGenerationMethod(method): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/caches/identifier-cache.ts:105](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/caches/identifier-cache.ts#L105) ## Parameters ### method `null` | `GenerationMethod` ## Returns `void` --- --- url: /api/@warp-drive/core/functions/setIdentifierResetMethod.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / setIdentifierResetMethod ```ts function setIdentifierResetMethod(method): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/caches/identifier-cache.ts:117](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/caches/identifier-cache.ts#L117) ## Parameters ### method `null` | `ResetMethod` ## Returns `void` --- --- url: /api/@warp-drive/core/functions/setIdentifierUpdateMethod.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / setIdentifierUpdateMethod ```ts function setIdentifierUpdateMethod(method): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/caches/identifier-cache.ts:109](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/caches/identifier-cache.ts#L109) ## Parameters ### method `null` | `UpdateMethod` ## Returns `void` --- --- url: /api/@warp-drive/core/functions/setKeyInfoForResource.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / setKeyInfoForResource ```ts function setKeyInfoForResource(method): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/caches/identifier-cache.ts:121](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/caches/identifier-cache.ts#L121) ## Parameters ### method `null` | `KeyInfoMethod` ## Returns `void` --- --- url: /api/@warp-drive/core/functions/storeFor.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / storeFor ```ts function storeFor(record): undefined | Store; ``` Defined in: [warp-drive-packages/core/src/store/-private/caches/instance-cache.ts:91](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/caches/instance-cache.ts#L91) ## Parameters ### record `unknown` ## Returns `undefined` | [`Store`](../classes/Store.md) --- --- url: /api/@warp-drive/core/interfaces/StoreRequestContext.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / StoreRequestContext Defined in: [warp-drive-packages/core/src/store/-private/cache-handler/handler.ts:37](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/cache-handler/handler.ts#L37) ## Extends * [`RequestContext`](../types/request/interfaces/RequestContext.md) ## Properties ### id ```ts id: number; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:342](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L342) #### Inherited from [`RequestContext`](../types/request/interfaces/RequestContext.md).[`id`](../types/request/interfaces/RequestContext.md#id) *** ### request ```ts request: Readonly, "controller">> & object & object; ``` Defined in: [warp-drive-packages/core/src/store/-private/cache-handler/handler.ts:38](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/cache-handler/handler.ts#L38) #### Type declaration ##### bodyUsed? ```ts readonly optional bodyUsed: boolean; ``` Whether the request body has been read. ##### cacheOptions? ```ts readonly optional cacheOptions: Readonly>; ``` ##### data? ```ts readonly optional data: Readonly>; ``` ##### headers? ```ts readonly optional headers: ImmutableHeaders; ``` ##### options? ```ts readonly optional options: Readonly>; ``` #### Type declaration ##### store ```ts store: Store; ``` #### See [ImmutableRequestInfo](../types/request/type-aliases/ImmutableRequestInfo.md) #### Overrides [`RequestContext`](../types/request/interfaces/RequestContext.md).[`request`](../types/request/interfaces/RequestContext.md#request) ## Methods ### setResponse() ```ts setResponse(response): void; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:345](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L345) #### Parameters ##### response `null` | `Response` | [`ResponseInfo`](../types/request/interfaces/ResponseInfo.md) #### Returns `void` #### Inherited from [`RequestContext`](../types/request/interfaces/RequestContext.md).[`setResponse`](../types/request/interfaces/RequestContext.md#setresponse) *** ### setStream() ```ts setStream(stream): void; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:344](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L344) #### Parameters ##### stream `ReadableStream`<`any`> | `Promise`<`null` | `ReadableStream`<`any`>> #### Returns `void` #### Inherited from [`RequestContext`](../types/request/interfaces/RequestContext.md).[`setStream`](../types/request/interfaces/RequestContext.md#setstream) --- --- url: /api/@warp-drive/core/interfaces/CachePolicy.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / CachePolicy Defined in: [warp-drive-packages/core/src/store/-private/cache-handler/types.ts:19](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/cache-handler/types.ts#L19) A service which an application may provide to the store via the store's `lifetimes` property to configure the behavior of the CacheHandler. The default behavior for request lifetimes is to never expire unless manually refreshed via `cacheOptions.reload` or `cacheOptions.backgroundReload`. Implementing this service allows you to programatically define when a request should be considered expired. (Interface) CachePolicy ## Methods ### didRequest()? ```ts optional didRequest( request, response, identifier, store): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/cache-handler/types.ts:100](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/cache-handler/types.ts#L100) Invoked when a request has been fulfilled from the configured request handlers. This is invoked for both foreground and background requests once the cache has been updated. Note, this is invoked regardless of whether the request has a cache-key. It is best practice to notify the store of any requests marked as invalidated so that request subscriptions can reload when needed. ```ts store.notifications.notify(identifier, 'invalidated'); ``` This allows anything subscribed to the request to be notified of the change e.g. ```ts store.notifications.subscribe(identifier, (_, type) => { if (type === 'invalidated') { // do update } }); ``` #### Parameters ##### request [`ImmutableRequestInfo`](../types/request/type-aliases/ImmutableRequestInfo.md) ##### response `null` | `Response` | [`ResponseInfo`](../types/request/interfaces/ResponseInfo.md) ##### identifier `null` | [`StableDocumentIdentifier`](../types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store [`Store`](../classes/Store.md) #### Returns `void` *** ### isHardExpired() ```ts isHardExpired(identifier, store): boolean; ``` Defined in: [warp-drive-packages/core/src/store/-private/cache-handler/types.ts:35](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/cache-handler/types.ts#L35) Invoked to determine if the request may be fulfilled from cache if possible. Note, this is only invoked if the request has a cache-key. If no cache entry is found or the entry is hard expired, the request will be fulfilled from the configured request handlers and the cache will be updated before returning the response. #### Parameters ##### identifier [`StableDocumentIdentifier`](../types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store [`Store`](../classes/Store.md) #### Returns `boolean` true if the request is considered hard expired *** ### isSoftExpired() ```ts isSoftExpired(identifier, store): boolean; ``` Defined in: [warp-drive-packages/core/src/store/-private/cache-handler/types.ts:50](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/cache-handler/types.ts#L50) Invoked if `isHardExpired` is false to determine if the request should be update behind the scenes if cache data is already available. Note, this is only invoked if the request has a cache-key. If true, the request will be fulfilled from cache while a backgrounded request is made to update the cache via the configured request handlers. #### Parameters ##### identifier [`StableDocumentIdentifier`](../types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store [`Store`](../classes/Store.md) #### Returns `boolean` true if the request is considered soft expired *** ### willRequest()? ```ts optional willRequest( request, identifier, store): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/cache-handler/types.ts:64](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/cache-handler/types.ts#L64) Invoked when a request will be sent to the configured request handlers. This is invoked for both foreground and background requests. Note, this is invoked regardless of whether the request has a cache-key. #### Parameters ##### request [`ImmutableRequestInfo`](../types/request/type-aliases/ImmutableRequestInfo.md) ##### identifier `null` | [`StableDocumentIdentifier`](../types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store [`Store`](../classes/Store.md) #### Returns `void` --- --- url: /api/@warp-drive/core/reactive/classes/SchemaRecord.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [reactive](../index.md) / SchemaRecord Defined in: [warp-drive-packages/core/src/reactive/-private/record.ts:78](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/record.ts#L78) A class that uses a the ResourceSchema for a ResourceType and a ResouceKey to transform data from the cache into a rich, reactive object. This class is not directly instantiable. To use it, you should configure the store's `instantiateRecord` and `teardownRecord` hooks with the matching hooks provided by this package. ## Properties ### \[toStringTag] ```ts [toStringTag]: `SchemaRecord<${string}>`; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/record.ts:93](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/record.ts#L93) ## Methods ### \_\_\_(unique) Symbol(Checkout)() ```ts ___(unique) Symbol(Checkout)(): Promise; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/record.ts:744](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/record.ts#L744) Create an editable copy of the record SchemaRecord instances are not editable by default. This method creates an editable copy of the record. To use, import the `Checkout` symbol from `@warp-drive/schema-record` and call it on the record. ```ts import { Checkout } from '@warp-drive/schema-record'; const record = store.peekRecord('user', '1'); const editableRecord = await record[Checkout](); ``` #### Returns `Promise`<`SchemaRecord`> a promise that resolves to the editable record #### Throws if the record is already editable or if the record is embedded --- --- url: /api/@warp-drive/core/reactive/classes/SchemaService.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [reactive](../index.md) / SchemaService Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:216](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L216) A SchemaService designed to work with dynamically registered schemas. SchemaService ## Implements * [`SchemaService`](../../types/interfaces/SchemaService.md) ## Constructors ### Constructor ```ts new SchemaService(): SchemaService; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:243](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L243) #### Returns `SchemaService` ## Methods ### ~~attributesDefinitionFor()~~ ```ts attributesDefinitionFor(identifier): Record; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:218](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L218) DEPRECATED - use `fields` instead Returns definitions for all properties of the specified resource that are considered "attributes". Generally these are properties that are not related to book-keeping state on the client and do not represent a linkage to another resource. The return value should be a dictionary of key:value pairs where the `key` is the attribute or property's name and `value` is an object with at least the property `name` which should also match `key`. Optionally, this object may also specify `type`, which should be a string reference to a `transform`, and `options` which should be dictionary in which any key:value pairs are permissable. For instance, when using `@ember-data/model`, the following attribute definition: ```ts class extends Model { @attr('string', { defaultValue: 'hello' }) greeting; @attr('date') birthday; @attr firstName; } ``` Would be returned as: ```js { greeting: { name: 'greeting', type: 'string', options: { defaultValue: 'hello' } }, birthday: { name: 'birthday', type: 'date' }, firstName: { name: 'firstName' } } ``` #### Parameters ##### identifier ###### type `string` #### Returns `Record`<`string`, [`LegacyAttributeField`](../../types/schema/fields/interfaces/LegacyAttributeField.md)> #### Deprecated *** ### derivation() ```ts derivation(field): Derivation; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:279](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L279) Returns the derivation registered with the name provided by `field.type`. Validates that the field is a valid DerivedField. #### Parameters ##### field [`DerivedField`](../../types/schema/fields/interfaces/DerivedField.md) | { `type`: `string`; } #### Returns [`Derivation`](../../types/schema/concepts/type-aliases/Derivation.md) *** ### ~~doesTypeExist()~~ ```ts doesTypeExist(type): boolean; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:217](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L217) DEPRECATED - use `hasResource` instead Queries whether the SchemaService recognizes `type` as a resource type #### Parameters ##### type `string` #### Returns `boolean` #### Deprecated *** ### fields() ```ts fields(resource): Map; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:396](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L396) Queries for the fields of a given resource type or resource identity. Should error if the resource type is not recognized. #### Parameters ##### resource ###### type `string` #### Returns `Map`<`string`, [`FieldSchema`](../../types/schema/fields/type-aliases/FieldSchema.md)> *** ### hashFn() ```ts hashFn(field): HashFn; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:296](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L296) Returns the hash function registered with the name provided by `field.type`. Validates that the field is a valid HashField. #### Parameters ##### field [`HashField`](../../types/schema/fields/interfaces/HashField.md) | { `type`: `string`; } #### Returns [`HashFn`](../../types/schema/concepts/type-aliases/HashFn.md) *** ### hasResource() ```ts hasResource(resource): boolean; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:406](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L406) Queries whether the SchemaService recognizes `type` as a resource type #### Parameters ##### resource ###### type `string` #### Returns `boolean` *** ### hasTrait() ```ts hasTrait(type): boolean; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:256](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L256) Queries whether the SchemaService recognizes `type` as a resource trait #### Parameters ##### type `string` #### Returns `boolean` *** ### registerDerivation() ```ts registerDerivation(derivation): void; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:354](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L354) Enables registration of a derivation. The derivation can later be retrieved by the name attached to it's `[Type]` property. #### Type Parameters ##### R `R` ##### T `T` ##### FM `FM` *extends* `null` | [`ObjectValue`](../../types/json/raw/interfaces/ObjectValue.md) #### Parameters ##### derivation [`Derivation`](../../types/schema/concepts/type-aliases/Derivation.md)<`R`, `T`, `FM`> #### Returns `void` *** ### registerHashFn() ```ts registerHashFn(hashFn): void; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:392](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L392) Enables registration of a hashing function The hashing function can later be retrieved by the name attached to it's `[Type]` property. #### Type Parameters ##### T `T` *extends* `object` #### Parameters ##### hashFn [`HashFn`](../../types/schema/concepts/type-aliases/HashFn.md)<`T`> #### Returns `void` *** ### registerResource() ```ts registerResource(schema): void; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:322](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L322) Enables registration of a single Schema representing either a resource in PolarisMode or LegacyMode or an ObjectSchema representing an embedded structure in other schemas. This can be useful for either pre-loading schema information or for registering schema information delivered by API calls or other sources just-in-time. #### Parameters ##### schema [`ResourceSchema`](../../types/schema/fields/type-aliases/ResourceSchema.md) | [`ObjectSchema`](../../types/schema/fields/interfaces/ObjectSchema.md) #### Returns `void` *** ### registerResources() ```ts registerResources(schemas): void; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:317](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L317) Enables registration of multiple Schemas at once. This can be useful for either pre-loading schema information or for registering schema information delivered by API calls or other sources just-in-time. #### Parameters ##### schemas ( | [`ResourceSchema`](../../types/schema/fields/type-aliases/ResourceSchema.md) | [`ObjectSchema`](../../types/schema/fields/interfaces/ObjectSchema.md))\[] #### Returns `void` *** ### registerTransformation() ```ts registerTransformation(transformation): void; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:350](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L350) Enables registration of a transformation. The transformation can later be retrieved by the name attached to it's `[Type]` property. #### Type Parameters ##### T `T` *extends* [`Value`](../../types/json/raw/type-aliases/Value.md) = `string` ##### PT `PT` = `unknown` #### Parameters ##### transformation [`Transformation`](../type-aliases/Transformation.md)<`T`, `PT`> #### Returns `void` *** ### ~~relationshipsDefinitionFor()~~ ```ts relationshipsDefinitionFor(identifier): Record; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:219](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L219) DEPRECATED - use `fields` instead Returns definitions for all properties of the specified resource that are considered "relationships". Generally these are properties that represent a linkage to another resource. The return value should be a dictionary of key:value pairs where the `key` is the relationship or property's name and `value` is an object with at least the following properties: * `name` which should also match the `key` used in the dictionary. * `kind` which should be either `belongsTo` or `hasMany` * `type` which should be the related resource's string "type" * `options` which should be a dictionary allowing any key but with at least the below keys present. * `options.async` a boolean representing whether data for this relationship is typically loaded on-demand. * `options.inverse` a string or null representing the field name / key of the corresponding relationship on the inverse resource. Additionally the following options properties are optional. See [Polymorphic Relationships](https://rfcs.emberjs.com/id/0793-polymporphic-relations-without-inheritance) * `options.polymorphic` a boolean representing whether multiple resource types can be used to satisfy this relationship. * `options.as` a string representing the abstract type that the concrete side of a relationship must specify when fulfilling a polymorphic inverse. For example, the following Model using @ember-data/model would generate this relationships definition by default: ```js class User extends Model { @belongsTo('user', { async: false, inverse: null }) bestFriend; @hasMany('user', { async: true, inverse: 'friends' }) friends; @hasMany('pet', { async: false, polymorphic: true, inverse: 'owner' }) pets; } ``` Which would be returned as ```js { bestFriend: { name: 'bestFriend', kind: 'belongsTo', type: 'user', options: { async: false, inverse: null } }, friends: { name: 'friends', kind: 'hasMany', type: 'user', options: { async: true, inverse: 'friends' } }, pets: { name: 'pets', kind: 'hasMany', type: 'pet', options: { async: false, polymorphic: true, inverse: 'owner' } }, } ``` #### Parameters ##### identifier ###### type `string` #### Returns `Record`<`string`, [`LegacyRelationshipField`](../../types/schema/fields/type-aliases/LegacyRelationshipField.md)> #### Deprecated *** ### resource() ```ts resource(resource): | ResourceSchema | ObjectSchema; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:313](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L313) Returns the schema for the provided resource type. #### Parameters ##### resource [`StableRecordIdentifier`](../../types/identifier/type-aliases/StableRecordIdentifier.md) | { `type`: `string`; } #### Returns | [`ResourceSchema`](../../types/schema/fields/type-aliases/ResourceSchema.md) | [`ObjectSchema`](../../types/schema/fields/interfaces/ObjectSchema.md) *** ### resourceHasTrait() ```ts resourceHasTrait(resource, trait): boolean; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:259](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L259) Queries whether the given resource has the given trait #### Parameters ##### resource [`StableRecordIdentifier`](../../types/identifier/type-aliases/StableRecordIdentifier.md) | { `type`: `string`; } ##### trait `string` #### Returns `boolean` *** ### resourceTypes() ```ts resourceTypes(): readonly string[]; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:252](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L252) Returns all known resource types #### Returns readonly `string`\[] *** ### transformation() ```ts transformation(field): Transformation; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:262](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L262) Returns the transformation registered with the name provided by `field.type`. Validates that the field is a valid transformable. #### Parameters ##### field [`GenericField`](../../types/schema/fields/interfaces/GenericField.md) | [`ObjectField`](../../types/schema/fields/interfaces/ObjectField.md) | [`ArrayField`](../../types/schema/fields/interfaces/ArrayField.md) | { `type`: `string`; } #### Returns [`Transformation`](../type-aliases/Transformation.md) --- --- url: /api/@warp-drive/core/reactive/functions/fromIdentity.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [reactive](../index.md) / fromIdentity ## Call Signature ```ts function fromIdentity( record, options, key): string; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:116](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L116) A derivation that computes its value from the record's identity. It can be used via a derived field definition like: ```ts { kind: 'derived', name: 'id', type: '@identity', options: { key: 'id' } } ``` Valid keys are `'id'`, `'lid'`, `'type'`, and `'^'`. `^` returns the entire identifier object. ### Parameters #### record [`SchemaRecord`](../classes/SchemaRecord.md) #### options { `key`: `"lid"`; } | { `key`: `"type"`; } #### key `string` ### Returns `string` ## Call Signature ```ts function fromIdentity( record, options, key): null | string; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:117](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L117) A derivation that computes its value from the record's identity. It can be used via a derived field definition like: ```ts { kind: 'derived', name: 'id', type: '@identity', options: { key: 'id' } } ``` Valid keys are `'id'`, `'lid'`, `'type'`, and `'^'`. `^` returns the entire identifier object. ### Parameters #### record [`SchemaRecord`](../classes/SchemaRecord.md) #### options ##### key `"id"` #### key `string` ### Returns `null` | `string` ## Call Signature ```ts function fromIdentity( record, options, key): StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:118](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L118) A derivation that computes its value from the record's identity. It can be used via a derived field definition like: ```ts { kind: 'derived', name: 'id', type: '@identity', options: { key: 'id' } } ``` Valid keys are `'id'`, `'lid'`, `'type'`, and `'^'`. `^` returns the entire identifier object. ### Parameters #### record [`SchemaRecord`](../classes/SchemaRecord.md) #### options ##### key `"^"` #### key `string` ### Returns [`StableRecordIdentifier`](../../types/identifier/type-aliases/StableRecordIdentifier.md) ## Call Signature ```ts function fromIdentity( record, options, key): asserts options; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:119](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L119) A derivation that computes its value from the record's identity. It can be used via a derived field definition like: ```ts { kind: 'derived', name: 'id', type: '@identity', options: { key: 'id' } } ``` Valid keys are `'id'`, `'lid'`, `'type'`, and `'^'`. `^` returns the entire identifier object. ### Parameters #### record [`SchemaRecord`](../classes/SchemaRecord.md) #### options `null` #### key `string` ### Returns `asserts options` --- --- url: /api/@warp-drive/core/reactive/functions/instantiateRecord.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [reactive](../index.md) / instantiateRecord ```ts function instantiateRecord( store, identifier, createArgs?): SchemaRecord; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/hooks.ts:10](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/hooks.ts#L10) ## Parameters ### store [`Store`](../../classes/Store.md) ### identifier [`StableRecordIdentifier`](../../types/identifier/type-aliases/StableRecordIdentifier.md) ### createArgs? `Record`<`string`, `unknown`> ## Returns [`SchemaRecord`](../classes/SchemaRecord.md) --- --- url: /api/@warp-drive/core/reactive/functions/registerDerivations.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [reactive](../index.md) / registerDerivations ```ts function registerDerivations(schema): void; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:147](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L147) Registers the default derivations for records that want to use the PolarisMode defaults provided by ```ts import { withDefaults } from '@warp-drive/schema-record'; ``` ## Parameters ### schema [`SchemaService`](../../types/interfaces/SchemaService.md) ## Returns `void` --- --- url: /api/@warp-drive/core/reactive/functions/teardownRecord.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [reactive](../index.md) / teardownRecord ```ts function teardownRecord(record): void; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/hooks.ts:36](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/hooks.ts#L36) ## Parameters ### record `unknown` ## Returns `void` --- --- url: /api/@warp-drive/core/reactive/functions/withDefaults.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [reactive](../index.md) / withDefaults ```ts function withDefaults(schema): ResourceSchema; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:84](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L84) Utility for constructing a ResourceSchema with the recommended fields for the PolarisMode experience. Using this requires registering the PolarisMode derivations ```ts import { registerDerivations } from '@warp-drive/schema-record'; registerDerivations(schema); ``` ## Parameters ### schema [`WithPartial`](../../types/utils/type-aliases/WithPartial.md)<[`PolarisResourceSchema`](../../types/schema/fields/interfaces/PolarisResourceSchema.md), `"identity"`> ## Returns [`ResourceSchema`](../../types/schema/fields/type-aliases/ResourceSchema.md) --- --- url: /api/@warp-drive/core/reactive.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / reactive SchemaRecord is a reactive object that transforms raw data from an Cache | associated cache into reactive data backed by Signals. The shape of the object and the transformation of raw cache data into its reactive form is controlled by a resource schema. Resource schemas are simple JSON, allowing them to be defined and delivered from anywhere. The capabilities that SchemaRecord brings to [*Warp***Drive**](https://github.com/emberjs/data/) will simplify even the most complex parts of your app's state management. ## Installation Install using your javascript package manager of choice. For instance with [pnpm](https://pnpm.io/) ```cli pnpm add @warp-drive/schema-record ``` *** ## Getting Started If this package is how you are first learning about WarpDrive/EmberData, we recommend starting with learning about [Requests](../modules/@ember-data%2Frequest) and the [Store](../modules/@ember-data%2Fstore). *** ## 🚀 Setup SchemaRecord integrates with WarpDrive via the Store's resource lifecycle hooks. When WarpDrive needs to create a new record instance to give reactive access to a resource in the cache, it calls `instantiateRecord`. When it no longer needs that instance, it will call `teardownRecord`. ```diff import Store from '@ember-data/store'; +import { instantiateRecord, teardownRecord, registerDerivations, SchemaService } from '@warp-drive/schema-record'; class AppStore extends Store { + createSchemaService() { + const schema = new SchemaService(); + registerDerivations(schema); + return schema; + } + instantiateRecord(identifier, createArgs) { + return instantiateRecord(this, identifier, createArgs); + } + teardownRecord(record) { + return teardownRecord(record); + } } ``` Any Store API that returns a record instance will use the `instantiateRecord` hook configured above to instantiate a SchemaRecord once this is in place. After that, its up to you what SchemaRecord can do. *** ## Start Using ### Modes SchemaRecord has two modes: `legacy` and `polaris`. **LegacyMode** can be used to emulate the behaviors and capabilities of WarpDrive's `Model` class, and because there is little distinction between Model and SchemaRecord in LegacyMode we refer to both of these approaches as LegacyMode. This mode is the default experience in V5. In LegacyMode: * records are mutable * local changes immediately reflect app wide * records have all the APIs of Model (references, state props, currentState, methods etc) * the continued use of `@ember-data/model` and `@ember-data/legacy-compat` packages is required (though most imports from them can be removed) * `async: true` relationships are supported (but not recommended outside of [LinksMode](https://github.com/emberjs/data/blob/main/guides/relationships/features/links-mode.md)) *** **PolarisMode** is an upcoming suite of features that will become the default experience in V6. In PolarisMode: * records are immutable, unless creating a new resource or explicitly checking out a record for editing * local changes are isolated until committed, displaying only via the editable version of the record * records have a more limited API, focused on only what is in their schema. * some common operations may have more friction to perform because intended utilities are not yet available * `async: true` relationships are not supported (see [LinksMode](https://github.com/emberjs/data/blob/main/guides/relationships/features/links-mode.md)) * `@ember-data/model` and `@ember-data/legacy-compat` packages are not required These modes are interopable. The reactive object (record) for a resource in PolarisMode can relate to a record in LegacyMode and vice-versa. This interopability is true whether the record in LegacyMode is a SchemaRecord or a Model. *** ### About SchemaRecord is a reactive object that transforms raw data from an associated cache into reactive data backed by Signals. The shape of the object and the transformation of raw cache data into its reactive form is controlled by a resource schema. For instance, lets say your API is a [{JSON:API}](https://jsonapi.org) and your store is using the Cache provided by [@ember-data/json-api](../modules/@ember-data%2Fjson-api), and a request returns the following raw data: ```ts { data: { type: 'user', id: '1', attributes: { firstName: 'Chris', lastName: 'Thoburn' }, relationships: { pets: { data: [{ type: 'dog', id: '1' }] }} }, included: [ { type: 'dog', id: '1', attributes: { name: 'Rey' }, relationships: { owner: { data: { type: 'user', id: '1' }}} } ] } ``` We could describe the `'user'` and `'dog'` resources in the above payload with the following schemas: ```ts store.schema.registerResources([ { type: 'user', identity: { type: '@id', name: 'id' }, fields: [ { type: '@identity', name: '$type', kind: 'derived', options: { key: 'type' }, }, { kind: 'field', name: 'firstName' }, { kind: 'field', name: 'lastName' }, { kind: 'derived', name: 'name', type: 'concat', options: { fields: ['firstName', 'lastName'], separator: ' ' } }, { kind: 'hasMany', name: 'pets', type: 'pet', options: { async: false, inverse: 'owner', polymorphic: true, linksMode: true, } } ] }, { type: 'dog', identity: { type: '@id', name: 'id' }, fields: [ { type: '@identity', name: '$type', kind: 'derived', options: { key: 'type' }, }, { kind: 'field', name: 'name' }, { kind: 'belongsTo', name: 'owner', type: 'user', options: { async: false, inverse: 'pets', as: 'pet', linksMode: true, } } ] } ]); ``` With these schemas in place, the reactive objects that the store would provide us whenever we encountered a `'user'` or a `'dog'` would be: ```ts interface Pet { readonly id: string; readonly owner: User; } interface Dog extends Pet { readonly $type: 'dog'; readonly name: string; } interface EditableUser { readonly $type: 'user'; readonly id: string; firstName: string; lastName: string; readonly name: string; pets: Array; } interface User { readonly $type: 'user'; readonly id: string; readonly firstName: string; readonly lastName: string; readonly name: string; readonly pets: Readonly>; [Checkout]: Promise }> ``` Note how based on the schema the reactive object we receive is able to produce `name` on user (despite no name field being in the cache), provide `$type` pulled from the identity of the resource, and flatten the individual attributes and relationships onto the record for easier use. Notice also how we typed this object with `readonly`. This is because while SchemaRecord instances are ***deeply reactive***, they are also ***immutable***. We can mutate a SchemaRecord only be explicitly asking permission to do so, and in the process gaining access to an editable copy. The immutable version will not show any in-process edits made to this editable copy. ```ts import { Checkout } from '@warp-drive/schema-record'; const editable = await user[Checkout](); ``` *** ### Utilities SchemaRecord provides a schema builder that simplifies setting up a couple of conventional fields like identity and `$type`. We can rewrite the schema definition above using this utility like so: ```ts import { withDefaults } from '@warp-drive/schema-record'; store.schema.registerResources([ withDefaults({ type: 'user', fields: [ { kind: 'field', name: 'firstName' }, { kind: 'field', name: 'lastName' }, { kind: 'derived', name: 'name', type: 'concat', options: { fields: ['firstName', 'lastName'], separator: ' ' } }, { kind: 'hasMany', name: 'pets', type: 'pet', options: { async: false, inverse: 'owner', polymorphic: true, linksMode: true, resetOnRemoteUpdate: false, } } ] }), withDefaults({ type: 'dog', fields: [ { kind: 'field', name: 'name' }, { kind: 'belongsTo', name: 'owner', type: 'user', options: { async: false, inverse: 'pets', as: 'pet', linksMode: true, resetOnRemoteUpdate: false, } } ] }) ]); ``` Additionally, `@warp-drive/core-types` provides several utilities for type-checking and narrowing schemas. * PolarisResourceSchema * LegacyResourceSchema * ObjectSchema * resourceSchema * objectSchema * isResourceSchema * isLegacyResourceSchema *** ### Field Schemas LegacyMode * LegacyModeFieldSchema PolarisMode * PolarisModeFieldSchema ## Classes * [SchemaRecord](classes/SchemaRecord.md) * [SchemaService](classes/SchemaService.md) ## Type Aliases * [Transformation](type-aliases/Transformation.md) ## Variables * [Checkout](variables/Checkout.md) ## Functions * [fromIdentity](functions/fromIdentity.md) * [instantiateRecord](functions/instantiateRecord.md) * [registerDerivations](functions/registerDerivations.md) * [teardownRecord](functions/teardownRecord.md) * [withDefaults](functions/withDefaults.md) --- --- url: /api/@warp-drive/core/reactive/type-aliases/Transformation.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [reactive](../index.md) / Transformation ```ts type Transformation = object; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:160](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L160) ## Type Parameters ### T `T` *extends* [`Value`](../../types/json/raw/type-aliases/Value.md) = [`Value`](../../types/json/raw/type-aliases/Value.md) ### PT `PT` = `unknown` ## Properties ### \_\_\_(unique) Symbol($type) ```ts ___(unique) Symbol($type): string; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:164](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L164) ## Methods ### defaultValue()? ```ts optional defaultValue(options, identifier): T; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:163](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L163) #### Parameters ##### options `null` | `Record`<`string`, `unknown`> ##### identifier [`StableRecordIdentifier`](../../types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `T` *** ### hydrate() ```ts hydrate( value, options, record): PT; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:162](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L162) #### Parameters ##### value `undefined` | `T` ##### options `null` | `Record`<`string`, `unknown`> ##### record [`SchemaRecord`](../classes/SchemaRecord.md) #### Returns `PT` *** ### serialize() ```ts serialize( value, options, record): T; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/schema.ts:161](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/schema.ts#L161) #### Parameters ##### value `PT` ##### options `null` | `Record`<`string`, `unknown`> ##### record [`SchemaRecord`](../classes/SchemaRecord.md) #### Returns `T` --- --- url: /api/@warp-drive/core/reactive/variables/Checkout.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [reactive](../index.md) / Checkout ```ts const Checkout: "___(unique) Symbol(Checkout)"; ``` Defined in: [warp-drive-packages/core/src/reactive/-private/symbols.ts:41](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/reactive/-private/symbols.ts#L41) --- --- url: /api/@warp-drive/core/request/classes/Context.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [request](../index.md) / Context Defined in: [warp-drive-packages/core/src/request/-private/context.ts:158](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/context.ts#L158) ## Constructors ### Constructor ```ts new Context(owner, isCacheHandler): Context; ``` Defined in: [warp-drive-packages/core/src/request/-private/context.ts:165](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/context.ts#L165) #### Parameters ##### owner `ContextOwner` ##### isCacheHandler `boolean` #### Returns `Context` ## Properties ### id ```ts id: number; ``` Defined in: [warp-drive-packages/core/src/request/-private/context.ts:161](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/context.ts#L161) *** ### request ```ts request: ImmutableRequestInfo; ``` Defined in: [warp-drive-packages/core/src/request/-private/context.ts:160](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/context.ts#L160) ## Accessors ### hasRequestedStream #### Get Signature ```ts get hasRequestedStream(): boolean; ``` Defined in: [warp-drive-packages/core/src/request/-private/context.ts:187](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/context.ts#L187) ##### Returns `boolean` ## Methods ### \_finalize() ```ts _finalize(): void; ``` Defined in: [warp-drive-packages/core/src/request/-private/context.ts:191](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/context.ts#L191) #### Returns `void` *** ### setIdentifier() ```ts setIdentifier(identifier): void; ``` Defined in: [warp-drive-packages/core/src/request/-private/context.ts:179](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/context.ts#L179) #### Parameters ##### identifier [`StableDocumentIdentifier`](../../types/identifier/type-aliases/StableDocumentIdentifier.md) #### Returns `void` *** ### setResponse() ```ts setResponse(response): void; ``` Defined in: [warp-drive-packages/core/src/request/-private/context.ts:175](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/context.ts#L175) #### Parameters ##### response `null` | `Response` | [`ResponseInfo`](../../types/request/interfaces/ResponseInfo.md) #### Returns `void` *** ### setStream() ```ts setStream(stream): void; ``` Defined in: [warp-drive-packages/core/src/request/-private/context.ts:172](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/context.ts#L172) #### Parameters ##### stream `ReadableStream`<`any`> | `Promise`<`null` | `ReadableStream`<`any`>> #### Returns `void` --- --- url: /api/@warp-drive/core/request/functions/createDeferred.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [request](../index.md) / createDeferred ```ts function createDeferred(): Deferred; ``` Defined in: [warp-drive-packages/core/src/request/-private/future.ts:10](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/future.ts#L10) ## Type Parameters ### T `T` ## Returns [`Deferred`](../type-aliases/Deferred.md)<`T`> --- --- url: /api/@warp-drive/core/request/functions/getPromiseResult.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [request](../index.md) / getPromiseResult ```ts function getPromiseResult(promise): undefined | CacheResult; ``` Defined in: [warp-drive-packages/core/src/request/-private/promise-cache.ts:28](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/promise-cache.ts#L28) ## Type Parameters ### T `T` ### E `E` ## Parameters ### promise `Promise`<`T`> | [`Awaitable`](../type-aliases/Awaitable.md)<`T`, `E`> ## Returns `undefined` | `CacheResult`<`T`, `E`> --- --- url: /api/@warp-drive/core/request/functions/setPromiseResult.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [request](../index.md) / setPromiseResult ```ts function setPromiseResult(promise, result): void; ``` Defined in: [warp-drive-packages/core/src/request/-private/promise-cache.ts:24](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/promise-cache.ts#L24) ## Parameters ### promise [`Awaitable`](../type-aliases/Awaitable.md)<`unknown`, `unknown`> | `Promise`<`unknown`> ### result `CacheResult` ## Returns `void` --- --- url: /api/@warp-drive/core/request.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / request ## Classes * [Context](classes/Context.md) ## Interfaces * [CacheHandler](interfaces/CacheHandler.md) * [Future](interfaces/Future.md) * [Handler](interfaces/Handler.md) ## Type Aliases * [Awaitable](type-aliases/Awaitable.md) * [Deferred](type-aliases/Deferred.md) * [ManagedRequestPriority](type-aliases/ManagedRequestPriority.md) * [NextFn](type-aliases/NextFn.md) ## Functions * [createDeferred](functions/createDeferred.md) * [getPromiseResult](functions/getPromiseResult.md) * [setPromiseResult](functions/setPromiseResult.md) --- --- url: /api/@warp-drive/core/request/interfaces/CacheHandler.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [request](../index.md) / CacheHandler Defined in: [warp-drive-packages/core/src/request/-private/types.ts:229](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/types.ts#L229) The CacheHandler is identical to other handlers ecxept that it is allowed to return a value synchronously. This is useful for features like reducing microtask queueing when de-duping. A RequestManager may only have one CacheHandler, registered via `manager.useCache(CacheHandler)`. (Interface) CacheHandler ## Methods ### request() ```ts request(context, next): | T | Promise< | T | StructuredDataDocument> | Future; ``` Defined in: [warp-drive-packages/core/src/request/-private/types.ts:239](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/types.ts#L239) Method to implement to handle requests. Receives the request context and a nextFn to call to pass-along the request to other handlers. #### Type Parameters ##### T `T` = `unknown` #### Parameters ##### context [`RequestContext`](../../types/request/interfaces/RequestContext.md) ##### next [`NextFn`](../type-aliases/NextFn.md)<`T`> #### Returns | `T` | `Promise`< | `T` | [`StructuredDataDocument`](../../types/request/interfaces/StructuredDataDocument.md)<`T`>> | [`Future`](Future.md)<`T`> --- --- url: /api/@warp-drive/core/request/interfaces/Future.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [request](../index.md) / Future Defined in: [warp-drive-packages/core/src/request/-private/types.ts:37](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/types.ts#L37) A Future is a Promise which resolves to a StructuredDocument while providing the ability to `abort` the underlying request, `getStream` the response before the outer promise resolves; Future ## Extends * `Promise`<[`StructuredDataDocument`](../../types/request/interfaces/StructuredDataDocument.md)<`T`>> ## Type Parameters ### T `T` ## Properties ### \_\_\_(unique) Symbol(IS\_FUTURE) ```ts ___(unique) Symbol(IS_FUTURE): true; ``` Defined in: [warp-drive-packages/core/src/request/-private/types.ts:38](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/types.ts#L38) *** ### \[toStringTag] ```ts readonly [toStringTag]: string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:176 #### Inherited from ```ts Promise.[toStringTag] ``` *** ### id ```ts id: number; ``` Defined in: [warp-drive-packages/core/src/request/-private/types.ts:83](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/types.ts#L83) The id of the associated request, if any, as assigned by the RequestManager *** ### lid ```ts lid: | null | StableDocumentIdentifier; ``` Defined in: [warp-drive-packages/core/src/request/-private/types.ts:73](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/types.ts#L73) The identifier of the associated request, if any, as assigned by the CacheHandler. ## Methods ### abort() ```ts abort(reason?): void; ``` Defined in: [warp-drive-packages/core/src/request/-private/types.ts:46](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/types.ts#L46) Cancel this request by firing the AbortController's signal. #### Parameters ##### reason? `string` optional reason for aborting the request #### Returns `void` *** ### catch() ```ts catch(onrejected?): Promise< | StructuredDataDocument | TResult>; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1557 Attaches a callback for only the rejection of the Promise. #### Type Parameters ##### TResult `TResult` = `never` #### Parameters ##### onrejected? The callback to execute when the Promise is rejected. `null` | (`reason`) => `TResult` | `PromiseLike`<`TResult`> #### Returns `Promise`< | [`StructuredDataDocument`](../../types/request/interfaces/StructuredDataDocument.md)<`T`> | `TResult`> A Promise for the completion of the callback. #### Inherited from ```ts Promise.catch ``` *** ### finally() ```ts finally(onfinally?): Promise>; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2018.promise.d.ts:29 Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback. #### Parameters ##### onfinally? The callback to execute when the Promise is settled (fulfilled or rejected). `null` | () => `void` #### Returns `Promise`<[`StructuredDataDocument`](../../types/request/interfaces/StructuredDataDocument.md)<`T`>> A Promise for the completion of the callback. #### Inherited from ```ts Promise.finally ``` *** ### getStream() ```ts getStream(): Promise>; ``` Defined in: [warp-drive-packages/core/src/request/-private/types.ts:53](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/types.ts#L53) Get the response stream, if any, once made available. #### Returns `Promise`<`null` | `ReadableStream`<`any`>> *** ### onFinalize() ```ts onFinalize(cb): void; ``` Defined in: [warp-drive-packages/core/src/request/-private/types.ts:63](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/types.ts#L63) Run a callback when this request completes. Use sparingly, mostly useful for instrumentation and infrastructure. #### Parameters ##### cb () => `void` the callback to run #### Returns `void` *** ### then() ```ts then(onfulfilled?, onrejected?): Promise; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1550 Attaches callbacks for the resolution and/or rejection of the Promise. #### Type Parameters ##### TResult1 `TResult1` = [`StructuredDataDocument`](../../types/request/interfaces/StructuredDataDocument.md)<`T`> ##### TResult2 `TResult2` = `never` #### Parameters ##### onfulfilled? The callback to execute when the Promise is resolved. `null` | (`value`) => `TResult1` | `PromiseLike`<`TResult1`> ##### onrejected? The callback to execute when the Promise is rejected. `null` | (`reason`) => `TResult2` | `PromiseLike`<`TResult2`> #### Returns `Promise`<`TResult1` | `TResult2`> A Promise for the completion of which ever callback is executed. #### Inherited from ```ts Promise.then ``` --- --- url: /api/@warp-drive/core/request/interfaces/Handler.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [request](../index.md) / Handler Defined in: [warp-drive-packages/core/src/request/-private/types.ts:205](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/types.ts#L205) Requests are fulfilled by handlers. A handler receives the request context as well as a `next` function with which to pass along a request to the next handler if it so chooses. A handler may be any object with a `request` method. This allows both stateful and non-stateful handlers to be utilized. If a handler calls `next`, it receives a `Future` which resolves to a `StructuredDocument` that it can then compose how it sees fit with its own response. ```ts type NextFn

= (req: RequestInfo) => Future

; interface Handler { async request(context: RequestContext, next: NextFn

): T; } ``` `RequestContext` contains a readonly version of the RequestInfo as well as a few methods for building up the `StructuredDocument` and `Future` that will be part of the response. ```ts interface RequestContext { readonly request: RequestInfo; setStream(stream: ReadableStream | Promise): void; setResponse(response: Response | ResponseInfo): void; } ``` A basic `fetch` handler with support for streaming content updates while the download is still underway might look like the following, where we use [`response.clone()`](https://developer.mozilla.org/en-US/docs/Web/API/Response/clone) to `tee` the `ReadableStream` into two streams. A more efficient handler might read from the response stream, building up the response content before passing along the chunk downstream. ```ts const FetchHandler = { async request(context) { const response = await fetch(context.request); context.setResponse(reponse); context.setStream(response.clone().body); return response.json(); } } ``` ### Stream Currying `RequestManager.request` and `next` differ from `fetch` in one **crucial detail** in that the outer Promise resolves only once the response stream has been processed. For context, it helps to understand a few of the use-cases that RequestManager is intended to allow. * to manage and return streaming content (such as video files) * to fulfill a request from multiple sources or by splitting one request into multiple requests * for instance one API call for a user and another for the user's friends * or e.g. fulfilling part of the request from one source (one API, in-memory, localStorage, IndexedDB etc.) and the rest from another source (a different API, a WebWorker, etc.) * to coalesce multiple requests * to decorate a request with additional info * e.g. an Auth handler that ensures the correct tokens or headers or cookies are attached. *** `await fetch()` resolves at the moment headers are received. This allows for the body of the request to be processed as a stream by application code *while chunks are still being received by the browser*. When an app chooses to `await response.json()` what occurs is the browser reads the stream to completion and then returns the result. Additionally, this stream may only be read **once**. The `RequestManager` preserves this ability to subscribe to and utilize the stream by either the application or the handler – thereby delivering the full power and flexibility of native APIs – without restricting developers in ways that lead to complicated workarounds. Each handler may call `setStream` only once, but may do so *at any time* until the promise that the handler returns has resolved. The associated promise returned by calling `future.getStream` will resolve with the stream set by `setStream` if that method is called, or `null` if that method has not been called by the time that the handler's request method has resolved. Handlers that do not create a stream of their own, but which call `next`, should defensively pipe the stream forward. While this is not required (see automatic currying below) it is better to do so in most cases as otherwise the stream may not become available to downstream handlers or the application until the upstream handler has fully read it. ```ts context.setStream(future.getStream()); ``` Handlers that either call `next` multiple times or otherwise have reason to create multiple fetch requests should either choose to return no stream, meaningfully combine the streams, or select a single prioritized stream. Of course, any handler may choose to read and handle the stream, and return either no stream or a different stream in the process. ### Automatic Currying of Stream and Response In order to simplify the common case for handlers which decorate a request, if `next` is called only a single time and `setResponse` was never called by the handler, the response set by the next handler in the chain will be applied to that handler's outcome. For instance, this makes the following pattern possible `return (await next()).content;`. Similarly, if `next` is called only a single time and neither `setStream` nor `getStream` was called, we automatically curry the stream from the future returned by `next` onto the future returned by the handler. Finally, if the return value of a handler is a `Future`, we curry `content` and `errors` as well, thus enabling the simplest form `return next()`. In the case of the `Future` being returned, `Stream` proxying is automatic and immediate and does not wait for the `Future` to resolve. ### Handler Order Request handlers are registered by configuring the manager via `use` ```ts const manager = new RequestManager() .use([Handler1, Handler2]); ``` Handlers will be invoked in the order they are registered ("fifo", first-in first-out), and may only be registered up until the first request is made. It is recommended but not required to register all handlers at one time in order to ensure explicitly visible handler ordering. (Interface) Handler ## Methods ### request() ```ts request(context, next): | Promise< | T | StructuredDataDocument> | Future; ``` Defined in: [warp-drive-packages/core/src/request/-private/types.ts:215](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/types.ts#L215) Method to implement to handle requests. Receives the request context and a nextFn to call to pass-along the request to other handlers. #### Type Parameters ##### T `T` = `unknown` #### Parameters ##### context [`RequestContext`](../../types/request/interfaces/RequestContext.md) ##### next [`NextFn`](../type-aliases/NextFn.md)<`T`> #### Returns | `Promise`< | `T` | [`StructuredDataDocument`](../../types/request/interfaces/StructuredDataDocument.md)<`T`>> | [`Future`](Future.md)<`T`> --- --- url: /api/@warp-drive/core/request/type-aliases/Awaitable.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [request](../index.md) / Awaitable ```ts type Awaitable = object; ``` Defined in: [warp-drive-packages/core/src/request/-private/promise-cache.ts:5](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/promise-cache.ts#L5) ## Type Parameters ### T `T` = `unknown` ### E `E` = `unknown` ## Properties ### catch() ```ts catch: (onRejected) => unknown; ``` Defined in: [warp-drive-packages/core/src/request/-private/promise-cache.ts:7](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/promise-cache.ts#L7) #### Parameters ##### onRejected (`reason`) => `unknown` #### Returns `unknown` *** ### finally() ```ts finally: (onFinally) => unknown; ``` Defined in: [warp-drive-packages/core/src/request/-private/promise-cache.ts:8](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/promise-cache.ts#L8) #### Parameters ##### onFinally () => `unknown` #### Returns `unknown` *** ### then() ```ts then: (onFulfilled, onRejected) => unknown; ``` Defined in: [warp-drive-packages/core/src/request/-private/promise-cache.ts:6](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/promise-cache.ts#L6) #### Parameters ##### onFulfilled (`value`) => `unknown` ##### onRejected (`reason`) => `unknown` #### Returns `unknown` --- --- url: /api/@warp-drive/core/request/type-aliases/ManagedRequestPriority.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [request](../index.md) / ManagedRequestPriority ```ts type ManagedRequestPriority = object; ``` Defined in: [warp-drive-packages/core/src/request/-private/types.ts:21](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/types.ts#L21) ## Properties ### blocking ```ts blocking: boolean; ``` Defined in: [warp-drive-packages/core/src/request/-private/types.ts:21](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/types.ts#L21) --- --- url: /api/@warp-drive/core/request/type-aliases/Deferred.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [request](../index.md) / Deferred ```ts type Deferred = object; ``` Defined in: [warp-drive-packages/core/src/request/-private/types.ts:15](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/types.ts#L15) ## Type Parameters ### T `T` ## Properties ### promise ```ts promise: Promise; ``` Defined in: [warp-drive-packages/core/src/request/-private/types.ts:18](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/types.ts#L18) ## Methods ### reject() ```ts reject(v): void; ``` Defined in: [warp-drive-packages/core/src/request/-private/types.ts:17](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/types.ts#L17) #### Parameters ##### v `unknown` #### Returns `void` *** ### resolve() ```ts resolve(v): void; ``` Defined in: [warp-drive-packages/core/src/request/-private/types.ts:16](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/types.ts#L16) #### Parameters ##### v `T` #### Returns `void` --- --- url: /api/@warp-drive/core/request/type-aliases/NextFn.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [request](../index.md) / NextFn ```ts type NextFn

= (req) => Future

; ``` Defined in: [warp-drive-packages/core/src/request/-private/types.ts:92](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/request/-private/types.ts#L92) ## Type Parameters ### P `P` = `unknown` ## Parameters ### req [`RequestInfo`](../../types/request/interfaces/RequestInfo.md) ## Returns [`Future`](../interfaces/Future.md)<`P`> --- --- url: /api/@warp-drive/core/store/functions/parseCacheControl.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [store](../index.md) / parseCacheControl ```ts function parseCacheControl(header): CacheControlValue; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:96](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L96) Parses a string Cache-Control header value into an object with the following structure: ```ts interface CacheControlValue { immutable?: boolean; 'max-age'?: number; 'must-revalidate'?: boolean; 'must-understand'?: boolean; 'no-cache'?: boolean; 'no-store'?: boolean; 'no-transform'?: boolean; 'only-if-cached'?: boolean; private?: boolean; 'proxy-revalidate'?: boolean; public?: boolean; 's-maxage'?: number; 'stale-if-error'?: number; 'stale-while-revalidate'?: number; } ``` ## Parameters ### header `string` ## Returns [`CacheControlValue`](../interfaces/CacheControlValue.md) --- --- url: /api/@warp-drive/core/store/classes/DefaultCachePolicy.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [store](../index.md) / DefaultCachePolicy Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:500](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L500) A basic CachePolicy that can be added to the Store service. Determines staleness based on time since the request was last received from the API using the `date` header. Determines expiration based on configured constraints as well as a time based expiration strategy based on the `date` header. In order expiration is determined by: * Is explicitly invalidated * ↳ (if null) isExpired function \ * ↳ (if null) X-WarpDrive-Expires header \ * ↳ (if null) Cache-Control header \ * ↳ (if null) Expires header \ * ↳ (if null) Date header + apiCacheHardExpires < current time Invalidates any request for which `cacheOptions.types` was provided when a createRecord request for that type is successful. For this to work, the `createRecord` request must include the `cacheOptions.types` array with the types that should be invalidated, or its request should specify the identifiers of the records that are being created via `records`. Providing both is valid. > \[!NOTE] > only requests that had specified `cacheOptions.types` and occurred prior to the > createRecord request will be invalidated. This means that a given request should always > specify the types that would invalidate it to opt into this behavior. Abstracting this > behavior via builders is recommended to ensure consistency. This allows the Store's CacheHandler to determine if a request is expired and should be refetched upon next request. The `Fetch` handler provided by `@warp-drive/core` will automatically add the `date` header to responses if it is not present. > \[!NOTE] > Date headers do not have millisecond precision, so expiration times should > generally be larger than 1000ms. Usage: ```ts import { Store } from '@warp-drive/core'; import { DefaultCachePolicy } from '@warp-drive/core/store'; export class AppStore extends Store { lifetimes = new DefaultCachePolicy({ apiCacheSoftExpires: 30_000, apiCacheHardExpires: 60_000 }); } ``` In Testing environments, the `apiCacheSoftExpires` will always be `false` and `apiCacheHardExpires` will use the `apiCacheSoftExpires` value. This helps reduce flakiness and produce predictably rendered results in test suites. Requests that specifically set `cacheOptions.backgroundReload = true` will still be background reloaded in tests. This behavior can be opted out of by setting `disableTestOptimization = true` in the policy config. ## Constructors ### Constructor ```ts new DefaultCachePolicy(config): DefaultCachePolicy; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:519](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L519) #### Parameters ##### config [`PolicyConfig`](../type-aliases/PolicyConfig.md) #### Returns `DefaultCachePolicy` ## Properties ### \_stores ```ts _stores: WeakMap; types: Map>; }>; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:502](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L502) *** ### config ```ts config: PolicyConfig; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:501](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L501) ## Methods ### \_getStore() ```ts _getStore(store): object; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:507](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L507) #### Parameters ##### store `Store` #### Returns `object` ##### invalidated ```ts invalidated: Set; ``` ##### types ```ts types: Map>; ``` *** ### didRequest() ```ts didRequest( request, response, identifier, store): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:611](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L611) Invoked when a request has been fulfilled from the configured request handlers. This is invoked by the CacheHandler for both foreground and background requests once the cache has been updated. Note, this is invoked by the CacheHandler regardless of whether the request has a cache-key. This method should not be invoked directly by consumers. #### Parameters ##### request [`ImmutableRequestInfo`](../../types/request/type-aliases/ImmutableRequestInfo.md) ##### response `null` | `Response` | [`ResponseInfo`](../../types/request/interfaces/ResponseInfo.md) ##### identifier `null` | [`StableDocumentIdentifier`](../../types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store `Store` #### Returns `void` *** ### invalidateRequest() ```ts invalidateRequest(identifier, store): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:557](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L557) Invalidate a request by its identifier for a given store instance. While the store argument may seem redundant, the CachePolicy is designed to be shared across multiple stores / forks of the store. ```ts store.lifetimes.invalidateRequest(store, identifier); ``` #### Parameters ##### identifier [`StableDocumentIdentifier`](../../types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store `Store` #### Returns `void` *** ### invalidateRequestsForType() ```ts invalidateRequestsForType(type, store): void; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:580](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L580) Invalidate all requests associated to a specific type for a given store instance. While the store argument may seem redundant, the CachePolicy is designed to be shared across multiple stores / forks of the store. This invalidation is done automatically when using this service for both the CacheHandler and the LegacyNetworkHandler. ```ts store.lifetimes.invalidateRequestsForType(store, 'person'); ``` #### Parameters ##### type `string` ##### store `Store` #### Returns `void` *** ### isHardExpired() ```ts isHardExpired(identifier, store): boolean; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:664](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L664) Invoked to determine if the request may be fulfilled from cache if possible. Note, this is only invoked by the CacheHandler if the request has a cache-key. If no cache entry is found or the entry is hard expired, the request will be fulfilled from the configured request handlers and the cache will be updated before returning the response. #### Parameters ##### identifier [`StableDocumentIdentifier`](../../types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store `Store` #### Returns `boolean` true if the request is considered hard expired *** ### isSoftExpired() ```ts isSoftExpired(identifier, store): boolean; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:699](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L699) Invoked if `isHardExpired` is false to determine if the request should be update behind the scenes if cache data is already available. Note, this is only invoked by the CacheHandler if the request has a cache-key. If true, the request will be fulfilled from cache while a backgrounded request is made to update the cache via the configured request handlers. #### Parameters ##### identifier [`StableDocumentIdentifier`](../../types/identifier/type-aliases/StableDocumentIdentifier.md) ##### store `Store` #### Returns `boolean` true if the request is considered soft expired --- --- url: /api/@warp-drive/core/store.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / store ## Classes * [DefaultCachePolicy](classes/DefaultCachePolicy.md) ## Interfaces * [CacheControlValue](interfaces/CacheControlValue.md) ## Type Aliases * [PolicyConfig](type-aliases/PolicyConfig.md) ## Functions * [parseCacheControl](functions/parseCacheControl.md) --- --- url: /api/@warp-drive/core/store/interfaces/CacheControlValue.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [store](../index.md) / CacheControlValue Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:49](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L49) ## Properties ### immutable? ```ts optional immutable: boolean; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:50](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L50) *** ### max-age? ```ts optional max-age: number; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:51](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L51) *** ### must-revalidate? ```ts optional must-revalidate: boolean; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:52](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L52) *** ### must-understand? ```ts optional must-understand: boolean; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:53](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L53) *** ### no-cache? ```ts optional no-cache: boolean; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:54](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L54) *** ### no-store? ```ts optional no-store: boolean; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:55](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L55) *** ### no-transform? ```ts optional no-transform: boolean; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:56](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L56) *** ### only-if-cached? ```ts optional only-if-cached: boolean; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:57](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L57) *** ### private? ```ts optional private: boolean; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:58](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L58) *** ### proxy-revalidate? ```ts optional proxy-revalidate: boolean; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:59](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L59) *** ### public? ```ts optional public: boolean; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:60](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L60) *** ### s-maxage? ```ts optional s-maxage: number; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:61](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L61) *** ### stale-if-error? ```ts optional stale-if-error: number; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:62](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L62) *** ### stale-while-revalidate? ```ts optional stale-while-revalidate: number; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:63](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L63) --- --- url: /api/@warp-drive/core/store/type-aliases/PolicyConfig.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [store](../index.md) / PolicyConfig ```ts type PolicyConfig = object; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:298](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L298) The configuration options for the [DefaultCachePolicy](../classes/DefaultCachePolicy.md) ```ts import { DefaultCachePolicy } from '@warp-drive/core/store'; new DefaultCachePolicy({ // ... PolicyConfig Settings ... // }); ``` ## Properties ### apiCacheHardExpires ```ts apiCacheHardExpires: number; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:328](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L328) the number of milliseconds after which a request is considered expired and should be re-fetched. If a request is issued again after this time, the request will disregard the cache and wait for a fresh response from the API. This is calculated against the `date` header of the response. If your API does not provide a `date` header, the `Fetch` handler provided by `@warp-drive/core` will automatically add it to responses if it is not present. Responses without a `date` header will be considered hard expired immediately. *** ### apiCacheSoftExpires ```ts apiCacheSoftExpires: number; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:313](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L313) the number of milliseconds after which a request is considered stale. If a request is issued again after this time, the request will respond from cache immediately while a background request is made to update the cache. This is calculated against the `date` header of the response. If your API does not provide a `date` header, the `Fetch` handler provided by `@warp-drive/core` will automatically add it to responses if it is not present. Responses without a `date` header will be considered stale immediately. *** ### constraints? ```ts optional constraints: object; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:374](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L374) In addition to the simple time-based expiration strategy, CachePolicy supports various common server-supplied expiration strategies via headers, as well as custom expiration strategies via the `isExpired` function. Requests will be validated for expiration against these constraints. If any of these constraints are not met, the request will be considered expired. If all constraints are met, the request will be considered valid and the time based expiration strategy will NOT be used. Meeting a constraint means BOTH that the properties the constraint requires are present AND that the expiration time indicated by those properties has not been exceeded. In other words, if the properties for a constraint are not present, this does not count either as meeting or as not meeting the constraint, the constraint simply does not apply. The `isExpired` function is called with the request and should return `true` if the request is expired, `false` if it is not expired, and `null` if the expiration status is unknown. In order constraints are checked: * isExpired function * ↳ (if null) X-WarpDrive-Expires header * ↳ (if null) Cache-Control header * ↳ (if null) Expires header #### headers? ```ts optional headers: object; ``` Headers that should be checked for expiration. ##### headers.Cache-Control? ```ts optional headers.Cache-Control: boolean; ``` Whether the `Cache-Control` header should be checked for expiration. If `true`, then the `max-age` and `s-maxage` directives are used alongside the `Age` and `Date` headers to determine if the expiration time has passed. Other directives are ignored. 'Cache-Control' will take precedence over 'Expires' if both are present and both configured to be checked. ##### headers.Expires? ```ts optional headers.Expires: boolean; ``` Whether the `Expires` header should be checked for expiration. If `true`, then the `Expires` header is used to caclulate the expiration time and determine if the expiration time has passed. 'Cache-Control' will take precedence over 'Expires' if both are present. ##### headers.X-WarpDrive-Expires? ```ts optional headers.X-WarpDrive-Expires: boolean; ``` Whether the `X-WarpDrive-Expires` header should be checked for expiration. If `true`, then the `X-WarpDrive-Expires` header is used to caclulate the expiration time and determine if the expiration time has passed. This header will take precedence over 'Cache-Control' and 'Expires' if all three are present. The header's value should be a [UTC date string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString). #### isExpired()? ```ts optional isExpired: (request) => boolean | null; ``` A function that should be called to determine if the request is expired. If present, this function will be called with the request and should return `true` if the request is expired, `false` if it is not expired, and `null` if the expiration status is unknown. If the function does not return `null`, ##### Parameters ###### request [`StructuredDocument`](../../types/request/type-aliases/StructuredDocument.md)<[`ResourceDocument`](../../types/spec/document/type-aliases/ResourceDocument.md)> ##### Returns `boolean` | `null` *** ### disableTestOptimization? ```ts optional disableTestOptimization: boolean; ``` Defined in: [warp-drive-packages/core/src/store/-private/default-cache-policy.ts:341](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/default-cache-policy.ts#L341) In Testing environments, the `apiCacheSoftExpires` will always be `false` and `apiCacheHardExpires` will use the `apiCacheSoftExpires` value. This helps reduce flakiness and produce predictably rendered results in test suites. Requests that specifically set `cacheOptions.backgroundReload = true` will still be background reloaded in tests. This behavior can be opted out of by setting this value to `true`. --- --- url: /api/@warp-drive/core/type-aliases/CacheOperation.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / CacheOperation ```ts type CacheOperation = "added" | "removed" | "updated" | "state"; ``` Defined in: [warp-drive-packages/core/src/store/-private/managers/notification-manager.ts:12](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/managers/notification-manager.ts#L12) --- --- url: /api/@warp-drive/core/type-aliases/DocumentCacheOperation.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / DocumentCacheOperation ```ts type DocumentCacheOperation = "invalidated" | "added" | "removed" | "updated" | "state"; ``` Defined in: [warp-drive-packages/core/src/store/-private/managers/notification-manager.ts:13](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/managers/notification-manager.ts#L13) --- --- url: /api/@warp-drive/core/type-aliases/NotificationType.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / NotificationType ```ts type NotificationType = | "attributes" | "relationships" | "identity" | "errors" | "meta" | CacheOperation; ``` Defined in: [warp-drive-packages/core/src/store/-private/managers/notification-manager.ts:21](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/managers/notification-manager.ts#L21) --- --- url: /api/@warp-drive/core/type-aliases/StoreRequestInput.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / StoreRequestInput ```ts type StoreRequestInput = | ImmutableRequestInfo | LooseStoreRequestInfo; ``` Defined in: [warp-drive-packages/core/src/store/-private/cache-handler/handler.ts:35](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/cache-handler/handler.ts#L35) ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` --- --- url: /api/@warp-drive/core/types/cache/aliases.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / types/cache/aliases ## Type Aliases * [ResourceBlob](type-aliases/ResourceBlob.md) --- --- url: /api/@warp-drive/core/types/cache/aliases/type-aliases/ResourceBlob.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/aliases](../index.md) / ResourceBlob ```ts type ResourceBlob = unknown; ``` Defined in: [warp-drive-packages/core/src/types/cache/aliases.ts:12](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/aliases.ts#L12) --- --- url: /api/@warp-drive/core/types/cache/change.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / types/cache/change ## Interfaces * [Change](interfaces/Change.md) --- --- url: /api/@warp-drive/core/types/cache/change/interfaces/Change.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/change](../index.md) / Change Defined in: [warp-drive-packages/core/src/types/cache/change.ts:3](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/change.ts#L3) ## Properties ### identifier ```ts identifier: | StableDocumentIdentifier | StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/change.ts:4](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/change.ts#L4) *** ### op ```ts op: "remove" | "upsert"; ``` Defined in: [warp-drive-packages/core/src/types/cache/change.ts:5](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/change.ts#L5) *** ### patch? ```ts optional patch: unknown; ``` Defined in: [warp-drive-packages/core/src/types/cache/change.ts:6](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/change.ts#L6) --- --- url: /api/@warp-drive/core/types/cache.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / types/cache ## Interfaces * [Cache](interfaces/Cache.md) ## Type Aliases * [RelationshipDiff](type-aliases/RelationshipDiff.md) --- --- url: /api/@warp-drive/core/types/cache/mutations.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / types/cache/mutations ## Interfaces * [AddToResourceRelationshipMutation](interfaces/AddToResourceRelationshipMutation.md) * [RemoveFromResourceRelationshipMutation](interfaces/RemoveFromResourceRelationshipMutation.md) * [ReplaceRelatedRecordMutation](interfaces/ReplaceRelatedRecordMutation.md) * [ReplaceRelatedRecordsMutation](interfaces/ReplaceRelatedRecordsMutation.md) * [SortRelatedRecordsMutation](interfaces/SortRelatedRecordsMutation.md) ## Type Aliases * [Mutation](type-aliases/Mutation.md) --- --- url: /api/@warp-drive/core/types/cache/interfaces/Cache.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/cache](../index.md) / Cache Defined in: [warp-drive-packages/core/src/types/cache.ts:45](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L45) The interface for WarpDrive Caches. A Cache handles in-memory storage of Document and Resource data. (Interface) Cache ## Properties ### version ```ts version: "2"; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:53](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L53) The Cache Version that this implementation implements. ## Methods ### changedAttrs() ```ts changedAttrs(identifier): ChangedAttributesHash; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:392](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L392) Query the cache for the changed attributes of a resource. Returns a map of field names to tuples of \[old, new] values ``` { : [, ] } ``` #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `ChangedAttributesHash` `{ : [, ] }` *** ### changedRelationships() ```ts changedRelationships(identifier): Map; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:440](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L440) Query the cache for the changes to relationships of a resource. Returns a map of relationship names to RelationshipDiff objects. ```ts type RelationshipDiff = | { kind: 'collection'; remoteState: StableRecordIdentifier[]; additions: Set; removals: Set; localState: StableRecordIdentifier[]; reordered: boolean; } | { kind: 'resource'; remoteState: StableRecordIdentifier | null; localState: StableRecordIdentifier | null; }; ``` #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `Map`<`string`, [`RelationshipDiff`](../type-aliases/RelationshipDiff.md)> *** ### clientDidCreate() ```ts clientDidCreate(identifier, createArgs?): Record; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:301](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L301) \[LIFECYCLE] Signal to the cache that a new record has been instantiated on the client It returns properties from options that should be set on the record during the create process. This return value behavior is deprecated. #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### createArgs? `Record`<`string`, `unknown`> #### Returns `Record`<`string`, `unknown`> *** ### commitWasRejected() ```ts commitWasRejected(identifier, errors?): void; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:331](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L331) \[LIFECYCLE] Signals to the cache that a resource was update via a save transaction failed. #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### errors? [`ApiError`](../../spec/error/interfaces/ApiError.md)\[] #### Returns `void` *** ### didCommit() ```ts didCommit(identifier, result): SingleResourceDataDocument; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:321](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L321) \[LIFECYCLE] Signals to the cache that a resource was successfully updated as part of a save transaction. #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) the primary identifier that was operated on ##### result [`StructuredDataDocument`](../../request/interfaces/StructuredDataDocument.md)<`unknown`> #### Returns [`SingleResourceDataDocument`](../../spec/document/interfaces/SingleResourceDataDocument.md) *** ### diff() ```ts diff(): Promise; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:255](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L255) Generate the list of changes applied to all record in the store. Each individual resource or document that has been mutated should be described as an individual `Change` entry in the returned array. A `Change` is described by an object containing up to three properties: (1) the `identifier` of the entity that changed; (2) the `op` code of that change being one of `upsert` or `remove`, and if the op is `upsert` a `patch` containing the data to merge into the cache for the given entity. This `patch` is opaque to the Store but should be understood by the Cache and may expect to be utilized by an Adapter when generating data during a `save` operation. It is generally recommended that the `patch` contain only the updated state, ignoring fields that are unchanged ```ts interface Change { identifier: StableRecordIdentifier | StableDocumentIdentifier; op: 'upsert' | 'remove'; patch?: unknown; } ``` #### Returns `Promise`<[`Change`](../change/interfaces/Change.md)\[]> *** ### dump() ```ts dump(): Promise>; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:268](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L268) Serialize the entire contents of the Cache into a Stream which may be fed back into a new instance of the same Cache via `cache.hydrate`. #### Returns `Promise`<`ReadableStream`<`unknown`>> *** ### fork() ```ts fork(): Promise; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:208](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L208) Create a fork of the cache from the current state. Applications should typically not call this method themselves, preferring instead to fork at the Store level, which will utilize this method to fork the cache. #### Returns `Promise`<`Cache`> *** ### getAttr() ```ts getAttr(identifier, field): undefined | Value; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:355](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L355) Retrieve the data for an attribute from the cache #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### field `string` | `string`\[] #### Returns `undefined` | [`Value`](../../json/raw/type-aliases/Value.md) *** ### getErrors() ```ts getErrors(identifier): ApiError[]; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:514](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L514) Query the cache for any validation errors applicable to the given resource. #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns [`ApiError`](../../spec/error/interfaces/ApiError.md)\[] *** ### getRelationship() ```ts getRelationship( identifier, field, isCollection?): | ResourceRelationship | CollectionRelationship; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:472](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L472) Query the cache for the current state of a relationship property #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### field `string` ##### isCollection? `boolean` #### Returns | [`ResourceRelationship`](../relationship/interfaces/ResourceRelationship.md)<[`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md)> | [`CollectionRelationship`](../relationship/interfaces/CollectionRelationship.md)<[`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md)> resource relationship object *** ### getRemoteAttr() ```ts getRemoteAttr(identifier, field): undefined | Value; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:365](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L365) Retrieve remote state without any local changes for a specific attribute #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### field `string` | `string`\[] #### Returns `undefined` | [`Value`](../../json/raw/type-aliases/Value.md) *** ### getRemoteRelationship() ```ts getRemoteRelationship( identifier, field, isCollection?): | ResourceRelationship | CollectionRelationship; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:486](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L486) Query the cache for the server state of a relationship property without any local changes #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### field `string` ##### isCollection? `boolean` #### Returns | [`ResourceRelationship`](../relationship/interfaces/ResourceRelationship.md)<[`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md)> | [`CollectionRelationship`](../relationship/interfaces/CollectionRelationship.md)<[`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md)> resource relationship object *** ### hasChangedAttrs() ```ts hasChangedAttrs(identifier): boolean; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:401](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L401) Query the cache for whether any mutated attributes exist #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` *** ### hasChangedRelationships() ```ts hasChangedRelationships(identifier): boolean; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:449](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L449) Query the cache for whether any mutated attributes exist #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` *** ### hydrate() ```ts hydrate(stream): Promise; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:286](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L286) hydrate a Cache from a Stream with content previously serialized from another instance of the same Cache, resolving when hydration is complete. This method should expect to be called both in the context of restoring the Cache during application rehydration after SSR **AND** at unknown times during the lifetime of an already booted application when it is desired to bulk-load additional information into the cache. This latter behavior supports optimizing pre/fetching of data for route transitions via data-only SSR modes. #### Parameters ##### stream `ReadableStream`<`unknown`> #### Returns `Promise`<`void`> *** ### isDeleted() ```ts isDeleted(identifier): boolean; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:543](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L543) Query the cache for whether a given resource is marked as deleted (but not necessarily persisted yet). #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` *** ### isDeletionCommitted() ```ts isDeletionCommitted(identifier): boolean; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:553](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L553) Query the cache for whether a given resource has been deleted and that deletion has also been persisted. #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` *** ### isEmpty() ```ts isEmpty(identifier): boolean; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:523](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L523) Query the cache for whether a given resource has any available data #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` *** ### isNew() ```ts isNew(identifier): boolean; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:533](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L533) Query the cache for whether a given resource was created locally and not yet persisted. #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` *** ### merge() ```ts merge(cache): Promise; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:221](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L221) Merge a fork back into a parent Cache. Applications should typically not call this method themselves, preferring instead to merge at the Store level, which will utilize this method to merge the caches. #### Parameters ##### cache `Cache` #### Returns `Promise`<`void`> *** ### mutate() ```ts mutate(mutation): void; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:98](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L98) Update the "local" or "current" (unpersisted) state of the Cache #### Parameters ##### mutation [`Mutation`](../mutations/type-aliases/Mutation.md) #### Returns `void` *** ### patch() ```ts patch(op): void; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:89](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L89) Update the "remote" or "canonical" (persisted) state of the Cache by merging new information into the existing state. #### Parameters ##### op the operation(s) to perform [`Operation`](../operations/type-aliases/Operation.md) | [`Operation`](../operations/type-aliases/Operation.md)\[] #### Returns `void` *** ### peek() #### Call Signature ```ts peek(identifier): null | T; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:131](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L131) Peek resource data from the Cache. In development, if the return value is JSON the return value will be deep-cloned and deep-frozen to prevent mutation thereby enforcing cache Immutability. This form of peek is useful for implementations that want to feed raw-data from cache to the UI or which want to interact with a blob of data directly from the presentation cache. An implementation might want to do this because de-referencing records which read from their own blob is generally safer because the record does not require retainining connections to the Store and Cache to present data on a per-field basis. This generally takes the place of `getAttr` as an API and may even take the place of `getRelationship` depending on implementation specifics, though this latter usage is less recommended due to the advantages of the Graph handling necessary entanglements and notifications for relational data. ##### Type Parameters ###### T `T` = `unknown` ##### Parameters ###### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md)<[`TypeFromInstanceOrString`](../../record/type-aliases/TypeFromInstanceOrString.md)<`T`>> ##### Returns `null` | `T` the known resource data #### Call Signature ```ts peek(identifier): | null | ResourceDocument; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:132](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L132) ##### Parameters ###### identifier [`StableDocumentIdentifier`](../../identifier/type-aliases/StableDocumentIdentifier.md) ##### Returns | `null` | [`ResourceDocument`](../../spec/document/type-aliases/ResourceDocument.md) *** ### peekRemoteState() #### Call Signature ```ts peekRemoteState(identifier): null | T; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:167](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L167) Peek remote resource data from the Cache. This will give the data provided from the server without any local changes. In development, if the return value is JSON the return value will be deep-cloned and deep-frozen to prevent mutation thereby enforcing cache Immutability. This form of peek is useful for implementations that want to feed raw-data from cache to the UI or which want to interact with a blob of data directly from the presentation cache. An implementation might want to do this because de-referencing records which read from their own blob is generally safer because the record does not require retainining connections to the Store and Cache to present data on a per-field basis. This generally takes the place of `getAttr` as an API and may even take the place of `getRelationship` depending on implementation specifics, though this latter usage is less recommended due to the advantages of the Graph handling necessary entanglements and notifications for relational data. ##### Type Parameters ###### T `T` = `unknown` ##### Parameters ###### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md)<[`TypeFromInstanceOrString`](../../record/type-aliases/TypeFromInstanceOrString.md)<`T`>> ##### Returns `null` | `T` the known resource data #### Call Signature ```ts peekRemoteState(identifier): | null | ResourceDocument; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:168](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L168) ##### Parameters ###### identifier [`StableDocumentIdentifier`](../../identifier/type-aliases/StableDocumentIdentifier.md) ##### Returns | `null` | [`ResourceDocument`](../../spec/document/type-aliases/ResourceDocument.md) *** ### peekRequest() ```ts peekRequest(identifier): | null | StructuredDocument; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:182](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L182) Peek the Cache for the existing request data associated with a cacheable request This is effectively the reverse of `put` for a request in that it will return the the request, response, and content whereas `peek` will return just the `content`. #### Parameters ##### identifier [`StableDocumentIdentifier`](../../identifier/type-aliases/StableDocumentIdentifier.md) #### Returns | `null` | [`StructuredDocument`](../../request/type-aliases/StructuredDocument.md)<[`ResourceDocument`](../../spec/document/type-aliases/ResourceDocument.md)> *** ### put() ```ts put(doc): ResourceDocument; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:79](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L79) Cache the response to a request Unlike `store.push` which has UPSERT semantics, `put` has `replace` semantics similar to the `http` method `PUT` the individually cacheable resource data it may contain should upsert, but the document data surrounding it should fully replace any existing information Note that in order to support inserting arbitrary data to the cache that did not originate from a request `put` should expect to sometimes encounter a document with only a `content` member and therefor must not assume the existence of `request` and `response` on the document. #### Type Parameters ##### T `T` #### Parameters ##### doc [`StructuredDocument`](../../request/type-aliases/StructuredDocument.md)<`T`> | { `content`: `T`; } #### Returns [`ResourceDocument`](../../spec/document/type-aliases/ResourceDocument.md) *** ### rollbackAttrs() ```ts rollbackAttrs(identifier): string[]; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:412](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L412) Tell the cache to discard any uncommitted mutations to attributes This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `string`\[] the names of fields that were restored *** ### rollbackRelationships() ```ts rollbackRelationships(identifier): string[]; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:462](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L462) Tell the cache to discard any uncommitted mutations to relationships. This will also discard the change on any appropriate inverses. This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `string`\[] the names of relationships that were restored *** ### setAttr() ```ts setAttr( identifier, field, value): void; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:377](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L377) Mutate the data for an attribute in the cache This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### field `string` | `string`\[] ##### value [`Value`](../../json/raw/type-aliases/Value.md) #### Returns `void` *** ### setIsDeleted() ```ts setIsDeleted(identifier, isDeleted): void; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:505](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L505) Update the cache state for the given resource to be marked as locally deleted, or remove such a mark. This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### isDeleted `boolean` #### Returns `void` *** ### unloadRecord() ```ts unloadRecord(identifier): void; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:342](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L342) \[LIFECYCLE] Signals to the cache that all data for a resource should be cleared. This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `void` *** ### upsert() ```ts upsert( identifier, data, hasRecord): void | string[]; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:193](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L193) Push resource data from a remote source into the cache for this identifier #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### data `unknown` ##### hasRecord `boolean` #### Returns `void` | `string`\[] if `hasRecord` is true then calculated key changes should be returned *** ### willCommit() ```ts willCommit(identifier, context): void; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:310](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L310) \[LIFECYCLE] Signals to the cache that a resource will be part of a save transaction. #### Parameters ##### identifier [`StableRecordIdentifier`](../../identifier/type-aliases/StableRecordIdentifier.md) ##### context [`RequestContext`](../../request/interfaces/RequestContext.md) #### Returns `void` --- --- url: >- /api/@warp-drive/core/types/cache/mutations/interfaces/AddToResourceRelationshipMutation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/mutations](../index.md) / AddToResourceRelationshipMutation Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:3](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L3) ## Properties ### field ```ts field: string; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:6](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L6) *** ### index? ```ts optional index: number; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:8](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L8) *** ### op ```ts op: "add"; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:4](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L4) *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:5](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L5) *** ### value ```ts value: | StableRecordIdentifier | StableRecordIdentifier[]; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:7](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L7) --- --- url: >- /api/@warp-drive/core/types/cache/mutations/interfaces/ReplaceRelatedRecordMutation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/mutations](../index.md) / ReplaceRelatedRecordMutation Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:19](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L19) ## Properties ### field ```ts field: string; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:22](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L22) *** ### index? ```ts optional index: number; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:28](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L28) *** ### op ```ts op: "replaceRelatedRecord"; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:20](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L20) *** ### prior? ```ts optional prior: StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:27](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L27) *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:21](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L21) *** ### value ```ts value: | null | StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:24](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L24) --- --- url: >- /api/@warp-drive/core/types/cache/mutations/interfaces/ReplaceRelatedRecordsMutation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/mutations](../index.md) / ReplaceRelatedRecordsMutation Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:31](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L31) ## Properties ### field ```ts field: string; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:34](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L34) *** ### index? ```ts optional index: number; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:43](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L43) *** ### op ```ts op: "replaceRelatedRecords"; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:32](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L32) *** ### prior? ```ts optional prior: StableRecordIdentifier[]; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:40](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L40) *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:33](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L33) *** ### value ```ts value: StableRecordIdentifier[]; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:37](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L37) --- --- url: >- /api/@warp-drive/core/types/cache/mutations/interfaces/SortRelatedRecordsMutation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/mutations](../index.md) / SortRelatedRecordsMutation Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:46](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L46) ## Properties ### field ```ts field: string; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:49](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L49) *** ### op ```ts op: "sortRelatedRecords"; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:47](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L47) *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:48](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L48) *** ### value ```ts value: StableRecordIdentifier[]; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:50](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L50) --- --- url: /api/@warp-drive/core/types/cache/mutations/type-aliases/Mutation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/mutations](../index.md) / Mutation ```ts type Mutation = | ReplaceRelatedRecordsMutation | ReplaceRelatedRecordMutation | RemoveFromResourceRelationshipMutation | AddToResourceRelationshipMutation | SortRelatedRecordsMutation; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:67](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L67) --- --- url: /api/@warp-drive/core/types/cache/operations.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / types/cache/operations ## Interfaces * [AddResourceOperation](interfaces/AddResourceOperation.md) * [AddToDocumentOperation](interfaces/AddToDocumentOperation.md) * [AddToResourceRelationshipOperation](interfaces/AddToResourceRelationshipOperation.md) * [MergeOperation](interfaces/MergeOperation.md) * [Op](interfaces/Op.md) * [RemoveDocumentOperation](interfaces/RemoveDocumentOperation.md) * [RemoveFromDocumentOperation](interfaces/RemoveFromDocumentOperation.md) * [RemoveFromResourceRelationshipOperation](interfaces/RemoveFromResourceRelationshipOperation.md) * [RemoveResourceOperation](interfaces/RemoveResourceOperation.md) * [UpdateResourceFieldOperation](interfaces/UpdateResourceFieldOperation.md) * [UpdateResourceOperation](interfaces/UpdateResourceOperation.md) * [UpdateResourceRelationshipOperation](interfaces/UpdateResourceRelationshipOperation.md) ## Type Aliases * [Operation](type-aliases/Operation.md) --- --- url: >- /api/@warp-drive/core/types/cache/mutations/interfaces/RemoveFromResourceRelationshipMutation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/mutations](../index.md) / RemoveFromResourceRelationshipMutation Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:11](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L11) ## Properties ### field ```ts field: string; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:14](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L14) *** ### index? ```ts optional index: number; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:16](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L16) *** ### op ```ts op: "remove"; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:12](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L12) *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:13](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L13) *** ### value ```ts value: | StableRecordIdentifier | StableRecordIdentifier[]; ``` Defined in: [warp-drive-packages/core/src/types/cache/mutations.ts:15](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/mutations.ts#L15) --- --- url: >- /api/@warp-drive/core/types/cache/operations/interfaces/AddResourceOperation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/operations](../index.md) / AddResourceOperation Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:40](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L40) ## Extends * [`Op`](Op.md) ## Properties ### op ```ts op: "add"; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:41](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L41) #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableExistingRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:42](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L42) *** ### value ```ts value: ExistingResourceObject; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:43](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L43) --- --- url: >- /api/@warp-drive/core/types/cache/operations/interfaces/AddToDocumentOperation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/operations](../index.md) / AddToDocumentOperation Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:66](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L66) ## Extends * [`Op`](Op.md) ## Properties ### field ```ts field: "data" | "included"; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:69](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L69) *** ### index? ```ts optional index: number; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:71](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L71) *** ### op ```ts op: "add"; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:67](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L67) #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableDocumentIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:68](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L68) *** ### value ```ts value: | StableExistingRecordIdentifier | StableExistingRecordIdentifier[]; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:70](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L70) --- --- url: /api/@warp-drive/core/types/cache/operations/interfaces/MergeOperation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/operations](../index.md) / MergeOperation Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:22](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L22) ## Extends * [`Op`](Op.md) ## Properties ### op ```ts op: "mergeIdentifiers"; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:23](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L23) #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:25](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L25) *** ### value ```ts value: StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:27](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L27) --- --- url: /api/@warp-drive/core/types/cache/operations/interfaces/Op.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/operations](../index.md) / Op Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:10](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L10) ## Extended by * [`MergeOperation`](MergeOperation.md) * [`RemoveDocumentOperation`](RemoveDocumentOperation.md) * [`RemoveResourceOperation`](RemoveResourceOperation.md) * [`AddResourceOperation`](AddResourceOperation.md) * [`UpdateResourceOperation`](UpdateResourceOperation.md) * [`UpdateResourceFieldOperation`](UpdateResourceFieldOperation.md) * [`UpdateResourceRelationshipOperation`](UpdateResourceRelationshipOperation.md) * [`AddToDocumentOperation`](AddToDocumentOperation.md) * [`AddToResourceRelationshipOperation`](AddToResourceRelationshipOperation.md) * [`RemoveFromResourceRelationshipOperation`](RemoveFromResourceRelationshipOperation.md) * [`RemoveFromDocumentOperation`](RemoveFromDocumentOperation.md) ## Properties ### op ```ts op: string; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:11](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L11) --- --- url: >- /api/@warp-drive/core/types/cache/operations/interfaces/AddToResourceRelationshipOperation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/operations](../index.md) / AddToResourceRelationshipOperation Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:73](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L73) ## Extends * [`Op`](Op.md) ## Properties ### field ```ts field: string; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:76](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L76) *** ### index? ```ts optional index: number; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:78](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L78) *** ### op ```ts op: "add"; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:74](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L74) #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableExistingRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:75](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L75) *** ### value ```ts value: | StableExistingRecordIdentifier | StableExistingRecordIdentifier[]; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:77](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L77) --- --- url: >- /api/@warp-drive/core/types/cache/operations/interfaces/RemoveDocumentOperation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/operations](../index.md) / RemoveDocumentOperation Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:30](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L30) ## Extends * [`Op`](Op.md) ## Properties ### op ```ts op: "remove"; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:31](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L31) #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableDocumentIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:32](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L32) --- --- url: >- /api/@warp-drive/core/types/cache/operations/interfaces/RemoveFromDocumentOperation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/operations](../index.md) / RemoveFromDocumentOperation Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:89](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L89) ## Extends * [`Op`](Op.md) ## Properties ### field ```ts field: "data" | "included"; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:92](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L92) *** ### index? ```ts optional index: number; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:94](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L94) *** ### op ```ts op: "remove"; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:90](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L90) #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableDocumentIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:91](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L91) *** ### value ```ts value: | StableExistingRecordIdentifier | StableExistingRecordIdentifier[]; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:93](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L93) --- --- url: >- /api/@warp-drive/core/types/cache/operations/interfaces/RemoveFromResourceRelationshipOperation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/operations](../index.md) / RemoveFromResourceRelationshipOperation Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:81](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L81) ## Extends * [`Op`](Op.md) ## Properties ### field ```ts field: string; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:84](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L84) *** ### index? ```ts optional index: number; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:86](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L86) *** ### op ```ts op: "remove"; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:82](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L82) #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableExistingRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:83](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L83) *** ### value ```ts value: | StableExistingRecordIdentifier | StableExistingRecordIdentifier[]; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:85](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L85) --- --- url: >- /api/@warp-drive/core/types/cache/operations/interfaces/RemoveResourceOperation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/operations](../index.md) / RemoveResourceOperation Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:35](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L35) ## Extends * [`Op`](Op.md) ## Properties ### op ```ts op: "remove"; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:36](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L36) #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableExistingRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:37](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L37) --- --- url: >- /api/@warp-drive/core/types/cache/operations/interfaces/UpdateResourceFieldOperation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/operations](../index.md) / UpdateResourceFieldOperation Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:52](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L52) ## Extends * [`Op`](Op.md) ## Properties ### field ```ts field: string; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:55](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L55) *** ### op ```ts op: "update"; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:53](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L53) #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableExistingRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:54](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L54) *** ### value ```ts value: Value; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:56](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L56) --- --- url: >- /api/@warp-drive/core/types/cache/operations/interfaces/UpdateResourceRelationshipOperation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/operations](../index.md) / UpdateResourceRelationshipOperation Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:59](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L59) ## Extends * [`Op`](Op.md) ## Properties ### field ```ts field: string; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:62](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L62) *** ### op ```ts op: "update"; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:60](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L60) #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableExistingRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:61](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L61) *** ### value ```ts value: Relationship>; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:63](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L63) --- --- url: /api/@warp-drive/core/types/cache/operations/type-aliases/Operation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/operations](../index.md) / Operation ```ts type Operation = | MergeOperation | RemoveResourceOperation | RemoveDocumentOperation | AddResourceOperation | UpdateResourceOperation | UpdateResourceFieldOperation | AddToResourceRelationshipOperation | RemoveFromResourceRelationshipOperation | AddToDocumentOperation | RemoveFromDocumentOperation; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:101](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L101) --- --- url: /api/@warp-drive/core/types/cache/relationship.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / types/cache/relationship ## Interfaces * [CollectionRelationship](interfaces/CollectionRelationship.md) * [ResourceRelationship](interfaces/ResourceRelationship.md) ## Type Aliases * [Relationship](type-aliases/Relationship.md) --- --- url: >- /api/@warp-drive/core/types/cache/operations/interfaces/UpdateResourceOperation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/operations](../index.md) / UpdateResourceOperation Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:46](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L46) ## Extends * [`Op`](Op.md) ## Properties ### op ```ts op: "update"; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:47](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L47) #### Overrides [`Op`](Op.md).[`op`](Op.md#op) *** ### record ```ts record: StableExistingRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:48](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L48) *** ### value ```ts value: ExistingResourceObject; ``` Defined in: [warp-drive-packages/core/src/types/cache/operations.ts:49](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/operations.ts#L49) --- --- url: >- /api/@warp-drive/core/types/cache/relationship/interfaces/CollectionRelationship.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/relationship](../index.md) / CollectionRelationship Defined in: [warp-drive-packages/core/src/types/cache/relationship.ts:13](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/relationship.ts#L13) ## Type Parameters ### T `T` = [`StableRecordIdentifier`](../../../identifier/type-aliases/StableRecordIdentifier.md) ## Properties ### data? ```ts optional data: T[]; ``` Defined in: [warp-drive-packages/core/src/types/cache/relationship.ts:14](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/relationship.ts#L14) *** ### links? ```ts optional links: PaginationLinks; ``` Defined in: [warp-drive-packages/core/src/types/cache/relationship.ts:16](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/relationship.ts#L16) *** ### meta? ```ts optional meta: ObjectValue; ``` Defined in: [warp-drive-packages/core/src/types/cache/relationship.ts:15](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/relationship.ts#L15) --- --- url: >- /api/@warp-drive/core/types/cache/relationship/interfaces/ResourceRelationship.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/relationship](../index.md) / ResourceRelationship Defined in: [warp-drive-packages/core/src/types/cache/relationship.ts:5](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/relationship.ts#L5) ## Type Parameters ### T `T` = [`StableRecordIdentifier`](../../../identifier/type-aliases/StableRecordIdentifier.md) ## Properties ### data? ```ts optional data: null | T; ``` Defined in: [warp-drive-packages/core/src/types/cache/relationship.ts:6](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/relationship.ts#L6) *** ### links? ```ts optional links: Links; ``` Defined in: [warp-drive-packages/core/src/types/cache/relationship.ts:8](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/relationship.ts#L8) *** ### meta? ```ts optional meta: ObjectValue; ``` Defined in: [warp-drive-packages/core/src/types/cache/relationship.ts:7](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/relationship.ts#L7) --- --- url: /api/@warp-drive/core/types/cache/relationship/type-aliases/Relationship.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/cache/relationship](../index.md) / Relationship ```ts type Relationship = | ResourceRelationship | CollectionRelationship; ``` Defined in: [warp-drive-packages/core/src/types/cache/relationship.ts:19](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache/relationship.ts#L19) ## Type Parameters ### T `T` = [`StableRecordIdentifier`](../../../identifier/type-aliases/StableRecordIdentifier.md) --- --- url: /api/@warp-drive/core/types/cache/type-aliases/RelationshipDiff.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/cache](../index.md) / RelationshipDiff ```ts type RelationshipDiff = | { additions: Set; kind: "collection"; localState: StableRecordIdentifier[]; remoteState: StableRecordIdentifier[]; removals: Set; reordered: boolean; } | { kind: "resource"; localState: | StableRecordIdentifier | null; remoteState: | StableRecordIdentifier | null; }; ``` Defined in: [warp-drive-packages/core/src/types/cache.ts:21](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/cache.ts#L21) --- --- url: /api/@warp-drive/core/types/graph.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / types/graph ## Interfaces * [DeleteRecordOperation](interfaces/DeleteRecordOperation.md) * [Operation](interfaces/Operation.md) * [ReplaceRelatedRecordOperation](interfaces/ReplaceRelatedRecordOperation.md) * [ReplaceRelatedRecordsOperation](interfaces/ReplaceRelatedRecordsOperation.md) * [SortRelatedRecords](interfaces/SortRelatedRecords.md) * [UnknownOperation](interfaces/UnknownOperation.md) * [UpdateRelationshipOperation](interfaces/UpdateRelationshipOperation.md) ## Type Aliases * [LocalRelationshipOperation](type-aliases/LocalRelationshipOperation.md) * [RemoteRelationshipOperation](type-aliases/RemoteRelationshipOperation.md) --- --- url: /api/@warp-drive/core/types/graph/interfaces/DeleteRecordOperation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/graph](../index.md) / DeleteRecordOperation Defined in: [warp-drive-packages/core/src/types/graph.ts:24](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L24) ## Properties ### isNew ```ts isNew: boolean; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:27](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L27) *** ### op ```ts op: "deleteRecord"; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:25](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L25) *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:26](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L26) --- --- url: /api/@warp-drive/core/types/graph/interfaces/Operation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/graph](../index.md) / Operation Defined in: [warp-drive-packages/core/src/types/graph.ts:13](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L13) ## Properties ### op ```ts op: string; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:14](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L14) --- --- url: /api/@warp-drive/core/types/graph/interfaces/ReplaceRelatedRecordsOperation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/graph](../index.md) / ReplaceRelatedRecordsOperation Defined in: [warp-drive-packages/core/src/types/graph.ts:52](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L52) ## Properties ### field ```ts field: string; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:55](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L55) *** ### index? ```ts optional index: number; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:58](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L58) *** ### op ```ts op: "replaceRelatedRecords"; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:53](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L53) *** ### prior? ```ts optional prior: StableRecordIdentifier[]; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:57](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L57) *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:54](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L54) *** ### value ```ts value: StableRecordIdentifier[]; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:56](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L56) --- --- url: /api/@warp-drive/core/types/graph/interfaces/ReplaceRelatedRecordOperation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/graph](../index.md) / ReplaceRelatedRecordOperation Defined in: [warp-drive-packages/core/src/types/graph.ts:36](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L36) ## Properties ### field ```ts field: string; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:39](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L39) *** ### index? ```ts optional index: number; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:42](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L42) *** ### op ```ts op: "replaceRelatedRecord"; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:37](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L37) *** ### prior? ```ts optional prior: StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:41](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L41) *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:38](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L38) *** ### value ```ts value: | null | StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:40](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L40) --- --- url: /api/@warp-drive/core/types/graph/interfaces/SortRelatedRecords.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/graph](../index.md) / SortRelatedRecords Defined in: [warp-drive-packages/core/src/types/graph.ts:45](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L45) ## Properties ### field ```ts field: string; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:48](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L48) *** ### op ```ts op: "sortRelatedRecords"; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:46](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L46) *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:47](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L47) *** ### value ```ts value: StableRecordIdentifier[]; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:49](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L49) --- --- url: /api/@warp-drive/core/types/graph/interfaces/UnknownOperation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/graph](../index.md) / UnknownOperation Defined in: [warp-drive-packages/core/src/types/graph.ts:30](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L30) ## Properties ### field ```ts field: string; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:33](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L33) *** ### op ```ts op: "never"; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:31](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L31) *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:32](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L32) --- --- url: /api/@warp-drive/core/types/graph/interfaces/UpdateRelationshipOperation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/graph](../index.md) / UpdateRelationshipOperation Defined in: [warp-drive-packages/core/src/types/graph.ts:17](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L17) ## Properties ### field ```ts field: string; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:20](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L20) *** ### op ```ts op: "updateRelationship"; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:18](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L18) *** ### record ```ts record: StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:19](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L19) *** ### value ```ts value: | SingleResourceRelationship< | ExistingResourceIdentifierObject | NewResourceIdentifierObject> | CollectionResourceRelationship< | ExistingResourceIdentifierObject | NewResourceIdentifierObject>; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:21](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L21) --- --- url: /api/@warp-drive/core/types/graph/type-aliases/LocalRelationshipOperation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/graph](../index.md) / LocalRelationshipOperation ```ts type LocalRelationshipOperation = | ReplaceRelatedRecordsOperation | ReplaceRelatedRecordOperation | AddToResourceRelationshipMutation | RemoveFromResourceRelationshipMutation | SortRelatedRecords; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:71](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L71) --- --- url: /api/@warp-drive/core/types/graph/type-aliases/RemoteRelationshipOperation.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/graph](../index.md) / RemoteRelationshipOperation ```ts type RemoteRelationshipOperation = | UpdateResourceRelationshipOperation | UpdateRelationshipOperation | ReplaceRelatedRecordOperation | ReplaceRelatedRecordsOperation | RemoveFromResourceRelationshipOperation | AddToResourceRelationshipOperation | DeleteRecordOperation | SortRelatedRecords; ``` Defined in: [warp-drive-packages/core/src/types/graph.ts:61](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/graph.ts#L61) --- --- url: /api/@warp-drive/core/types/identifier.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / types/identifier ## Interfaces * [ExistingRecordIdentifier](interfaces/ExistingRecordIdentifier.md) * [Identifier](interfaces/Identifier.md) * [NewRecordIdentifier](interfaces/NewRecordIdentifier.md) ## Type Aliases * [IdentifierBucket](type-aliases/IdentifierBucket.md) * [RequestKey](type-aliases/RequestKey.md) * [ResourceKey](type-aliases/ResourceKey.md) * [StableDocumentIdentifier](type-aliases/StableDocumentIdentifier.md) * [StableRecordIdentifier](type-aliases/StableRecordIdentifier.md) ## Variables * [CACHE\_OWNER](variables/CACHE_OWNER.md) * [DEBUG\_CLIENT\_ORIGINATED](variables/DEBUG_CLIENT_ORIGINATED.md) * [DEBUG\_IDENTIFIER\_BUCKET](variables/DEBUG_IDENTIFIER_BUCKET.md) * [DEBUG\_STALE\_CACHE\_OWNER](variables/DEBUG_STALE_CACHE_OWNER.md) --- --- url: /api/@warp-drive/core/types/identifier/interfaces/ExistingRecordIdentifier.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/identifier](../index.md) / ExistingRecordIdentifier Defined in: [warp-drive-packages/core/src/types/identifier.ts:22](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L22) ## Extends * [`Identifier`](Identifier.md) ## Type Parameters ### T `T` *extends* `string` = `string` ## Properties ### clientId? ```ts optional clientId: string; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:19](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L19) #### Inherited from [`Identifier`](Identifier.md).[`clientId`](Identifier.md#clientid) *** ### id ```ts id: string; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:23](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L23) *** ### lid ```ts lid: string; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:18](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L18) #### Inherited from [`Identifier`](Identifier.md).[`lid`](Identifier.md#lid) *** ### type ```ts type: T; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:24](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L24) --- --- url: /api/@warp-drive/core/types/identifier/interfaces/Identifier.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/identifier](../index.md) / Identifier Defined in: [warp-drive-packages/core/src/types/identifier.ts:17](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L17) ## Extended by * [`ExistingRecordIdentifier`](ExistingRecordIdentifier.md) * [`NewRecordIdentifier`](NewRecordIdentifier.md) ## Properties ### clientId? ```ts optional clientId: string; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:19](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L19) *** ### lid ```ts lid: string; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:18](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L18) --- --- url: /api/@warp-drive/core/types/identifier/interfaces/NewRecordIdentifier.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/identifier](../index.md) / NewRecordIdentifier Defined in: [warp-drive-packages/core/src/types/identifier.ts:27](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L27) ## Extends * [`Identifier`](Identifier.md) ## Type Parameters ### T `T` *extends* `string` = `string` ## Properties ### clientId? ```ts optional clientId: string; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:19](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L19) #### Inherited from [`Identifier`](Identifier.md).[`clientId`](Identifier.md#clientid) *** ### id ```ts id: null | string; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:28](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L28) *** ### lid ```ts lid: string; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:18](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L18) #### Inherited from [`Identifier`](Identifier.md).[`lid`](Identifier.md#lid) *** ### type ```ts type: T; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:29](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L29) --- --- url: /api/@warp-drive/core/types/identifier/type-aliases/IdentifierBucket.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/identifier](../index.md) / IdentifierBucket ```ts type IdentifierBucket = "record" | "document"; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:15](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L15) --- --- url: /api/@warp-drive/core/types/identifier/type-aliases/RequestKey.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/identifier](../index.md) / RequestKey ```ts type RequestKey = StableDocumentIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:35](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L35) --- --- url: /api/@warp-drive/core/types/identifier/type-aliases/ResourceKey.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/identifier](../index.md) / ResourceKey ```ts type ResourceKey = StableRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:133](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L133) ## Type Parameters ### T `T` *extends* `string` = `string` --- --- url: >- /api/@warp-drive/core/types/identifier/type-aliases/StableDocumentIdentifier.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/identifier](../index.md) / StableDocumentIdentifier ```ts type StableDocumentIdentifier = object; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:32](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L32) ## Properties ### lid ```ts lid: string; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:33](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L33) --- --- url: /api/@warp-drive/core/types/identifier/type-aliases/StableRecordIdentifier.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/identifier](../index.md) / StableRecordIdentifier ```ts type StableRecordIdentifier = | StableExistingRecordIdentifier | StableNewRecordIdentifier; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:129](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L129) the primary id for the record this identity belongs to. `null` if not yet assigned an id. ## Type Parameters ### T `T` *extends* `string` = `string` --- --- url: /api/@warp-drive/core/types/identifier/variables/DEBUG_CLIENT_ORIGINATED.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/identifier](../index.md) / DEBUG\_CLIENT\_ORIGINATED ```ts const DEBUG_CLIENT_ORIGINATED: unique symbol; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:4](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L4) --- --- url: /api/@warp-drive/core/types/identifier/variables/CACHE_OWNER.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/identifier](../index.md) / CACHE\_OWNER ```ts const CACHE_OWNER: "__$co"; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:13](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L13) --- --- url: /api/@warp-drive/core/types/identifier/variables/DEBUG_IDENTIFIER_BUCKET.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/identifier](../index.md) / DEBUG\_IDENTIFIER\_BUCKET ```ts const DEBUG_IDENTIFIER_BUCKET: unique symbol; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:5](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L5) --- --- url: /api/@warp-drive/core/types/identifier/variables/DEBUG_STALE_CACHE_OWNER.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/identifier](../index.md) / DEBUG\_STALE\_CACHE\_OWNER ```ts const DEBUG_STALE_CACHE_OWNER: unique symbol; ``` Defined in: [warp-drive-packages/core/src/types/identifier.ts:6](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/identifier.ts#L6) --- --- url: /api/@warp-drive/core/types.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / types This package provides core types, type-utilities, symbols and constants used across the WarpDrive ecosystem. ## Interfaces * [BaseFinderOptions](interfaces/BaseFinderOptions.md) * [FindRecordOptions](interfaces/FindRecordOptions.md) * [ModelSchema](interfaces/ModelSchema.md) * [SchemaService](interfaces/SchemaService.md) ## Type Aliases * [CacheCapabilitiesManager](type-aliases/CacheCapabilitiesManager.md) * [FindAllOptions](type-aliases/FindAllOptions.md) * [LegacyResourceQuery](type-aliases/LegacyResourceQuery.md) * [QueryOptions](type-aliases/QueryOptions.md) ## References ### ResourceKey Re-exports [ResourceKey](identifier/type-aliases/ResourceKey.md) *** ### StableRecordIdentifier Re-exports [StableRecordIdentifier](identifier/type-aliases/StableRecordIdentifier.md) --- --- url: /api/@warp-drive/core/types/interfaces/BaseFinderOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [types](../index.md) / BaseFinderOptions Defined in: [warp-drive-packages/core/src/store/-types/q/store.ts:4](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/store.ts#L4) ## Extended by * [`FindRecordOptions`](FindRecordOptions.md) ## Type Parameters ### T `T` = `unknown` ## Properties ### adapterOptions? ```ts optional adapterOptions: Record; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/store.ts:8](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/store.ts#L8) *** ### backgroundReload? ```ts optional backgroundReload: boolean; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/store.ts:6](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/store.ts#L6) *** ### include? ```ts optional include: T extends TypedRecordInstance ? Includes>[] : string | string[]; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/store.ts:7](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/store.ts#L7) *** ### reload? ```ts optional reload: boolean; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/store.ts:5](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/store.ts#L5) --- --- url: /api/@warp-drive/core/types/interfaces/FindRecordOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [types](../index.md) / FindRecordOptions Defined in: [warp-drive-packages/core/src/store/-types/q/store.ts:10](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/store.ts#L10) ## Extends * [`BaseFinderOptions`](BaseFinderOptions.md)<`T`> ## Type Parameters ### T `T` = `unknown` ## Properties ### adapterOptions? ```ts optional adapterOptions: Record; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/store.ts:8](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/store.ts#L8) #### Inherited from [`BaseFinderOptions`](BaseFinderOptions.md).[`adapterOptions`](BaseFinderOptions.md#adapteroptions) *** ### backgroundReload? ```ts optional backgroundReload: boolean; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/store.ts:6](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/store.ts#L6) #### Inherited from [`BaseFinderOptions`](BaseFinderOptions.md).[`backgroundReload`](BaseFinderOptions.md#backgroundreload) *** ### include? ```ts optional include: T extends TypedRecordInstance ? Exclude<_ExtractUnion<3, T, true, NONE, NONE, 1>, NONE>[] : string | string[]; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/store.ts:7](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/store.ts#L7) #### Inherited from [`BaseFinderOptions`](BaseFinderOptions.md).[`include`](BaseFinderOptions.md#include) *** ### preload? ```ts optional preload: Record; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/store.ts:26](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/store.ts#L26) Data to preload into the store before the request is made. This feature is *highly* discouraged and has no corresponding feature when using builders and handlers. Excepting relationships: the data should be in the form of a JSON object where the keys are fields on the record and the value is the raw value to be added to the cache. Relationships can either be provided as string IDs from which an identifier will be built base upon the relationship's expected resource type, or be record instances from which the identifier will be extracted. *** ### reload? ```ts optional reload: boolean; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/store.ts:5](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/store.ts#L5) #### Inherited from [`BaseFinderOptions`](BaseFinderOptions.md).[`reload`](BaseFinderOptions.md#reload) --- --- url: /api/@warp-drive/core/types/interfaces/ModelSchema.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [types](../index.md) / ModelSchema Defined in: [warp-drive-packages/core/src/store/-types/q/ds-model.ts:15](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/ds-model.ts#L15) Minimum subset of static schema methods and properties on the "model" class. Only used when using the legacy schema-service implementation for @ember-data/model or when wrapping schema for legacy Adapters/Serializers. ## Type Parameters ### T `T` = `unknown` ## Properties ### attributes ```ts attributes: Map, LegacyAttributeField>; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/ds-model.ts:18](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/ds-model.ts#L18) *** ### fields ```ts fields: Map, "attribute" | "belongsTo" | "hasMany">; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/ds-model.ts:17](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/ds-model.ts#L17) *** ### modelName ```ts modelName: T extends TypedRecordInstance ? TypeFromInstance> : string; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/ds-model.ts:16](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/ds-model.ts#L16) *** ### relationshipsByName ```ts relationshipsByName: Map, LegacyRelationshipField>; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/ds-model.ts:19](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/ds-model.ts#L19) ## Methods ### eachAttribute() ```ts eachAttribute(callback, binding?): void; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/ds-model.ts:20](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/ds-model.ts#L20) #### Type Parameters ##### K `K` *extends* `string` #### Parameters ##### callback (`this`, `key`, `attribute`) => `void` ##### binding? `T` #### Returns `void` *** ### eachRelationship() ```ts eachRelationship(callback, binding?): void; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/ds-model.ts:24](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/ds-model.ts#L24) #### Type Parameters ##### K `K` *extends* `string` #### Parameters ##### callback (`this`, `key`, `relationship`) => `void` ##### binding? `T` #### Returns `void` *** ### eachTransformedAttribute() ```ts eachTransformedAttribute(callback, binding?): void; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/ds-model.ts:28](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/ds-model.ts#L28) #### Type Parameters ##### K `K` *extends* `string` #### Parameters ##### callback (`this`, `key`, `type`) => `void` ##### binding? `T` #### Returns `void` --- --- url: /api/@warp-drive/core/types/interfaces/SchemaService.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [types](../index.md) / SchemaService Defined in: [warp-drive-packages/core/src/store/-types/q/schema-service.ts:73](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/schema-service.ts#L73) The SchemaService provides the ability to query for information about the structure of any resource type. Applications can provide any implementation of the SchemaService they please so long as it conforms to this interface. The design of the service means that schema information could be lazily populated, derived-on-demand, or progressively enhanced during the course of an application's runtime. The primary requirement is merely that any information the service needs to correctly respond to an inquest is available by the time it is asked. The `@ember-data/model` package provides an implementation of this service which makes use of your model classes as the source of information to respond to queries about resource schema. While this is useful, this may not be ideal for your application. For instance, Schema information could be sideloaded or pre-flighted for API calls, resulting in no need to bundle and ship potentially large and expensive JSON or large Javascript based Models to pull information from. To register a custom schema implementation, implement the store's `createSchemaService` hook to return an instance of your service. ```ts import Store from '@ember-data/store'; import CustomSchemas from './custom-schemas'; export default class extends Store { createSchemaService() { return new CustomSchemas(); } } ``` At runtime, both the `Store` and the `CacheCapabilitiesManager` provide access to this service via the `schema` property. ```ts export default class extends Component { @service store; get fields() { return this.store .schema .fields(this.args.dataType); } } ``` (Interface) SchemaService ## Methods ### ~~attributesDefinitionFor()?~~ ```ts optional attributesDefinitionFor(identifier): AttributesSchema; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/schema-service.ts:266](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/schema-service.ts#L266) DEPRECATED - use `fields` instead Returns definitions for all properties of the specified resource that are considered "attributes". Generally these are properties that are not related to book-keeping state on the client and do not represent a linkage to another resource. The return value should be a dictionary of key:value pairs where the `key` is the attribute or property's name and `value` is an object with at least the property `name` which should also match `key`. Optionally, this object may also specify `type`, which should be a string reference to a `transform`, and `options` which should be dictionary in which any key:value pairs are permissable. For instance, when using `@ember-data/model`, the following attribute definition: ```ts class extends Model { @attr('string', { defaultValue: 'hello' }) greeting; @attr('date') birthday; @attr firstName; } ``` Would be returned as: ```js { greeting: { name: 'greeting', type: 'string', options: { defaultValue: 'hello' } }, birthday: { name: 'birthday', type: 'date' }, firstName: { name: 'firstName' } } ``` #### Parameters ##### identifier `RecordIdentifier` | `ObjectWithStringTypeProperty` #### Returns `AttributesSchema` #### Deprecated *** ### derivation() ```ts derivation(field): Derivation; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/schema-service.ts:153](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/schema-service.ts#L153) Returns the derivation registered with the name provided by `field.type`. Validates that the field is a valid DerivedField. #### Parameters ##### field [`DerivedField`](../schema/fields/interfaces/DerivedField.md) | `ObjectWithStringTypeProperty` #### Returns [`Derivation`](../schema/concepts/type-aliases/Derivation.md) *** ### ~~doesTypeExist()?~~ ```ts optional doesTypeExist(type): boolean; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/schema-service.ts:84](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/schema-service.ts#L84) DEPRECATED - use `hasResource` instead Queries whether the SchemaService recognizes `type` as a resource type #### Parameters ##### type `string` #### Returns `boolean` #### Deprecated *** ### fields() ```ts fields(resource): Map; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/schema-service.ts:123](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/schema-service.ts#L123) Queries for the fields of a given resource type or resource identity. Should error if the resource type is not recognized. #### Parameters ##### resource [`StableRecordIdentifier`](../identifier/type-aliases/StableRecordIdentifier.md) | `ObjectWithStringTypeProperty` #### Returns `Map`<`string`, [`FieldSchema`](../schema/fields/type-aliases/FieldSchema.md)> *** ### hashFn() ```ts hashFn(field): HashFn; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/schema-service.ts:143](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/schema-service.ts#L143) Returns the hash function registered with the name provided by `field.type`. Validates that the field is a valid HashField. #### Parameters ##### field [`HashField`](../schema/fields/interfaces/HashField.md) | `ObjectWithStringTypeProperty` #### Returns [`HashFn`](../schema/concepts/type-aliases/HashFn.md) *** ### hasResource() ```ts hasResource(resource): boolean; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/schema-service.ts:93](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/schema-service.ts#L93) Queries whether the SchemaService recognizes `type` as a resource type #### Parameters ##### resource [`StableRecordIdentifier`](../identifier/type-aliases/StableRecordIdentifier.md) | `ObjectWithStringTypeProperty` #### Returns `boolean` *** ### hasTrait() ```ts hasTrait(type): boolean; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/schema-service.ts:102](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/schema-service.ts#L102) Queries whether the SchemaService recognizes `type` as a resource trait #### Parameters ##### type `string` #### Returns `boolean` *** ### registerDerivation() ```ts registerDerivation(derivation): void; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/schema-service.ts:210](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/schema-service.ts#L210) Enables registration of a derivation. The derivation can later be retrieved by the name attached to it's `[Type]` property. #### Type Parameters ##### R `R` ##### T `T` ##### FM `FM` *extends* `null` | [`ObjectValue`](../json/raw/interfaces/ObjectValue.md) #### Parameters ##### derivation [`Derivation`](../schema/concepts/type-aliases/Derivation.md)<`R`, `T`, `FM`> #### Returns `void` *** ### registerHashFn() ```ts registerHashFn(hashFn): void; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/schema-service.ts:221](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/schema-service.ts#L221) Enables registration of a hashing function The hashing function can later be retrieved by the name attached to it's `[Type]` property. #### Parameters ##### hashFn [`HashFn`](../schema/concepts/type-aliases/HashFn.md) #### Returns `void` *** ### registerResource() ```ts registerResource(schema): void; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/schema-service.ts:188](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/schema-service.ts#L188) Enables registration of a single Schema representing either a resource in PolarisMode or LegacyMode or an ObjectSchema representing an embedded structure in other schemas. This can be useful for either pre-loading schema information or for registering schema information delivered by API calls or other sources just-in-time. #### Parameters ##### schema [`Schema`](../schema/fields/type-aliases/Schema.md) #### Returns `void` *** ### registerResources() ```ts registerResources(schemas): void; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/schema-service.ts:174](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/schema-service.ts#L174) Enables registration of multiple Schemas at once. This can be useful for either pre-loading schema information or for registering schema information delivered by API calls or other sources just-in-time. #### Parameters ##### schemas [`Schema`](../schema/fields/type-aliases/Schema.md)\[] #### Returns `void` *** ### registerTransformation() ```ts registerTransformation(transform): void; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/schema-service.ts:199](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/schema-service.ts#L199) Enables registration of a transformation. The transformation can later be retrieved by the name attached to it's `[Type]` property. #### Parameters ##### transform [`Transformation`](../schema/concepts/type-aliases/Transformation.md) #### Returns `void` *** ### ~~relationshipsDefinitionFor()?~~ ```ts optional relationshipsDefinitionFor(identifier): RelationshipsSchema; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/schema-service.ts:348](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/schema-service.ts#L348) DEPRECATED - use `fields` instead Returns definitions for all properties of the specified resource that are considered "relationships". Generally these are properties that represent a linkage to another resource. The return value should be a dictionary of key:value pairs where the `key` is the relationship or property's name and `value` is an object with at least the following properties: * `name` which should also match the `key` used in the dictionary. * `kind` which should be either `belongsTo` or `hasMany` * `type` which should be the related resource's string "type" * `options` which should be a dictionary allowing any key but with at least the below keys present. * `options.async` a boolean representing whether data for this relationship is typically loaded on-demand. * `options.inverse` a string or null representing the field name / key of the corresponding relationship on the inverse resource. Additionally the following options properties are optional. See [Polymorphic Relationships](https://rfcs.emberjs.com/id/0793-polymporphic-relations-without-inheritance) * `options.polymorphic` a boolean representing whether multiple resource types can be used to satisfy this relationship. * `options.as` a string representing the abstract type that the concrete side of a relationship must specify when fulfilling a polymorphic inverse. For example, the following Model using @ember-data/model would generate this relationships definition by default: ```js class User extends Model { @belongsTo('user', { async: false, inverse: null }) bestFriend; @hasMany('user', { async: true, inverse: 'friends' }) friends; @hasMany('pet', { async: false, polymorphic: true, inverse: 'owner' }) pets; } ``` Which would be returned as ```js { bestFriend: { name: 'bestFriend', kind: 'belongsTo', type: 'user', options: { async: false, inverse: null } }, friends: { name: 'friends', kind: 'hasMany', type: 'user', options: { async: true, inverse: 'friends' } }, pets: { name: 'pets', kind: 'hasMany', type: 'pet', options: { async: false, polymorphic: true, inverse: 'owner' } }, } ``` #### Parameters ##### identifier `RecordIdentifier` | `ObjectWithStringTypeProperty` #### Returns `RelationshipsSchema` #### Deprecated *** ### resource() ```ts resource(resource): Schema; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/schema-service.ts:162](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/schema-service.ts#L162) Returns the schema for the provided resource type. #### Parameters ##### resource [`StableRecordIdentifier`](../identifier/type-aliases/StableRecordIdentifier.md) | `ObjectWithStringTypeProperty` #### Returns [`Schema`](../schema/fields/type-aliases/Schema.md) *** ### resourceHasTrait() ```ts resourceHasTrait(resource, trait): boolean; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/schema-service.ts:112](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/schema-service.ts#L112) Queries whether the given resource has the given trait #### Parameters ##### resource [`StableRecordIdentifier`](../identifier/type-aliases/StableRecordIdentifier.md) | `ObjectWithStringTypeProperty` ##### trait `string` #### Returns `boolean` *** ### resourceTypes() ```ts resourceTypes(): readonly string[]; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/schema-service.ts:356](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/schema-service.ts#L356) Returns all known resource types #### Returns readonly `string`\[] *** ### transformation() ```ts transformation(field): Transformation; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/schema-service.ts:133](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/schema-service.ts#L133) Returns the transformation registered with the name provided by `field.type`. Validates that the field is a valid transformable. #### Parameters ##### field [`GenericField`](../schema/fields/interfaces/GenericField.md) | [`ObjectField`](../schema/fields/interfaces/ObjectField.md) | [`ArrayField`](../schema/fields/interfaces/ArrayField.md) | `ObjectWithStringTypeProperty` #### Returns [`Transformation`](../schema/concepts/type-aliases/Transformation.md) --- --- url: /api/@warp-drive/core/types/json/raw.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / types/json/raw ## Interfaces * [ObjectValue](interfaces/ObjectValue.md) ## Type Aliases * [ArrayValue](type-aliases/ArrayValue.md) * [PrimitiveValue](type-aliases/PrimitiveValue.md) * [Value](type-aliases/Value.md) --- --- url: /api/@warp-drive/core/types/json/raw/interfaces/ObjectValue.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/json/raw](../index.md) / ObjectValue Defined in: [warp-drive-packages/core/src/types/json/raw.ts:2](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/json/raw.ts#L2) ## Indexable ```ts [key: string]: Value ``` --- --- url: /api/@warp-drive/core/types/json/raw/type-aliases/ArrayValue.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/json/raw](../index.md) / ArrayValue ```ts type ArrayValue = Value[]; ``` Defined in: [warp-drive-packages/core/src/types/json/raw.ts:5](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/json/raw.ts#L5) --- --- url: /api/@warp-drive/core/types/json/raw/type-aliases/PrimitiveValue.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/json/raw](../index.md) / PrimitiveValue ```ts type PrimitiveValue = string | number | boolean | null; ``` Defined in: [warp-drive-packages/core/src/types/json/raw.ts:1](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/json/raw.ts#L1) --- --- url: /api/@warp-drive/core/types/json/raw/type-aliases/Value.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/json/raw](../index.md) / Value ```ts type Value = | PrimitiveValue | ArrayValue | ObjectValue; ``` Defined in: [warp-drive-packages/core/src/types/json/raw.ts:7](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/json/raw.ts#L7) --- --- url: /api/@warp-drive/core/types/params.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / types/params ## Type Aliases * [QueryParamsSerializationOptions](type-aliases/QueryParamsSerializationOptions.md) * [QueryParamsSource](type-aliases/QueryParamsSource.md) * [Serializable](type-aliases/Serializable.md) * [SerializablePrimitive](type-aliases/SerializablePrimitive.md) --- --- url: >- /api/@warp-drive/core/types/params/type-aliases/QueryParamsSerializationOptions.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/params](../index.md) / QueryParamsSerializationOptions ```ts type QueryParamsSerializationOptions = object; ``` Defined in: [warp-drive-packages/core/src/types/params.ts:5](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/params.ts#L5) ## Properties ### arrayFormat? ```ts optional arrayFormat: "bracket" | "indices" | "repeat" | "comma"; ``` Defined in: [warp-drive-packages/core/src/types/params.ts:6](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/params.ts#L6) --- --- url: /api/@warp-drive/core/types/params/type-aliases/QueryParamsSource.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/params](../index.md) / QueryParamsSource ```ts type QueryParamsSource = | object & Record, Serializable> | URLSearchParams; ``` Defined in: [warp-drive-packages/core/src/types/params.ts:9](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/params.ts#L9) ## Type Parameters ### T `T` = `unknown` --- --- url: /api/@warp-drive/core/types/params/type-aliases/Serializable.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/params](../index.md) / Serializable ```ts type Serializable = | SerializablePrimitive | SerializablePrimitive[]; ``` Defined in: [warp-drive-packages/core/src/types/params.ts:4](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/params.ts#L4) --- --- url: /api/@warp-drive/core/types/record/functions/createIncludeValidator.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/record](../index.md) / createIncludeValidator ```ts function createIncludeValidator(): (includes) => U; ``` Defined in: [warp-drive-packages/core/src/types/record.ts:187](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/record.ts#L187) ## Type Parameters ### T `T` *extends* [`TypedRecordInstance`](../interfaces/TypedRecordInstance.md) ## Returns ```ts (includes): U; ``` ### Type Parameters #### U `U` *extends* `string` ### Parameters #### includes [`_StringSatisfiesIncludes`](../type-aliases/StringSatisfiesIncludes.md)<`U`, `Exclude`<`_ExtractUnion`<`3`, `T`, `true`, `NONE`, `NONE`, `1`>, `NONE`>> ### Returns `U` --- --- url: /api/@warp-drive/core/types/params/type-aliases/SerializablePrimitive.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/params](../index.md) / SerializablePrimitive ```ts type SerializablePrimitive = string | number | boolean | null; ``` Defined in: [warp-drive-packages/core/src/types/params.ts:3](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/params.ts#L3) --- --- url: /api/@warp-drive/core/types/record.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / types/record ## Interfaces * [TypedRecordInstance](interfaces/TypedRecordInstance.md) ## Type Aliases * [\_StringSatisfiesIncludes](type-aliases/StringSatisfiesIncludes.md) * [ExtractSuggestedCacheTypes](type-aliases/ExtractSuggestedCacheTypes.md) * [Includes](type-aliases/Includes.md) * [OpaqueRecordInstance](type-aliases/OpaqueRecordInstance.md) * [StringSatisfiesIncludes](type-aliases/StringSatisfiesIncludes-1.md) * [TypeFromInstance](type-aliases/TypeFromInstance.md) * [TypeFromInstanceOrString](type-aliases/TypeFromInstanceOrString.md) ## Functions * [createIncludeValidator](functions/createIncludeValidator.md) --- --- url: /api/@warp-drive/core/types/record/type-aliases/ExtractSuggestedCacheTypes.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/record](../index.md) / ExtractSuggestedCacheTypes ```ts type ExtractSuggestedCacheTypes = ExtractUnion; ``` Defined in: [warp-drive-packages/core/src/types/record.ts:157](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/record.ts#L157) A utility that provides the union of all ResourceName for all potential includes for the given TypedRecordInstance. ## Type Parameters ### T `T` *extends* [`TypedRecordInstance`](../interfaces/TypedRecordInstance.md) ### MAX\_DEPTH `MAX_DEPTH` *extends* `_DEPTHCOUNT` = `DEFAULT_MAX_DEPTH` --- --- url: /api/@warp-drive/core/types/record/type-aliases/Includes.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/record](../index.md) / Includes ```ts type Includes = ExtractUnion; ``` Defined in: [warp-drive-packages/core/src/types/record.ts:169](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/record.ts#L169) A utility that provides the union type of all valid include paths for the given TypedRecordInstance. Cyclical paths are filtered out. ## Type Parameters ### T `T` *extends* [`TypedRecordInstance`](../interfaces/TypedRecordInstance.md) ### MAX\_DEPTH `MAX_DEPTH` *extends* `_DEPTHCOUNT` = `DEFAULT_MAX_DEPTH` --- --- url: /api/@warp-drive/core/types/record/interfaces/TypedRecordInstance.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/record](../index.md) / TypedRecordInstance Defined in: [warp-drive-packages/core/src/types/record.ts:14](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/record.ts#L14) Records may be anything, They don't even have to be objects. Whatever they are, if they have a Type property, that property will be used by WarpDrive and WarpDrive to provide better type safety and intellisense. TypedRecordInstance ## Properties ### \_\_\_(unique) Symbol($type) ```ts ___(unique) Symbol($type): string; ``` Defined in: [warp-drive-packages/core/src/types/record.ts:30](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/record.ts#L30) The type of the resource. This is an optional feature that can be used by record implementations to provide a typescript hint for the type of the resource. When used, WarpDrive APIs can take advantage of this to provide better type safety and intellisense. --- --- url: /api/@warp-drive/core/types/record/type-aliases/OpaqueRecordInstance.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/record](../index.md) / OpaqueRecordInstance ```ts type OpaqueRecordInstance = unknown; ``` Defined in: [warp-drive-packages/core/src/types/record.ts:175](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/record.ts#L175) --- --- url: /api/@warp-drive/core/types/record/type-aliases/StringSatisfiesIncludes-1.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/record](../index.md) / StringSatisfiesIncludes ```ts type StringSatisfiesIncludes = _StringSatisfiesIncludes; ``` Defined in: [warp-drive-packages/core/src/types/record.ts:185](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/record.ts#L185) ## Type Parameters ### T `T` *extends* `string` ### SET `SET` *extends* `string` --- --- url: /api/@warp-drive/core/types/record/type-aliases/StringSatisfiesIncludes.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/record](../index.md) / \_StringSatisfiesIncludes ```ts type _StringSatisfiesIncludes = T extends SET ? FT : T extends `${infer U},${infer V}` ? U extends SET ? _StringSatisfiesIncludes, FT> : never : never; ``` Defined in: [warp-drive-packages/core/src/types/record.ts:177](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/record.ts#L177) ## Type Parameters ### T `T` *extends* `string` ### SET `SET` *extends* `string` ### FT `FT` *extends* `string` --- --- url: /api/@warp-drive/core/types/record/type-aliases/TypeFromInstance.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/record](../index.md) / TypeFromInstance ```ts type TypeFromInstance = T extends TypedRecordInstance ? T[typeof Type] : never; ``` Defined in: [warp-drive-packages/core/src/types/record.ts:38](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/record.ts#L38) A type utility that extracts the Type if available, otherwise it returns never. ## Type Parameters ### T `T` --- --- url: /api/@warp-drive/core/types/record/type-aliases/TypeFromInstanceOrString.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/record](../index.md) / TypeFromInstanceOrString ```ts type TypeFromInstanceOrString = T extends TypedRecordInstance ? T[typeof Type] : string; ``` Defined in: [warp-drive-packages/core/src/types/record.ts:45](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/record.ts#L45) A type utility that extracts the Type if available, otherwise it returns string ## Type Parameters ### T `T` --- --- url: /api/@warp-drive/core/types/request/functions/withBrand.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / withBrand ```ts function withBrand(obj): RequestInfo & object; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:348](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L348) ## Type Parameters ### T `T` ## Parameters ### obj [`RequestInfo`](../interfaces/RequestInfo.md) ## Returns [`RequestInfo`](../interfaces/RequestInfo.md)<`T`, `unknown`> & `object` --- --- url: /api/@warp-drive/core/types/request.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / types/request ## Interfaces * [ImmutableHeaders](interfaces/ImmutableHeaders.md) * [RequestContext](interfaces/RequestContext.md) * [RequestInfo](interfaces/RequestInfo.md) * [ResponseInfo](interfaces/ResponseInfo.md) * [StructuredDataDocument](interfaces/StructuredDataDocument.md) * [StructuredErrorDocument](interfaces/StructuredErrorDocument.md) ## Type Aliases * [CacheOptions](type-aliases/CacheOptions.md) * [ConstrainedRequestOptions](type-aliases/ConstrainedRequestOptions.md) * [CreateRequestOptions](type-aliases/CreateRequestOptions.md) * [DeleteRequestOptions](type-aliases/DeleteRequestOptions.md) * [FindRecordOptions](type-aliases/FindRecordOptions.md) * [FindRecordRequestOptions](type-aliases/FindRecordRequestOptions.md) * [HTTPMethod](type-aliases/HTTPMethod.md) * [ImmutableCreateRequestOptions](type-aliases/ImmutableCreateRequestOptions.md) * [ImmutableDeleteRequestOptions](type-aliases/ImmutableDeleteRequestOptions.md) * [ImmutableRequestInfo](type-aliases/ImmutableRequestInfo.md) * [ImmutableUpdateRequestOptions](type-aliases/ImmutableUpdateRequestOptions.md) * [PostQueryRequestOptions](type-aliases/PostQueryRequestOptions.md) * [QueryRequestOptions](type-aliases/QueryRequestOptions.md) * [RemotelyAccessibleIdentifier](type-aliases/RemotelyAccessibleIdentifier.md) * [StructuredDocument](type-aliases/StructuredDocument.md) * [UpdateRequestOptions](type-aliases/UpdateRequestOptions.md) ## Variables * [EnableHydration](variables/EnableHydration.md) * [IS\_FUTURE](variables/IS_FUTURE.md) * [SkipCache](variables/SkipCache.md) * [STRUCTURED](variables/STRUCTURED.md) ## Functions * [withBrand](functions/withBrand.md) --- --- url: /api/@warp-drive/core/types/request/interfaces/ImmutableHeaders.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / ImmutableHeaders Defined in: [warp-drive-packages/core/src/types/request.ts:257](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L257) ## Extends * `Headers` ## Methods ### append() ```ts append(name, value): void; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:14286 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append) #### Parameters ##### name `string` ##### value `string` #### Returns `void` #### Inherited from ```ts Headers.append ``` *** ### clone()? ```ts optional clone(): Headers; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:258](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L258) #### Returns `Headers` *** ### delete() ```ts delete(name): void; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:14288 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete) #### Parameters ##### name `string` #### Returns `void` #### Inherited from ```ts Headers.delete ``` *** ### forEach() ```ts forEach(callbackfn, thisArg?): void; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:14297 #### Parameters ##### callbackfn (`value`, `key`, `parent`) => `void` ##### thisArg? `any` #### Returns `void` #### Inherited from ```ts Headers.forEach ``` *** ### get() ```ts get(name): null | string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:14290 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get) #### Parameters ##### name `string` #### Returns `null` | `string` #### Inherited from ```ts Headers.get ``` *** ### getSetCookie() ```ts getSetCookie(): string[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:14292 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie) #### Returns `string`\[] #### Inherited from ```ts Headers.getSetCookie ``` *** ### has() ```ts has(name): boolean; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:14294 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has) #### Parameters ##### name `string` #### Returns `boolean` #### Inherited from ```ts Headers.has ``` *** ### set() ```ts set(name, value): void; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:14296 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set) #### Parameters ##### name `string` ##### value `string` #### Returns `void` #### Inherited from ```ts Headers.set ``` *** ### toJSON() ```ts toJSON(): [string, string][]; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:259](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L259) #### Returns \[`string`, `string`]\[] --- --- url: /api/@warp-drive/core/types/request/interfaces/RequestContext.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / RequestContext Defined in: [warp-drive-packages/core/src/types/request.ts:337](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L337) ## Extended by * [`StoreRequestContext`](../../../interfaces/StoreRequestContext.md) ## Properties ### id ```ts id: number; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:342](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L342) *** ### request ```ts request: ImmutableRequestInfo; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:341](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L341) #### See [ImmutableRequestInfo](../type-aliases/ImmutableRequestInfo.md) ## Methods ### setResponse() ```ts setResponse(response): void; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:345](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L345) #### Parameters ##### response `null` | `Response` | [`ResponseInfo`](ResponseInfo.md) #### Returns `void` *** ### setStream() ```ts setStream(stream): void; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:344](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L344) #### Parameters ##### stream `ReadableStream`<`any`> | `Promise`<`null` | `ReadableStream`<`any`>> #### Returns `void` --- --- url: /api/@warp-drive/core/types/request/interfaces/RequestInfo.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / RequestInfo Defined in: [warp-drive-packages/core/src/types/request.ts:267](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L267) Extends JavaScript's native Request object with additional properties specific to the RequestManager's capabilities. ## Extends * `Request` ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(EnableHydration)? ```ts optional ___(unique) Symbol(EnableHydration): boolean; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:309](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L309) *** ### \_\_\_(unique) Symbol(RequestSignature)? ```ts optional ___(unique) Symbol(RequestSignature): RT; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:307](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L307) *** ### body? ```ts optional body: null | BodyInit; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:245](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L245) Any body that you want to add to your request. Note that a GET or HEAD request may not have a body. #### Inherited from ```ts Request.body ``` *** ### cache? ```ts optional cache: RequestCache; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:203](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L203) Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching. #### Inherited from ```ts Request.cache ``` *** ### cacheOptions? ```ts optional cacheOptions: CacheOptions; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:277](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L277) #### See [CacheOptions](../type-aliases/CacheOptions.md) *** ### controller? ```ts optional controller: AbortController; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:272](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L272) If provided, used instead of the AbortController auto-configured for each request by the RequestManager *** ### credentials? ```ts optional credentials: RequestCredentials; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:206](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L206) Returns the credentials mode associated with request, which is a string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. #### Inherited from ```ts Request.credentials ``` *** ### data? ```ts optional data: Record; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:299](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L299) data that a handler should convert into the query (GET) or body (POST). Note: It is recommended that builders set query params and body directly in most scenarios. *** ### destination? ```ts optional destination: RequestDestination; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:209](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L209) Returns the kind of resource requested by request, e.g., "document" or "script". #### Inherited from ```ts Request.destination ``` *** ### disableTestWaiter? ```ts optional disableTestWaiter: boolean; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:290](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L290) *** ### duplex? ```ts optional duplex: "half"; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:254](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L254) When sending a ReadableStream as the body of a request, 'half' must be specified. [Half Duplex Further Reading](https://developer.chrome.com/docs/capabilities/web-apis/fetch-streaming-requests#half_duplex) #### Inherited from ```ts Request.duplex ``` *** ### headers? ```ts optional headers: Headers; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:212](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L212) Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header. #### Inherited from ```ts Request.headers ``` *** ### integrity? ```ts optional integrity: string; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:215](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L215) Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. \[SRI] #### Inherited from ```ts Request.integrity ``` *** ### keepalive? ```ts optional keepalive: boolean; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:218](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L218) Returns a boolean indicating whether or not request can outlive the global in which it was created. #### Inherited from ```ts Request.keepalive ``` *** ### method? ```ts optional method: HTTPMethod; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:221](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L221) Returns request's HTTP method, which is "GET" by default. #### Inherited from ```ts Request.method ``` *** ### mode? ```ts optional mode: RequestMode; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:227](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L227) Returns the mode associated with request, which is a string indicating whether the request will use CORS, or will be restricted to same-origin URLs. `no-cors` is not allowed for streaming request bodies. #### Inherited from ```ts Request.mode ``` *** ### op? ```ts optional op: string; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:280](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L280) *** ### options? ```ts optional options: Record; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:305](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L305) options specifically intended for handlers to utilize to process the request *** ### records? ```ts optional records: StableRecordIdentifier[]; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:288](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L288) The identifiers of the primary resources involved in the request (if any). This may be used by handlers to perform transactional operations on the store. *** ### redirect? ```ts optional redirect: RequestRedirect; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:230](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L230) Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default. #### Inherited from ```ts Request.redirect ``` *** ### referrer? ```ts optional referrer: string; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:233](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L233) Returns the referrer of request. Its value can be a same-origin URL if explicitly set in init, the empty string to indicate no referrer, and "about:client" when defaulting to the global's default. This is used during fetching to determine the value of the `Referer` header of the request being made. #### Inherited from ```ts Request.referrer ``` *** ### referrerPolicy? ```ts optional referrerPolicy: ReferrerPolicy; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:236](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L236) Returns the referrer policy associated with request. This is used during fetching to compute the value of the request's referrer. #### Inherited from ```ts Request.referrerPolicy ``` *** ### signal? ```ts optional signal: AbortSignal; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:239](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L239) Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler. #### Inherited from ```ts Request.signal ``` *** ### store? ```ts optional store: unknown; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:278](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L278) *** ### url? ```ts optional url: string; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:242](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L242) Returns the URL of request as a string. #### Inherited from ```ts Request.url ``` --- --- url: /api/@warp-drive/core/types/request/interfaces/ResponseInfo.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / ResponseInfo Defined in: [warp-drive-packages/core/src/types/request.ts:327](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L327) ## Properties ### headers ```ts readonly headers: ImmutableHeaders; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:328](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L328) *** ### ok ```ts readonly ok: boolean; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:329](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L329) *** ### redirected ```ts readonly redirected: boolean; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:330](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L330) *** ### status ```ts readonly status: number; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:331](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L331) *** ### statusText ```ts readonly statusText: string; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:332](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L332) *** ### type ```ts readonly type: ResponseType; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:333](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L333) *** ### url ```ts readonly url: string; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:334](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L334) --- --- url: /api/@warp-drive/core/types/request/interfaces/StructuredDataDocument.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / StructuredDataDocument Defined in: [warp-drive-packages/core/src/types/request.ts:176](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L176) ## Type Parameters ### T `T` ## Properties ### \_\_\_(unique) Symbol(DOC)? ```ts optional ___(unique) Symbol(DOC): true; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:177](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L177) *** ### content ```ts content: T; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:183](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L183) *** ### request ```ts request: ImmutableRequestInfo; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:181](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L181) #### See [ImmutableRequestInfo](../type-aliases/ImmutableRequestInfo.md) *** ### response ```ts response: null | Response | ResponseInfo; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:182](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L182) --- --- url: /api/@warp-drive/core/types/request/interfaces/StructuredErrorDocument.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / StructuredErrorDocument Defined in: [warp-drive-packages/core/src/types/request.ts:185](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L185) ## Extends * `Error` ## Type Parameters ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(DOC)? ```ts optional ___(unique) Symbol(DOC): true; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:186](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L186) *** ### cause? ```ts optional cause: unknown; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26 #### Inherited from ```ts Error.cause ``` *** ### content? ```ts optional content: T; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:190](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L190) *** ### error ```ts error: string | object; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:189](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L189) *** ### message ```ts message: string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1077 #### Inherited from ```ts Error.message ``` *** ### name ```ts name: string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 #### Inherited from ```ts Error.name ``` *** ### request ```ts request: ImmutableRequestInfo; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:187](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L187) *** ### response ```ts response: null | Response | ResponseInfo; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:188](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L188) *** ### stack? ```ts optional stack: string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1078 #### Inherited from ```ts Error.stack ``` --- --- url: /api/@warp-drive/core/types/request/type-aliases/CacheOptions.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / CacheOptions ```ts type CacheOptions = object; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:34](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L34) Use these options to adjust CacheHandler behavior for a request. ## Type Parameters ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(SkipCache)? ```ts optional ___(unique) Symbol(SkipCache): boolean; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:78](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L78) If true, the request will never be handled by the cache-manager and thus will never resolve from cache nor update the cache. Generally this is only used for legacy request that manage resource cache updates in a non-standard way via the LegacyNetworkHandler. *** ### backgroundReload? ```ts optional backgroundReload: boolean; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:52](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L52) If true, and a cached response is present and not expired, the request will be made in the background and the cached response will be returned. *** ### key? ```ts optional key: string; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:40](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L40) A key that uniquely identifies this request. If not present, the url wil be used as the key for any GET request, while all other requests will not be cached. *** ### reload? ```ts optional reload: boolean; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:46](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L46) If true, the request will be made even if a cached response is present and not expired. *** ### types? ```ts optional types: T extends TypedRecordInstance ? ExtractSuggestedCacheTypes[] : string[]; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:68](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L68) Useful for metadata around when to invalidate the cache. Typically used by strategies that invalidate requests by resource type when a new resource of that type has been created. See the CachePolicy implementation provided by `@ember-data/request-utils` for an example. It is recommended to only use this for query/queryRecord requests where new records created later would affect the results, though using it for findRecord requests is also supported if desired where it may be useful when a create may affect the result of a sideloaded relationship. Generally it is better to patch the cache directly for relationship updates than to invalidate findRecord requests for one. --- --- url: /api/@warp-drive/core/types/request/type-aliases/ConstrainedRequestOptions.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / ConstrainedRequestOptions ```ts type ConstrainedRequestOptions = object; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:163](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L163) ## Properties ### backgroundReload? ```ts optional backgroundReload: boolean; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:165](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L165) *** ### host? ```ts optional host: string; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:166](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L166) *** ### namespace? ```ts optional namespace: string; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:167](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L167) *** ### reload? ```ts optional reload: boolean; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:164](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L164) *** ### resourcePath? ```ts optional resourcePath: string; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:168](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L168) *** ### urlParamsSettings? ```ts optional urlParamsSettings: QueryParamsSerializationOptions; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:169](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L169) --- --- url: /api/@warp-drive/core/types/request/type-aliases/CreateRequestOptions.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / CreateRequestOptions ```ts type CreateRequestOptions = object; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:140](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L140) ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(RequestSignature)? ```ts optional ___(unique) Symbol(RequestSignature): RT; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:150](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L150) *** ### body? ```ts optional body: string | BodyInit | FormData; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:145](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L145) *** ### data ```ts data: object; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:146](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L146) #### record ```ts record: StableRecordIdentifier>; ``` *** ### headers ```ts headers: Headers; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:143](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L143) *** ### method ```ts method: "POST"; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:142](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L142) *** ### op ```ts op: "createRecord"; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:144](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L144) *** ### records ```ts records: [ResourceIdentifierObject>]; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:149](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L149) *** ### url ```ts url: string; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:141](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L141) --- --- url: /api/@warp-drive/core/types/request/type-aliases/DeleteRequestOptions.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / DeleteRequestOptions ```ts type DeleteRequestOptions = object; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:109](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L109) ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(RequestSignature)? ```ts optional ___(unique) Symbol(RequestSignature): RT; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:119](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L119) *** ### body? ```ts optional body: string | BodyInit | FormData; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:114](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L114) *** ### data ```ts data: object; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:115](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L115) #### record ```ts record: StableRecordIdentifier>; ``` *** ### headers ```ts headers: Headers; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:112](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L112) *** ### method ```ts method: "DELETE"; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:111](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L111) *** ### op ```ts op: "deleteRecord"; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:113](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L113) *** ### records ```ts records: [ResourceIdentifierObject>]; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:118](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L118) *** ### url ```ts url: string; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:110](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L110) --- --- url: /api/@warp-drive/core/types/request/type-aliases/FindRecordRequestOptions.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / FindRecordRequestOptions ```ts type FindRecordRequestOptions = object; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:80](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L80) ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(RequestSignature)? ```ts optional ___(unique) Symbol(RequestSignature): RT; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:87](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L87) *** ### cacheOptions? ```ts optional cacheOptions: CacheOptions; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:84](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L84) *** ### headers ```ts headers: Headers; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:83](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L83) *** ### method ```ts method: "GET"; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:82](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L82) *** ### op ```ts op: "findRecord"; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:85](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L85) *** ### records ```ts records: [ResourceIdentifierObject>]; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:86](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L86) *** ### url ```ts url: string; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:81](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L81) --- --- url: /api/@warp-drive/core/types/request/type-aliases/FindRecordOptions.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / FindRecordOptions ```ts type FindRecordOptions = ConstrainedRequestOptions & object; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:172](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L172) ## Type declaration ### include? ```ts optional include: T extends TypedRecordInstance ? Includes[] : string | string[]; ``` ## Type Parameters ### T `T` = `unknown` --- --- url: /api/@warp-drive/core/types/request/type-aliases/HTTPMethod.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / HTTPMethod ```ts type HTTPMethod = | "QUERY" | "GET" | "OPTIONS" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "CONNECT" | "TRACE"; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:18](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L18) --- --- url: >- /api/@warp-drive/core/types/request/type-aliases/ImmutableCreateRequestOptions.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / ImmutableCreateRequestOptions ```ts type ImmutableCreateRequestOptions = ImmutableRequest; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:155](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L155) --- --- url: >- /api/@warp-drive/core/types/request/type-aliases/ImmutableDeleteRequestOptions.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / ImmutableDeleteRequestOptions ```ts type ImmutableDeleteRequestOptions = ImmutableRequest; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:153](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L153) --- --- url: /api/@warp-drive/core/types/request/type-aliases/ImmutableRequestInfo.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / ImmutableRequestInfo ```ts type ImmutableRequestInfo = Readonly, "controller">> & object; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:316](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L316) Immutable version of [RequestInfo](../interfaces/RequestInfo.md). This is what is passed to handlers. ## Type declaration ### bodyUsed? ```ts readonly optional bodyUsed: boolean; ``` Whether the request body has been read. ### cacheOptions? ```ts readonly optional cacheOptions: Readonly>; ``` ### data? ```ts readonly optional data: Readonly>; ``` ### headers? ```ts readonly optional headers: ImmutableHeaders; ``` ### options? ```ts readonly optional options: Readonly>; ``` ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` --- --- url: /api/@warp-drive/core/types/request/type-aliases/PostQueryRequestOptions.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / PostQueryRequestOptions ```ts type PostQueryRequestOptions = object; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:99](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L99) ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(RequestSignature)? ```ts optional ___(unique) Symbol(RequestSignature): RT; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:106](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L106) *** ### body? ```ts optional body: string | BodyInit | FormData; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:103](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L103) *** ### cacheOptions ```ts cacheOptions: CacheOptions & object; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:104](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L104) #### Type declaration ##### key ```ts key: string; ``` *** ### headers ```ts headers: Headers; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:102](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L102) *** ### method ```ts method: "POST" | "QUERY"; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:101](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L101) *** ### op ```ts op: "query"; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:105](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L105) *** ### url ```ts url: string; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:100](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L100) --- --- url: >- /api/@warp-drive/core/types/request/type-aliases/ImmutableUpdateRequestOptions.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / ImmutableUpdateRequestOptions ```ts type ImmutableUpdateRequestOptions = ImmutableRequest; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:154](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L154) --- --- url: /api/@warp-drive/core/types/request/type-aliases/QueryRequestOptions.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / QueryRequestOptions ```ts type QueryRequestOptions = object; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:90](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L90) ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(RequestSignature)? ```ts optional ___(unique) Symbol(RequestSignature): RT; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:96](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L96) *** ### cacheOptions? ```ts optional cacheOptions: CacheOptions; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:94](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L94) *** ### headers ```ts headers: Headers; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:93](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L93) *** ### method ```ts method: "GET"; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:92](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L92) *** ### op ```ts op: "query"; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:95](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L95) *** ### url ```ts url: string; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:91](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L91) --- --- url: >- /api/@warp-drive/core/types/request/type-aliases/RemotelyAccessibleIdentifier.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / RemotelyAccessibleIdentifier ```ts type RemotelyAccessibleIdentifier = object; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:157](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L157) ## Type Parameters ### T `T` *extends* `string` = `string` ## Properties ### id ```ts id: string; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:158](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L158) *** ### lid? ```ts optional lid: string; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:160](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L160) *** ### type ```ts type: T; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:159](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L159) --- --- url: /api/@warp-drive/core/types/request/type-aliases/UpdateRequestOptions.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / UpdateRequestOptions ```ts type UpdateRequestOptions = object; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:127](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L127) ## Type Parameters ### RT `RT` = `unknown` ### T `T` = `unknown` ## Properties ### \_\_\_(unique) Symbol(RequestSignature)? ```ts optional ___(unique) Symbol(RequestSignature): RT; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:137](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L137) *** ### body? ```ts optional body: string | BodyInit | FormData; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:132](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L132) *** ### data ```ts data: object; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:133](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L133) #### record ```ts record: StableRecordIdentifier>; ``` *** ### headers ```ts headers: Headers; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:130](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L130) *** ### method ```ts method: "PATCH" | "PUT"; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:129](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L129) *** ### op ```ts op: "updateRecord"; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:131](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L131) *** ### records ```ts records: [ResourceIdentifierObject>]; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:136](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L136) *** ### url ```ts url: string; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:128](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L128) --- --- url: /api/@warp-drive/core/types/request/type-aliases/StructuredDocument.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / StructuredDocument ```ts type StructuredDocument = | StructuredDataDocument | StructuredErrorDocument; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:192](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L192) ## Type Parameters ### T `T` --- --- url: /api/@warp-drive/core/types/request/variables/EnableHydration.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / EnableHydration ```ts const EnableHydration: "___(unique) Symbol(EnableHydration)"; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:11](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L11) --- --- url: /api/@warp-drive/core/types/request/variables/IS_FUTURE.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / IS\_FUTURE ```ts const IS_FUTURE: "___(unique) Symbol(IS_FUTURE)"; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:15](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L15) --- --- url: /api/@warp-drive/core/types/request/variables/STRUCTURED.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / STRUCTURED ```ts const STRUCTURED: "___(unique) Symbol(DOC)"; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:16](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L16) --- --- url: /api/@warp-drive/core/types/request/variables/SkipCache.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/request](../index.md) / SkipCache ```ts const SkipCache: "___(unique) Symbol(SkipCache)"; ``` Defined in: [warp-drive-packages/core/src/types/request.ts:10](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/request.ts#L10) --- --- url: /api/@warp-drive/core/types/runtime/functions/getRuntimeConfig.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/runtime](../index.md) / getRuntimeConfig ```ts function getRuntimeConfig(): object; ``` Defined in: [warp-drive-packages/core/src/types/runtime.ts:25](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/runtime.ts#L25) ## Returns `object` ### debug ```ts debug: Partial; ``` --- --- url: /api/@warp-drive/core/types/runtime/functions/setLogging.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/runtime](../index.md) / setLogging ```ts function setLogging(config): void; ``` Defined in: [warp-drive-packages/core/src/types/runtime.ts:36](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/runtime.ts#L36) Upserts the specified logging configuration into the runtime config. globalThis.setWarpDriveLogging({ LOG\_CACHE: true } }); ## Parameters ### config `Partial`<`LOG_CONFIG`> ## Returns `void` --- --- url: /api/@warp-drive/core/types/runtime.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / types/runtime ## Functions * [getRuntimeConfig](functions/getRuntimeConfig.md) * [setLogging](functions/setLogging.md) --- --- url: /api/@warp-drive/core/types/schema/concepts.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / types/schema/concepts ## Type Aliases * [Derivation](type-aliases/Derivation.md) * [HashFn](type-aliases/HashFn.md) * [Transformation](type-aliases/Transformation.md) --- --- url: /api/@warp-drive/core/types/schema/concepts/type-aliases/Derivation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/concepts](../index.md) / Derivation ```ts type Derivation = object & (record, options, prop) => T; ``` Defined in: [warp-drive-packages/core/src/types/schema/concepts.ts:13](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/concepts.ts#L13) ## Type declaration ### \_\_\_(unique) Symbol($type) ```ts ___(unique) Symbol($type): string; ``` ## Type Parameters ### R `R` = `unknown` ### T `T` = `unknown` ### FM `FM` *extends* [`ObjectValue`](../../../json/raw/interfaces/ObjectValue.md) | `null` = [`ObjectValue`](../../../json/raw/interfaces/ObjectValue.md) | `null` --- --- url: /api/@warp-drive/core/types/schema/concepts/type-aliases/HashFn.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/concepts](../index.md) / HashFn ```ts type HashFn = object & (data, options, prop) => string; ``` Defined in: [warp-drive-packages/core/src/types/schema/concepts.ts:17](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/concepts.ts#L17) ## Type declaration ### \_\_\_(unique) Symbol($type) ```ts ___(unique) Symbol($type): string; ``` ## Type Parameters ### T `T` *extends* `object` = `object` --- --- url: /api/@warp-drive/core/types/schema/concepts/type-aliases/Transformation.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/concepts](../index.md) / Transformation ```ts type Transformation = object; ``` Defined in: [warp-drive-packages/core/src/types/schema/concepts.ts:6](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/concepts.ts#L6) ## Type Parameters ### T `T` *extends* [`Value`](../../../json/raw/type-aliases/Value.md) = [`Value`](../../../json/raw/type-aliases/Value.md) ### PT `PT` = `unknown` ## Properties ### \_\_\_(unique) Symbol($type) ```ts ___(unique) Symbol($type): string; ``` Defined in: [warp-drive-packages/core/src/types/schema/concepts.ts:10](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/concepts.ts#L10) ## Methods ### defaultValue()? ```ts optional defaultValue(options, identifier): T; ``` Defined in: [warp-drive-packages/core/src/types/schema/concepts.ts:9](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/concepts.ts#L9) #### Parameters ##### options `null` | [`ObjectValue`](../../../json/raw/interfaces/ObjectValue.md) ##### identifier [`StableRecordIdentifier`](../../../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `T` *** ### hydrate() ```ts hydrate( value, options, record): PT; ``` Defined in: [warp-drive-packages/core/src/types/schema/concepts.ts:8](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/concepts.ts#L8) #### Parameters ##### value `undefined` | `T` ##### options `null` | [`ObjectValue`](../../../json/raw/interfaces/ObjectValue.md) ##### record `unknown` #### Returns `PT` *** ### serialize() ```ts serialize( value, options, record): T; ``` Defined in: [warp-drive-packages/core/src/types/schema/concepts.ts:7](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/concepts.ts#L7) #### Parameters ##### value `PT` ##### options `null` | [`ObjectValue`](../../../json/raw/interfaces/ObjectValue.md) ##### record `unknown` #### Returns `T` --- --- url: /api/@warp-drive/core/types/schema/fields.type-test.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / types/schema/fields.type-test --- --- url: /api/@warp-drive/core/types/schema/fields/functions/isLegacyResourceSchema.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / isLegacyResourceSchema ```ts function isLegacyResourceSchema(schema): schema is LegacyResourceSchema; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:2020](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L2020) A type utility to narrow a schema to LegacyResourceSchema ## Parameters ### schema [`ResourceSchema`](../type-aliases/ResourceSchema.md) | [`ObjectSchema`](../interfaces/ObjectSchema.md) ## Returns `schema is LegacyResourceSchema` --- --- url: /api/@warp-drive/core/types/schema/fields/functions/isResourceSchema.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / isResourceSchema ```ts function isResourceSchema(schema): schema is ResourceSchema; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:2009](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L2009) A type utility to narrow a schema to a ResourceSchema ## Parameters ### schema [`ResourceSchema`](../type-aliases/ResourceSchema.md) | [`ObjectSchema`](../interfaces/ObjectSchema.md) ## Returns `schema is ResourceSchema` --- --- url: /api/@warp-drive/core/types/schema/fields/functions/objectSchema.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / objectSchema ```ts function objectSchema(schema): T; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1998](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1998) A no-op type utility that enables type-checking object schema definitions. Will return the passed in schema. ## Type Parameters ### T `T` *extends* [`ObjectSchema`](../interfaces/ObjectSchema.md) ## Parameters ### schema `T` ## Returns `T` the passed in schema --- --- url: /api/@warp-drive/core/types/schema/fields/functions/resourceSchema.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / resourceSchema ```ts function resourceSchema(schema): T; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1982](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1982) A no-op type utility that enables type-checking resource schema definitions. Will return the passed in schema. This will not validate relationship inverses or related types, as doing so would require a full schema graph to be passed in and no cycles in the graph to be present. ## Type Parameters ### T `T` *extends* | [`PolarisResourceSchema`](../interfaces/PolarisResourceSchema.md) | [`LegacyResourceSchema`](../interfaces/LegacyResourceSchema.md) ## Parameters ### schema [`PolarisResourceSchema`](../interfaces/PolarisResourceSchema.md) | [`LegacyResourceSchema`](../interfaces/LegacyResourceSchema.md) ## Returns `T` the passed in schema --- --- url: /api/@warp-drive/core/types/schema/fields.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / types/schema/fields ## Interfaces * [ArrayField](interfaces/ArrayField.md) * [CollectionField](interfaces/CollectionField.md) * [DerivedField](interfaces/DerivedField.md) * [GenericField](interfaces/GenericField.md) * [HashField](interfaces/HashField.md) * [IdentityField](interfaces/IdentityField.md) * [LegacyAliasField](interfaces/LegacyAliasField.md) * [LegacyAttributeField](interfaces/LegacyAttributeField.md) * [LegacyBelongsToField](interfaces/LegacyBelongsToField.md) * [LegacyHasManyField](interfaces/LegacyHasManyField.md) * [LegacyResourceSchema](interfaces/LegacyResourceSchema.md) * [LinksModeBelongsToField](interfaces/LinksModeBelongsToField.md) * [LinksModeHasManyField](interfaces/LinksModeHasManyField.md) * [LocalField](interfaces/LocalField.md) * [ObjectAliasField](interfaces/ObjectAliasField.md) * [ObjectField](interfaces/ObjectField.md) * [ObjectSchema](interfaces/ObjectSchema.md) * [PolarisAliasField](interfaces/PolarisAliasField.md) * [PolarisResourceSchema](interfaces/PolarisResourceSchema.md) * [ResourceField](interfaces/ResourceField.md) * [SchemaArrayField](interfaces/SchemaArrayField.md) * [SchemaObjectField](interfaces/SchemaObjectField.md) ## Type Aliases * [FieldSchema](type-aliases/FieldSchema.md) * [LegacyField](type-aliases/LegacyField.md) * [LegacyModeFieldSchema](type-aliases/LegacyModeFieldSchema.md) * [LegacyRelationshipField](type-aliases/LegacyRelationshipField.md) * [ObjectFieldSchema](type-aliases/ObjectFieldSchema.md) * [PolarisModeFieldSchema](type-aliases/PolarisModeFieldSchema.md) * [ResourceSchema](type-aliases/ResourceSchema.md) * [Schema](type-aliases/Schema.md) ## Functions * [isLegacyResourceSchema](functions/isLegacyResourceSchema.md) * [isResourceSchema](functions/isResourceSchema.md) * [objectSchema](functions/objectSchema.md) * [resourceSchema](functions/resourceSchema.md) --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/ArrayField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / ArrayField Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:589](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L589) Represents a field whose value is an array of primitive values. If the array's elements are not primitive values, use 'schema-array' instead. (Type) ArrayField ## Properties ### kind ```ts kind: "array"; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:597](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L597) The kind of field this is. *** ### name ```ts name: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:606](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L606) The name of the field. *** ### options? ```ts optional options: ObjectValue; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:629](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L629) Options to pass to the transform, if any Must comply to the specific transform's options schema. *** ### type? ```ts optional type: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:617](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L617) The name of a transform to pass each item in the array through before displaying or or serializing it. --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/DerivedField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / DerivedField Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:764](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L764) Represents a field whose value is derived from other fields in the schema. The value is read-only, and is not stored in the cache, nor is it sent to the server. Usage of derived fields should be minimized to scenarios where the derivation is known to be safe. For instance, derivations that required fields that are not always loaded or that require access to related resources that may not be loaded should be avoided. (Type) DerivedField ## Properties ### kind ```ts kind: "derived"; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:772](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L772) The kind of field this is. *** ### name ```ts name: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:781](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L781) The name of the field. *** ### options? ```ts optional options: ObjectValue; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:816](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L816) Options to pass to the derivation, if any Must comply to the specific derivation's options schema. *** ### type ```ts type: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:804](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L804) The name of the derivation to use. Derivations are functions that take the record, options, and the name of the field as arguments, and return the derived value. Derivations are memoized, and are only recomputed when the fields they depend on change. Derivations are not stored in the cache, and are not sent to the server. Derivation functions must be explicitly registered with the schema service. --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/GenericField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / GenericField Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:20](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L20) A generic "field" that can be used to define primitive value fields. Replaces "attribute" for primitive value fields. Can also be used to eject from deep-tracking of objects or arrays. A major difference between "field" and "attribute" is that "type" points to a legacy transform on "attribute" that a serializer *might* use, while "type" points to a new-style transform on "field" that a record implmentation *must* use. (Type) GenericField ## Properties ### kind ```ts kind: "field"; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:28](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L28) The kind of field this is. *** ### name ```ts name: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:37](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L37) The name of the field. *** ### options? ```ts optional options: ObjectValue; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:58](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L58) Options to pass to the transform, if any Must comply to the specific transform's options schema. *** ### type? ```ts optional type: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:46](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L46) the name of the transform to use, if any --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/CollectionField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / CollectionField Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:923](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L923) Represents a field that is a reference to a collection of other resources, potentially paginate. SUPPORT FOR THIS FEATURE IS NOT YET IMPLEMENTED BY SchemaRecord (Type) CollectionField ## Properties ### kind ```ts kind: "collection"; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:931](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L931) The kind of field this is. *** ### name ```ts name: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:940](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L940) The name of the field. *** ### options? ```ts optional options: object; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:960](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L960) Options for resources are optional. If not present, all options are presumed to be falsey #### as? ```ts optional as: string; ``` If this field is satisfying a polymorphic relationship on another resource, then this should be set to the trait or abstract type that this resource implements. #### async? ```ts optional async: boolean; ``` Whether the relationship is async If true, it is expected that the cache data for this field will contain links that can be used to fetch the related resources when needed. When false, it is expected that all related resources are loaded together with this resource, and that the cache data for this field will contain the full list of pointers. When true, it is expected that the relationship is paginated. If the relationship is not paginated, then the cache data for "page 1" would contain the full list of pointers, and loading "page 1" would load all related resources. #### inverse? ```ts optional inverse: null | string; ``` The name of the inverse field on the related resource that points back to this field on this resource to form a bidirectional relationship. If null, the relationship is unidirectional. #### polymorphic? ```ts optional polymorphic: boolean; ``` Whether this field is a polymorphic relationship, meaning that it can point to multiple types of resources so long as they implement the trait or abstract type specified in `type`. *** ### type ```ts type: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:952](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L952) The name of the resource that this field refers to. In the case of a polymorphic relationship, this should be the trait or abstract type. --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/HashField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / HashField Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:341](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L341) Represents a specialized field whose computed value will be used as the primary key of a schema-object for serializability and comparison purposes. This field functions similarly to derived fields in that it is non-settable, derived state but differs in that it is only able to compute off of cache state and is given no access to a record instance. This means that if a hashing function wants to compute its value taking into account transformations and derivations it must perform those itself. A schema-array can declare its "key" value to be `@hash` if a schema-object has such a field. Only one hash field is permittable per schema-object, and it should be placed in the `ResourceSchema`'s `@id` field in place of an `IdentityField`. (Type) HashField ## Properties ### kind ```ts kind: "@hash"; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:349](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L349) The kind of field this is. *** ### name ```ts name: null | string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:362](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L362) The name of the field that serves as the hash for the resource. Only required if access to this value by the UI is desired, it can be `null` otherwise. *** ### options? ```ts optional options: ObjectValue; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:383](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L383) Any options that should be provided to the hash function. *** ### type ```ts type: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:373](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L373) The name of a function to run to compute the hash. The function will only have access to the cached data for the record. --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/IdentityField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / IdentityField Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:296](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L296) Represents a field whose value is the primary key of the resource. This allows any field to serve as the primary key while still being able to drive identity needs within the system. This is useful for resources that use for instance 'uuid', 'urn' or 'entityUrn' or 'primaryKey' as their primary key field instead of 'id'. (Type) IdentityField ## Properties ### kind ```ts kind: "@id"; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:304](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L304) The kind of field this is. *** ### name ```ts name: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:314](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L314) The name of the field that serves as the primary key for the resource. --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/LegacyAliasField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / LegacyAliasField Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:90](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L90) A field that can be used to alias one key to another key present in the cache version of the resource. Unlike DerivedField, an AliasField may write to its source when a record is in an editable mode. AliasFields may utilize a transform, specified by type, to pre/post process the field. An AliasField may also specify a `kind` via options. `kind` may be any other valid field kind other than * `@hash` * `@id` * `@local` * `derived` This allows an AliasField to rename any field in the cache. Alias fields are generally intended to be used to support migrating between different schemas, though there are times where they are useful as a form of advanced derivation when used with a transform. For instance, an AliasField could be used to expose both a string and a Date version of the same field, with both being capable of being written to. (Type) LegacyAliasField ## Properties ### kind ```ts kind: "alias"; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:98](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L98) The kind of field this is. *** ### name ```ts name: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:107](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L107) The name of the field. *** ### options ```ts options: | GenericField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | LegacyAttributeField | LegacyBelongsToField | LegacyHasManyField; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:125](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L125) The field def for which this is an alias. *** ### type ```ts type: null; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:116](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L116) Always null (for now) --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/LegacyAttributeField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / LegacyAttributeField Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1032](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1032) > \[!CAUTION] > This Field is LEGACY > It cannot be used with PolarisMode A generic "field" that can be used to define primitive value fields. If the field points to an object or array, it will not be deep-tracked. Transforms when defined are legacy transforms that a serializer *might* use, but their usage is not guaranteed. (Type) LegacyAttributeField ## Properties ### kind ```ts kind: "attribute"; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1040](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1040) The kind of field this is. *** ### name ```ts name: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1049](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1049) The name of the field. *** ### options? ```ts optional options: ObjectValue; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1065](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1065) Options to pass to the transform, if any Must comply to the specific transform's options schema. *** ### type? ```ts optional type: null | string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1057](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1057) The name of the transform to use, if any --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/LegacyBelongsToField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / LegacyBelongsToField Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1080](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1080) > \[!CAUTION] > This Field is LEGACY Represents a field that is a reference to another resource. This is the legacy version of the `ResourceField`. (Type) LegacyBelongsToField ## Properties ### kind ```ts kind: "belongsTo"; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1088](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1088) The kind of field this is. *** ### name ```ts name: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1097](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1097) The name of the field. *** ### options ```ts options: object; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1115](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1115) Options for belongsTo are mandatory. #### as? ```ts optional as: string; ``` If this field is satisfying a polymorphic relationship on another resource, then this should be set to the trait or abstract type that this resource implements. #### async ```ts async: boolean; ``` Whether the relationship is async If true, it is expected that the cache data for this field will contain a link or a pointer that can be used to fetch the related resource when needed. Pointers are highly discouraged. #### inverse ```ts inverse: null | string; ``` The name of the inverse field on the related resource that points back to this field on this resource to form a bidirectional relationship. If null, the relationship is unidirectional. #### linksMode? ```ts optional linksMode: true; ``` Whether this field should ever make use of the legacy support infra from @ember-data/model and the LegacyNetworkMiddleware for adapters and serializers. When true, none of the legacy support will be utilized. Sync relationships will be expected to already have all their data. When reloading a sync relationship you would be expected to have a `related link` available from a prior relationship payload e.g. ```ts { data: { type: 'user', id: '2', attributes: { name: 'Chris' }, relationships: { bestFriend: { links: { related: "/users/1/bestFriend" }, data: { type: 'user', id: '1' }, } } }, included: [ { type: 'user', id: '1', attributes: { name: 'Krystan' } } ] } ``` Async relationships will be loaded via their link if needed. #### polymorphic? ```ts optional polymorphic: boolean; ``` Whether this field is a polymorphic relationship, meaning that it can point to multiple types of resources so long as they implement the trait or abstract type specified in `type`. #### resetOnRemoteUpdate? ```ts optional resetOnRemoteUpdate: false; ``` When omitted, the cache data for this field will clear local state of all changes except for the addition of records still in the "new" state any time the remote data for this field is updated. When set to `false`, the cache data for this field will instead intelligently commit any changes from local state that are present in the remote data, leaving any remaining changes in local state still. *** ### type ```ts type: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1109](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1109) The name of the resource that this field refers to. In the case of a polymorphic relationship, this should be the trait or abstract type. --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/LegacyHasManyField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / LegacyHasManyField Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1353](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1353) > \[!CAUTION] > This Field is LEGACY Represents a field that is a reference to a collection of other resources. This is the legacy version of the `CollectionField`. (Type) LegacyHasManyField ## Properties ### kind ```ts kind: "hasMany"; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1361](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1361) The kind of field this is. *** ### name ```ts name: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1370](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1370) The name of the field. *** ### options ```ts options: object; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1388](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1388) Options for hasMany are mandatory. #### as? ```ts optional as: string; ``` If this field is satisfying a polymorphic relationship on another resource, then this should be set to the trait or abstract type that this resource implements. #### async ```ts async: boolean; ``` Whether the relationship is async If true, it is expected that the cache data for this field will contain links or pointers that can be used to fetch the related resources when needed. When false, it is expected that all related resources are loaded together with this resource, and that the cache data for this field will contain the full list of pointers. hasMany relationships do not support pagination. #### inverse ```ts inverse: null | string; ``` The name of the inverse field on the related resource that points back to this field on this resource to form a bidirectional relationship. If null, the relationship is unidirectional. #### linksMode? ```ts optional linksMode: true; ``` Whether this field should ever make use of the legacy support infra from @ember-data/model and the LegacyNetworkMiddleware for adapters and serializers. When true, none of the legacy support will be utilized. Sync relationships will be expected to already have all their data. When reloading a sync relationship you would be expected to have a `related link` available from a prior relationship payload e.g. ```ts { data: { type: 'user', id: '2', attributes: { name: 'Chris' }, relationships: { bestFriends: { links: { related: "/users/1/bestFriends" }, data: [ { type: 'user', id: '1' } ], } } }, included: [ { type: 'user', id: '1', attributes: { name: 'Krystan' } } ] } ``` Async relationships will be loaded via their link if needed. #### polymorphic? ```ts optional polymorphic: boolean; ``` Whether this field is a polymorphic relationship, meaning that it can point to multiple types of resources so long as they implement the trait or abstract type specified in `type`. #### resetOnRemoteUpdate? ```ts optional resetOnRemoteUpdate: false; ``` When omitted, the cache data for this field will clear local state of all changes except for the addition of records still in the "new" state any time the remote data for this field is updated. When set to `false`, the cache data for this field will instead intelligently commit any changes from local state that are present in the remote data, leaving any remaining changes in local state still. *** ### type ```ts type: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1382](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1382) the name of the resource that this field refers to. In the case of a polymorphic relationship, this should be the trait or abstract type. --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/LegacyResourceSchema.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / LegacyResourceSchema Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1833](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1833) Represents a schema for a primary resource in LegacyMode Primary resources are objects with a unique identity of their own which may allow them to appear in relationships, or in multiple response documents. (Type) LegacyResourceSchema ## Properties ### fields ```ts fields: LegacyModeFieldSchema[]; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1885](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1885) The fields that make up the shape of the resource *** ### identity ```ts identity: IdentityField; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1854](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1854) This should be an IdentityField. To maximize compatibility with Model where `id` was the name of the identity field, we recommend using `{ kind: '@id', name: 'id' }` for records in legacy mode, but this is not required. *** ### legacy ```ts legacy: true; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1841](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1841) A flag indicating that this is a legacy resource schema *** ### traits? ```ts optional traits: string[]; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1899](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1899) A list of traits that this resource implements. The fields for these traits should still be defined in the fields array. Each trait should be a string that matches the `type` of another resource schema. The trait can be abstract and reference a resource type that is never defined as a schema. *** ### type ```ts type: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1876](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1876) The name of the schema For cacheable resources, this should be the primary resource type. The names of object and resource schemas share a single namespace and must not conflict. We recommend a naming convention for object schemas such as below for ensuring uniqueness: * for globally shared objects: The pattern `$field:${KlassName}` e.g. `$field:AddressObject` * for resource-specific objects: The pattern `$${ResourceKlassName}:$field:${KlassName}` e.g. `$User:$field:ReusableAddress` * for inline objects: The pattern `$${ResourceKlassName}.${fieldPath}:$field:anonymous` e.g. `$User.shippingAddress:$field:anonymous` --- --- url: >- /api/@warp-drive/core/types/schema/fields/interfaces/LinksModeBelongsToField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / LinksModeBelongsToField Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1219](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1219) > \[!CAUTION] > This Field is LEGACY Represents a field that is a reference to another resource. This is the legacy version of the `ResourceField`. (Type) LinksModeBelongsToField ## Properties ### kind ```ts kind: "belongsTo"; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1227](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1227) The kind of field this is. *** ### name ```ts name: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1236](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1236) The name of the field. *** ### options ```ts options: object; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1254](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1254) Options for belongsTo are mandatory. #### as? ```ts optional as: string; ``` If this field is satisfying a polymorphic relationship on another resource, then this should be set to the trait or abstract type that this resource implements. #### async ```ts async: false; ``` Whether the relationship is async MUST be false for PolarisMode + LinksMode #### inverse ```ts inverse: null | string; ``` The name of the inverse field on the related resource that points back to this field on this resource to form a bidirectional relationship. If null, the relationship is unidirectional. #### linksMode ```ts linksMode: true; ``` Whether this field should ever make use of the legacy support infra from @ember-data/model and the LegacyNetworkMiddleware for adapters and serializers. MUST be true for PolarisMode + LinksMode When true, none of the legacy support will be utilized. Sync relationships will be expected to already have all their data. When reloading a sync relationship you would be expected to have a `related link` available from a prior relationship payload e.g. ```ts { data: { type: 'user', id: '2', attributes: { name: 'Chris' }, relationships: { bestFriend: { links: { related: "/users/1/bestFriend" }, data: { type: 'user', id: '1' }, } } }, included: [ { type: 'user', id: '1', attributes: { name: 'Krystan' } } ] } ``` Async relationships will be loaded via their link if needed. Activating LinksMode will *also* deactivate the deprecated `resetOnRemoteUpdate` behavior for this field. This means that when new remote state is received, the cache will intelligently commit any changes from local state that are present in the remote data for this field, leaving any remaining changes in local state still. Previously, the cache would clear local state of all changes except for the addition of records still in the "new" state any time the remote data for this field was updated. #### polymorphic? ```ts optional polymorphic: boolean; ``` Whether this field is a polymorphic relationship, meaning that it can point to multiple types of resources so long as they implement the trait or abstract type specified in `type`. *** ### type ```ts type: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1248](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1248) The name of the resource that this field refers to. In the case of a polymorphic relationship, this should be the trait or abstract type. --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/LinksModeHasManyField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / LinksModeHasManyField Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1497](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1497) > \[!CAUTION] > This Field is LEGACY Represents a field that is a reference to a collection of other resources. This is the legacy version of the `CollectionField`. (Type) LinksModeHasManyField ## Properties ### kind ```ts kind: "hasMany"; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1505](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1505) The kind of field this is. *** ### name ```ts name: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1514](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1514) The name of the field. *** ### options ```ts options: object; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1532](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1532) Options for hasMany are mandatory. #### as? ```ts optional as: string; ``` If this field is satisfying a polymorphic relationship on another resource, then this should be set to the trait or abstract type that this resource implements. #### async ```ts async: false; ``` Whether the relationship is async MUST be false for PolarisMode + LinksMode If true, it is expected that the cache data for this field will contain links or pointers that can be used to fetch the related resources when needed. When false, it is expected that all related resources are loaded together with this resource, and that the cache data for this field will contain the full list of pointers. hasMany relationships do not support pagination. #### inverse ```ts inverse: null | string; ``` The name of the inverse field on the related resource that points back to this field on this resource to form a bidirectional relationship. If null, the relationship is unidirectional. #### linksMode ```ts linksMode: true; ``` Whether this field should ever make use of the legacy support infra from @ember-data/model and the LegacyNetworkMiddleware for adapters and serializers. MUST be true for PolarisMode + LinksMode When true, none of the legacy support will be utilized. Sync relationships will be expected to already have all their data. When reloading a sync relationship you would be expected to have a `related link` available from a prior relationship payload e.g. ```ts { data: { type: 'user', id: '2', attributes: { name: 'Chris' }, relationships: { bestFriends: { links: { related: "/users/1/bestFriends" }, data: [ { type: 'user', id: '1' } ], } } }, included: [ { type: 'user', id: '1', attributes: { name: 'Krystan' } } ] } ``` Async relationships will be loaded via their link if needed. Activating LinksMode will *also* deactivate the deprecated `resetOnRemoteUpdate` behavior for this field. This means that when new remote state is received, the cache will intelligently commit any changes from local state that are present in the remote data for this field, leaving any remaining changes in local state still. Previously, the cache would clear local state of all changes except for the addition of records still in the "new" state any time the remote data for this field was updated. #### polymorphic? ```ts optional polymorphic: boolean; ``` Whether this field is a polymorphic relationship, meaning that it can point to multiple types of resources so long as they implement the trait or abstract type specified in `type`. *** ### type ```ts type: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1526](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1526) the name of the resource that this field refers to. In the case of a polymorphic relationship, this should be the trait or abstract type. --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/LocalField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / LocalField Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:416](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L416) Represents a field whose value is a local value that is not stored in the cache, nor is it sent to the server. Local fields can be written to, and their value is both memoized and reactive (though not deep-tracked). Because their state is not derived from the cache data or the server, they represent a divorced uncanonical source of state. For this reason Local fields should be used sparingly. Currently, while we document this feature here, only allow our own SchemaRecord default fields to utilize them and the feature should be considered private. Example use cases that drove the creation of local fields are states like `isDestroying` and `isDestroyed` which are specific to a record instance but not stored in the cache. We wanted to be able to drive these fields from schema the same as all other fields. Don't make us regret this decision. (Type) LocalField ## Properties ### kind ```ts kind: "@local"; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:424](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L424) The kind of field this is. *** ### name ```ts name: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:433](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L433) The name of the field. *** ### options? ```ts optional options: object; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:451](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L451) Options for the field. #### defaultValue? ```ts optional defaultValue: PrimitiveValue; ``` *** ### type? ```ts optional type: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:442](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L442) Not currently utilized, we are considering allowing transforms to operate on local fields --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/ObjectAliasField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / ObjectAliasField Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:243](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L243) A field that can be used to alias one key to another key present in the cache version of the resource. Unlike DerivedField, an AliasField may write to its source when a record is in an editable mode. AliasFields may utilize a transform, specified by type, to pre/post process the field. An AliasField may also specify a `kind` via options. `kind` may be any other valid field kind other than * `@hash` * `@id` * `@local` * `derived` This allows an AliasField to rename any field in the cache. Alias fields are generally intended to be used to support migrating between different schemas, though there are times where they are useful as a form of advanced derivation when used with a transform. For instance, an AliasField could be used to expose both a string and a Date version of the same field, with both being capable of being written to. (Type) ObjectAliasField ## Properties ### kind ```ts kind: "alias"; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:251](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L251) The kind of field this is. *** ### name ```ts name: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:260](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L260) The name of the field. *** ### options ```ts options: | GenericField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:278](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L278) The field def for which this is an alias. *** ### type ```ts type: null; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:269](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L269) Always null (for now) --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/ObjectField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / ObjectField Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:466](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L466) Represents a field whose value is an object with keys pointing to values that are primitive values. If values of the keys are not primitives, or if the key/value pairs have well-defined shape, use 'schema-object' instead. (Type) ObjectField ## Properties ### kind ```ts kind: "object"; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:474](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L474) The kind of field this is. *** ### name ```ts name: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:483](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L483) The name of the field. *** ### options? ```ts optional options: ObjectValue; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:505](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L505) Options to pass to the transform, if any Must comply to the specific transform's options schema. *** ### type? ```ts optional type: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:493](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L493) The name of a transform to pass the entire object through before displaying or serializing it. --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/ObjectSchema.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / ObjectSchema Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1923](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1923) Represents a schema for an object that is not a primary resource (has no unique identity of its own). ObjectSchemas may not currently contain relationships. (Type) ObjectSchema ## Properties ### fields ```ts fields: ObjectFieldSchema[]; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1963](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1963) The fields that make up the shape of the object *** ### identity ```ts identity: null | HashField; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1935](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1935) Either a HashField from which to calculate an identity or null In the case of `null`, the object's identity will be based on the referential identity of the object in the cache itself when an identity is needed. *** ### type ```ts type: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1954](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1954) The name of the schema The names of object and resource schemas share a single namespace and must not conflict. We recommend a naming convention for object schemas such as below for ensuring uniqueness: * for globally shared objects: The pattern `$field:${KlassName}` e.g. `$field:AddressObject` * for resource-specific objects: The pattern `$${ResourceKlassName}:$field:${KlassName}` e.g. `$User:$field:ReusableAddress` * for inline objects: The pattern `$${ResourceKlassName}.${fieldPath}:$field:anonymous` e.g. `$User.shippingAddress:$field:anonymous` --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/PolarisAliasField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / PolarisAliasField Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:167](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L167) A field that can be used to alias one key to another key present in the cache version of the resource. Unlike DerivedField, an AliasField may write to its source when a record is in an editable mode. AliasFields may utilize a transform, specified by type, to pre/post process the field. An AliasField may also specify a `kind` via options. `kind` may be any other valid field kind other than * `@hash` * `@id` * `@local` * `derived` This allows an AliasField to rename any field in the cache. Alias fields are generally intended to be used to support migrating between different schemas, though there are times where they are useful as a form of advanced derivation when used with a transform. For instance, an AliasField could be used to expose both a string and a Date version of the same field, with both being capable of being written to. (Type) PolarisAliasField ## Properties ### kind ```ts kind: "alias"; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:175](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L175) The kind of field this is. *** ### name ```ts name: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:184](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L184) The name of the field. *** ### options ```ts options: | GenericField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | LinksModeBelongsToField | LinksModeHasManyField; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:202](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L202) The field def for which this is an alias. *** ### type ```ts type: null; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:193](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L193) Always null (for now) --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/PolarisResourceSchema.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / PolarisResourceSchema Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1760](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1760) Represents a schema for a primary resource in PolarisMode. Primary resources are objects with a unique identity of their own which may allow them to appear in relationships, or in multiple response documents. (Type) PolarisResourceSchema ## Properties ### fields ```ts fields: PolarisModeFieldSchema[]; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1806](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1806) The fields that make up the shape of the resource *** ### identity ```ts identity: IdentityField; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1772](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1772) For primary resources, this should be an IdentityField for schema-objects, this should be either a HashField or null *** ### legacy? ```ts optional legacy: false; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1761](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1761) *** ### traits? ```ts optional traits: string[]; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1820](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1820) A list of traits that this resource implements. The fields for these traits should still be defined in the fields array. Each trait should be a string that matches the `type` of another resource schema. The trait can be abstract and reference a resource type that is never defined as a schema. *** ### type ```ts type: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1797](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1797) The name of the schema For cacheable resources, this should be the primary resource type. For object schemas, this should be the name of the object schema. The names of object and resource schemas share a single namespace and must not conflict. We recommend a naming convention for object schemas such as below for ensuring uniqueness: * for globally shared objects: The pattern `$field:${KlassName}` e.g. `$field:AddressObject` * for resource-specific objects: The pattern `$${ResourceKlassName}:$field:${KlassName}` e.g. `$User:$field:ReusableAddress` * for inline objects: The pattern `$${ResourceKlassName}.${fieldPath}:$field:anonymous` e.g. `$User.shippingAddress:$field:anonymous` --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/ResourceField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / ResourceField Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:829](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L829) Represents a field that is a reference to another resource. SUPPORT FOR THIS FEATURE IS NOT YET IMPLEMENTED BY SchemaRecord (Type) ResourceField ## Properties ### kind ```ts kind: "resource"; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:837](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L837) The kind of field this is. *** ### name ```ts name: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:846](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L846) The name of the field. *** ### options? ```ts optional options: object; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:869](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L869) Options for resources are optional. If not present, all options are presumed to be falsey #### as? ```ts optional as: string; ``` If this field is satisfying a polymorphic relationship on another resource, then this should be set to the trait or abstract type that this resource implements. #### async? ```ts optional async: boolean; ``` Whether the relationship is async If true, it is expected that the cache data for this field will contain a link that can be used to fetch the related resource when needed. #### inverse? ```ts optional inverse: null | string; ``` The name of the inverse field on the related resource that points back to this field on this resource to form a bidirectional relationship. If null, the relationship is unidirectional. #### polymorphic? ```ts optional polymorphic: boolean; ``` Whether this field is a polymorphic relationship, meaning that it can point to multiple types of resources so long as they implement the trait or abstract type specified in `type`. *** ### type ```ts type: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:858](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L858) The name of the resource that this field refers to. In the case of a polymorphic relationship, this should be the trait or abstract type. --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/SchemaArrayField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / SchemaArrayField Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:643](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L643) Represents a field whose value is an array of objects with a well-defined structure described by a non-resource schema. If the array's elements are not well-defined, use 'array' instead. (Type) SchemaArrayField ## Properties ### kind ```ts kind: "schema-array"; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:651](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L651) The kind of field this is. *** ### name ```ts name: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:660](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L660) The name of the field. *** ### options? ```ts optional options: object; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:703](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L703) Options for configuring the behavior of the SchemaArray. * `key` Configures how the SchemaArray determines whether an object in the cache is the same as an object previously used to instantiate one of the schema-objects it contains. The default is `'@identity'`. Valid options are: * `'@identity'` (default) : the cached object's referential identity will be used. This may result in significant instability when resource data is updated from the API * `'@index'` : the cached object's index in the array will be used. This is only a good choice for arrays that rarely if ever change membership * `'@hash'` : will lookup the `@hash` function supplied in the ResourceSchema for The contained schema-object and use the computed result to determine and compare identity. * \ (string) : the name of a field to use as the key, only GenericFields (kind `field`) Are valid field names for this purpose. The cache state without transforms applied will be used when comparing values. The field value should be unique enough to guarantee two schema-objects of the same type will not collide. * `polymorphic` : Whether this SchemaArray is Polymorphic. * `type` : If the SchemaArray is Polymorphic, the key on the raw cache data to use as the "resource-type" value for the schema-object. #### key? ```ts optional key: string; ``` Configures how the SchemaArray determines whether an object in the cache is the same as an object previously used to instantiate one of the schema-objects it contains. The default is `'@identity'`. Valid options are: * `'@identity'` (default) : the cached object's referential identity will be used. This may result in significant instability when resource data is updated from the API * `'@index'` : the cached object's index in the array will be used. This is only a good choice for arrays that rarely if ever change membership * `'@hash'` : will lookup the `@hash` function supplied in the ResourceSchema for The contained schema-object and use the computed result to determine and compare identity. * \ (string) : the name of a field to use as the key, only GenericFields (kind `field`) Are valid field names for this purpose. The cache state without transforms applied will be used when comparing values. The field value should be unique enough to guarantee two schema-objects of the same type will not collide. #### polymorphic? ```ts optional polymorphic: boolean; ``` Whether this SchemaArray is Polymorphic. If the SchemaArray is polymorphic, `options.type` must also be supplied. #### type? ```ts optional type: string; ``` If the SchemaArray is Polymorphic, the key on the raw cache data to use as the "resource-type" value for the schema-object. Defaults to "type". *** ### type ```ts type: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:670](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L670) The name of the ObjectSchema that describes the structure of the objects in the array. --- --- url: /api/@warp-drive/core/types/schema/fields/interfaces/SchemaObjectField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / SchemaObjectField Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:519](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L519) Represents a field whose value is an object with a well-defined structure described by a non-resource schema. If the object's structure is not well-defined, use 'object' instead. (Type) SchemaObjectField ## Properties ### kind ```ts kind: "schema-object"; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:527](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L527) The kind of field this is. *** ### name ```ts name: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:536](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L536) The name of the field. *** ### options? ```ts optional options: object; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:559](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L559) Options for configuring the behavior of the SchemaObject. * `polymorphic` : Whether this SchemaObject is Polymorphic. * `type` : If the SchemaObject is Polymorphic, the key on the raw cache data to use as the "resource-type" value for the schema-object. #### polymorphic? ```ts optional polymorphic: boolean; ``` Whether this SchemaObject is Polymorphic. If the SchemaObject is polymorphic, `options.type` must also be supplied. #### type? ```ts optional type: string; ``` If the SchemaObject is Polymorphic, the key on the raw cache data to use as the "resource-type" value for the schema-object. Defaults to "type". *** ### type ```ts type: string; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:546](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L546) The name of the ObjectSchema that describes the structure of the object. --- --- url: /api/@warp-drive/core/types/schema/fields/type-aliases/FieldSchema.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / FieldSchema ```ts type FieldSchema = | GenericField | LegacyAliasField | PolarisAliasField | LocalField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | DerivedField | ResourceField | CollectionField | LegacyAttributeField | LegacyBelongsToField | LegacyHasManyField | LinksModeBelongsToField | LinksModeHasManyField; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1715](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1715) A union of all possible LegacyMode and PolarisMode field schemas. You likely will want to use PolarisModeFieldSchema, LegacyModeFieldSchema, or ObjectFieldSchema instead as appropriate as they are more specific and will provide better guidance around what is valid. (Type) FieldSchema --- --- url: /api/@warp-drive/core/types/schema/fields/type-aliases/LegacyField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / LegacyField ```ts type LegacyField = | LegacyAttributeField | LegacyBelongsToField | LegacyHasManyField | LinksModeBelongsToField | LinksModeHasManyField; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:2024](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L2024) --- --- url: >- /api/@warp-drive/core/types/schema/fields/type-aliases/LegacyModeFieldSchema.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / LegacyModeFieldSchema ```ts type LegacyModeFieldSchema = | GenericField | LegacyAliasField | LocalField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | DerivedField | LegacyAttributeField | LegacyBelongsToField | LegacyHasManyField; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1653](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1653) A union of all possible LegacyMode field schemas. Available field schemas are: * [GenericField](../interfaces/GenericField.md) * [LegacyAliasField](../interfaces/LegacyAliasField.md) * [LocalField](../interfaces/LocalField.md) * [ObjectField](../interfaces/ObjectField.md) * [SchemaObjectField](../interfaces/SchemaObjectField.md) * [ArrayField](../interfaces/ArrayField.md) * [SchemaArrayField](../interfaces/SchemaArrayField.md) * [DerivedField](../interfaces/DerivedField.md) * [ResourceField (not yet implemented)](../interfaces/ResourceField.md) * [CollectionField (not yet implemented)](../interfaces/CollectionField.md) * [LegacyAttributeField](../interfaces/LegacyAttributeField.md) * [LegacyBelongsToField](../interfaces/LegacyBelongsToField.md) * [LegacyHasManyField](../interfaces/LegacyHasManyField.md) (Type) LegacyModeFieldSchema --- --- url: >- /api/@warp-drive/core/types/schema/fields/type-aliases/LegacyRelationshipField.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / LegacyRelationshipField ```ts type LegacyRelationshipField = | LegacyBelongsToField | LegacyHasManyField | LinksModeBelongsToField | LinksModeHasManyField; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:2030](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L2030) --- --- url: /api/@warp-drive/core/types/schema/fields/type-aliases/ObjectFieldSchema.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / ObjectFieldSchema ```ts type ObjectFieldSchema = | GenericField | ObjectAliasField | LocalField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | DerivedField; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1740](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1740) A union of all possible field schemas that can be used in an ObjectSchema. (Type) ObjectFieldSchema --- --- url: >- /api/@warp-drive/core/types/schema/fields/type-aliases/PolarisModeFieldSchema.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / PolarisModeFieldSchema ```ts type PolarisModeFieldSchema = | GenericField | PolarisAliasField | LocalField | ObjectField | SchemaObjectField | ArrayField | SchemaArrayField | DerivedField | LinksModeBelongsToField | LinksModeHasManyField; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1689](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1689) A union of all possible PolarisMode field schemas. Available field schemas are: * [GenericField](../interfaces/GenericField.md) * [PolarisAliasField](../interfaces/PolarisAliasField.md) * [LocalField](../interfaces/LocalField.md) * [ObjectField](../interfaces/ObjectField.md) * [SchemaObjectField](../interfaces/SchemaObjectField.md) * [ArrayField](../interfaces/ArrayField.md) * [SchemaArrayField](../interfaces/SchemaArrayField.md) * [DerivedField](../interfaces/DerivedField.md) * [ResourceField (not yet implemented)](../interfaces/ResourceField.md) * [CollectionField (not yet implemented)](../interfaces/CollectionField.md) * [LinksModeBelongsToField](../interfaces/LinksModeBelongsToField.md) * [LinksModeHasManyField](../interfaces/LinksModeHasManyField.md) (Type) PolarisModeFieldSchema --- --- url: /api/@warp-drive/core/types/schema/fields/type-aliases/ResourceSchema.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / ResourceSchema ```ts type ResourceSchema = | PolarisResourceSchema | LegacyResourceSchema; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1912](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1912) A type which represents a valid JSON schema definition for either a PolarisMode or a LegacyMode resource. Note, this is separate from the type returned by the SchemaService which provides fields as a Map instead of as an Array. --- --- url: /api/@warp-drive/core/types/schema/fields/type-aliases/Schema.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/schema/fields](../index.md) / Schema ```ts type Schema = | ResourceSchema | ObjectSchema; ``` Defined in: [warp-drive-packages/core/src/types/schema/fields.ts:1966](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/schema/fields.ts#L1966) --- --- url: /api/@warp-drive/core/types/spec/document.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / types/spec/document ## Interfaces * [CollectionResourceDataDocument](interfaces/CollectionResourceDataDocument.md) * [ResourceErrorDocument](interfaces/ResourceErrorDocument.md) * [ResourceMetaDocument](interfaces/ResourceMetaDocument.md) * [SingleResourceDataDocument](interfaces/SingleResourceDataDocument.md) ## Type Aliases * [ResourceDataDocument](type-aliases/ResourceDataDocument.md) * [ResourceDocument](type-aliases/ResourceDocument.md) --- --- url: >- /api/@warp-drive/core/types/spec/document/interfaces/CollectionResourceDataDocument.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/document](../index.md) / CollectionResourceDataDocument Defined in: [warp-drive-packages/core/src/types/spec/document.ts:21](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L21) ## Type Parameters ### T `T` = `StableExistingRecordIdentifier` ## Properties ### data ```ts data: T[]; ``` Defined in: [warp-drive-packages/core/src/types/spec/document.ts:26](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L26) *** ### included? ```ts optional included: T[]; ``` Defined in: [warp-drive-packages/core/src/types/spec/document.ts:27](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L27) *** ### lid? ```ts optional lid: string; ``` Defined in: [warp-drive-packages/core/src/types/spec/document.ts:23](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L23) *** ### links? ```ts optional links: | Links | PaginationLinks; ``` Defined in: [warp-drive-packages/core/src/types/spec/document.ts:24](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L24) *** ### meta? ```ts optional meta: ObjectValue; ``` Defined in: [warp-drive-packages/core/src/types/spec/document.ts:25](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L25) --- --- url: /api/@warp-drive/core/types/spec/document/interfaces/ResourceErrorDocument.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/document](../index.md) / ResourceErrorDocument Defined in: [warp-drive-packages/core/src/types/spec/document.ts:34](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L34) ## Properties ### errors ```ts errors: ApiError[]; ``` Defined in: [warp-drive-packages/core/src/types/spec/document.ts:39](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L39) *** ### lid? ```ts optional lid: string; ``` Defined in: [warp-drive-packages/core/src/types/spec/document.ts:36](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L36) *** ### links? ```ts optional links: | Links | PaginationLinks; ``` Defined in: [warp-drive-packages/core/src/types/spec/document.ts:37](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L37) *** ### meta? ```ts optional meta: ObjectValue; ``` Defined in: [warp-drive-packages/core/src/types/spec/document.ts:38](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L38) --- --- url: /api/@warp-drive/core/types/spec/document/interfaces/ResourceMetaDocument.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/document](../index.md) / ResourceMetaDocument Defined in: [warp-drive-packages/core/src/types/spec/document.ts:5](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L5) ## Properties ### lid? ```ts optional lid: string; ``` Defined in: [warp-drive-packages/core/src/types/spec/document.ts:7](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L7) *** ### links? ```ts optional links: | Links | PaginationLinks; ``` Defined in: [warp-drive-packages/core/src/types/spec/document.ts:9](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L9) *** ### meta ```ts meta: ObjectValue; ``` Defined in: [warp-drive-packages/core/src/types/spec/document.ts:8](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L8) --- --- url: >- /api/@warp-drive/core/types/spec/document/interfaces/SingleResourceDataDocument.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/document](../index.md) / SingleResourceDataDocument Defined in: [warp-drive-packages/core/src/types/spec/document.ts:12](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L12) ## Type Parameters ### T `T` = `StableExistingRecordIdentifier` ### R `R` = `StableExistingRecordIdentifier` ## Properties ### data ```ts data: null | T; ``` Defined in: [warp-drive-packages/core/src/types/spec/document.ts:17](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L17) *** ### included? ```ts optional included: R[]; ``` Defined in: [warp-drive-packages/core/src/types/spec/document.ts:18](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L18) *** ### lid? ```ts optional lid: string; ``` Defined in: [warp-drive-packages/core/src/types/spec/document.ts:14](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L14) *** ### links? ```ts optional links: | Links | PaginationLinks; ``` Defined in: [warp-drive-packages/core/src/types/spec/document.ts:15](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L15) *** ### meta? ```ts optional meta: ObjectValue; ``` Defined in: [warp-drive-packages/core/src/types/spec/document.ts:16](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L16) --- --- url: /api/@warp-drive/core/types/spec/document/type-aliases/ResourceDataDocument.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/document](../index.md) / ResourceDataDocument ```ts type ResourceDataDocument = | SingleResourceDataDocument | CollectionResourceDataDocument; ``` Defined in: [warp-drive-packages/core/src/types/spec/document.ts:30](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L30) ## Type Parameters ### T `T` = `StableExistingRecordIdentifier` --- --- url: /api/@warp-drive/core/types/spec/error.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / types/spec/error ## Interfaces * [ApiError](interfaces/ApiError.md) --- --- url: /api/@warp-drive/core/types/spec/document/type-aliases/ResourceDocument.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/document](../index.md) / ResourceDocument ```ts type ResourceDocument = | ResourceMetaDocument | SingleResourceDataDocument | CollectionResourceDataDocument | ResourceErrorDocument; ``` Defined in: [warp-drive-packages/core/src/types/spec/document.ts:42](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/document.ts#L42) ## Type Parameters ### T `T` = `StableExistingRecordIdentifier` --- --- url: /api/@warp-drive/core/types/spec/error/interfaces/ApiError.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/error](../index.md) / ApiError Defined in: [warp-drive-packages/core/src/types/spec/error.ts:3](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/error.ts#L3) ## Properties ### code? ```ts optional code: string; ``` Defined in: [warp-drive-packages/core/src/types/spec/error.ts:12](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/error.ts#L12) *** ### detail? ```ts optional detail: string; ``` Defined in: [warp-drive-packages/core/src/types/spec/error.ts:6](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/error.ts#L6) *** ### id? ```ts optional id: string; ``` Defined in: [warp-drive-packages/core/src/types/spec/error.ts:4](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/error.ts#L4) *** ### links? ```ts optional links: object; ``` Defined in: [warp-drive-packages/core/src/types/spec/error.ts:7](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/error.ts#L7) #### about? ```ts optional about: Link; ``` #### type? ```ts optional type: Link; ``` *** ### meta? ```ts optional meta: ObjectValue; ``` Defined in: [warp-drive-packages/core/src/types/spec/error.ts:18](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/error.ts#L18) *** ### source? ```ts optional source: object; ``` Defined in: [warp-drive-packages/core/src/types/spec/error.ts:13](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/error.ts#L13) #### header? ```ts optional header: string; ``` #### parameter? ```ts optional parameter: string; ``` #### pointer ```ts pointer: string; ``` *** ### status? ```ts optional status: string; ``` Defined in: [warp-drive-packages/core/src/types/spec/error.ts:11](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/error.ts#L11) *** ### title? ```ts optional title: string; ``` Defined in: [warp-drive-packages/core/src/types/spec/error.ts:5](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/error.ts#L5) --- --- url: /api/@warp-drive/core/types/spec/json-api-raw.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / types/spec/json-api-raw ## Interfaces * [CollectionResourceRelationship](interfaces/CollectionResourceRelationship.md) * [Links](interfaces/Links.md) * [PaginationLinks](interfaces/PaginationLinks.md) * [ResourceIdentifier](interfaces/ResourceIdentifier.md) * [SingleResourceRelationship](interfaces/SingleResourceRelationship.md) ## Type Aliases * [CollectionResourceDocument](type-aliases/CollectionResourceDocument.md) * [EmptyResourceDocument](type-aliases/EmptyResourceDocument.md) * [InnerRelationshipDocument](type-aliases/InnerRelationshipDocument.md) * [Link](type-aliases/Link.md) * [LinkObject](type-aliases/LinkObject.md) * [Meta](type-aliases/Meta.md) * [NewResourceObject](type-aliases/NewResourceObject.md) * [ResourceIdentifierObject](type-aliases/ResourceIdentifierObject.md) * [ResourceObject](type-aliases/ResourceObject.md) * [ResourceRelationshipsObject](type-aliases/ResourceRelationshipsObject.md) * [SingleResourceDocument](type-aliases/SingleResourceDocument.md) --- --- url: >- /api/@warp-drive/core/types/spec/json-api-raw/interfaces/CollectionResourceRelationship.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/json-api-raw](../index.md) / CollectionResourceRelationship Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:102](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L102) ## Type Parameters ### T `T` = `ExistingResourceIdentifierObject` | `NewResourceIdentifierObject` ## Properties ### data? ```ts optional data: T[]; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:103](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L103) *** ### links? ```ts optional links: PaginationLinks; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:105](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L105) *** ### meta? ```ts optional meta: ObjectValue; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:104](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L104) --- --- url: /api/@warp-drive/core/types/spec/json-api-raw/interfaces/Links.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/json-api-raw](../index.md) / Links Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:6](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L6) ## Extended by * [`PaginationLinks`](PaginationLinks.md) ## Properties ### related? ```ts optional related: null | Link; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:7](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L7) *** ### self? ```ts optional self: null | Link; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:8](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L8) --- --- url: /api/@warp-drive/core/types/spec/json-api-raw/interfaces/ResourceIdentifier.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/json-api-raw](../index.md) / ResourceIdentifier Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:86](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L86) ## Properties ### lid ```ts lid: string; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:87](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L87) --- --- url: >- /api/@warp-drive/core/types/spec/json-api-raw/interfaces/SingleResourceRelationship.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/json-api-raw](../index.md) / SingleResourceRelationship Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:96](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L96) ## Type Parameters ### T `T` = `ExistingResourceIdentifierObject` | `NewResourceIdentifierObject` ## Properties ### data? ```ts optional data: null | T; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:97](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L97) *** ### links? ```ts optional links: Links; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:99](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L99) *** ### meta? ```ts optional meta: ObjectValue; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:98](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L98) --- --- url: /api/@warp-drive/core/types/spec/json-api-raw/interfaces/PaginationLinks.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/json-api-raw](../index.md) / PaginationLinks Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:10](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L10) ## Extends * [`Links`](Links.md) ## Properties ### first? ```ts optional first: null | Link; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:11](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L11) *** ### last? ```ts optional last: null | Link; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:12](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L12) *** ### next? ```ts optional next: null | Link; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:14](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L14) *** ### prev? ```ts optional prev: null | Link; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:13](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L13) *** ### related? ```ts optional related: null | Link; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:7](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L7) #### Inherited from [`Links`](Links.md).[`related`](Links.md#related) *** ### self? ```ts optional self: null | Link; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:8](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L8) #### Inherited from [`Links`](Links.md).[`self`](Links.md#self) --- --- url: >- /api/@warp-drive/core/types/spec/json-api-raw/type-aliases/CollectionResourceDocument.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/json-api-raw](../index.md) / CollectionResourceDocument ```ts type CollectionResourceDocument = Document & object; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:154](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L154) ## Type declaration ### data ```ts data: ExistingResourceObject[]; ``` ## Type Parameters ### T `T` *extends* `string` = `string` --- --- url: >- /api/@warp-drive/core/types/spec/json-api-raw/type-aliases/EmptyResourceDocument.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/json-api-raw](../index.md) / EmptyResourceDocument ```ts type EmptyResourceDocument = Document & object; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:146](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L146) ## Type declaration ### data ```ts data: null; ``` --- --- url: >- /api/@warp-drive/core/types/spec/json-api-raw/type-aliases/InnerRelationshipDocument.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/json-api-raw](../index.md) / InnerRelationshipDocument ```ts type InnerRelationshipDocument = | SingleResourceRelationship | CollectionResourceRelationship; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:108](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L108) ## Type Parameters ### T `T` = `ExistingResourceIdentifierObject` | `NewResourceIdentifierObject` --- --- url: /api/@warp-drive/core/types/spec/json-api-raw/type-aliases/Link.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/json-api-raw](../index.md) / Link ```ts type Link = string | LinkObject; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:5](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L5) --- --- url: /api/@warp-drive/core/types/spec/json-api-raw/type-aliases/LinkObject.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/json-api-raw](../index.md) / LinkObject ```ts type LinkObject = object; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:4](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L4) ## Properties ### href ```ts href: string; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:4](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L4) *** ### meta? ```ts optional meta: Meta; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:4](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L4) --- --- url: >- /api/@warp-drive/core/types/spec/json-api-raw/type-aliases/NewResourceObject.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/json-api-raw](../index.md) / NewResourceObject ```ts type NewResourceObject = NewResourceIdentifierObject & object; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:128](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L128) ## Type declaration ### attributes? ```ts optional attributes: ObjectValue; ``` ### links? ```ts optional links: Links; ``` ### meta? ```ts optional meta: Meta; ``` ### relationships? ```ts optional relationships: ResourceRelationshipsObject; ``` ## Type Parameters ### T `T` *extends* `string` = `string` --- --- url: /api/@warp-drive/core/types/spec/json-api-raw/type-aliases/Meta.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/json-api-raw](../index.md) / Meta ```ts type Meta = ObjectValue; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:3](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L3) --- --- url: >- /api/@warp-drive/core/types/spec/json-api-raw/type-aliases/ResourceIdentifierObject.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/json-api-raw](../index.md) / ResourceIdentifierObject ```ts type ResourceIdentifierObject = | ResourceIdentifier | ExistingResourceIdentifierObject | NewResourceIdentifierObject; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:90](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L90) ## Type Parameters ### T `T` *extends* `string` = `string` --- --- url: /api/@warp-drive/core/types/spec/json-api-raw/type-aliases/ResourceObject.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/json-api-raw](../index.md) / ResourceObject ```ts type ResourceObject = | ExistingResourceObject | NewResourceObject; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:135](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L135) ## Type Parameters ### T `T` *extends* `string` = `string` --- --- url: >- /api/@warp-drive/core/types/spec/json-api-raw/type-aliases/ResourceRelationshipsObject.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/json-api-raw](../index.md) / ResourceRelationshipsObject ```ts type ResourceRelationshipsObject = Record>; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:112](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L112) ## Type Parameters ### T `T` = `ExistingResourceIdentifierObject` | `NewResourceIdentifierObject` --- --- url: >- /api/@warp-drive/core/types/spec/json-api-raw/type-aliases/SingleResourceDocument.md --- [Documentation](../../../../../../index.md) / [@warp-drive/core](../../../../index.md) / [types/spec/json-api-raw](../index.md) / SingleResourceDocument ```ts type SingleResourceDocument = Document & object; ``` Defined in: [warp-drive-packages/core/src/types/spec/json-api-raw.ts:150](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/spec/json-api-raw.ts#L150) ## Type declaration ### data ```ts data: ExistingResourceObject; ``` ## Type Parameters ### T `T` *extends* `string` = `string` --- --- url: /api/@warp-drive/core/types/symbols.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / types/symbols ## Variables * [RecordStore](variables/RecordStore.md) * [RequestSignature](variables/RequestSignature.md) * [ResourceType](variables/ResourceType.md) * [TransformName](variables/TransformName.md) * [Type](variables/Type.md) --- --- url: /api/@warp-drive/core/types/symbols/variables/RecordStore.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/symbols](../index.md) / RecordStore ```ts const RecordStore: "___(unique) Symbol(Store)"; ``` Defined in: [warp-drive-packages/core/src/types/symbols.ts:3](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/symbols.ts#L3) --- --- url: /api/@warp-drive/core/types/symbols/variables/RequestSignature.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/symbols](../index.md) / RequestSignature ```ts const RequestSignature: "___(unique) Symbol(RequestSignature)"; ``` Defined in: [warp-drive-packages/core/src/types/symbols.ts:84](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/symbols.ts#L84) Symbol for use by builders to indicate the return type generic to use for store.request() --- --- url: /api/@warp-drive/core/types/symbols/variables/ResourceType.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/symbols](../index.md) / ResourceType ```ts const ResourceType: "___(unique) Symbol($type)" = Type; ``` Defined in: [warp-drive-packages/core/src/types/symbols.ts:58](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/symbols.ts#L58) Symbol for the type of a resource. This is an optional feature that can be used by record implementations to provide a typescript hint for the type of the resource. When used, EmberData/WarpDrive APIs can take advantage of this to provide better type safety and intellisense. --- --- url: /api/@warp-drive/core/types/symbols/variables/TransformName.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/symbols](../index.md) / TransformName ```ts const TransformName: "___(unique) Symbol($type)" = Type; ``` Defined in: [warp-drive-packages/core/src/types/symbols.ts:76](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/symbols.ts#L76) Symbol for the name of a transform. This is an optional feature that can be used by transform implementations to provide a typescript hint for the name of the transform. If not used, `attr('name')` will allow any string name. `attr('name')` will always allow any string name. If used, `attr('name')` will enforce that the name is the same as the transform name. --- --- url: /api/@warp-drive/core/types/symbols/variables/Type.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/symbols](../index.md) / Type ```ts const Type: "___(unique) Symbol($type)"; ``` Defined in: [warp-drive-packages/core/src/types/symbols.ts:43](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/symbols.ts#L43) Symbol for the name of a resource, transformation or derivation. ### With Resources This is an optional feature that can be used by record implementations to provide a typescript hint for the type of the resource. When used, EmberData/WarpDrive APIs can take advantage of this to provide better type safety and intellisense. ### With Derivations Required for derivations registered with `store.registerDerivation(derivation)`. ```ts function concat(record: object, options: ObjectValue | null, prop: string): string {} concat[Name] = 'concat'; ``` ### With Transforms Required for new-style transformations registered with `store.registerTransform(transform)`. For legacy transforms, if not used, `attr('name')` will allow any string name. `attr('name')` will always allow any string name. If used, `attr('name')` will enforce that the name is the same as the transform name. --- --- url: /api/@warp-drive/core/types/type-aliases/CacheCapabilitiesManager.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [types](../index.md) / CacheCapabilitiesManager ```ts type CacheCapabilitiesManager = object; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts:18](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts#L18) CacheCapabilitiesManager provides encapsulated API access to the minimal subset of the Store's functionality that Cache implementations should interact with. It is provided to the Store's `createCache` hook. Cache implementations should not need more than this API provides. This class cannot be directly instantiated. CacheCapabilitiesManager ## Properties ### identifierCache ```ts identifierCache: IdentifierCache; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts:30](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts#L30) Provides access to the IdentifierCache instance for this Store instance. The IdentifierCache can be used to peek, generate or retrieve a stable unique identifier for any resource. *** ### schema ```ts schema: SchemaService; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts:56](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts#L56) Provides access to the SchemaService instance for this Store instance. The SchemaService can be used to query for information about the schema of a resource. ## Methods ### disconnectRecord() ```ts disconnectRecord(identifier): void; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts:77](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts#L77) Signal to the store that the specified record may be considered fully removed from the cache. Generally this means that not only does no data exist for the identified resource, no known relationships still point to it either. #### Parameters ##### identifier [`StableRecordIdentifier`](../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `void` *** ### ~~getSchemaDefinitionService()~~ ```ts getSchemaDefinitionService(): SchemaService; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts:44](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts#L44) DEPRECATED - use the schema property Provides access to the SchemaService instance for this Store instance. The SchemaService can be used to query for information about the schema of a resource. #### Returns [`SchemaService`](../interfaces/SchemaService.md) #### Deprecated *** ### hasRecord() ```ts hasRecord(identifier): boolean; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts:87](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts#L87) Use this method to determine if the Store has an instantiated record associated with an identifier. #### Parameters ##### identifier [`StableRecordIdentifier`](../identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` *** ### notifyChange() #### Call Signature ```ts notifyChange( identifier, namespace, key): void; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts:102](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts#L102) Notify subscribers of the NotificationManager that cache state has changed. `attributes` and `relationships` do not require a key, but if one is specified it is assumed to be the name of the attribute or relationship that has been updated. No other namespaces currently expect the `key` argument. ##### Parameters ###### identifier [`StableRecordIdentifier`](../identifier/type-aliases/StableRecordIdentifier.md) ###### namespace `"added"` | `"removed"` ###### key `null` ##### Returns `void` #### Call Signature ```ts notifyChange( identifier, namespace, key): void; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts:103](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts#L103) ##### Parameters ###### identifier [`StableDocumentIdentifier`](../identifier/type-aliases/StableDocumentIdentifier.md) ###### namespace `"added"` | `"removed"` | `"updated"` ###### key `null` ##### Returns `void` #### Call Signature ```ts notifyChange( identifier, namespace, key): void; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts:104](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts#L104) ##### Parameters ###### identifier [`StableRecordIdentifier`](../identifier/type-aliases/StableRecordIdentifier.md) ###### namespace [`NotificationType`](../../type-aliases/NotificationType.md) ###### key `null` | `string` ##### Returns `void` #### Call Signature ```ts notifyChange( identifier, namespace, key): void; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts:105](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts#L105) ##### Parameters ###### identifier [`StableDocumentIdentifier`](../identifier/type-aliases/StableDocumentIdentifier.md) | [`StableRecordIdentifier`](../identifier/type-aliases/StableRecordIdentifier.md) ###### namespace [`NotificationType`](../../type-aliases/NotificationType.md) ###### key `null` | `string` ##### Returns `void` *** ### setRecordId() ```ts setRecordId(identifier, id): void; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts:66](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/cache-capabilities-manager.ts#L66) Update the `id` for the record corresponding to the identifier This operation can only be done for records whose `id` is `null`. #### Parameters ##### identifier [`StableRecordIdentifier`](../identifier/type-aliases/StableRecordIdentifier.md) ##### id `string` #### Returns `void` --- --- url: /api/@warp-drive/core/types/type-aliases/FindAllOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [types](../index.md) / FindAllOptions ```ts type FindAllOptions = BaseFinderOptions; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/store.ts:33](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/store.ts#L33) ## Type Parameters ### T `T` = `unknown` --- --- url: /api/@warp-drive/core/types/type-aliases/QueryOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [types](../index.md) / QueryOptions ```ts type QueryOptions = { [K in string | "adapterOptions"]?: K extends "adapterOptions" ? Record : unknown }; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/store.ts:29](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/store.ts#L29) --- --- url: /api/@warp-drive/core/types/type-aliases/LegacyResourceQuery.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / [types](../index.md) / LegacyResourceQuery ```ts type LegacyResourceQuery = object; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/store.ts:34](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/store.ts#L34) ## Type Parameters ### T `T` = `unknown` ## Indexable ```ts [key: string]: undefined | Value ``` ## Properties ### include? ```ts optional include: T extends TypedRecordInstance ? Includes[] : string | string[]; ``` Defined in: [warp-drive-packages/core/src/store/-types/q/store.ts:35](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-types/q/store.ts#L35) --- --- url: /api/@warp-drive/core/types/utils.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / types/utils ## Type Aliases * [Mutable](type-aliases/Mutable.md) * [WithPartial](type-aliases/WithPartial.md) --- --- url: /api/@warp-drive/core/types/utils/type-aliases/WithPartial.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/utils](../index.md) / WithPartial ```ts type WithPartial = Omit & Partial>; ``` Defined in: [warp-drive-packages/core/src/types/utils.ts:1](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/utils.ts#L1) ## Type Parameters ### T `T` ### K `K` *extends* keyof `T` --- --- url: /api/@warp-drive/core/types/utils/type-aliases/Mutable.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [types/utils](../index.md) / Mutable ```ts type Mutable = { -readonly [P in keyof T]: T[P] }; ``` Defined in: [warp-drive-packages/core/src/types/utils.ts:3](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/types/utils.ts#L3) ## Type Parameters ### T `T` --- --- url: /api/@warp-drive/core/utils/string.md --- [Documentation](../../../../index.md) / [@warp-drive/core](../../index.md) / utils/string ## Variables * [STRING\_DASHERIZE\_CACHE](variables/STRING_DASHERIZE_CACHE.md) --- --- url: /api/@warp-drive/core/utils/string/variables/STRING_DASHERIZE_CACHE.md --- [Documentation](../../../../../index.md) / [@warp-drive/core](../../../index.md) / [utils/string](../index.md) / STRING\_DASHERIZE\_CACHE ```ts const STRING_DASHERIZE_CACHE: LRUCache; ``` Defined in: [warp-drive-packages/core/src/utils/string.ts:91](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/utils/string.ts#L91) --- --- url: /api/@warp-drive/core/variables/CacheHandler.md --- [Documentation](../../../index.md) / [@warp-drive/core](../index.md) / CacheHandler ```ts const CacheHandler: CacheHandler; ``` Defined in: [warp-drive-packages/core/src/store/-private/cache-handler/handler.ts:81](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/core/src/store/-private/cache-handler/handler.ts#L81) A CacheHandler that adds support for using an WarpDrive Cache with a RequestManager. This handler will only run when a request has supplied a `store` instance. Requests issued by the store via `store.request()` will automatically have the `store` instance attached to the request. ```ts requestManager.request({ store: store, url: '/api/posts', method: 'GET' }); ``` When this handler elects to handle a request, it will return the raw `StructuredDocument` unless the request has `[EnableHydration]` set to `true`. In this case, the handler will return a `Document` instance that will automatically update the UI when the cache is updated in the future and will hydrate any identifiers in the StructuredDocument into Record instances. When issuing a request via the store, \[EnableHydration] is automatically set to `true`. This means that if desired you can issue requests that utilize the cache without needing to also utilize Record instances if desired. Said differently, you could elect to issue all requests via a RequestManager, without ever using the store directly, by setting \[EnableHydration] to `true` and providing a store instance. Not necessarily the most useful thing, but the decoupled nature of the RequestManager and incremental-feature approach of WarpDrive allows for this flexibility. ```ts import { EnableHydration } from '@warp-drive/core/types/request'; requestManager.request({ store: store, url: '/api/posts', method: 'GET', [EnableHydration]: true }); ``` --- --- url: /api/@warp-drive/experiments/data-worker.md --- [Documentation](../../../index.md) / [@warp-drive/experiments](../index.md) / data-worker ## Classes * [DataWorker](classes/DataWorker.md) ## Variables * [CacheHandler](variables/CacheHandler.md) --- --- url: /api/@warp-drive/experiments/data-worker/variables/CacheHandler.md --- [Documentation](../../../../index.md) / [@warp-drive/experiments](../../index.md) / [data-worker](../index.md) / CacheHandler ```ts const CacheHandler: CacheHandler; ``` Defined in: [data-worker/cache-handler.ts:28](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/cache-handler.ts#L28) A simplified CacheHandler that hydrates ResourceDataDocuments from the cache with their referenced resources. --- --- url: /api/@warp-drive/experiments/document-storage/classes/DocumentStorage.md --- [Documentation](../../../../index.md) / [@warp-drive/experiments](../../index.md) / [document-storage](../index.md) / DocumentStorage Defined in: [document-storage/index.ts:407](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/document-storage/index.ts#L407) DocumentStorage is a wrapper around the StorageManager API that provides a simple interface for reading and updating documents and requests. Some goals for this experiment: * optimize for storing requests/documents * optimize for storing resources * optimize for looking up resources associated to a document * optimize for notifying cross-tab when data is updated optional features: * support for offline mode * ?? support for relationship based cache traversal * a way to index records by type + another field (e.g updatedAt/createAt/name) such that simple queries can be done without having to scan all records ## Constructors ### Constructor ```ts new DocumentStorage(options): DocumentStorage; ``` Defined in: [document-storage/index.ts:410](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/document-storage/index.ts#L410) #### Parameters ##### options `Partial`<`DocumentStorageOptions`> = `{}` #### Returns `DocumentStorage` ## Properties ### \_storage ```ts readonly _storage: InternalDocumentStorage; ``` Defined in: [document-storage/index.ts:408](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/document-storage/index.ts#L408) ## Methods ### clear() ```ts clear(reset?): Promise; ``` Defined in: [document-storage/index.ts:448](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/document-storage/index.ts#L448) #### Parameters ##### reset? `boolean` #### Returns `Promise`<`void`> *** ### getDocument() ```ts getDocument(key): Promise; ``` Defined in: [document-storage/index.ts:430](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/document-storage/index.ts#L430) #### Parameters ##### key `DocumentIdentifier` #### Returns `Promise`<`null` | `CacheDocument`> *** ### putDocument() ```ts putDocument(document, resourceCollector): Promise; ``` Defined in: [document-storage/index.ts:434](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/document-storage/index.ts#L434) #### Parameters ##### document `CacheFileDocument` ##### resourceCollector (`resourceIdentifier`) => `ExistingResourceObject` #### Returns `Promise`<`void`> *** ### putResources() ```ts putResources(document, resourceCollector): Promise; ``` Defined in: [document-storage/index.ts:441](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/document-storage/index.ts#L441) #### Parameters ##### document [`ResourceDataDocument`](../../../core-types/spec/document/type-aliases/ResourceDataDocument.md)<[`ExistingRecordIdentifier`](../../../core-types/identifier/interfaces/ExistingRecordIdentifier.md)<`string`>> ##### resourceCollector (`resourceIdentifier`) => `ExistingResourceObject` #### Returns `Promise`<`void`> --- --- url: /api/@warp-drive/experiments/data-worker/classes/DataWorker.md --- [Documentation](../../../../index.md) / [@warp-drive/experiments](../../index.md) / [data-worker](../index.md) / DataWorker Defined in: [data-worker/worker.ts:10](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/worker.ts#L10) ## Constructors ### Constructor ```ts new DataWorker(UserStore, options?): DataWorker; ``` Defined in: [data-worker/worker.ts:18](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/worker.ts#L18) #### Parameters ##### UserStore *typeof* [`default`](../../../../@ember-data/store/index/classes/default.md) ##### options? ###### persisted `boolean` ###### scope? `string` #### Returns `DataWorker` ## Properties ### isSharedWorker ```ts isSharedWorker: boolean; ``` Defined in: [data-worker/worker.ts:14](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/worker.ts#L14) *** ### options ```ts options: object; ``` Defined in: [data-worker/worker.ts:15](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/worker.ts#L15) #### persisted ```ts persisted: boolean; ``` #### scope? ```ts optional scope: string; ``` *** ### pending ```ts pending: Map>>; ``` Defined in: [data-worker/worker.ts:13](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/worker.ts#L13) *** ### storage ```ts storage: DocumentStorage; ``` Defined in: [data-worker/worker.ts:16](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/worker.ts#L16) *** ### store ```ts store: default; ``` Defined in: [data-worker/worker.ts:11](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/worker.ts#L11) *** ### threads ```ts threads: Map; ``` Defined in: [data-worker/worker.ts:12](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/worker.ts#L12) ## Methods ### abortRequest() ```ts abortRequest(event): void; ``` Defined in: [data-worker/worker.ts:86](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/worker.ts#L86) #### Parameters ##### event `AbortEventData` #### Returns `void` *** ### initialize() ```ts initialize(): void; ``` Defined in: [data-worker/worker.ts:31](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/worker.ts#L31) #### Returns `void` *** ### request() ```ts request(event): Promise; ``` Defined in: [data-worker/worker.ts:96](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/worker.ts#L96) #### Parameters ##### event `RequestEventData` #### Returns `Promise`<`void`> *** ### setupThread() ```ts setupThread(thread, port): void; ``` Defined in: [data-worker/worker.ts:65](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/worker.ts#L65) #### Parameters ##### thread `string` ##### port `MessagePort` #### Returns `void` --- --- url: /api/@warp-drive/experiments/document-storage.md --- [Documentation](../../../index.md) / [@warp-drive/experiments](../index.md) / document-storage ## Classes * [DocumentStorage](classes/DocumentStorage.md) --- --- url: /api/@warp-drive/experiments/image-fetch/classes/ImageFetch.md --- [Documentation](../../../../index.md) / [@warp-drive/experiments](../../index.md) / [image-fetch](../index.md) / ImageFetch Defined in: [image-worker/fetch.ts:17](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/fetch.ts#L17) ## Constructors ### Constructor ```ts new ImageFetch(worker): ImageFetch; ``` Defined in: [image-worker/fetch.ts:24](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/fetch.ts#L24) #### Parameters ##### worker `null` | `Worker` | `SharedWorker` #### Returns `ImageFetch` ## Properties ### cache ```ts cache: Map; ``` Defined in: [image-worker/fetch.ts:22](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/fetch.ts#L22) *** ### channel ```ts channel: MessageChannel; ``` Defined in: [image-worker/fetch.ts:21](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/fetch.ts#L21) *** ### pending ```ts pending: Map>; ``` Defined in: [image-worker/fetch.ts:20](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/fetch.ts#L20) *** ### threadId ```ts threadId: string; ``` Defined in: [image-worker/fetch.ts:19](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/fetch.ts#L19) *** ### worker ```ts worker: Worker | SharedWorker; ``` Defined in: [image-worker/fetch.ts:18](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/fetch.ts#L18) ## Methods ### \_send() ```ts _send(event): void; ``` Defined in: [image-worker/fetch.ts:71](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/fetch.ts#L71) #### Parameters ##### event `RequestEventData` #### Returns `void` *** ### cleanupRequest() ```ts cleanupRequest(url): | undefined | Deferred; ``` Defined in: [image-worker/fetch.ts:64](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/fetch.ts#L64) #### Parameters ##### url `string` #### Returns | `undefined` | [`Deferred`](../../../../@ember-data/request/index/type-aliases/Deferred.md)<`string`> *** ### load() ```ts load(url): Promise; ``` Defined in: [image-worker/fetch.ts:76](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/fetch.ts#L76) #### Parameters ##### url `string` #### Returns `Promise`<`string`> --- --- url: /api/@warp-drive/experiments/image-fetch.md --- [Documentation](../../../index.md) / [@warp-drive/experiments](../index.md) / image-fetch ## Classes * [ImageFetch](classes/ImageFetch.md) --- --- url: /api/@warp-drive/experiments/image-worker/classes/ImageWorker.md --- [Documentation](../../../../index.md) / [@warp-drive/experiments](../../index.md) / [image-worker](../index.md) / ImageWorker Defined in: [image-worker/worker.ts:11](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/worker.ts#L11) ## Constructors ### Constructor ```ts new ImageWorker(options?): ImageWorker; ``` Defined in: [image-worker/worker.ts:18](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/worker.ts#L18) #### Parameters ##### options? ###### persisted `boolean` #### Returns `ImageWorker` ## Properties ### cache ```ts cache: Map; ``` Defined in: [image-worker/worker.ts:16](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/worker.ts#L16) *** ### isSharedWorker ```ts isSharedWorker: boolean; ``` Defined in: [image-worker/worker.ts:15](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/worker.ts#L15) *** ### options ```ts options: object; ``` Defined in: [image-worker/worker.ts:14](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/worker.ts#L14) #### persisted ```ts persisted: boolean; ``` *** ### pendingImages ```ts pendingImages: Map>; ``` Defined in: [image-worker/worker.ts:13](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/worker.ts#L13) *** ### threads ```ts threads: Map; ``` Defined in: [image-worker/worker.ts:12](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/worker.ts#L12) ## Methods ### fetch() ```ts fetch(url): Promise; ``` Defined in: [image-worker/worker.ts:31](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/worker.ts#L31) #### Parameters ##### url `string` #### Returns `Promise`<`string`> *** ### initialize() ```ts initialize(): void; ``` Defined in: [image-worker/worker.ts:50](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/worker.ts#L50) #### Returns `void` *** ### request() ```ts request(event): Promise; ``` Defined in: [image-worker/worker.ts:95](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/worker.ts#L95) #### Parameters ##### event `RequestEventData` #### Returns `Promise`<`void`> *** ### setupThread() ```ts setupThread(thread, port): void; ``` Defined in: [image-worker/worker.ts:78](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/image-worker/worker.ts#L78) #### Parameters ##### thread `string` ##### port `MessagePort` #### Returns `void` --- --- url: /api/@warp-drive/experiments/image-worker.md --- [Documentation](../../../index.md) / [@warp-drive/experiments](../index.md) / image-worker ## Classes * [ImageWorker](classes/ImageWorker.md) --- --- url: /api/@warp-drive/experiments.md --- [Documentation](../../index.md) / @warp-drive/experiments ## Modules * [data-worker](data-worker/index.md) * [document-storage](document-storage/index.md) * [image-fetch](image-fetch/index.md) * [image-worker](image-worker/index.md) * [persisted-cache](persisted-cache/index.md) * [worker-fetch](worker-fetch/index.md) --- --- url: /api/@warp-drive/experiments/persisted-cache.md --- [Documentation](../../../index.md) / [@warp-drive/experiments](../index.md) / persisted-cache --- --- url: /api/@warp-drive/experiments/worker-fetch/classes/WorkerFetch.md --- [Documentation](../../../../index.md) / [@warp-drive/experiments](../../index.md) / [worker-fetch](../index.md) / WorkerFetch Defined in: [data-worker/fetch.ts:41](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/fetch.ts#L41) ## Constructors ### Constructor ```ts new WorkerFetch(worker): WorkerFetch; ``` Defined in: [data-worker/fetch.ts:50](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/fetch.ts#L50) #### Parameters ##### worker `null` | `Worker` | `SharedWorker` #### Returns `WorkerFetch` ## Properties ### channel ```ts channel: MessageChannel; ``` Defined in: [data-worker/fetch.ts:48](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/fetch.ts#L48) *** ### pending ```ts pending: Map void; context: Context; deferred: Deferred; signal: null | AbortSignal; stack: string; }>; ``` Defined in: [data-worker/fetch.ts:44](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/fetch.ts#L44) *** ### threadId ```ts threadId: string; ``` Defined in: [data-worker/fetch.ts:43](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/fetch.ts#L43) *** ### worker ```ts worker: Worker | SharedWorker; ``` Defined in: [data-worker/fetch.ts:42](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/fetch.ts#L42) ## Methods ### cleanupRequest() ```ts cleanupRequest(id): | undefined | { abortFn: () => void; context: Context; deferred: Deferred; signal: null | AbortSignal; stack: string; }; ``` Defined in: [data-worker/fetch.ts:102](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/fetch.ts#L102) #### Parameters ##### id `number` #### Returns | `undefined` | { `abortFn`: () => `void`; `context`: [`Context`](../../../../@ember-data/request/index/classes/Context.md); `deferred`: [`Deferred`](../../../../@ember-data/request/index/type-aliases/Deferred.md)<`unknown`>; `signal`: `null` | `AbortSignal`; `stack`: `string`; } *** ### request() ```ts request(context, next): | Promise | Future; ``` Defined in: [data-worker/fetch.ts:118](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/fetch.ts#L118) #### Type Parameters ##### T `T` #### Parameters ##### context [`Context`](../../../../@ember-data/request/index/classes/Context.md) ##### next [`NextFn`](../../../../@ember-data/request/index/type-aliases/NextFn.md)<`T`> #### Returns | `Promise`<`T`> | [`Future`](../../../../@ember-data/request/index/interfaces/Future.md)<`T`> *** ### send() ```ts send(event): void; ``` Defined in: [data-worker/fetch.ts:113](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/experiments/src/data-worker/fetch.ts#L113) #### Parameters ##### event `RequestEventData` | `AbortEventData` #### Returns `void` --- --- url: /api/@warp-drive/experiments/worker-fetch.md --- [Documentation](../../../index.md) / [@warp-drive/experiments](../index.md) / worker-fetch ## Classes * [WorkerFetch](classes/WorkerFetch.md) --- --- url: /api/@warp-drive/json-api/classes/JSONAPICache.md --- [Documentation](../../../index.md) / [@warp-drive/json-api](../index.md) / JSONAPICache Defined in: [cache.ts:146](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L146) A JSON:API Cache implementation. What cache the store uses is configurable. Using a different implementation can be achieved by implementing the store's createCache hook. This is the cache implementation used by `ember-data`. ```js import Cache from '@ember-data/json-api'; import Store from '@ember-data/store'; export default class extends Store { createCache(wrapper) { return new Cache(wrapper); } } ``` Cache ## Implements * [`Cache`](../../core-types/cache/interfaces/Cache.md) ## Constructors ### Constructor ```ts new JSONAPICache(capabilities): JSONAPICache; ``` Defined in: [cache.ts:167](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L167) #### Parameters ##### capabilities [`CacheCapabilitiesManager`](../../core-types/index/type-aliases/CacheCapabilitiesManager.md) #### Returns `JSONAPICache` ## Properties ### version ```ts version: "2"; ``` Defined in: [cache.ts:154](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L154) The Cache Version that this implementation implements. #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`version`](../../core-types/cache/interfaces/Cache.md#version) ## Methods ### changedAttrs() ```ts changedAttrs(identifier): ChangedAttributesHash; ``` Defined in: [cache.ts:1416](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L1416) Query the cache for the changed attributes of a resource. #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `ChangedAttributesHash` `{ : [, ] }` #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`changedAttrs`](../../core-types/cache/interfaces/Cache.md#changedattrs) *** ### changedRelationships() ```ts changedRelationships(identifier): Map; ``` Defined in: [cache.ts:1529](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L1529) Query the cache for the changes to relationships of a resource. Returns a map of relationship names to RelationshipDiff objects. ```ts type RelationshipDiff = | { kind: 'collection'; remoteState: StableRecordIdentifier[]; additions: Set; removals: Set; localState: StableRecordIdentifier[]; reordered: boolean; } | { kind: 'resource'; remoteState: StableRecordIdentifier | null; localState: StableRecordIdentifier | null; }; ``` #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `Map`<`string`, [`RelationshipDiff`](../../core-types/cache/type-aliases/RelationshipDiff.md)> #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`changedRelationships`](../../core-types/cache/interfaces/Cache.md#changedrelationships) *** ### clientDidCreate() ```ts clientDidCreate(identifier, options?): Record; ``` Defined in: [cache.ts:768](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L768) \[LIFECYCLE] Signal to the cache that a new record has been instantiated on the client It returns properties from options that should be set on the record during the create process. This return value behavior is deprecated. #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### options? `Record`<`string`, [`Value`](../../core-types/json/raw/type-aliases/Value.md)> #### Returns `Record`<`string`, `unknown`> #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`clientDidCreate`](../../core-types/cache/interfaces/Cache.md#clientdidcreate) *** ### commitWasRejected() ```ts commitWasRejected(identifier, errors?): void; ``` Defined in: [cache.ts:1053](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L1053) \[LIFECYCLE] Signals to the cache that a resource was update via a save transaction failed. #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### errors? [`ApiError`](../../core-types/spec/error/interfaces/ApiError.md)\[] #### Returns `void` #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`commitWasRejected`](../../core-types/cache/interfaces/Cache.md#commitwasrejected) *** ### didCommit() ```ts didCommit(committedIdentifier, result): SingleResourceDataDocument; ``` Defined in: [cache.ts:909](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L909) \[LIFECYCLE] Signals to the cache that a resource was successfully updated as part of a save transaction. #### Parameters ##### committedIdentifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### result [`StructuredDataDocument`](../../core-types/request/interfaces/StructuredDataDocument.md)<[`SingleResourceDocument`](../../core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md)> #### Returns [`SingleResourceDataDocument`](../../core-types/spec/document/interfaces/SingleResourceDataDocument.md) #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`didCommit`](../../core-types/cache/interfaces/Cache.md#didcommit) *** ### diff() ```ts diff(): Promise; ``` Defined in: [cache.ts:716](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L716) Generate the list of changes applied to all record in the store. Each individual resource or document that has been mutated should be described as an individual `Change` entry in the returned array. A `Change` is described by an object containing up to three properties: (1) the `identifier` of the entity that changed; (2) the `op` code of that change being one of `upsert` or `remove`, and if the op is `upsert` a `patch` containing the data to merge into the cache for the given entity. This `patch` is opaque to the Store but should be understood by the Cache and may expect to be utilized by an Adapter when generating data during a `save` operation. It is generally recommended that the `patch` contain only the updated state, ignoring fields that are unchanged ```ts interface Change { identifier: StableRecordIdentifier | StableDocumentIdentifier; op: 'upsert' | 'remove'; patch?: unknown; } ``` #### Returns `Promise`<[`Change`](../../core-types/cache/change/interfaces/Change.md)\[]> #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`diff`](../../core-types/cache/interfaces/Cache.md#diff) *** ### dump() ```ts dump(): Promise>; ``` Defined in: [cache.ts:731](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L731) Serialize the entire contents of the Cache into a Stream which may be fed back into a new instance of the same Cache via `cache.hydrate`. #### Returns `Promise`<`ReadableStream`<`unknown`>> #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`dump`](../../core-types/cache/interfaces/Cache.md#dump) *** ### getAttr() ```ts getAttr(identifier, attr): undefined | Value; ``` Defined in: [cache.ts:1165](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L1165) Retrieve the data for an attribute from the cache #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### attr `string` | `string`\[] #### Returns `undefined` | [`Value`](../../core-types/json/raw/type-aliases/Value.md) #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`getAttr`](../../core-types/cache/interfaces/Cache.md#getattr) *** ### getErrors() ```ts getErrors(identifier): ApiError[]; ``` Defined in: [cache.ts:1610](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L1610) Query the cache for any validation errors applicable to the given resource. #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns [`ApiError`](../../core-types/spec/error/interfaces/ApiError.md)\[] #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`getErrors`](../../core-types/cache/interfaces/Cache.md#geterrors) *** ### getRelationship() ```ts getRelationship(identifier, field): | ResourceRelationship | CollectionRelationship; ``` Defined in: [cache.ts:1572](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L1572) Query the cache for the current state of a relationship property #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### field `string` #### Returns | [`ResourceRelationship`](../../core-types/cache/relationship/interfaces/ResourceRelationship.md)<[`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md)> | [`CollectionRelationship`](../../core-types/cache/relationship/interfaces/CollectionRelationship.md)<[`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md)> resource relationship object #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`getRelationship`](../../core-types/cache/interfaces/Cache.md#getrelationship) *** ### getRemoteAttr() ```ts getRemoteAttr(identifier, attr): undefined | Value; ``` Defined in: [cache.ts:1230](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L1230) Retrieve remote state without any local changes for a specific attribute #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### attr `string` | `string`\[] #### Returns `undefined` | [`Value`](../../core-types/json/raw/type-aliases/Value.md) #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`getRemoteAttr`](../../core-types/cache/interfaces/Cache.md#getremoteattr) *** ### getRemoteRelationship() ```ts getRemoteRelationship(identifier, field): | ResourceRelationship | CollectionRelationship; ``` Defined in: [cache.ts:1576](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L1576) Query the cache for the server state of a relationship property without any local changes #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### field `string` #### Returns | [`ResourceRelationship`](../../core-types/cache/relationship/interfaces/ResourceRelationship.md)<[`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md)> | [`CollectionRelationship`](../../core-types/cache/relationship/interfaces/CollectionRelationship.md)<[`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md)> resource relationship object #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`getRemoteRelationship`](../../core-types/cache/interfaces/Cache.md#getremoterelationship) *** ### hasChangedAttrs() ```ts hasChangedAttrs(identifier): boolean; ``` Defined in: [cache.ts:1440](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L1440) Query the cache for whether any mutated attributes exist #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`hasChangedAttrs`](../../core-types/cache/interfaces/Cache.md#haschangedattrs) *** ### hasChangedRelationships() ```ts hasChangedRelationships(identifier): boolean; ``` Defined in: [cache.ts:1540](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L1540) Query the cache for whether any mutated relationships exist #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`hasChangedRelationships`](../../core-types/cache/interfaces/Cache.md#haschangedrelationships) *** ### hydrate() ```ts hydrate(stream): Promise; ``` Defined in: [cache.ts:751](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L751) hydrate a Cache from a Stream with content previously serialized from another instance of the same Cache, resolving when hydration is complete. This method should expect to be called both in the context of restoring the Cache during application rehydration after SSR **AND** at unknown times during the lifetime of an already booted application when it is desired to bulk-load additional information into the cache. This latter behavior supports optimizing pre/fetching of data for route transitions via data-only SSR modes. #### Parameters ##### stream `ReadableStream`<`unknown`> #### Returns `Promise`<`void`> #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`hydrate`](../../core-types/cache/interfaces/Cache.md#hydrate) *** ### isDeleted() ```ts isDeleted(identifier): boolean; ``` Defined in: [cache.ts:1647](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L1647) Query the cache for whether a given resource is marked as deleted (but not necessarily persisted yet). #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`isDeleted`](../../core-types/cache/interfaces/Cache.md#isdeleted) *** ### isDeletionCommitted() ```ts isDeletionCommitted(identifier): boolean; ``` Defined in: [cache.ts:1660](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L1660) Query the cache for whether a given resource has been deleted and that deletion has also been persisted. #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`isDeletionCommitted`](../../core-types/cache/interfaces/Cache.md#isdeletioncommitted) *** ### isEmpty() ```ts isEmpty(identifier): boolean; ``` Defined in: [cache.ts:1621](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L1621) Query the cache for whether a given resource has any available data #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`isEmpty`](../../core-types/cache/interfaces/Cache.md#isempty) *** ### isNew() ```ts isNew(identifier): boolean; ``` Defined in: [cache.ts:1634](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L1634) Query the cache for whether a given resource was created locally and not yet persisted. #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `boolean` #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`isNew`](../../core-types/cache/interfaces/Cache.md#isnew) *** ### merge() ```ts merge(cache): Promise; ``` Defined in: [cache.ts:680](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L680) Merge a fork back into a parent Cache. Applications should typically not call this method themselves, preferring instead to merge at the Store level, which will utilize this method to merge the caches. #### Parameters ##### cache [`Cache`](../../core-types/cache/interfaces/Cache.md) #### Returns `Promise`<`void`> #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`merge`](../../core-types/cache/interfaces/Cache.md#merge) *** ### mutate() ```ts mutate(mutation): void; ``` Defined in: [cache.ts:440](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L440) Update the "local" or "current" (unpersisted) state of the Cache #### Parameters ##### mutation [`LocalRelationshipOperation`](../../core-types/graph/type-aliases/LocalRelationshipOperation.md) #### Returns `void` #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`mutate`](../../core-types/cache/interfaces/Cache.md#mutate) *** ### patch() ```ts patch(op): void; ``` Defined in: [cache.ts:411](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L411) Update the "remote" or "canonical" (persisted) state of the Cache by merging new information into the existing state. #### Parameters ##### op the operation or list of operations to perform [`Operation`](../../core-types/cache/operations/type-aliases/Operation.md) | [`Operation`](../../core-types/cache/operations/type-aliases/Operation.md)\[] #### Returns `void` #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`patch`](../../core-types/cache/interfaces/Cache.md#patch) *** ### peek() #### Call Signature ```ts peek(identifier): | null | ResourceObject; ``` Defined in: [cache.ts:491](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L491) Peek resource data from the Cache. In development, if the return value is JSON the return value will be deep-cloned and deep-frozen to prevent mutation thereby enforcing cache Immutability. This form of peek is useful for implementations that want to feed raw-data from cache to the UI or which want to interact with a blob of data directly from the presentation cache. An implementation might want to do this because de-referencing records which read from their own blob is generally safer because the record does not require retainining connections to the Store and Cache to present data on a per-field basis. This generally takes the place of `getAttr` as an API and may even take the place of `getRelationship` depending on implementation specifics, though this latter usage is less recommended due to the advantages of the Graph handling necessary entanglements and notifications for relational data. ##### Parameters ###### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### Returns | `null` | [`ResourceObject`](../../core-types/spec/json-api-raw/type-aliases/ResourceObject.md) the known resource data ##### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`peek`](../../core-types/cache/interfaces/Cache.md#peek) #### Call Signature ```ts peek(identifier): | null | ResourceDocument; ``` Defined in: [cache.ts:492](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L492) Peek resource data from the Cache. In development, if the return value is JSON the return value will be deep-cloned and deep-frozen to prevent mutation thereby enforcing cache Immutability. This form of peek is useful for implementations that want to feed raw-data from cache to the UI or which want to interact with a blob of data directly from the presentation cache. An implementation might want to do this because de-referencing records which read from their own blob is generally safer because the record does not require retainining connections to the Store and Cache to present data on a per-field basis. This generally takes the place of `getAttr` as an API and may even take the place of `getRelationship` depending on implementation specifics, though this latter usage is less recommended due to the advantages of the Graph handling necessary entanglements and notifications for relational data. ##### Parameters ###### identifier [`StableDocumentIdentifier`](../../core-types/identifier/type-aliases/StableDocumentIdentifier.md) ##### Returns | `null` | [`ResourceDocument`](../../core-types/spec/document/type-aliases/ResourceDocument.md) the known resource data ##### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`peek`](../../core-types/cache/interfaces/Cache.md#peek) *** ### peekRemoteState() #### Call Signature ```ts peekRemoteState(identifier): | null | ResourceObject; ``` Defined in: [cache.ts:551](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L551) Peek remote resource data from the Cache. This will give the data provided from the server without any local changes. In development, if the return value is JSON the return value will be deep-cloned and deep-frozen to prevent mutation thereby enforcing cache Immutability. This form of peek is useful for implementations that want to feed raw-data from cache to the UI or which want to interact with a blob of data directly from the presentation cache. An implementation might want to do this because de-referencing records which read from their own blob is generally safer because the record does not require retainining connections to the Store and Cache to present data on a per-field basis. This generally takes the place of `getAttr` as an API and may even take the place of `getRelationship` depending on implementation specifics, though this latter usage is less recommended due to the advantages of the Graph handling necessary entanglements and notifications for relational data. ##### Parameters ###### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### Returns | `null` | [`ResourceObject`](../../core-types/spec/json-api-raw/type-aliases/ResourceObject.md) the known resource data ##### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`peekRemoteState`](../../core-types/cache/interfaces/Cache.md#peekremotestate) #### Call Signature ```ts peekRemoteState(identifier): | null | ResourceDocument; ``` Defined in: [cache.ts:552](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L552) ##### Parameters ###### identifier [`StableDocumentIdentifier`](../../core-types/identifier/type-aliases/StableDocumentIdentifier.md) ##### Returns | `null` | [`ResourceDocument`](../../core-types/spec/document/type-aliases/ResourceDocument.md) ##### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`peekRemoteState`](../../core-types/cache/interfaces/Cache.md#peekremotestate) *** ### peekRequest() ```ts peekRequest(identifier): | null | StructuredDocument; ``` Defined in: [cache.ts:621](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L621) Peek the Cache for the existing request data associated with a cacheable request. This is effectively the reverse of `put` for a request in that it will return the the request, response, and content whereas `peek` will return just the `content`. #### Parameters ##### identifier [`StableDocumentIdentifier`](../../core-types/identifier/type-aliases/StableDocumentIdentifier.md) #### Returns | `null` | [`StructuredDocument`](../../core-types/request/type-aliases/StructuredDocument.md)<[`ResourceDocument`](../../core-types/spec/document/type-aliases/ResourceDocument.md)> #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`peekRequest`](../../core-types/cache/interfaces/Cache.md#peekrequest) *** ### put() #### Call Signature ```ts put(doc): SingleResourceDataDocument; ``` Defined in: [cache.ts:217](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L217) Cache the response to a request Implements `Cache.put`. Expects a StructuredDocument whose `content` member is a JsonApiDocument. ```js cache.put({ request: { url: 'https://api.example.com/v1/user/1' }, content: { data: { type: 'user', id: '1', attributes: { name: 'Chris' } } } }) ``` > **Note** > The nested `content` and `data` members are not a mistake. This is because > there are two separate concepts involved here, the `StructuredDocument` which contains > the context of a given Request that has been issued with the returned contents as its > `content` property, and a `JSON:API Document` which is the json contents returned by > this endpoint and which uses its `data` property to signify which resources are the > primary resources associated with the request. StructuredDocument's with urls will be cached as full documents with associated resource membership order and contents preserved but linked into the cache. ##### Type Parameters ###### T `T` *extends* [`SingleResourceDocument`](../../core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md) ##### Parameters ###### doc [`StructuredDataDocument`](../../core-types/request/interfaces/StructuredDataDocument.md)<`T`> ##### Returns [`SingleResourceDataDocument`](../../core-types/spec/document/interfaces/SingleResourceDataDocument.md) ##### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`put`](../../core-types/cache/interfaces/Cache.md#put) #### Call Signature ```ts put(doc): CollectionResourceDataDocument; ``` Defined in: [cache.ts:218](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L218) Cache the response to a request Implements `Cache.put`. Expects a StructuredDocument whose `content` member is a JsonApiDocument. ```js cache.put({ request: { url: 'https://api.example.com/v1/user/1' }, content: { data: { type: 'user', id: '1', attributes: { name: 'Chris' } } } }) ``` > **Note** > The nested `content` and `data` members are not a mistake. This is because > there are two separate concepts involved here, the `StructuredDocument` which contains > the context of a given Request that has been issued with the returned contents as its > `content` property, and a `JSON:API Document` which is the json contents returned by > this endpoint and which uses its `data` property to signify which resources are the > primary resources associated with the request. StructuredDocument's with urls will be cached as full documents with associated resource membership order and contents preserved but linked into the cache. ##### Type Parameters ###### T `T` *extends* [`CollectionResourceDocument`](../../core-types/spec/json-api-raw/type-aliases/CollectionResourceDocument.md) ##### Parameters ###### doc [`StructuredDataDocument`](../../core-types/request/interfaces/StructuredDataDocument.md)<`T`> ##### Returns [`CollectionResourceDataDocument`](../../core-types/spec/document/interfaces/CollectionResourceDataDocument.md) ##### Implementation of ```ts Cache.put ``` #### Call Signature ```ts put(doc): ResourceErrorDocument; ``` Defined in: [cache.ts:219](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L219) Cache the response to a request Implements `Cache.put`. Expects a StructuredDocument whose `content` member is a JsonApiDocument. ```js cache.put({ request: { url: 'https://api.example.com/v1/user/1' }, content: { data: { type: 'user', id: '1', attributes: { name: 'Chris' } } } }) ``` > **Note** > The nested `content` and `data` members are not a mistake. This is because > there are two separate concepts involved here, the `StructuredDocument` which contains > the context of a given Request that has been issued with the returned contents as its > `content` property, and a `JSON:API Document` which is the json contents returned by > this endpoint and which uses its `data` property to signify which resources are the > primary resources associated with the request. StructuredDocument's with urls will be cached as full documents with associated resource membership order and contents preserved but linked into the cache. ##### Type Parameters ###### T `T` *extends* [`ResourceErrorDocument`](../../core-types/spec/document/interfaces/ResourceErrorDocument.md) ##### Parameters ###### doc [`StructuredErrorDocument`](../../core-types/request/interfaces/StructuredErrorDocument.md)<`T`> ##### Returns [`ResourceErrorDocument`](../../core-types/spec/document/interfaces/ResourceErrorDocument.md) ##### Implementation of ```ts Cache.put ``` #### Call Signature ```ts put(doc): ResourceMetaDocument; ``` Defined in: [cache.ts:220](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L220) Cache the response to a request Implements `Cache.put`. Expects a StructuredDocument whose `content` member is a JsonApiDocument. ```js cache.put({ request: { url: 'https://api.example.com/v1/user/1' }, content: { data: { type: 'user', id: '1', attributes: { name: 'Chris' } } } }) ``` > **Note** > The nested `content` and `data` members are not a mistake. This is because > there are two separate concepts involved here, the `StructuredDocument` which contains > the context of a given Request that has been issued with the returned contents as its > `content` property, and a `JSON:API Document` which is the json contents returned by > this endpoint and which uses its `data` property to signify which resources are the > primary resources associated with the request. StructuredDocument's with urls will be cached as full documents with associated resource membership order and contents preserved but linked into the cache. ##### Type Parameters ###### T `T` *extends* [`ResourceMetaDocument`](../../core-types/spec/document/interfaces/ResourceMetaDocument.md) ##### Parameters ###### doc [`StructuredDataDocument`](../../core-types/request/interfaces/StructuredDataDocument.md)<`T`> ##### Returns [`ResourceMetaDocument`](../../core-types/spec/document/interfaces/ResourceMetaDocument.md) ##### Implementation of ```ts Cache.put ``` *** ### rollbackAttrs() ```ts rollbackAttrs(identifier): string[]; ``` Defined in: [cache.ts:1468](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L1468) Tell the cache to discard any uncommitted mutations to attributes This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `string`\[] the names of fields that were restored #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`rollbackAttrs`](../../core-types/cache/interfaces/Cache.md#rollbackattrs) *** ### rollbackRelationships() ```ts rollbackRelationships(identifier): string[]; ``` Defined in: [cache.ts:1555](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L1555) Tell the cache to discard any uncommitted mutations to relationships. This will also discard the change on any appropriate inverses. This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `string`\[] the names of relationships that were restored #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`rollbackRelationships`](../../core-types/cache/interfaces/Cache.md#rollbackrelationships) *** ### setAttr() ```ts setAttr( identifier, attr, value): void; ``` Defined in: [cache.ts:1299](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L1299) Mutate the data for an attribute in the cache This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### attr `string` | `string`\[] ##### value [`Value`](../../core-types/json/raw/type-aliases/Value.md) #### Returns `void` #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`setAttr`](../../core-types/cache/interfaces/Cache.md#setattr) *** ### setIsDeleted() ```ts setIsDeleted(identifier, isDeleted): void; ``` Defined in: [cache.ts:1596](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L1596) Update the cache state for the given resource to be marked as locally deleted, or remove such a mark. This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### isDeleted `boolean` #### Returns `void` #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`setIsDeleted`](../../core-types/cache/interfaces/Cache.md#setisdeleted) *** ### unloadRecord() ```ts unloadRecord(identifier): void; ``` Defined in: [cache.ts:1083](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L1083) \[LIFECYCLE] Signals to the cache that all data for a resource should be cleared. This method is a candidate to become a mutation #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `void` #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`unloadRecord`](../../core-types/cache/interfaces/Cache.md#unloadrecord) *** ### upsert() ```ts upsert( identifier, data, calculateChanges?): void | string[]; ``` Defined in: [cache.ts:634](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L634) Push resource data from a remote source into the cache for this identifier #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) ##### data `ExistingResourceObject` ##### calculateChanges? `boolean` #### Returns `void` | `string`\[] if `hasRecord` is true then calculated key changes should be returned #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`upsert`](../../core-types/cache/interfaces/Cache.md#upsert) *** ### willCommit() ```ts willCommit(identifier): void; ``` Defined in: [cache.ts:847](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/json-api/src/-private/cache.ts#L847) \[LIFECYCLE] Signals to the cache that a resource will be part of a save transaction. #### Parameters ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `void` #### Implementation of [`Cache`](../../core-types/cache/interfaces/Cache.md).[`willCommit`](../../core-types/cache/interfaces/Cache.md#willcommit) --- --- url: /api/@warp-drive/json-api.md --- [Documentation](../../index.md) / @warp-drive/json-api ## Classes * [JSONAPICache](classes/JSONAPICache.md) --- --- url: /api/@warp-drive/legacy/adapter/classes/Adapter.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [adapter](../index.md) / Adapter Defined in: [warp-drive-packages/legacy/src/adapter.ts:257](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L257) An adapter is an object that receives requests from a store and translates them into the appropriate action to take against your persistence layer. The persistence layer is usually an HTTP API but may be anything, such as the browser's local storage. Typically the adapter is not invoked directly instead its functionality is accessed through the `store`. > ⚠️ CAUTION you likely want the docs for [MinimumAdapterInterface](../../compat/interfaces/MinimumAdapterInterface.md) > as extending this abstract class is unnecessary. ### Creating an Adapter Create a new subclass of `Adapter` in the `app/adapters` folder: ```js [app/adapters/application.js] import { Adapter } from '@warp-drive/legacy/adapter'; export default class extends Adapter { // ...your code here } ``` Model-specific adapters can be created by putting your adapter class in an `app/adapters/` + `model-name` + `.js` file of the application. ```js [app/adapters/post.js] import { Adapter } from '@warp-drive/legacy/adapter'; export default class extends Adapter { // ...Post-specific adapter code goes here } ``` `Adapter` is an abstract base class that you should override in your application to customize it for your backend. The minimum set of methods that you should implement is: * `findRecord()` * `createRecord()` * `updateRecord()` * `deleteRecord()` * `findAll()` * `query()` To improve the network performance of your application, you can optimize your adapter by overriding these lower-level methods: * `findMany()` For an example of the implementation, see `RESTAdapter`, the included REST adapter. Adapter ## Extends * `EmberObject` ## Extended by * [`RESTAdapter`](../rest/classes/RESTAdapter.md) ## Implements * [`MinimumAdapterInterface`](../../compat/interfaces/MinimumAdapterInterface.md) ## Constructors ### Constructor ```ts new Adapter(owner?): Adapter; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/index.d.ts:31 #### Parameters ##### owner? `Owner` #### Returns `Adapter` #### Inherited from ```ts EmberObject.constructor ``` ## Properties ### \_coalesceFindRequests ```ts _coalesceFindRequests: boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:260](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L260) *** ### concatenatedProperties? ```ts optional concatenatedProperties: string | string[]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:655 #### Inherited from ```ts EmberObject.concatenatedProperties ``` *** ### mergedProperties? ```ts optional mergedProperties: unknown[]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:656 #### Inherited from ```ts EmberObject.mergedProperties ``` *** ### store ```ts store: default; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:258](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L258) *** ### \_lazyInjections()? ```ts readonly static optional _lazyInjections: () => void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:654 #### Returns `void` #### Inherited from ```ts EmberObject._lazyInjections ``` *** ### \_onLookup()? ```ts readonly static optional _onLookup: (debugContainerKey) => void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:653 #### Parameters ##### debugContainerKey `string` #### Returns `void` #### Inherited from ```ts EmberObject._onLookup ``` *** ### \[INIT\_FACTORY]? ```ts static optional [INIT_FACTORY]: null; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/mixin.d.ts:116 #### Inherited from ```ts EmberObject.[INIT_FACTORY] ``` *** ### isClass ```ts readonly static isClass: boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:651 #### Inherited from ```ts EmberObject.isClass ``` *** ### isMethod ```ts readonly static isMethod: boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:652 #### Inherited from ```ts EmberObject.isMethod ``` *** ### PrototypeMixin ```ts static PrototypeMixin: any; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:647 #### Inherited from ```ts EmberObject.PrototypeMixin ``` *** ### superclass ```ts static superclass: any; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:648 #### Inherited from ```ts EmberObject.superclass ``` ## Accessors ### \_debugContainerKey #### Get Signature ```ts get _debugContainerKey(): false | `${string}:${string}`; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/index.d.ts:34 ##### Returns `false` | `` `${string}:${string}` `` #### Inherited from ```ts EmberObject._debugContainerKey ``` *** ### coalesceFindRequests #### Get Signature ```ts get coalesceFindRequests(): boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:646](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L646) By default the store will try to coalesce all `findRecord` calls within the same runloop into as few requests as possible by calling groupRecordsForFindMany and passing it into a findMany call. You can opt out of this behaviour by either not implementing the findMany hook or by setting coalesceFindRequests to false. ##### Returns `boolean` #### Set Signature ```ts set coalesceFindRequests(value): void; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:654](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L654) **`Optional`** If your adapter implements `findMany`, setting this to `true` will cause `findRecord` requests triggered within the same `runloop` to be coalesced into one or more calls to `adapter.findMany`. The number of calls made and the records contained in each call can be tuned by your adapter's `groupRecordsForHasMany` method. Implementing coalescing using this flag and the associated methods does not always offer the right level of correctness, timing control or granularity. If your application would be better suited coalescing across multiple types, coalescing for longer than a single runloop, or with a more custom request structure, coalescing within your application adapter may prove more effective. ##### Parameters ###### value `boolean` ##### Returns `void` **`Optional`** If your adapter implements `findMany`, setting this to `true` will cause `findRecord` requests triggered within the same `runloop` to be coalesced into one or more calls to `adapter.findMany`. The number of calls made and the records contained in each call can be tuned by your adapter's `groupRecordsForHasMany` method. Implementing coalescing using this flag and the associated methods does not always offer the right level of correctness, timing control or granularity. If your application would be better suited coalescing across multiple types, coalescing for longer than a single runloop, or with a more custom request structure, coalescing within your application adapter may prove more effective. #### Implementation of [`MinimumAdapterInterface`](../../compat/interfaces/MinimumAdapterInterface.md).[`coalesceFindRequests`](../../compat/interfaces/MinimumAdapterInterface.md#coalescefindrequests) *** ### isDestroyed #### Get Signature ```ts get isDestroyed(): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:272 Destroyed object property flag. if this property is `true` the observers and bindings were already removed by the effect of calling the `destroy()` method. ##### Default ```ts false @public ``` ##### Returns `boolean` #### Set Signature ```ts set isDestroyed(_value): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:273 ##### Parameters ###### \_value `boolean` ##### Returns `void` #### Inherited from ```ts EmberObject.isDestroyed ``` *** ### isDestroying #### Get Signature ```ts get isDestroying(): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:284 Destruction scheduled flag. The `destroy()` method has been called. The object stays intact until the end of the run loop at which point the `isDestroyed` flag is set. ##### Default ```ts false @public ``` ##### Returns `boolean` #### Set Signature ```ts set isDestroying(_value): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:285 ##### Parameters ###### \_value `boolean` ##### Returns `void` #### Inherited from ```ts EmberObject.isDestroying ``` ## Methods ### addObserver() #### Call Signature ```ts addObserver( key, target, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:333 Adds an observer on a property. This is the core method used to register an observer for a property. Once you call this method, any time the key's value is set, your observer will be notified. Note that the observers are triggered any time the value is set, regardless of whether it has actually changed. Your observer should be prepared to handle that. There are two common invocation patterns for `.addObserver()`: * Passing two arguments: * the name of the property to observe (as a string) * the function to invoke (an actual function) * Passing three arguments: * the name of the property to observe (as a string) * the target object (will be used to look up and invoke a function on) * the name of the function to invoke on the target object (as a string). ```app/components/my-component.js import Component from '@ember/component'; export default Component.extend({ init() { this._super(...arguments); // the following are equivalent: // using three arguments this.addObserver('foo', this, 'fooDidChange'); // using two arguments this.addObserver('foo', (...args) => { this.fooDidChange(...args); }); }, fooDidChange() { // your custom logic code } }); ``` ### Observer Methods Observer methods have the following signature: ```app/components/my-component.js import Component from '@ember/component'; export default Component.extend({ init() { this._super(...arguments); this.addObserver('foo', this, 'fooDidChange'); }, fooDidChange(sender, key, value, rev) { // your code } }); ``` The `sender` is the object that changed. The `key` is the property that changes. The `value` property is currently reserved and unused. The `rev` is the last property revision of the object when it changed, which you can use to detect if the key value has really changed or not. Usually you will not need the value or revision parameters at the end. In this case, it is common to write observer methods that take only a sender and key value as parameters or, if you aren't interested in any of these values, to write an observer that has no parameters at all. ##### Type Parameters ###### Target `Target` ##### Parameters ###### key keyof `Adapter` The key to observe ###### target `Target` The target object to invoke ###### method `ObserverMethod`<`Target`, `Adapter`> The method to invoke ##### Returns `this` ##### Method addObserver ##### Inherited from ```ts EmberObject.addObserver ``` #### Call Signature ```ts addObserver(key, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:338 ##### Parameters ###### key keyof `Adapter` ###### method `ObserverMethod`<`Adapter`, `Adapter`> ##### Returns `this` ##### Inherited from ```ts EmberObject.addObserver ``` *** ### cacheFor() ```ts cacheFor(key): unknown; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:413 Returns the cached value of a computed property, if it exists. This allows you to inspect the value of a computed property without accidentally invoking it if it is intended to be generated lazily. #### Type Parameters ##### K `K` *extends* keyof `Adapter` #### Parameters ##### key `K` #### Returns `unknown` The cached value of the computed property, if any #### Method cacheFor #### Inherited from ```ts EmberObject.cacheFor ``` *** ### createRecord() ```ts createRecord( store, type, snapshot): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:526](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L526) Implement this method in a subclass to handle the creation of new records. Serializes the record and sends it to the server. Example ```js [app/adapters/application.js] import { Adapter } from '@warp-drive/legacy/adapter'; import RSVP from 'RSVP'; import $ from 'jquery'; export default class ApplicationAdapter extends Adapter { createRecord(store, type, snapshot) { let data = this.serialize(snapshot, { includeId: true }); return new RSVP.Promise(function (resolve, reject) { $.ajax({ type: 'POST', url: `/${type.modelName}`, dataType: 'json', data: data }).then(function (data) { resolve(data); }, function (jqXHR) { jqXHR.then = null; // tame jQuery's ill mannered promises reject(jqXHR); }); }); } } ``` #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) ##### type [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md) the Model class of the record ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../compat/type-aliases/AdapterPayload.md)> promise #### Implementation of [`MinimumAdapterInterface`](../../compat/interfaces/MinimumAdapterInterface.md).[`createRecord`](../../compat/interfaces/MinimumAdapterInterface.md#createrecord) *** ### decrementProperty() ```ts decrementProperty(keyName, decrement?): number; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:387 Set the value of a property to the current value minus some amount. ```javascript player.decrementProperty('lives'); orc.decrementProperty('health', 5); ``` #### Parameters ##### keyName keyof `Adapter` The name of the property to decrement ##### decrement? `number` The amount to decrement by. Defaults to 1 #### Returns `number` The new property value #### Method decrementProperty #### Inherited from ```ts EmberObject.decrementProperty ``` *** ### deleteRecord() ```ts deleteRecord( store, type, snapshot): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:630](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L630) Implement this method in a subclass to handle the deletion of a record. Sends a delete request for the record to the server. Example ```js [app/adapters/application.js] import { Adapter } from '@warp-drive/legacy/adapter'; import RSVP from 'RSVP'; import $ from 'jquery'; export default class ApplicationAdapter extends Adapter { deleteRecord(store, type, snapshot) { let data = this.serialize(snapshot, { includeId: true }); let id = snapshot.id; return new RSVP.Promise(function(resolve, reject) { $.ajax({ type: 'DELETE', url: `/${type.modelName}/${id}`, dataType: 'json', data: data }).then(function(data) { resolve(data) }, function(jqXHR) { jqXHR.then = null; // tame jQuery's ill mannered promises reject(jqXHR); }); }); } } ``` #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) ##### type [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md) the Model class of the record ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../compat/type-aliases/AdapterPayload.md)> promise #### Implementation of [`MinimumAdapterInterface`](../../compat/interfaces/MinimumAdapterInterface.md).[`deleteRecord`](../../compat/interfaces/MinimumAdapterInterface.md#deleterecord) *** ### destroy() ```ts destroy(): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:300 Destroys an object by setting the `isDestroyed` flag and removing its metadata, which effectively destroys observers and bindings. If you try to set a property on a destroyed object, an exception will be raised. Note that destruction is scheduled for the end of the run loop and does not happen immediately. It will set an isDestroying flag immediately. #### Returns `this` receiver #### Method destroy #### Implementation of [`MinimumAdapterInterface`](../../compat/interfaces/MinimumAdapterInterface.md).[`destroy`](../../compat/interfaces/MinimumAdapterInterface.md#destroy) #### Inherited from ```ts EmberObject.destroy ``` *** ### findAll() ```ts findAll( store, type, neverSet, snapshotRecordArray): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:333](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L333) The `findAll()` method is used to retrieve all records for a given type. Example ```js [app/adapters/application.js] import { Adapter } from '@warp-drive/legacy/adapter'; import RSVP from 'RSVP'; import $ from 'jquery'; export default class ApplicationAdapter extends Adapter { findAll(store, type) { return new RSVP.Promise(function(resolve, reject) { $.getJSON(`/${type.modelName}`).then(function(data) { resolve(data); }, function(jqXHR) { reject(jqXHR); }); }); } } ``` #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) ##### type [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md) ##### neverSet `null` a value is never provided to this argument ##### snapshotRecordArray `SnapshotRecordArray` #### Returns `Promise`<[`AdapterPayload`](../../compat/type-aliases/AdapterPayload.md)> promise #### Implementation of [`MinimumAdapterInterface`](../../compat/interfaces/MinimumAdapterInterface.md).[`findAll`](../../compat/interfaces/MinimumAdapterInterface.md#findall) *** ### findRecord() ```ts findRecord( store, type, id, snapshot): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:297](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L297) The `findRecord()` method is invoked when the store is asked for a record that has not previously been loaded. In response to `findRecord()` being called, you should query your persistence layer for a record with the given ID. The `findRecord` method should return a promise that will resolve to a JavaScript object that will be normalized by the serializer. Here is an example of the `findRecord` implementation: ```js [app/adapters/application.js] import { Adapter } from '@warp-drive/legacy/adapter'; import RSVP from 'RSVP'; import $ from 'jquery'; export default class ApplicationAdapter extends Adapter { findRecord(store, type, id, snapshot) { return new RSVP.Promise(function(resolve, reject) { $.getJSON(`/${type.modelName}/${id}`).then(function(data) { resolve(data); }, function(jqXHR) { reject(jqXHR); }); }); } } ``` #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) ##### type [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md) ##### id `string` ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../compat/type-aliases/AdapterPayload.md)> promise #### Implementation of [`MinimumAdapterInterface`](../../compat/interfaces/MinimumAdapterInterface.md).[`findRecord`](../../compat/interfaces/MinimumAdapterInterface.md#findrecord) *** ### get() #### Call Signature ```ts get(key): Adapter[K]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:121 Retrieves the value of a property from the object. This method is usually similar to using `object[keyName]` or `object.keyName`, however it supports both computed properties and the unknownProperty handler. Because `get` unifies the syntax for accessing all these kinds of properties, it can make many refactorings easier, such as replacing a simple property with a computed property, or vice versa. ### Computed Properties Computed properties are methods defined with the `property` modifier declared at the end, such as: ```javascript import { computed } from '@ember/object'; fullName: computed('firstName', 'lastName', function() { return this.get('firstName') + ' ' + this.get('lastName'); }) ``` When you call `get` on a computed property, the function will be called and the return value will be returned instead of the function itself. ### Unknown Properties Likewise, if you try to call `get` on a property whose value is `undefined`, the `unknownProperty()` method will be called on the object. If this method returns any value other than `undefined`, it will be returned instead. This allows you to implement "virtual" properties that are not defined upfront. ##### Type Parameters ###### K `K` *extends* keyof `Adapter` ##### Parameters ###### key `K` ##### Returns `Adapter`\[`K`] The property value or undefined. ##### Method get ##### Inherited from ```ts EmberObject.get ``` #### Call Signature ```ts get(key): unknown; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:122 ##### Parameters ###### key `string` ##### Returns `unknown` ##### Inherited from ```ts EmberObject.get ``` *** ### getProperties() #### Call Signature ```ts getProperties(list): { [Key in keyof Adapter]: Adapter[Key] }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:144 To get the values of multiple properties at once, call `getProperties` with a list of strings or an array: ```javascript record.getProperties('firstName', 'lastName', 'zipCode'); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } ``` is equivalent to: ```javascript record.getProperties(['firstName', 'lastName', 'zipCode']); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } ``` ##### Type Parameters ###### L `L` *extends* keyof `Adapter`\[] ##### Parameters ###### list `L` of keys to get ##### Returns `{ [Key in keyof Adapter]: Adapter[Key] }` ##### Method getProperties ##### Inherited from ```ts EmberObject.getProperties ``` #### Call Signature ```ts getProperties(...list): { [Key in keyof Adapter]: Adapter[Key] }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:149 ##### Type Parameters ###### L `L` *extends* keyof `Adapter`\[] ##### Parameters ###### list ...`L` ##### Returns `{ [Key in keyof Adapter]: Adapter[Key] }` ##### Inherited from ```ts EmberObject.getProperties ``` #### Call Signature ```ts getProperties(list): { [Key in string]: unknown }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:154 ##### Type Parameters ###### L `L` *extends* `string`\[] ##### Parameters ###### list `L` ##### Returns `{ [Key in string]: unknown }` ##### Inherited from ```ts EmberObject.getProperties ``` #### Call Signature ```ts getProperties(...list): { [Key in string]: unknown }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:159 ##### Type Parameters ###### L `L` *extends* `string`\[] ##### Parameters ###### list ...`L` ##### Returns `{ [Key in string]: unknown }` ##### Inherited from ```ts EmberObject.getProperties ``` *** ### groupRecordsForFindMany() ```ts groupRecordsForFindMany(store, snapshots): Snapshot[][]; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:710](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L710) Organize records into groups, each of which is to be passed to separate calls to `findMany`. For example, if your API has nested URLs that depend on the parent, you will want to group records by their parent. The default implementation returns the records as a single group. #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) ##### snapshots `Snapshot`<`unknown`>\[] #### Returns `Snapshot`<`unknown`>\[]\[] an array of arrays of records, each of which is to be loaded separately by `findMany`. #### Implementation of [`MinimumAdapterInterface`](../../compat/interfaces/MinimumAdapterInterface.md).[`groupRecordsForFindMany`](../../compat/interfaces/MinimumAdapterInterface.md#grouprecordsforfindmany) *** ### incrementProperty() ```ts incrementProperty(keyName, increment?): number; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:372 Set the value of a property to the current value plus some amount. ```javascript person.incrementProperty('age'); team.incrementProperty('score', 2); ``` #### Parameters ##### keyName keyof `Adapter` The name of the property to increment ##### increment? `number` The amount to increment by. Defaults to 1 #### Returns `number` The new property value #### Method incrementProperty #### Inherited from ```ts EmberObject.incrementProperty ``` *** ### init() ```ts init(_properties): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:114 An overridable method called when objects are instantiated. By default, does nothing unless it is overridden during class definition. Example: ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ init() { alert(`Name is ${this.get('name')}`); } }); let steve = Person.create({ name: 'Steve' }); // alerts 'Name is Steve'. ``` NOTE: If you do override `init` for a framework class like `Component` from `@ember/component`, be sure to call `this._super(...arguments)` in your `init` declaration! If you don't, Ember may not have an opportunity to do important setup work, and you'll see strange behavior in your application. #### Parameters ##### \_properties `undefined` | `object` #### Returns `void` #### Method init #### Inherited from ```ts EmberObject.init ``` *** ### notifyPropertyChange() ```ts notifyPropertyChange(keyName): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:249 Convenience method to call `propertyWillChange` and `propertyDidChange` in succession. Notify the observer system that a property has just changed. Sometimes you need to change a value directly or indirectly without actually calling `get()` or `set()` on it. In this case, you can use this method instead. Calling this method will notify all observers that the property has potentially changed value. #### Parameters ##### keyName `string` The property key to be notified about. #### Returns `this` #### Method notifyPropertyChange #### Inherited from ```ts EmberObject.notifyPropertyChange ``` *** ### query() ```ts query( store, type, query): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:377](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L377) This method is called when you call `query` on the store. Example ```js [app/adapters/application.js] import { Adapter } from '@warp-drive/legacy/adapter'; import RSVP from 'RSVP'; import $ from 'jquery'; export default class ApplicationAdapter extends Adapter { query(store, type, query) { return new RSVP.Promise(function(resolve, reject) { $.getJSON(`/${type.modelName}`, query).then(function(data) { resolve(data); }, function(jqXHR) { reject(jqXHR); }); }); } } ``` #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) ##### type [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md) ##### query `any` #### Returns `Promise`<[`AdapterPayload`](../../compat/type-aliases/AdapterPayload.md)> promise #### Implementation of [`MinimumAdapterInterface`](../../compat/interfaces/MinimumAdapterInterface.md).[`query`](../../compat/interfaces/MinimumAdapterInterface.md#query) *** ### queryRecord() ```ts queryRecord( store, type, query, adapterOptions): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:414](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L414) The `queryRecord()` method is invoked when the store is asked for a single record through a query object. In response to `queryRecord()` being called, you should always fetch fresh data. Once found, you can asynchronously call the store's `push()` method to push the record into the store. Here is an example `queryRecord` implementation: Example ```js [app/adapters/application.js] import { Adapter, BuildURLMixin } from '@warp-drive/legacy/adapter'; export default class ApplicationAdapter extends Adapter.extend(BuildURLMixin) { queryRecord(store, type, query) { return fetch(`/${type.modelName}`, { body: JSON.stringify(query) }) .then((response) => response.json()); } } ``` #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) ##### type [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md) ##### query `any` ##### adapterOptions `any` #### Returns `Promise`<[`AdapterPayload`](../../compat/type-aliases/AdapterPayload.md)> promise #### Implementation of [`MinimumAdapterInterface`](../../compat/interfaces/MinimumAdapterInterface.md).[`queryRecord`](../../compat/interfaces/MinimumAdapterInterface.md#queryrecord) *** ### removeObserver() #### Call Signature ```ts removeObserver( key, target, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:352 Remove an observer you have previously registered on this object. Pass the same key, target, and method you passed to `addObserver()` and your target will no longer receive notifications. ##### Type Parameters ###### Target `Target` ##### Parameters ###### key keyof `Adapter` The key to observe ###### target `Target` The target object to invoke ###### method `ObserverMethod`<`Target`, `Adapter`> The method to invoke ##### Returns `this` ##### Method removeObserver ##### Inherited from ```ts EmberObject.removeObserver ``` #### Call Signature ```ts removeObserver(key, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:357 ##### Parameters ###### key keyof `Adapter` ###### method `ObserverMethod`<`Adapter`, `Adapter`> ##### Returns `this` ##### Inherited from ```ts EmberObject.removeObserver ``` *** ### reopen() ```ts reopen(...args): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:81 #### Parameters ##### args ...(`Record`<`string`, `unknown`> | `Mixin`)\[] #### Returns `this` #### Inherited from ```ts EmberObject.reopen ``` *** ### serialize() ```ts serialize(snapshot, options): Record; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:476](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L476) Proxies to the serializer's `serialize` method. Example ```js [app/adapters/application.js] import { Adapter } from '@warp-drive/legacy/adapter'; export default class ApplicationAdapter extends Adapter { createRecord(store, type, snapshot) { let data = this.serialize(snapshot, { includeId: true }); let url = `/${type.modelName}`; // ... } } ``` #### Parameters ##### snapshot `Snapshot` ##### options [`SerializerOptions`](../../compat/type-aliases/SerializerOptions.md) #### Returns `Record`<`string`, `unknown`> serialized snapshot *** ### set() #### Call Signature ```ts set(key, value): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:208 Sets the provided key or path to the value. ```javascript record.set("key", value); ``` This method is generally very similar to calling `object["key"] = value` or `object.key = value`, except that it provides support for computed properties, the `setUnknownProperty()` method and property observers. ### Computed Properties If you try to set a value on a key that has a computed property handler defined (see the `get()` method for an example), then `set()` will call that method, passing both the value and key instead of simply changing the value itself. This is useful for those times when you need to implement a property that is composed of one or more member properties. ### Unknown Properties If you try to set a value on a key that is undefined in the target object, then the `setUnknownProperty()` handler will be called instead. This gives you an opportunity to implement complex "virtual" properties that are not predefined on the object. If `setUnknownProperty()` returns undefined, then `set()` will simply set the value on the object. ### Property Observers In addition to changing the property, `set()` will also register a property change with the object. Unless you have placed this call inside of a `beginPropertyChanges()` and `endPropertyChanges(),` any "local" observers (i.e. observer methods declared on the same object), will be called immediately. Any "remote" observers (i.e. observer methods declared on another object) will be placed in a queue and called at a later time in a coalesced manner. ##### Type Parameters ###### K `K` *extends* keyof `Adapter` ###### T `T` *extends* | `undefined` | `string` | `boolean` | `unknown`\[] | [`default`](../../../../@ember-data/store/index/classes/default.md) | `string`\[] | `Owner` | (`store`, `type`, `id`, `snapshot`) => `Promise`<[`AdapterPayload`](../../compat/type-aliases/AdapterPayload.md)> | (`store`, `type`, `neverSet`, `snapshotRecordArray`) => `Promise`<[`AdapterPayload`](../../compat/type-aliases/AdapterPayload.md)> | (`store`, `type`, `query`) => `Promise`<[`AdapterPayload`](../../compat/type-aliases/AdapterPayload.md)> | (`store`, `type`, `query`, `adapterOptions`) => `Promise`<[`AdapterPayload`](../../compat/type-aliases/AdapterPayload.md)> | (`store`, `type`, `snapshot`) => `Promise`<[`AdapterPayload`](../../compat/type-aliases/AdapterPayload.md)> | (`store`, `type`, `snapshot`) => `Promise`<[`AdapterPayload`](../../compat/type-aliases/AdapterPayload.md)> | (`store`, `type`, `snapshot`) => `Promise`<[`AdapterPayload`](../../compat/type-aliases/AdapterPayload.md)> | (`store`, `snapshots`) => `Snapshot`<`unknown`>\[]\[] | (`store`, `snapshot`) => `boolean` | (`store`, `snapshotRecordArray`) => `boolean` | (`store`, `snapshot`) => `boolean` | (`store`, `snapshotRecordArray`) => `boolean` | () => `string` | { } | () => `void` | (...`args`) => `this` | (`_properties`) => `void` | () => `this` | { <`K`> (`key`): `Adapter`\[`K`]; (`key`): `unknown`; } | { <`L`> (`list`): `{ [Key in keyof Adapter]: Adapter[Key] }`; <`L`> (...`list`): `{ [Key in keyof Adapter]: Adapter[Key] }`; <`L`> (`list`): `{ [Key in string]: unknown }`; <`L`> (...`list`): `{ [Key in string]: unknown }`; } | { <`K`, `T`> (`key`, `value`): `T`; <`T`> (`key`, `value`): `T`; } | { <`K`, `P`> (`hash`): `P`; <`T`> (`hash`): `T`; } | (`keyName`) => `this` | { <`Target`> (`key`, `target`, `method`): `this`; (`key`, `method`): `this`; } | { <`Target`> (`key`, `target`, `method`): `this`; (`key`, `method`): `this`; } | (`keyName`, `increment?`) => `number` | (`keyName`, `decrement?`) => `number` | (`keyName`) => `boolean` | <`K`>(`key`) => `unknown` | (`snapshot`, `options`) => `Record`<`string`, `unknown`> ##### Parameters ###### key `K` ###### value `T` The value to set or `null`. ##### Returns `T` The passed value ##### Method set ##### Inherited from ```ts EmberObject.set ``` #### Call Signature ```ts set(key, value): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:209 ##### Type Parameters ###### T `T` ##### Parameters ###### key `string` ###### value `T` ##### Returns `T` ##### Inherited from ```ts EmberObject.set ``` *** ### setProperties() #### Call Signature ```ts setProperties(hash): P; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:224 Sets a list of properties at once. These properties are set inside a single `beginPropertyChanges` and `endPropertyChanges` batch, so observers will be buffered. ```javascript record.setProperties({ firstName: 'Charles', lastName: 'Jolley' }); ``` ##### Type Parameters ###### K `K` *extends* keyof `Adapter` ###### P `P` *extends* `{ [Key in keyof Adapter]: Adapter[Key] }` ##### Parameters ###### hash `P` the hash of keys and values to set ##### Returns `P` The passed in hash ##### Method setProperties ##### Inherited from ```ts EmberObject.setProperties ``` #### Call Signature ```ts setProperties(hash): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:232 ##### Type Parameters ###### T `T` *extends* `Record`<`string`, `unknown`> ##### Parameters ###### hash `T` ##### Returns `T` ##### Inherited from ```ts EmberObject.setProperties ``` *** ### shouldBackgroundReloadAll() ```ts shouldBackgroundReloadAll(store, snapshotRecordArray): boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:887](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L887) This method is used by the store to determine if the store should reload a record array after the `store.findAll` method resolves with a cached record array. This method is *only* checked by the store when the store is returning a cached record array. If this method returns `true` the store will re-fetch all records from the adapter. For example, if you do not want to fetch complex data over a mobile connection, or if the network is down, you can implement `shouldBackgroundReloadAll` as follows: ```javascript shouldBackgroundReloadAll(store, snapshotArray) { let { downlink, effectiveType } = navigator.connection; return downlink > 0 && effectiveType === '4g'; } ``` By default this method returns `true`, indicating that a background reload should always be triggered. #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) ##### snapshotRecordArray `SnapshotRecordArray` #### Returns `boolean` #### Since 1.13.0 #### Implementation of [`MinimumAdapterInterface`](../../compat/interfaces/MinimumAdapterInterface.md).[`shouldBackgroundReloadAll`](../../compat/interfaces/MinimumAdapterInterface.md#shouldbackgroundreloadall) *** ### shouldBackgroundReloadRecord() ```ts shouldBackgroundReloadRecord(store, snapshot): boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:851](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L851) This method is used by the store to determine if the store should reload a record after the `store.findRecord` method resolves a cached record. This method is *only* checked by the store when the store is returning a cached record. If this method returns `true` the store will re-fetch a record from the adapter. For example, if you do not want to fetch complex data over a mobile connection, or if the network is down, you can implement `shouldBackgroundReloadRecord` as follows: ```javascript shouldBackgroundReloadRecord(store, snapshot) { let { downlink, effectiveType } = navigator.connection; return downlink > 0 && effectiveType === '4g'; } ``` By default, this hook returns `true` so the data for the record is updated in the background. #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) ##### snapshot `Snapshot` #### Returns `boolean` #### Since 1.13.0 #### Implementation of [`MinimumAdapterInterface`](../../compat/interfaces/MinimumAdapterInterface.md).[`shouldBackgroundReloadRecord`](../../compat/interfaces/MinimumAdapterInterface.md#shouldbackgroundreloadrecord) *** ### shouldReloadAll() ```ts shouldReloadAll(store, snapshotRecordArray): boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:815](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L815) This method is used by the store to determine if the store should reload all records from the adapter when records are requested by `store.findAll`. If this method returns `true`, the store will re-fetch all records from the adapter. If this method returns `false`, the store will resolve immediately using the cached records. For example, if you are building an events ticketing system, in which users can only reserve tickets for 20 minutes at a time, and want to ensure that in each route you have data that is no more than 20 minutes old you could write: ```javascript shouldReloadAll(store, snapshotArray) { let snapshots = snapshotArray.snapshots(); return snapshots.any((ticketSnapshot) => { let lastAccessedAt = ticketSnapshot.attr('lastAccessedAt'); let timeDiff = moment().diff(lastAccessedAt, 'minutes'); if (timeDiff > 20) { return true; } else { return false; } }); } ``` This method would ensure that whenever you do `store.findAll('ticket')` you will always get a list of tickets that are no more than 20 minutes old. In case a cached version is more than 20 minutes old, `findAll` will not resolve until you fetched the latest versions. By default, this method returns `true` if the passed `snapshotRecordArray` is empty (meaning that there are no records locally available yet), otherwise, it returns `false`. Note that, with default settings, `shouldBackgroundReloadAll` will always re-fetch all the records in the background even if `shouldReloadAll` returns `false`. You can override `shouldBackgroundReloadAll` if this does not suit your use case. #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) ##### snapshotRecordArray `SnapshotRecordArray` #### Returns `boolean` #### Since 1.13.0 #### Implementation of [`MinimumAdapterInterface`](../../compat/interfaces/MinimumAdapterInterface.md).[`shouldReloadAll`](../../compat/interfaces/MinimumAdapterInterface.md#shouldreloadall) *** ### shouldReloadRecord() ```ts shouldReloadRecord(store, snapshot): boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:760](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L760) This method is used by the store to determine if the store should reload a record from the adapter when a record is requested by `store.findRecord`. If this method returns `true`, the store will re-fetch a record from the adapter. If this method returns `false`, the store will resolve immediately using the cached record. For example, if you are building an events ticketing system, in which users can only reserve tickets for 20 minutes at a time, and want to ensure that in each route you have data that is no more than 20 minutes old you could write: ```javascript shouldReloadRecord(store, ticketSnapshot) { let lastAccessedAt = ticketSnapshot.attr('lastAccessedAt'); let timeDiff = moment().diff(lastAccessedAt, 'minutes'); if (timeDiff > 20) { return true; } else { return false; } } ``` This method would ensure that whenever you do `store.findRecord('ticket', id)` you will always get a ticket that is no more than 20 minutes old. In case the cached version is more than 20 minutes old, `findRecord` will not resolve until you fetched the latest version. By default this hook returns `false`, as most UIs should not block user interactions while waiting on data update. Note that, with default settings, `shouldBackgroundReloadRecord` will always re-fetch the records in the background even if `shouldReloadRecord` returns `false`. You can override `shouldBackgroundReloadRecord` if this does not suit your use case. #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) ##### snapshot `Snapshot` #### Returns `boolean` #### Since 1.13.0 #### Implementation of [`MinimumAdapterInterface`](../../compat/interfaces/MinimumAdapterInterface.md).[`shouldReloadRecord`](../../compat/interfaces/MinimumAdapterInterface.md#shouldreloadrecord) *** ### toggleProperty() ```ts toggleProperty(keyName): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:401 Set the value of a boolean property to the opposite of its current value. ```javascript starship.toggleProperty('warpDriveEngaged'); ``` #### Parameters ##### keyName keyof `Adapter` The name of the property to toggle #### Returns `boolean` The new property value #### Method toggleProperty #### Inherited from ```ts EmberObject.toggleProperty ``` *** ### toString() ```ts toString(): string; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:347 Returns a string representation which attempts to provide more information than Javascript's `toString` typically does, in a generic way for all Ember objects. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend(); person = Person.create(); person.toString(); //=> "" ``` If the object's class is not defined on an Ember namespace, it will indicate it is a subclass of the registered superclass: ```javascript const Student = Person.extend(); let student = Student.create(); student.toString(); //=> "<(subclass of Person):ember1025>" ``` If the method `toStringExtension` is defined, its return value will be included in the output. ```javascript const Teacher = Person.extend({ toStringExtension() { return this.get('fullName'); } }); teacher = Teacher.create(); teacher.toString(); //=> "" ``` #### Returns `string` string representation #### Method toString #### Inherited from ```ts EmberObject.toString ``` *** ### updateRecord() ```ts updateRecord( store, type, snapshot): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:582](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L582) Implement this method in a subclass to handle the updating of a record. Serializes the record update and sends it to the server. The updateRecord method is expected to return a promise that will resolve with the serialized record. This allows the backend to inform the Ember Data store the current state of this record after the update. If it is not possible to return a serialized record the updateRecord promise can also resolve with `undefined` and the Ember Data store will assume all of the updates were successfully applied on the backend. Example ```js [app/adapters/application.js] import { Adapter } from '@warp-drive/legacy/adapter'; import RSVP from 'RSVP'; import $ from 'jquery'; export default class ApplicationAdapter extends Adapter { updateRecord(store, type, snapshot) { let data = this.serialize(snapshot, { includeId: true }); let id = snapshot.id; return new RSVP.Promise(function(resolve, reject) { $.ajax({ type: 'PUT', url: `/${type.modelName}/${id}`, dataType: 'json', data: data }).then(function(data) { resolve(data); }, function(jqXHR) { jqXHR.then = null; // tame jQuery's ill mannered promises reject(jqXHR); }); }); } } ``` #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) ##### type [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md) the Model class of the record ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../compat/type-aliases/AdapterPayload.md)> promise #### Implementation of [`MinimumAdapterInterface`](../../compat/interfaces/MinimumAdapterInterface.md).[`updateRecord`](../../compat/interfaces/MinimumAdapterInterface.md#updaterecord) *** ### willDestroy() ```ts willDestroy(): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:307 Override to implement teardown. #### Returns `void` #### Method willDestroy #### Inherited from ```ts EmberObject.willDestroy ``` *** ### create() #### Call Signature ```ts readonly static create(this): InstanceType; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:487 Creates an instance of a class. Accepts either no arguments, or an object containing values to initialize the newly instantiated object with. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ helloWorld() { alert(`Hi, my name is ${this.get('name')}`); } }); let tom = Person.create({ name: 'Tom Dale' }); tom.helloWorld(); // alerts "Hi, my name is Tom Dale". ``` `create` will call the `init` function if defined during `AnyObject.extend` If no arguments are passed to `create`, it will not set values to the new instance during initialization: ```javascript let noName = Person.create(); noName.helloWorld(); // alerts undefined ``` NOTE: For performance reasons, you cannot declare methods or computed properties during `create`. You should instead declare methods and computed properties when using `extend`. ##### Type Parameters ###### C `C` *extends* *typeof* `CoreObject` ##### Parameters ###### this `C` ##### Returns `InstanceType`<`C`> ##### Method create ##### For @ember/object ##### Static ##### Inherited from ```ts EmberObject.create ``` #### Call Signature ```ts readonly static create(this, ...args): InstanceType & MergeArray; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:488 Creates an instance of a class. Accepts either no arguments, or an object containing values to initialize the newly instantiated object with. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ helloWorld() { alert(`Hi, my name is ${this.get('name')}`); } }); let tom = Person.create({ name: 'Tom Dale' }); tom.helloWorld(); // alerts "Hi, my name is Tom Dale". ``` `create` will call the `init` function if defined during `AnyObject.extend` If no arguments are passed to `create`, it will not set values to the new instance during initialization: ```javascript let noName = Person.create(); noName.helloWorld(); // alerts undefined ``` NOTE: For performance reasons, you cannot declare methods or computed properties during `create`. You should instead declare methods and computed properties when using `extend`. ##### Type Parameters ###### C `C` *extends* *typeof* `CoreObject` ###### I `I` *extends* `CoreObject` ###### K `K` *extends* `string` | `number` | `symbol` ###### Args `Args` *extends* `Partial`<{ \[Key in string | number | symbol]: I\[Key] }>\[] ##### Parameters ###### this `C` ###### args ...`Args` ##### Returns `InstanceType`<`C`> & `MergeArray`<`Args`> ##### Method create ##### For @ember/object ##### Static ##### Inherited from ```ts EmberObject.create ``` *** ### detectInstance() ```ts readonly static detectInstance(obj): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:600 #### Parameters ##### obj `unknown` #### Returns `boolean` #### Inherited from ```ts EmberObject.detectInstance ``` *** ### extend() ```ts readonly static extend(this, ...mixins?): Readonly & EmberClassConstructor & MergeArray; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:442 Creates a new subclass. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ say(thing) { alert(thing); } }); ``` This defines a new subclass of EmberObject: `Person`. It contains one method: `say()`. You can also create a subclass from any existing class by calling its `extend()` method. For example, you might want to create a subclass of Ember's built-in `Component` class: ```javascript import Component from '@ember/component'; const PersonComponent = Component.extend({ tagName: 'li', classNameBindings: ['isAdministrator'] }); ``` When defining a subclass, you can override methods but still access the implementation of your parent class by calling the special `_super()` method: ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ say(thing) { let name = this.get('name'); alert(`${name} says: ${thing}`); } }); const Soldier = Person.extend({ say(thing) { this._super(`${thing}, sir!`); }, march(numberOfHours) { alert(`${this.get('name')} marches for ${numberOfHours} hours.`); } }); let yehuda = Soldier.create({ name: 'Yehuda Katz' }); yehuda.say('Yes'); // alerts "Yehuda Katz says: Yes, sir!" ``` The `create()` on line #17 creates an *instance* of the `Soldier` class. The `extend()` on line #8 creates a *subclass* of `Person`. Any instance of the `Person` class will *not* have the `march()` method. You can also pass `Mixin` classes to add additional properties to the subclass. ```javascript import EmberObject from '@ember/object'; import Mixin from '@ember/object/mixin'; const Person = EmberObject.extend({ say(thing) { alert(`${this.get('name')} says: ${thing}`); } }); const SingingMixin = Mixin.create({ sing(thing) { alert(`${this.get('name')} sings: la la la ${thing}`); } }); const BroadwayStar = Person.extend(SingingMixin, { dance() { alert(`${this.get('name')} dances: tap tap tap tap `); } }); ``` The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. #### Type Parameters ##### Statics `Statics` ##### Instance `Instance` ##### M `M` *extends* `unknown`\[] #### Parameters ##### this `Statics` & `EmberClassConstructor`<`Instance`> ##### mixins? ...`M` One or more Mixin classes #### Returns `Readonly`<`Statics`> & `EmberClassConstructor`<`Instance`> & `MergeArray`<`M`> #### Method extend #### Static #### For @ember/object #### Inherited from ```ts EmberObject.extend ``` *** ### proto() ```ts readonly static proto(): CoreObject; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:649 #### Returns `CoreObject` #### Inherited from ```ts EmberObject.proto ``` *** ### reopenClass() ```ts readonly static reopenClass(this, ...mixins): C; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:595 Augments a constructor's own properties and functions: ```javascript import EmberObject from '@ember/object'; const MyObject = EmberObject.extend({ name: 'an object' }); MyObject.reopenClass({ canBuild: false }); MyObject.canBuild; // false o = MyObject.create(); ``` In other words, this creates static properties and functions for the class. These are only available on the class and not on any instance of that class. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ name: '', sayHello() { alert(`Hello. My name is ${this.get('name')}`); } }); Person.reopenClass({ species: 'Homo sapiens', createPerson(name) { return Person.create({ name }); } }); let tom = Person.create({ name: 'Tom Dale' }); let yehuda = Person.createPerson('Yehuda Katz'); tom.sayHello(); // "Hello. My name is Tom Dale" yehuda.sayHello(); // "Hello. My name is Yehuda Katz" alert(Person.species); // "Homo sapiens" ``` Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` variables. They are only valid on `Person`. To add functions and properties to instances of a constructor by extending the constructor's prototype see `reopen` #### Type Parameters ##### C `C` *extends* *typeof* `CoreObject` #### Parameters ##### this `C` ##### mixins ...(`Record`<`string`, `unknown`> | `Mixin`)\[] #### Returns `C` #### Method reopenClass #### For @ember/object #### Static #### Inherited from ```ts EmberObject.reopenClass ``` *** ### toString() ```ts static toString(): string; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:650 #### Returns `string` #### Inherited from ```ts EmberObject.toString ``` *** ### willReopen() ```ts readonly static willReopen(): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:533 #### Returns `void` #### Inherited from ```ts EmberObject.willReopen ``` --- --- url: /api/@warp-drive/legacy/adapter/error/classes/AbortError-1.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/error](../index.md) / AbortError Defined in: [warp-drive-packages/legacy/src/adapter/error.js:221](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L221) A `AbortError` is used by an adapter to signal that a request to the external API was aborted. For example, this can occur if the user navigates away from the current page after a request to the external API has been initiated but before a response has been received. AbortError ## Properties ### code ```ts code: string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:222](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L222) --- --- url: /api/@warp-drive/legacy/adapter/error/classes/AbortError.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/error](../index.md) / AbortError Defined in: [warp-drive-packages/legacy/src/adapter/error.js:221](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L221) A `AbortError` is used by an adapter to signal that a request to the external API was aborted. For example, this can occur if the user navigates away from the current page after a request to the external API has been initiated but before a response has been received. AbortError ```ts class AbortError(errors, message): void; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:221](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L221) A `AbortError` is used by an adapter to signal that a request to the external API was aborted. For example, this can occur if the user navigates away from the current page after a request to the external API has been initiated but before a response has been received. AbortError ## Parameters ### errors `any` ### message `any` ## Returns `void` ## Properties ### extend() ```ts static extend: (__namedParameters) => { (errors, message): void; extend: ({ message: defaultMessage }?: {}) => { (errors: any, message: any): void; prototype: any; extend: any; }; prototype: any; }; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:110](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L110) #### Parameters ##### \_\_namedParameters #### Returns ```ts (errors, message): void; ``` ##### Parameters ###### errors `any` ###### message `any` ##### Returns `void` ##### extend ```ts extend: ({ message: defaultMessage }?: {}) => { (errors: any, message: any): void; prototype: any; extend: any; }; ``` ##### prototype ```ts prototype: any; ``` --- --- url: /api/@warp-drive/legacy/adapter/error/classes/ConflictError.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/error](../index.md) / ConflictError Defined in: [warp-drive-packages/legacy/src/adapter/error.js:323](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L323) A `ConflictError` equates to a HTTP `409 Conflict` response status. It is used by an adapter to indicate that the request could not be processed because of a conflict in the request. An example scenario would be when creating a record with a client-generated ID but that ID is already known to the external API. ConflictError ```ts class ConflictError(errors, message): void; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:323](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L323) A `ConflictError` equates to a HTTP `409 Conflict` response status. It is used by an adapter to indicate that the request could not be processed because of a conflict in the request. An example scenario would be when creating a record with a client-generated ID but that ID is already known to the external API. ConflictError ## Parameters ### errors `any` ### message `any` ## Returns `void` ## Properties ### extend() ```ts static extend: (__namedParameters) => { (errors, message): void; extend: ({ message: defaultMessage }?: {}) => { (errors: any, message: any): void; prototype: any; extend: any; }; prototype: any; }; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:110](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L110) #### Parameters ##### \_\_namedParameters #### Returns ```ts (errors, message): void; ``` ##### Parameters ###### errors `any` ###### message `any` ##### Returns `void` ##### extend ```ts extend: ({ message: defaultMessage }?: {}) => { (errors: any, message: any): void; prototype: any; extend: any; }; ``` ##### prototype ```ts prototype: any; ``` --- --- url: /api/@warp-drive/legacy/adapter/error/classes/ConflictError-1.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/error](../index.md) / ConflictError Defined in: [warp-drive-packages/legacy/src/adapter/error.js:323](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L323) A `ConflictError` equates to a HTTP `409 Conflict` response status. It is used by an adapter to indicate that the request could not be processed because of a conflict in the request. An example scenario would be when creating a record with a client-generated ID but that ID is already known to the external API. ConflictError ## Properties ### code ```ts code: string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:327](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L327) --- --- url: /api/@warp-drive/legacy/adapter/error/classes/ForbiddenError.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/error](../index.md) / ForbiddenError Defined in: [warp-drive-packages/legacy/src/adapter/error.js:269](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L269) A `ForbiddenError` equates to a HTTP `403 Forbidden` response status. It is used by an adapter to signal that a request to the external API was valid but the server is refusing to respond to it. If authorization was provided and is valid, then the authenticated user does not have the necessary permissions for the request. ForbiddenError ```ts class ForbiddenError(errors, message): void; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:269](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L269) A `ForbiddenError` equates to a HTTP `403 Forbidden` response status. It is used by an adapter to signal that a request to the external API was valid but the server is refusing to respond to it. If authorization was provided and is valid, then the authenticated user does not have the necessary permissions for the request. ForbiddenError ## Parameters ### errors `any` ### message `any` ## Returns `void` ## Properties ### extend() ```ts static extend: (__namedParameters) => { (errors, message): void; extend: ({ message: defaultMessage }?: {}) => { (errors: any, message: any): void; prototype: any; extend: any; }; prototype: any; }; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:110](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L110) #### Parameters ##### \_\_namedParameters #### Returns ```ts (errors, message): void; ``` ##### Parameters ###### errors `any` ###### message `any` ##### Returns `void` ##### extend ```ts extend: ({ message: defaultMessage }?: {}) => { (errors: any, message: any): void; prototype: any; extend: any; }; ``` ##### prototype ```ts prototype: any; ``` --- --- url: /api/@warp-drive/legacy/adapter/error/classes/ForbiddenError-1.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/error](../index.md) / ForbiddenError Defined in: [warp-drive-packages/legacy/src/adapter/error.js:269](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L269) A `ForbiddenError` equates to a HTTP `403 Forbidden` response status. It is used by an adapter to signal that a request to the external API was valid but the server is refusing to respond to it. If authorization was provided and is valid, then the authenticated user does not have the necessary permissions for the request. ForbiddenError ## Properties ### code ```ts code: string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:273](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L273) --- --- url: /api/@warp-drive/legacy/adapter/error/classes/InvalidError-1.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/error](../index.md) / InvalidError Defined in: [warp-drive-packages/legacy/src/adapter/error.js:175](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L175) A `InvalidError` is used by an adapter to signal the external API was unable to process a request because the content was not semantically correct or meaningful per the API. Usually, this means a record failed some form of server-side validation. When a promise from an adapter is rejected with a `InvalidError` the record will transition to the `invalid` state and the errors will be set to the `errors` property on the record. For Ember Data to correctly map errors to their corresponding properties on the model, Ember Data expects each error to be a valid JSON-API error object with a `source/pointer` that matches the property name. For example, if you had a Post model that looked like this. ```js [app/models/post.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @attr('string') title; @attr('string') content; } ``` To show an error from the server related to the `title` and `content` properties your adapter could return a promise that rejects with a `InvalidError` object that looks like this: ```js [app/adapters/post.js] import RSVP from 'RSVP'; import RESTAdapter from '@ember-data/adapter/rest'; import { InvalidError } from '@ember-data/adapter/error'; export default class ApplicationAdapter extends RESTAdapter { updateRecord() { // Fictional adapter that always rejects return RSVP.reject(new InvalidError([ { detail: 'Must be unique', source: { pointer: '/data/attributes/title' } }, { detail: 'Must not be blank', source: { pointer: '/data/attributes/content'} } ])); } } ``` Your backend may use different property names for your records the store will attempt to extract and normalize the errors using the serializer's `extractErrors` method before the errors get added to the model. As a result, it is safe for the `InvalidError` to wrap the error payload unaltered. InvalidError ## Properties ### code ```ts code: string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:179](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L179) --- --- url: /api/@warp-drive/legacy/adapter/error/classes/InvalidError.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/error](../index.md) / InvalidError Defined in: [warp-drive-packages/legacy/src/adapter/error.js:175](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L175) A `InvalidError` is used by an adapter to signal the external API was unable to process a request because the content was not semantically correct or meaningful per the API. Usually, this means a record failed some form of server-side validation. When a promise from an adapter is rejected with a `InvalidError` the record will transition to the `invalid` state and the errors will be set to the `errors` property on the record. For Ember Data to correctly map errors to their corresponding properties on the model, Ember Data expects each error to be a valid JSON-API error object with a `source/pointer` that matches the property name. For example, if you had a Post model that looked like this. ```js [app/models/post.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @attr('string') title; @attr('string') content; } ``` To show an error from the server related to the `title` and `content` properties your adapter could return a promise that rejects with a `InvalidError` object that looks like this: ```js [app/adapters/post.js] import RSVP from 'RSVP'; import RESTAdapter from '@ember-data/adapter/rest'; import { InvalidError } from '@ember-data/adapter/error'; export default class ApplicationAdapter extends RESTAdapter { updateRecord() { // Fictional adapter that always rejects return RSVP.reject(new InvalidError([ { detail: 'Must be unique', source: { pointer: '/data/attributes/title' } }, { detail: 'Must not be blank', source: { pointer: '/data/attributes/content'} } ])); } } ``` Your backend may use different property names for your records the store will attempt to extract and normalize the errors using the serializer's `extractErrors` method before the errors get added to the model. As a result, it is safe for the `InvalidError` to wrap the error payload unaltered. InvalidError ```ts class InvalidError(errors, message): void; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:175](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L175) A `InvalidError` is used by an adapter to signal the external API was unable to process a request because the content was not semantically correct or meaningful per the API. Usually, this means a record failed some form of server-side validation. When a promise from an adapter is rejected with a `InvalidError` the record will transition to the `invalid` state and the errors will be set to the `errors` property on the record. For Ember Data to correctly map errors to their corresponding properties on the model, Ember Data expects each error to be a valid JSON-API error object with a `source/pointer` that matches the property name. For example, if you had a Post model that looked like this. ```js [app/models/post.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @attr('string') title; @attr('string') content; } ``` To show an error from the server related to the `title` and `content` properties your adapter could return a promise that rejects with a `InvalidError` object that looks like this: ```js [app/adapters/post.js] import RSVP from 'RSVP'; import RESTAdapter from '@ember-data/adapter/rest'; import { InvalidError } from '@ember-data/adapter/error'; export default class ApplicationAdapter extends RESTAdapter { updateRecord() { // Fictional adapter that always rejects return RSVP.reject(new InvalidError([ { detail: 'Must be unique', source: { pointer: '/data/attributes/title' } }, { detail: 'Must not be blank', source: { pointer: '/data/attributes/content'} } ])); } } ``` Your backend may use different property names for your records the store will attempt to extract and normalize the errors using the serializer's `extractErrors` method before the errors get added to the model. As a result, it is safe for the `InvalidError` to wrap the error payload unaltered. InvalidError ## Parameters ### errors `any` ### message `any` ## Returns `void` ## Properties ### extend() ```ts static extend: (__namedParameters) => { (errors, message): void; extend: ({ message: defaultMessage }?: {}) => { (errors: any, message: any): void; prototype: any; extend: any; }; prototype: any; }; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:110](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L110) #### Parameters ##### \_\_namedParameters #### Returns ```ts (errors, message): void; ``` ##### Parameters ###### errors `any` ###### message `any` ##### Returns `void` ##### extend ```ts extend: ({ message: defaultMessage }?: {}) => { (errors: any, message: any): void; prototype: any; extend: any; }; ``` ##### prototype ```ts prototype: any; ``` --- --- url: /api/@warp-drive/legacy/adapter/error/classes/NotFoundError-1.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/error](../index.md) / NotFoundError Defined in: [warp-drive-packages/legacy/src/adapter/error.js:307](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L307) A `NotFoundError` equates to a HTTP `404 Not Found` response status. It is used by an adapter to signal that a request to the external API was rejected because the resource could not be found on the API. An example use case would be to detect if the user has entered a route for a specific model that does not exist. For example: ```js [app/routes/post.js] import { NotFoundError } from '@ember-data/adapter/error'; export default class PostRoute extends Route { @service store; model(params) { return this.store.findRecord('post', params.post_id); } @action error(error, transition) { if (error instanceof NotFoundError) { // redirect to a list of all posts instead this.transitionTo('posts'); } else { // otherwise let the error bubble return true; } } } ``` NotFoundError ## Properties ### code ```ts code: string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:311](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L311) --- --- url: /api/@warp-drive/legacy/adapter/error/classes/NotFoundError.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/error](../index.md) / NotFoundError Defined in: [warp-drive-packages/legacy/src/adapter/error.js:307](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L307) A `NotFoundError` equates to a HTTP `404 Not Found` response status. It is used by an adapter to signal that a request to the external API was rejected because the resource could not be found on the API. An example use case would be to detect if the user has entered a route for a specific model that does not exist. For example: ```js [app/routes/post.js] import { NotFoundError } from '@ember-data/adapter/error'; export default class PostRoute extends Route { @service store; model(params) { return this.store.findRecord('post', params.post_id); } @action error(error, transition) { if (error instanceof NotFoundError) { // redirect to a list of all posts instead this.transitionTo('posts'); } else { // otherwise let the error bubble return true; } } } ``` NotFoundError ```ts class NotFoundError(errors, message): void; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:307](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L307) A `NotFoundError` equates to a HTTP `404 Not Found` response status. It is used by an adapter to signal that a request to the external API was rejected because the resource could not be found on the API. An example use case would be to detect if the user has entered a route for a specific model that does not exist. For example: ```js [app/routes/post.js] import { NotFoundError } from '@ember-data/adapter/error'; export default class PostRoute extends Route { @service store; model(params) { return this.store.findRecord('post', params.post_id); } @action error(error, transition) { if (error instanceof NotFoundError) { // redirect to a list of all posts instead this.transitionTo('posts'); } else { // otherwise let the error bubble return true; } } } ``` NotFoundError ## Parameters ### errors `any` ### message `any` ## Returns `void` ## Properties ### extend() ```ts static extend: (__namedParameters) => { (errors, message): void; extend: ({ message: defaultMessage }?: {}) => { (errors: any, message: any): void; prototype: any; extend: any; }; prototype: any; }; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:110](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L110) #### Parameters ##### \_\_namedParameters #### Returns ```ts (errors, message): void; ``` ##### Parameters ###### errors `any` ###### message `any` ##### Returns `void` ##### extend ```ts extend: ({ message: defaultMessage }?: {}) => { (errors: any, message: any): void; prototype: any; extend: any; }; ``` ##### prototype ```ts prototype: any; ``` --- --- url: /api/@warp-drive/legacy/adapter/error/classes/ServerError-1.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/error](../index.md) / ServerError Defined in: [warp-drive-packages/legacy/src/adapter/error.js:337](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L337) A `ServerError` equates to a HTTP `500 Internal Server Error` response status. It is used by the adapter to indicate that a request has failed because of an error in the external API. ServerError ## Properties ### code ```ts code: string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:341](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L341) --- --- url: /api/@warp-drive/legacy/adapter/error/classes/ServerError.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/error](../index.md) / ServerError Defined in: [warp-drive-packages/legacy/src/adapter/error.js:337](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L337) A `ServerError` equates to a HTTP `500 Internal Server Error` response status. It is used by the adapter to indicate that a request has failed because of an error in the external API. ServerError ```ts class ServerError(errors, message): void; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:337](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L337) A `ServerError` equates to a HTTP `500 Internal Server Error` response status. It is used by the adapter to indicate that a request has failed because of an error in the external API. ServerError ## Parameters ### errors `any` ### message `any` ## Returns `void` ## Properties ### extend() ```ts static extend: (__namedParameters) => { (errors, message): void; extend: ({ message: defaultMessage }?: {}) => { (errors: any, message: any): void; prototype: any; extend: any; }; prototype: any; }; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:110](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L110) #### Parameters ##### \_\_namedParameters #### Returns ```ts (errors, message): void; ``` ##### Parameters ###### errors `any` ###### message `any` ##### Returns `void` ##### extend ```ts extend: ({ message: defaultMessage }?: {}) => { (errors: any, message: any): void; prototype: any; extend: any; }; ``` ##### prototype ```ts prototype: any; ``` --- --- url: /api/@warp-drive/legacy/adapter/error/classes/TimeoutError-1.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/error](../index.md) / TimeoutError Defined in: [warp-drive-packages/legacy/src/adapter/error.js:209](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L209) A `TimeoutError` is used by an adapter to signal that a request to the external API has timed out. I.e. no response was received from the external API within an allowed time period. An example use case would be to warn the user to check their internet connection if an adapter operation has timed out: ```js [app/routes/application.js] import { TimeoutError } from '@ember-data/adapter/error'; export default class ApplicationRoute extends Route { @action error(error, transition) { if (error instanceof TimeoutError) { // alert the user alert('Are you still connected to the Internet?'); return; } // ...other error handling logic } } ``` TimeoutError ## Properties ### code ```ts code: string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:210](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L210) --- --- url: /api/@warp-drive/legacy/adapter/error/classes/TimeoutError.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/error](../index.md) / TimeoutError Defined in: [warp-drive-packages/legacy/src/adapter/error.js:209](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L209) A `TimeoutError` is used by an adapter to signal that a request to the external API has timed out. I.e. no response was received from the external API within an allowed time period. An example use case would be to warn the user to check their internet connection if an adapter operation has timed out: ```js [app/routes/application.js] import { TimeoutError } from '@ember-data/adapter/error'; export default class ApplicationRoute extends Route { @action error(error, transition) { if (error instanceof TimeoutError) { // alert the user alert('Are you still connected to the Internet?'); return; } // ...other error handling logic } } ``` TimeoutError ```ts class TimeoutError(errors, message): void; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:209](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L209) A `TimeoutError` is used by an adapter to signal that a request to the external API has timed out. I.e. no response was received from the external API within an allowed time period. An example use case would be to warn the user to check their internet connection if an adapter operation has timed out: ```js [app/routes/application.js] import { TimeoutError } from '@ember-data/adapter/error'; export default class ApplicationRoute extends Route { @action error(error, transition) { if (error instanceof TimeoutError) { // alert the user alert('Are you still connected to the Internet?'); return; } // ...other error handling logic } } ``` TimeoutError ## Parameters ### errors `any` ### message `any` ## Returns `void` ## Properties ### extend() ```ts static extend: (__namedParameters) => { (errors, message): void; extend: ({ message: defaultMessage }?: {}) => { (errors: any, message: any): void; prototype: any; extend: any; }; prototype: any; }; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:110](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L110) #### Parameters ##### \_\_namedParameters #### Returns ```ts (errors, message): void; ``` ##### Parameters ###### errors `any` ###### message `any` ##### Returns `void` ##### extend ```ts extend: ({ message: defaultMessage }?: {}) => { (errors: any, message: any): void; prototype: any; extend: any; }; ``` ##### prototype ```ts prototype: any; ``` --- --- url: /api/@warp-drive/legacy/adapter/error/classes/UnauthorizedError-1.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/error](../index.md) / UnauthorizedError Defined in: [warp-drive-packages/legacy/src/adapter/error.js:253](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L253) A `UnauthorizedError` equates to a HTTP `401 Unauthorized` response status. It is used by an adapter to signal that a request to the external API was rejected because authorization is required and has failed or has not yet been provided. An example use case would be to redirect the user to a login route if a request is unauthorized: ```js [app/routes/application.js] import { UnauthorizedError } from '@ember-data/adapter/error'; export default class ApplicationRoute extends Route { @action error(error, transition) { if (error instanceof UnauthorizedError) { // go to the login route this.transitionTo('login'); return; } // ...other error handling logic } } ``` UnauthorizedError ## Properties ### code ```ts code: string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:257](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L257) --- --- url: /api/@warp-drive/legacy/adapter/error/classes/UnauthorizedError.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/error](../index.md) / UnauthorizedError Defined in: [warp-drive-packages/legacy/src/adapter/error.js:253](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L253) A `UnauthorizedError` equates to a HTTP `401 Unauthorized` response status. It is used by an adapter to signal that a request to the external API was rejected because authorization is required and has failed or has not yet been provided. An example use case would be to redirect the user to a login route if a request is unauthorized: ```js [app/routes/application.js] import { UnauthorizedError } from '@ember-data/adapter/error'; export default class ApplicationRoute extends Route { @action error(error, transition) { if (error instanceof UnauthorizedError) { // go to the login route this.transitionTo('login'); return; } // ...other error handling logic } } ``` UnauthorizedError ```ts class UnauthorizedError(errors, message): void; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:253](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L253) A `UnauthorizedError` equates to a HTTP `401 Unauthorized` response status. It is used by an adapter to signal that a request to the external API was rejected because authorization is required and has failed or has not yet been provided. An example use case would be to redirect the user to a login route if a request is unauthorized: ```js [app/routes/application.js] import { UnauthorizedError } from '@ember-data/adapter/error'; export default class ApplicationRoute extends Route { @action error(error, transition) { if (error instanceof UnauthorizedError) { // go to the login route this.transitionTo('login'); return; } // ...other error handling logic } } ``` UnauthorizedError ## Parameters ### errors `any` ### message `any` ## Returns `void` ## Properties ### extend() ```ts static extend: (__namedParameters) => { (errors, message): void; extend: ({ message: defaultMessage }?: {}) => { (errors: any, message: any): void; prototype: any; extend: any; }; prototype: any; }; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:110](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L110) #### Parameters ##### \_\_namedParameters #### Returns ```ts (errors, message): void; ``` ##### Parameters ###### errors `any` ###### message `any` ##### Returns `void` ##### extend ```ts extend: ({ message: defaultMessage }?: {}) => { (errors: any, message: any): void; prototype: any; extend: any; }; ``` ##### prototype ```ts prototype: any; ``` --- --- url: /api/@warp-drive/legacy/adapter/error.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / adapter/error ## Classes * [AbortError](classes/AbortError.md) * [AbortError](classes/AbortError-1.md) * [ConflictError](classes/ConflictError.md) * [ConflictError](classes/ConflictError-1.md) * [ForbiddenError](classes/ForbiddenError.md) * [ForbiddenError](classes/ForbiddenError-1.md) * [InvalidError](classes/InvalidError.md) * [InvalidError](classes/InvalidError-1.md) * [NotFoundError](classes/NotFoundError.md) * [NotFoundError](classes/NotFoundError-1.md) * [ServerError](classes/ServerError.md) * [ServerError](classes/ServerError-1.md) * [TimeoutError](classes/TimeoutError.md) * [TimeoutError](classes/TimeoutError-1.md) * [UnauthorizedError](classes/UnauthorizedError.md) * [UnauthorizedError](classes/UnauthorizedError-1.md) ## Variables * [AdapterError](variables/AdapterError.md) --- --- url: /api/@warp-drive/legacy/adapter/error/variables/AdapterError.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/error](../index.md) / AdapterError ```ts const AdapterError: typeof _AdapterError; ``` Defined in: [warp-drive-packages/legacy/src/adapter/error.js:96](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/error.js#L96) --- --- url: /api/@warp-drive/legacy/adapter.md --- [Documentation](../../../index.md) / [@warp-drive/legacy](../index.md) / adapter ## Overview In order to properly fetch and update data, @warp-drive/legacy needs to understand how to connect to your API. `Adapters` accept various kinds of requests from the store and manage fulfillment of the request from your API. ### Request Flow When the store decides it needs to issue a request it uses the following flow to manage the request and process the data. * find the appropriate adapter * issue the request to the adapter * await the adapter's response * if an error occurs reject with the error * if no error * if there is response data * pass the response data to the appropriate serializer * update the cache using the JSON:API formatted data from the serializer's response * return the primary record(s) associated with the request ### Request Errors When a request errors and your adapter does not have the ability to recover from the error, you may either reject the promise returned by your adapter method with the error or simply throw the error. If the request was for a `createRecord` `updateRecord` or `deleteRecord` special rules apply to how this error will affect the state of the store and additional properties on the `Error` class may be used. See the documentation for these methods in [MinimumAdapterInterface](../compat/interfaces/MinimumAdapterInterface.md) for more information. ### Implementing an Adapter There are seven required adapter methods, one for each of the primary request types that @warp-drive/legacy issues. They are: * findRecord * findAll * queryRecord * query * createRecord * updateRecord * deleteRecord Each of these request types has a matching store method that triggers it and matching `requestType` that is passed to the serializer's `normalizeResponse` method. If your app only reads data but never writes data, it is not necessary to implement the methods for create, update, and delete. This extends to all of the store's find methods with the exception of `findRecord` (`findAll`, `query`, `queryRecord`): if you do not use the store method in your app then your Adapter does not need the method. ```ts async function fetchData(url, options = {}) { let response = await fetch(url, options); return response.toJSON(); } export default class ApplicationAdapter { findRecord(_, { modelName }, id) { return fetchData(`./${modelName}s/${id}`); } static create() { return new this(); } } ``` ### Adapter Resolution `store.adapterFor(name)` will lookup adapters defined in `app/adapters/` and return an instance. `adapterFor` first attempts to find an adapter with an exact match on `name`, then falls back to checking for the presence of an adapter named `application`. If no adapter is found, an error will be thrown. ```ts store.adapterFor('author'); // lookup paths (in order) => // app/adapters/author.js // app/adapters/application.js ``` Most requests in @warp-drive/legacy are made with respect to a particular `type` (or `modelName`) (e.g., "get me the full collection of **books**" or "get me the **employee** whose id is 37"). We refer to this as the **primary** resource `type`. `adapterFor` is used by the store to find an adapter with a name matching that of the primary resource `type` for the request, which then falls back to the `application` adapter. It is recommended that applications define only a single `application` adapter and serializer where possible, only implementing an adapter specific to the `type` when absolutely necessary. If you need to support multiple API versions for the same type, the per-type strategy for defining adapters might not be adequate. If you have multiple APIs or multiple API versions and the single application adapter and per-type strategy does not suite your needs, one strategy is to write an `application` adapter and serializer that make use of `options` to specify the desired format when making a request, then forwards to the request to the desired adapter or serializer as needed. ```js [app/adapters/application.js] export default class Adapter extends EmberObject { findRecord(store, schema, id, snapshot) { let { apiVersion } = snapshot.adapterOptions; return this.adapterFor(`-api-${apiVersion}`).findRecord(store, schema, id, snapshot); } } ``` ### Overriding `Store.adapterFor` ```js import Store from '@ember-data/store'; import Adapter from '@ember-data/adapter/json-api'; class extends Store { #adapter = new Adapter(); adapterFor() { return this.#adapter; } } ``` Note: If you are using Ember and would like to make use of `service` injections in your adapter, you will want to additionally `setOwner` for the Adapter. ```js import Store from '@ember-data/store'; import Adapter from '@ember-data/adapter/json-api'; import { getOwner, setOwner } from '@ember/owner'; class extends Store { #adapter = null; adapterFor() { let adapter = this.#adapter; if (!adapter) { const owner = getOwner(this); adapter = new Adapter(); setOwner(adapter, owner); this.#adapter = adapter; } return adapter; } } ``` By default when using with Ember you only need to implement this hook if you want your adapter usage to be statically analyzeable. *Ember***Data** will attempt to resolve adapters using Ember's resolver. To provide a single Adapter for your application like the above you would provide it as the default export of the file `app/adapters/application.{js/ts}` ### Using an Adapter Any adapter in `app/adapters/` can be looked up by `name` using `store.adapterFor(name)`. ### Default Adapters Applications whose API's structure endpoint URLs *very close to* or *exactly* the **REST** or **JSON:API** convention, the `@ember-data/adapter` package contains implementations these applications can extend. Many applications will find writing their own adapter to be allow greater flexibility, customization, and maintenance than attempting to override methods in these adapters. ## Classes * [Adapter](classes/Adapter.md) ## Interfaces * [BuildURLMixin](interfaces/BuildURLMixin.md) ## Variables * [BuildURLMixin](variables/BuildURLMixin.md) --- --- url: /api/@warp-drive/legacy/adapter/interfaces/BuildURLMixin.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [adapter](../index.md) / BuildURLMixin Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:17](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L17) ## Methods ### \_buildURL() ```ts _buildURL( this, modelName, id?): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:91](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L91) #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `undefined` | `null` | `string` ##### id? `null` | `string` #### Returns `string` *** ### buildURL() #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:18](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L18) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"findRecord"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:25](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L25) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` ###### snapshot `SnapshotRecordArray` ###### requestType `"findAll"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType, query): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:32](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L32) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` ###### snapshot `null` ###### requestType `"query"` ###### query `Record`<`string`, `unknown`> ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType, query): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:40](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L40) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` ###### snapshot `null` ###### requestType `"queryRecord"` ###### query `Record`<`string`, `unknown`> ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:48](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L48) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string`\[] ###### snapshot `Snapshot`<`unknown`>\[] ###### requestType `"findMany"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:55](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L55) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"findHasMany"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:62](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L62) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"findBelongsTo"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:69](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L69) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` | `string` ###### snapshot `Snapshot` ###### requestType `"createRecord"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:76](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L76) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"updateRecord"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:83](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L83) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"deleteRecord"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:90](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L90) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ##### Returns `string` *** ### pathForType() ```ts pathForType(this, modelName): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:103](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L103) #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `string` #### Returns `string` *** ### urlForCreateRecord() ```ts urlForCreateRecord( this, modelName, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:99](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L99) #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` *** ### urlForDeleteRecord() ```ts urlForDeleteRecord( this, id, modelName, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:101](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L101) #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` *** ### urlForFindAll() ```ts urlForFindAll( this, modelName, snapshots): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:93](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L93) #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `string` ##### snapshots `SnapshotRecordArray` #### Returns `string` *** ### urlForFindBelongsTo() ```ts urlForFindBelongsTo( this, id, modelName, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:98](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L98) #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` *** ### urlForFindHasMany() ```ts urlForFindHasMany( this, id, modelName, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:97](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L97) #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` *** ### urlForFindMany() ```ts urlForFindMany( this, ids, modelName, snapshots): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:96](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L96) #### Parameters ##### this `MixtBuildURLMixin` ##### ids `string`\[] ##### modelName `string` ##### snapshots `Snapshot`<`unknown`>\[] #### Returns `string` *** ### urlForFindRecord() ```ts urlForFindRecord( this, id, modelName, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:92](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L92) #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` *** ### urlForQuery() ```ts urlForQuery( this, query, modelName): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:95](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L95) #### Parameters ##### this `MixtBuildURLMixin` ##### query `Record`<`string`, `unknown`> ##### modelName `string` #### Returns `string` *** ### urlForQueryRecord() ```ts urlForQueryRecord( this, query, modelName): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:94](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L94) #### Parameters ##### this `MixtBuildURLMixin` ##### query `Record`<`string`, `unknown`> ##### modelName `string` #### Returns `string` *** ### urlForUpdateRecord() ```ts urlForUpdateRecord( this, id, modelName, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:100](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L100) #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` *** ### urlPrefix() ```ts urlPrefix( this, path?, parentURL?): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:102](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L102) #### Parameters ##### this `MixtBuildURLMixin` ##### path? `null` | `string` ##### parentURL? `string` #### Returns `string` --- --- url: /api/@warp-drive/legacy/adapter/json-api.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / adapter/json-api ## Classes * [JSONAPIAdapter](classes/JSONAPIAdapter.md) --- --- url: /api/@warp-drive/legacy/adapter/json-api/classes/JSONAPIAdapter.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/json-api](../index.md) / JSONAPIAdapter Defined in: [warp-drive-packages/legacy/src/adapter/json-api.ts:156](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/json-api.ts#L156) ## Overview The `JSONAPIAdapter` is an adapter whichtransforms the store's requests into HTTP requests that follow the [JSON API format](http://jsonapi.org/format/). ## JSON API Conventions The JSONAPIAdapter uses JSON API conventions for building the URL for a record and selecting the HTTP verb to use with a request. The actions you can take on a record map onto the following URLs in the JSON API adapter: ## Success and failure The JSONAPIAdapter will consider a success any response with a status code of the 2xx family ("Success"), as well as 304 ("Not Modified"). Any other status code will be considered a failure. On success, the request promise will be resolved with the full response payload. Failed responses with status code 422 ("Unprocessable Entity") will be considered "invalid". The response will be discarded, except for the `errors` key. The request promise will be rejected with a `InvalidError`. This error object will encapsulate the saved `errors` value. Any other status codes will be treated as an adapter error. The request promise will be rejected, similarly to the invalid case, but with an instance of `AdapterError` instead. ### Endpoint path customization Endpoint paths can be prefixed with a `namespace` by setting the namespace property on the adapter: ```js [app/adapters/application.js] import JSONAPIAdapter from '@ember-data/adapter/json-api'; export default class ApplicationAdapter extends JSONAPIAdapter { namespace = 'api/1'; } ``` Requests for the `person` model would now target `/api/1/people/1`. ### Host customization An adapter can target other hosts by setting the `host` property. ```js [app/adapters/application.js] import JSONAPIAdapter from '@ember-data/adapter/json-api'; export default class ApplicationAdapter extends JSONAPIAdapter { host = 'https://api.example.com'; } ``` Requests for the `person` model would now target `https://api.example.com/people/1`. ## Since 1.13.0 JSONAPIAdapter ## Extends * [`RESTAdapter`](../../rest/classes/RESTAdapter.md) ## Constructors ### Constructor ```ts new JSONAPIAdapter(owner?): JSONAPIAdapter; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:8 #### Parameters ##### owner? `Owner` #### Returns `JSONAPIAdapter` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`constructor`](../../rest/classes/RESTAdapter.md#constructor) ## Properties ### \_coalesceFindRequests ```ts _coalesceFindRequests: boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:302](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L302) #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`_coalesceFindRequests`](../../rest/classes/RESTAdapter.md#_coalescefindrequests) *** ### \_defaultContentType ```ts _defaultContentType: string = 'application/vnd.api+json'; ``` Defined in: [warp-drive-packages/legacy/src/adapter/json-api.ts:157](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/json-api.ts#L157) #### Overrides [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`_defaultContentType`](../../rest/classes/RESTAdapter.md#_defaultcontenttype) *** ### \_fastboot ```ts _fastboot: FastBoot; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:301](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L301) #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`_fastboot`](../../rest/classes/RESTAdapter.md#_fastboot) *** ### concatenatedProperties? ```ts optional concatenatedProperties: string | string[]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:655 #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`concatenatedProperties`](../../rest/classes/RESTAdapter.md#concatenatedproperties) *** ### headers ```ts headers: undefined | Record; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:511](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L511) Some APIs require HTTP headers, e.g. to provide an API key. Arbitrary headers can be set as key/value pairs on the `RESTAdapter`'s `headers` object and Ember Data will send them along with each ajax request. For dynamic headers see [headers customization](/ember-data/release/classes/RESTAdapter). ```js [app/adapters/application.js] import { RESTAdapter } from '@warp-drive/legacy/adapter/rest'; export default class ApplicationAdapter extends RESTAdapter { get headers() { return { 'API_KEY': 'secret key', 'ANOTHER_HEADER': 'Some header value' }; } } ``` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`headers`](../../rest/classes/RESTAdapter.md#headers) *** ### host ```ts host: null | string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:303](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L303) #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`host`](../../rest/classes/RESTAdapter.md#host) *** ### maxURLLength ```ts maxURLLength: number = 2048; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:867](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L867) #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`maxURLLength`](../../rest/classes/RESTAdapter.md#maxurllength) *** ### mergedProperties? ```ts optional mergedProperties: unknown[]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:656 #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`mergedProperties`](../../rest/classes/RESTAdapter.md#mergedproperties) *** ### namespace ```ts namespace: null | string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:304](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L304) #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`namespace`](../../rest/classes/RESTAdapter.md#namespace) *** ### store ```ts store: default; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:258](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L258) #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`store`](../../rest/classes/RESTAdapter.md#store) *** ### useFetch ```ts useFetch: boolean = true; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:314](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L314) This property allows ajax to still be used instead when `false`. #### Default ```ts true @public ``` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`useFetch`](../../rest/classes/RESTAdapter.md#usefetch) *** ### \_lazyInjections()? ```ts readonly static optional _lazyInjections: () => void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:654 #### Returns `void` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`_lazyInjections`](../../rest/classes/RESTAdapter.md#_lazyinjections) *** ### \_onLookup()? ```ts readonly static optional _onLookup: (debugContainerKey) => void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:653 #### Parameters ##### debugContainerKey `string` #### Returns `void` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`_onLookup`](../../rest/classes/RESTAdapter.md#_onlookup) *** ### \[INIT\_FACTORY]? ```ts static optional [INIT_FACTORY]: null; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/mixin.d.ts:116 #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`[INIT_FACTORY]`](../../rest/classes/RESTAdapter.md#init_factory) *** ### isClass ```ts readonly static isClass: boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:651 #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`isClass`](../../rest/classes/RESTAdapter.md#isclass) *** ### isMethod ```ts readonly static isMethod: boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:652 #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`isMethod`](../../rest/classes/RESTAdapter.md#ismethod) *** ### PrototypeMixin ```ts static PrototypeMixin: any; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:647 #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`PrototypeMixin`](../../rest/classes/RESTAdapter.md#prototypemixin) *** ### superclass ```ts static superclass: any; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:648 #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`superclass`](../../rest/classes/RESTAdapter.md#superclass) ## Accessors ### \_debugContainerKey #### Get Signature ```ts get _debugContainerKey(): false | `${string}:${string}`; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/index.d.ts:34 ##### Returns `false` | `` `${string}:${string}` `` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`_debugContainerKey`](../../rest/classes/RESTAdapter.md#_debugcontainerkey) *** ### coalesceFindRequests #### Get Signature ```ts get coalesceFindRequests(): boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter/json-api.ts:234](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/json-api.ts#L234) By default the JSONAPIAdapter will send each find request coming from a `store.find` or from accessing a relationship separately to the server. If your server supports passing ids as a query string, you can set coalesceFindRequests to true to coalesce all find requests within a single runloop. For example, if you have an initial payload of: ```javascript { data: { id: 1, type: 'post', relationship: { comments: { data: [ { id: 1, type: 'comment' }, { id: 2, type: 'comment' } ] } } } } ``` By default calling `post.comments` will trigger the following requests(assuming the comments haven't been loaded before): ``` GET /comments/1 GET /comments/2 ``` If you set coalesceFindRequests to `true` it will instead trigger the following request: ``` GET /comments?filter[id]=1,2 ``` Setting coalesceFindRequests to `true` also works for `store.find` requests and `belongsTo` relationships accessed within the same runloop. If you set `coalesceFindRequests: true` ```javascript store.findRecord('comment', 1); store.findRecord('comment', 2); ``` will also send a request to: `GET /comments?filter[id]=1,2` Note: Requests coalescing rely on URL building strategy. So if you override `buildURL` in your app `groupRecordsForFindMany` more likely should be overridden as well in order for coalescing to work. ##### Returns `boolean` #### Set Signature ```ts set coalesceFindRequests(value): void; ``` Defined in: [warp-drive-packages/legacy/src/adapter/json-api.ts:242](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/json-api.ts#L242) By default the RESTAdapter will send each find request coming from a `store.find` or from accessing a relationship separately to the server. If your server supports passing ids as a query string, you can set coalesceFindRequests to true to coalesce all find requests within a single runloop. For example, if you have an initial payload of: ```javascript { post: { id: 1, comments: [1, 2] } } ``` By default calling `post.comments` will trigger the following requests(assuming the comments haven't been loaded before): ``` GET /comments/1 GET /comments/2 ``` If you set coalesceFindRequests to `true` it will instead trigger the following request: ``` GET /comments?ids[]=1&ids[]=2 ``` Setting coalesceFindRequests to `true` also works for `store.find` requests and `belongsTo` relationships accessed within the same runloop. If you set `coalesceFindRequests: true` ```javascript store.findRecord('comment', 1); store.findRecord('comment', 2); ``` will also send a request to: `GET /comments?ids[]=1&ids[]=2` Note: Requests coalescing rely on URL building strategy. So if you override `buildURL` in your app `groupRecordsForFindMany` more likely should be overridden as well in order for coalescing to work. ##### Parameters ###### value `boolean` ##### Returns `void` **`Optional`** If your adapter implements `findMany`, setting this to `true` will cause `findRecord` requests triggered within the same `runloop` to be coalesced into one or more calls to `adapter.findMany`. The number of calls made and the records contained in each call can be tuned by your adapter's `groupRecordsForHasMany` method. Implementing coalescing using this flag and the associated methods does not always offer the right level of correctness, timing control or granularity. If your application would be better suited coalescing across multiple types, coalescing for longer than a single runloop, or with a more custom request structure, coalescing within your application adapter may prove more effective. #### Overrides [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`coalesceFindRequests`](../../rest/classes/RESTAdapter.md#coalescefindrequests) *** ### fastboot #### Get Signature ```ts get fastboot(): FastBoot; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:319](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L319) ##### Returns `FastBoot` #### Set Signature ```ts set fastboot(value): void; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:329](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L329) ##### Parameters ###### value `FastBoot` ##### Returns `void` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`fastboot`](../../rest/classes/RESTAdapter.md#fastboot) *** ### isDestroyed #### Get Signature ```ts get isDestroyed(): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:272 Destroyed object property flag. if this property is `true` the observers and bindings were already removed by the effect of calling the `destroy()` method. ##### Default ```ts false @public ``` ##### Returns `boolean` #### Set Signature ```ts set isDestroyed(_value): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:273 ##### Parameters ###### \_value `boolean` ##### Returns `void` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`isDestroyed`](../../rest/classes/RESTAdapter.md#isdestroyed) *** ### isDestroying #### Get Signature ```ts get isDestroying(): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:284 Destruction scheduled flag. The `destroy()` method has been called. The object stays intact until the end of the run loop at which point the `isDestroyed` flag is set. ##### Default ```ts false @public ``` ##### Returns `boolean` #### Set Signature ```ts set isDestroying(_value): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:285 ##### Parameters ###### \_value `boolean` ##### Returns `void` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`isDestroying`](../../rest/classes/RESTAdapter.md#isdestroying) ## Methods ### \_ajax() ```ts _ajax(options): void; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:1068](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L1068) #### Parameters ##### options [`FetchRequestInit`](../../rest/interfaces/FetchRequestInit.md) | [`JQueryRequestInit`](../../rest/interfaces/JQueryRequestInit.md) #### Returns `void` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`_ajax`](../../rest/classes/RESTAdapter.md#_ajax) *** ### \_ajaxURL() ```ts _ajaxURL(url): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:1132](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L1132) #### Parameters ##### url `string` #### Returns `string` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`_ajaxURL`](../../rest/classes/RESTAdapter.md#_ajaxurl) *** ### \_buildURL() ```ts _buildURL( this, modelName, id?): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:91](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L91) #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `undefined` | `null` | `string` ##### id? `null` | `string` #### Returns `string` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`_buildURL`](../../rest/classes/RESTAdapter.md#_buildurl) *** ### \_fetchRequest() ```ts _fetchRequest(options): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:1062](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L1062) #### Parameters ##### options [`FetchRequestInit`](../../rest/interfaces/FetchRequestInit.md) #### Returns `Promise`<`Response`> #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`_fetchRequest`](../../rest/classes/RESTAdapter.md#_fetchrequest) *** ### \_stripIDFromURL() ```ts _stripIDFromURL(store, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:839](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L839) #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### snapshot `Snapshot` #### Returns `string` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`_stripIDFromURL`](../../rest/classes/RESTAdapter.md#_stripidfromurl) *** ### addObserver() #### Call Signature ```ts addObserver( key, target, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:333 Adds an observer on a property. This is the core method used to register an observer for a property. Once you call this method, any time the key's value is set, your observer will be notified. Note that the observers are triggered any time the value is set, regardless of whether it has actually changed. Your observer should be prepared to handle that. There are two common invocation patterns for `.addObserver()`: * Passing two arguments: * the name of the property to observe (as a string) * the function to invoke (an actual function) * Passing three arguments: * the name of the property to observe (as a string) * the target object (will be used to look up and invoke a function on) * the name of the function to invoke on the target object (as a string). ```app/components/my-component.js import Component from '@ember/component'; export default Component.extend({ init() { this._super(...arguments); // the following are equivalent: // using three arguments this.addObserver('foo', this, 'fooDidChange'); // using two arguments this.addObserver('foo', (...args) => { this.fooDidChange(...args); }); }, fooDidChange() { // your custom logic code } }); ``` ### Observer Methods Observer methods have the following signature: ```app/components/my-component.js import Component from '@ember/component'; export default Component.extend({ init() { this._super(...arguments); this.addObserver('foo', this, 'fooDidChange'); }, fooDidChange(sender, key, value, rev) { // your code } }); ``` The `sender` is the object that changed. The `key` is the property that changes. The `value` property is currently reserved and unused. The `rev` is the last property revision of the object when it changed, which you can use to detect if the key value has really changed or not. Usually you will not need the value or revision parameters at the end. In this case, it is common to write observer methods that take only a sender and key value as parameters or, if you aren't interested in any of these values, to write an observer that has no parameters at all. ##### Type Parameters ###### Target `Target` ##### Parameters ###### key keyof `JSONAPIAdapter` The key to observe ###### target `Target` The target object to invoke ###### method `ObserverMethod`<`Target`, `JSONAPIAdapter`> The method to invoke ##### Returns `this` ##### Method addObserver ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`addObserver`](../../rest/classes/RESTAdapter.md#addobserver) #### Call Signature ```ts addObserver(key, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:338 ##### Parameters ###### key keyof `JSONAPIAdapter` ###### method `ObserverMethod`<`JSONAPIAdapter`, `JSONAPIAdapter`> ##### Returns `this` ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`addObserver`](../../rest/classes/RESTAdapter.md#addobserver) *** ### buildQuery() ```ts buildQuery(snapshot): QueryState; ``` Defined in: [warp-drive-packages/legacy/src/adapter/json-api.ts:276](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/json-api.ts#L276) Used by `findAll` and `findRecord` to build the query's `data` hash supplied to the ajax method. #### Parameters ##### snapshot `Snapshot`<`unknown`> | `SnapshotRecordArray` #### Returns [`QueryState`](../../rest/type-aliases/QueryState.md) #### Since 2.5.0 #### Overrides [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`buildQuery`](../../rest/classes/RESTAdapter.md#buildquery) *** ### buildURL() #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:18](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L18) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"findRecord"` ##### Returns `string` ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`buildURL`](../../rest/classes/RESTAdapter.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:25](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L25) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` ###### snapshot `SnapshotRecordArray` ###### requestType `"findAll"` ##### Returns `string` ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`buildURL`](../../rest/classes/RESTAdapter.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType, query): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:32](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L32) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` ###### snapshot `null` ###### requestType `"query"` ###### query `Record`<`string`, `unknown`> ##### Returns `string` ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`buildURL`](../../rest/classes/RESTAdapter.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType, query): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:40](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L40) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` ###### snapshot `null` ###### requestType `"queryRecord"` ###### query `Record`<`string`, `unknown`> ##### Returns `string` ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`buildURL`](../../rest/classes/RESTAdapter.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:48](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L48) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string`\[] ###### snapshot `Snapshot`<`unknown`>\[] ###### requestType `"findMany"` ##### Returns `string` ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`buildURL`](../../rest/classes/RESTAdapter.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:55](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L55) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"findHasMany"` ##### Returns `string` ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`buildURL`](../../rest/classes/RESTAdapter.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:62](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L62) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"findBelongsTo"` ##### Returns `string` ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`buildURL`](../../rest/classes/RESTAdapter.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:69](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L69) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` | `string` ###### snapshot `Snapshot` ###### requestType `"createRecord"` ##### Returns `string` ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`buildURL`](../../rest/classes/RESTAdapter.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:76](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L76) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"updateRecord"` ##### Returns `string` ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`buildURL`](../../rest/classes/RESTAdapter.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:83](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L83) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"deleteRecord"` ##### Returns `string` ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`buildURL`](../../rest/classes/RESTAdapter.md#buildurl) #### Call Signature ```ts buildURL( this, modelName, id, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:90](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L90) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ##### Returns `string` ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`buildURL`](../../rest/classes/RESTAdapter.md#buildurl) *** ### cacheFor() ```ts cacheFor(key): unknown; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:413 Returns the cached value of a computed property, if it exists. This allows you to inspect the value of a computed property without accidentally invoking it if it is intended to be generated lazily. #### Type Parameters ##### K `K` *extends* keyof `JSONAPIAdapter` #### Parameters ##### key `K` #### Returns `unknown` The cached value of the computed property, if any #### Method cacheFor #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`cacheFor`](../../rest/classes/RESTAdapter.md#cachefor) *** ### createRecord() ```ts createRecord( store, type, snapshot): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:786](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L786) Called by the store when a newly created record is saved via the `save` method on a model record instance. The `createRecord` method serializes the record and makes an Ajax (HTTP POST) request to a URL computed by `buildURL`. See `serialize` for information on how to customize the serialized form of a record. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### type [`ModelSchema`](../../../../core-types/index/interfaces/ModelSchema.md) ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`createRecord`](../../rest/classes/RESTAdapter.md#createrecord) *** ### decrementProperty() ```ts decrementProperty(keyName, decrement?): number; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:387 Set the value of a property to the current value minus some amount. ```javascript player.decrementProperty('lives'); orc.decrementProperty('health', 5); ``` #### Parameters ##### keyName keyof `JSONAPIAdapter` The name of the property to decrement ##### decrement? `number` The amount to decrement by. Defaults to 1 #### Returns `number` The new property value #### Method decrementProperty #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`decrementProperty`](../../rest/classes/RESTAdapter.md#decrementproperty) *** ### deleteRecord() ```ts deleteRecord( store, schema, snapshot): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:831](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L831) Called by the store when a record is deleted. The `deleteRecord` method makes an Ajax (HTTP DELETE) request to a URL computed by `buildURL`. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### schema [`ModelSchema`](../../../../core-types/index/interfaces/ModelSchema.md) ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`deleteRecord`](../../rest/classes/RESTAdapter.md#deleterecord) *** ### destroy() ```ts destroy(): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:300 Destroys an object by setting the `isDestroyed` flag and removing its metadata, which effectively destroys observers and bindings. If you try to set a property on a destroyed object, an exception will be raised. Note that destruction is scheduled for the end of the run loop and does not happen immediately. It will set an isDestroying flag immediately. #### Returns `this` receiver #### Method destroy #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`destroy`](../../rest/classes/RESTAdapter.md#destroy) *** ### findAll() ```ts findAll( store, type, sinceToken, snapshotRecordArray): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:551](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L551) Called by the store in order to fetch a JSON array for all of the records for a given type. The `findAll` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a promise for the resulting payload. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### type [`ModelSchema`](../../../../core-types/index/interfaces/ModelSchema.md) ##### sinceToken `null` ##### snapshotRecordArray `SnapshotRecordArray` #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`findAll`](../../rest/classes/RESTAdapter.md#findall) *** ### findBelongsTo() ```ts findBelongsTo( store, snapshot, url, relationship): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:758](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L758) Called by the store in order to fetch the JSON for the unloaded record in a belongs-to relationship that was originally specified as a URL (inside of `links`). For example, if your original payload looks like this: ```js { "person": { "id": 1, "name": "Tom Dale", "links": { "group": "/people/1/group" } } } ``` This method will be called with the parent record and `/people/1/group`. The `findBelongsTo` method will make an Ajax (HTTP GET) request to the originally specified URL. The format of your `links` value will influence the final request URL via the `urlPrefix` method: * Links beginning with `//`, `http://`, `https://`, will be used as is, with no further manipulation. * Links beginning with a single `/` will have the current adapter's `host` value prepended to it. * Links with no beginning `/` will have a parentURL prepended to it, via the current adapter's `buildURL`. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### snapshot `Snapshot` ##### url `string` ##### relationship `any` meta object describing the relationship #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`findBelongsTo`](../../rest/classes/RESTAdapter.md#findbelongsto) *** ### findHasMany() ```ts findHasMany( store, snapshot, url, relationship): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:704](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L704) Called by the store in order to fetch a JSON array for the unloaded records in a has-many relationship that were originally specified as a URL (inside of `links`). For example, if your original payload looks like this: ```js { "post": { "id": 1, "title": "Rails is omakase", "links": { "comments": "/posts/1/comments" } } } ``` This method will be called with the parent record and `/posts/1/comments`. The `findHasMany` method will make an Ajax (HTTP GET) request to the originally specified URL. The format of your `links` value will influence the final request URL via the `urlPrefix` method: * Links beginning with `//`, `http://`, `https://`, will be used as is, with no further manipulation. * Links beginning with a single `/` will have the current adapter's `host` value prepended to it. * Links with no beginning `/` will have a parentURL prepended to it, via the current adapter's `buildURL`. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### snapshot `Snapshot` ##### url `string` ##### relationship `Record`<`string`, `unknown`> meta object describing the relationship #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`findHasMany`](../../rest/classes/RESTAdapter.md#findhasmany) *** ### findMany() ```ts findMany( store, type, ids, snapshots): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/json-api.ts:246](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/json-api.ts#L246) Called by the store in order to fetch several records together if `coalesceFindRequests` is true For example, if the original payload looks like: ```js { "id": 1, "title": "Rails is omakase", "comments": [ 1, 2, 3 ] } ``` The IDs will be passed as a URL-encoded Array of IDs, in this form: ``` ids[]=1&ids[]=2&ids[]=3 ``` Many servers, such as Rails and PHP, will automatically convert this URL-encoded array into an Array for you on the server-side. If you want to encode the IDs, differently, just override this (one-line) method. The `findMany` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a promise for the resulting payload. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### type [`ModelSchema`](../../../../core-types/index/interfaces/ModelSchema.md) ##### ids `string`\[] ##### snapshots `Snapshot`<`unknown`>\[] #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise #### Overrides [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`findMany`](../../rest/classes/RESTAdapter.md#findmany) *** ### findRecord() ```ts findRecord( store, type, id, snapshot): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:530](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L530) Called by the store in order to fetch the JSON for a given type and ID. The `findRecord` method makes an Ajax request to a URL computed by `buildURL`, and returns a promise for the resulting payload. This method performs an HTTP `GET` request with the id provided as part of the query string. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### type [`ModelSchema`](../../../../core-types/index/interfaces/ModelSchema.md) ##### id `string` ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise #### Since 1.13.0 #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`findRecord`](../../rest/classes/RESTAdapter.md#findrecord) *** ### get() #### Call Signature ```ts get(key): JSONAPIAdapter[K]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:121 Retrieves the value of a property from the object. This method is usually similar to using `object[keyName]` or `object.keyName`, however it supports both computed properties and the unknownProperty handler. Because `get` unifies the syntax for accessing all these kinds of properties, it can make many refactorings easier, such as replacing a simple property with a computed property, or vice versa. ### Computed Properties Computed properties are methods defined with the `property` modifier declared at the end, such as: ```javascript import { computed } from '@ember/object'; fullName: computed('firstName', 'lastName', function() { return this.get('firstName') + ' ' + this.get('lastName'); }) ``` When you call `get` on a computed property, the function will be called and the return value will be returned instead of the function itself. ### Unknown Properties Likewise, if you try to call `get` on a property whose value is `undefined`, the `unknownProperty()` method will be called on the object. If this method returns any value other than `undefined`, it will be returned instead. This allows you to implement "virtual" properties that are not defined upfront. ##### Type Parameters ###### K `K` *extends* keyof `JSONAPIAdapter` ##### Parameters ###### key `K` ##### Returns `JSONAPIAdapter`\[`K`] The property value or undefined. ##### Method get ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`get`](../../rest/classes/RESTAdapter.md#get) #### Call Signature ```ts get(key): unknown; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:122 ##### Parameters ###### key `string` ##### Returns `unknown` ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`get`](../../rest/classes/RESTAdapter.md#get) *** ### getProperties() #### Call Signature ```ts getProperties(list): { [Key in keyof JSONAPIAdapter]: JSONAPIAdapter[Key] }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:144 To get the values of multiple properties at once, call `getProperties` with a list of strings or an array: ```javascript record.getProperties('firstName', 'lastName', 'zipCode'); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } ``` is equivalent to: ```javascript record.getProperties(['firstName', 'lastName', 'zipCode']); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } ``` ##### Type Parameters ###### L `L` *extends* keyof `JSONAPIAdapter`\[] ##### Parameters ###### list `L` of keys to get ##### Returns `{ [Key in keyof JSONAPIAdapter]: JSONAPIAdapter[Key] }` ##### Method getProperties ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`getProperties`](../../rest/classes/RESTAdapter.md#getproperties) #### Call Signature ```ts getProperties(...list): { [Key in keyof JSONAPIAdapter]: JSONAPIAdapter[Key] }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:149 ##### Type Parameters ###### L `L` *extends* keyof `JSONAPIAdapter`\[] ##### Parameters ###### list ...`L` ##### Returns `{ [Key in keyof JSONAPIAdapter]: JSONAPIAdapter[Key] }` ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`getProperties`](../../rest/classes/RESTAdapter.md#getproperties) #### Call Signature ```ts getProperties(list): { [Key in string]: unknown }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:154 ##### Type Parameters ###### L `L` *extends* `string`\[] ##### Parameters ###### list `L` ##### Returns `{ [Key in string]: unknown }` ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`getProperties`](../../rest/classes/RESTAdapter.md#getproperties) #### Call Signature ```ts getProperties(...list): { [Key in string]: unknown }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:159 ##### Type Parameters ###### L `L` *extends* `string`\[] ##### Parameters ###### list ...`L` ##### Returns `{ [Key in string]: unknown }` ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`getProperties`](../../rest/classes/RESTAdapter.md#getproperties) *** ### groupRecordsForFindMany() ```ts groupRecordsForFindMany(store, snapshots): Snapshot[][]; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:891](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L891) Organize records into groups, each of which is to be passed to separate calls to `findMany`. This implementation groups together records that have the same base URL but differing ids. For example `/comments/1` and `/comments/2` will be grouped together because we know findMany can coalesce them together as `/comments?ids[]=1&ids[]=2` It also supports urls where ids are passed as a query param, such as `/comments?id=1` but not those where there is more than 1 query param such as `/comments?id=2&name=David` Currently only the query param of `id` is supported. If you need to support others, please override this or the `_stripIDFromURL` method. It does not group records that have differing base urls, such as for example: `/posts/1/comments/2` and `/posts/2/comments/3` #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### snapshots `Snapshot`<`unknown`>\[] #### Returns `Snapshot`<`unknown`>\[]\[] an array of arrays of records, each of which is to be loaded separately by `findMany`. #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`groupRecordsForFindMany`](../../rest/classes/RESTAdapter.md#grouprecordsforfindmany) *** ### handleResponse() ```ts handleResponse( status, headers, payload, requestData): Payload | typeof _AdapterError; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:944](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L944) Takes an ajax response, and returns the json payload or an error. By default this hook just returns the json payload passed to it. You might want to override it in two cases: 1. Your API might return useful results in the response headers. Response headers are passed in as the second argument. 2. Your API might return errors as successful responses with status code 200 and an Errors text or object. You can return a `InvalidError` or a `AdapterError` (or a sub class) from this hook and it will automatically reject the promise and put your record into the invalid or error state. Returning a `InvalidError` from this method will cause the record to transition into the `invalid` state and make the `errors` object available on the record. When returning an `InvalidError` the store will attempt to normalize the error data returned from the server using the serializer's `extractErrors` method. #### Parameters ##### status `number` ##### headers `Record`<`string`, `string`> ##### payload `Payload` ##### requestData [`RequestData`](../../rest/type-aliases/RequestData.md) the original request information #### Returns `Payload` | *typeof* `_AdapterError` response #### Since 1.13.0 #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`handleResponse`](../../rest/classes/RESTAdapter.md#handleresponse) *** ### incrementProperty() ```ts incrementProperty(keyName, increment?): number; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:372 Set the value of a property to the current value plus some amount. ```javascript person.incrementProperty('age'); team.incrementProperty('score', 2); ``` #### Parameters ##### keyName keyof `JSONAPIAdapter` The name of the property to increment ##### increment? `number` The amount to increment by. Defaults to 1 #### Returns `number` The new property value #### Method incrementProperty #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`incrementProperty`](../../rest/classes/RESTAdapter.md#incrementproperty) *** ### init() ```ts init(_properties): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:114 An overridable method called when objects are instantiated. By default, does nothing unless it is overridden during class definition. Example: ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ init() { alert(`Name is ${this.get('name')}`); } }); let steve = Person.create({ name: 'Steve' }); // alerts 'Name is Steve'. ``` NOTE: If you do override `init` for a framework class like `Component` from `@ember/component`, be sure to call `this._super(...arguments)` in your `init` declaration! If you don't, Ember may not have an opportunity to do important setup work, and you'll see strange behavior in your application. #### Parameters ##### \_properties `undefined` | `object` #### Returns `void` #### Method init #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`init`](../../rest/classes/RESTAdapter.md#init) *** ### isInvalid() ```ts isInvalid( status, _headers, _payload): boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:1003](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L1003) Default `handleResponse` implementation uses this hook to decide if the response is an invalid error. #### Parameters ##### status `number` ##### \_headers `Record`<`string`, `unknown`> ##### \_payload `Payload` #### Returns `boolean` #### Since 1.13.0 #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`isInvalid`](../../rest/classes/RESTAdapter.md#isinvalid) *** ### isSuccess() ```ts isSuccess( status, _headers, _payload): boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:988](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L988) Default `handleResponse` implementation uses this hook to decide if the response is a success. #### Parameters ##### status `number` ##### \_headers `Record`<`string`, `unknown`> ##### \_payload `Payload` #### Returns `boolean` #### Since 1.13.0 #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`isSuccess`](../../rest/classes/RESTAdapter.md#issuccess) *** ### notifyPropertyChange() ```ts notifyPropertyChange(keyName): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:249 Convenience method to call `propertyWillChange` and `propertyDidChange` in succession. Notify the observer system that a property has just changed. Sometimes you need to change a value directly or indirectly without actually calling `get()` or `set()` on it. In this case, you can use this method instead. Calling this method will notify all observers that the property has potentially changed value. #### Parameters ##### keyName `string` The property key to be notified about. #### Returns `this` #### Method notifyPropertyChange #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`notifyPropertyChange`](../../rest/classes/RESTAdapter.md#notifypropertychange) *** ### pathForType() ```ts pathForType(modelName): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/json-api.ts:251](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/json-api.ts#L251) #### Parameters ##### modelName `string` #### Returns `string` #### Overrides [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`pathForType`](../../rest/classes/RESTAdapter.md#pathfortype) *** ### query() ```ts query( store, type, query): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:586](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L586) Called by the store in order to fetch a JSON array for the records that match a particular query. The `query` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a promise for the resulting payload. The `query` argument is a simple JavaScript object that will be passed directly to the server as parameters. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### type [`ModelSchema`](../../../../core-types/index/interfaces/ModelSchema.md) ##### query `Record`<`string`, `unknown`> #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`query`](../../rest/classes/RESTAdapter.md#query) *** ### queryRecord() ```ts queryRecord( store, type, query, adapterOptions): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:615](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L615) Called by the store in order to fetch a JSON object for the record that matches a particular query. The `queryRecord` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a promise for the resulting payload. The `query` argument is a simple JavaScript object that will be passed directly to the server as parameters. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### type [`ModelSchema`](../../../../core-types/index/interfaces/ModelSchema.md) ##### query `Record`<`string`, `unknown`> ##### adapterOptions `Record`<`string`, `unknown`> #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise #### Since 1.13.0 #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`queryRecord`](../../rest/classes/RESTAdapter.md#queryrecord) *** ### removeObserver() #### Call Signature ```ts removeObserver( key, target, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:352 Remove an observer you have previously registered on this object. Pass the same key, target, and method you passed to `addObserver()` and your target will no longer receive notifications. ##### Type Parameters ###### Target `Target` ##### Parameters ###### key keyof `JSONAPIAdapter` The key to observe ###### target `Target` The target object to invoke ###### method `ObserverMethod`<`Target`, `JSONAPIAdapter`> The method to invoke ##### Returns `this` ##### Method removeObserver ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`removeObserver`](../../rest/classes/RESTAdapter.md#removeobserver) #### Call Signature ```ts removeObserver(key, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:357 ##### Parameters ###### key keyof `JSONAPIAdapter` ###### method `ObserverMethod`<`JSONAPIAdapter`, `JSONAPIAdapter`> ##### Returns `this` ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`removeObserver`](../../rest/classes/RESTAdapter.md#removeobserver) *** ### reopen() ```ts reopen(...args): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:81 #### Parameters ##### args ...(`Record`<`string`, `unknown`> | `Mixin`)\[] #### Returns `this` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`reopen`](../../rest/classes/RESTAdapter.md#reopen) *** ### serialize() ```ts serialize(snapshot, options): Record; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:476](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L476) Proxies to the serializer's `serialize` method. Example ```js [app/adapters/application.js] import { Adapter } from '@warp-drive/legacy/adapter'; export default class ApplicationAdapter extends Adapter { createRecord(store, type, snapshot) { let data = this.serialize(snapshot, { includeId: true }); let url = `/${type.modelName}`; // ... } } ``` #### Parameters ##### snapshot `Snapshot` ##### options [`SerializerOptions`](../../../compat/type-aliases/SerializerOptions.md) #### Returns `Record`<`string`, `unknown`> serialized snapshot #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`serialize`](../../rest/classes/RESTAdapter.md#serialize) *** ### set() #### Call Signature ```ts set(key, value): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:208 Sets the provided key or path to the value. ```javascript record.set("key", value); ``` This method is generally very similar to calling `object["key"] = value` or `object.key = value`, except that it provides support for computed properties, the `setUnknownProperty()` method and property observers. ### Computed Properties If you try to set a value on a key that has a computed property handler defined (see the `get()` method for an example), then `set()` will call that method, passing both the value and key instead of simply changing the value itself. This is useful for those times when you need to implement a property that is composed of one or more member properties. ### Unknown Properties If you try to set a value on a key that is undefined in the target object, then the `setUnknownProperty()` handler will be called instead. This gives you an opportunity to implement complex "virtual" properties that are not predefined on the object. If `setUnknownProperty()` returns undefined, then `set()` will simply set the value on the object. ### Property Observers In addition to changing the property, `set()` will also register a property change with the object. Unless you have placed this call inside of a `beginPropertyChanges()` and `endPropertyChanges(),` any "local" observers (i.e. observer methods declared on the same object), will be called immediately. Any "remote" observers (i.e. observer methods declared on another object) will be placed in a queue and called at a later time in a coalesced manner. ##### Type Parameters ###### K `K` *extends* keyof `JSONAPIAdapter` ###### T `T` *extends* | `undefined` | `null` | `string` | `number` | `boolean` | `Record`<`string`, `unknown`> | `unknown`\[] | [`default`](../../../../../@ember-data/store/index/classes/default.md) | `string`\[] | `Owner` | (`this`, `id`, `modelName`, `snapshot`) => `string` | (`this`, `modelName`, `snapshots`) => `string` | (`this`, `query`, `modelName`) => `string` | (`this`, `query`, `modelName`) => `string` | (`this`, `ids`, `modelName`, `snapshots`) => `string` | (`this`, `id`, `modelName`, `snapshot`) => `string` | (`this`, `id`, `modelName`, `snapshot`) => `string` | (`this`, `modelName`, `snapshot`) => `string` | (`this`, `id`, `modelName`, `snapshot`) => `string` | (`this`, `id`, `modelName`, `snapshot`) => `string` | (`this`, `modelName`, `id?`) => `string` | (`this`, `path?`, `parentURL?`) => `string` | { (`this`, `modelName`, `id`, `snapshot`, `requestType`): `string`; (`this`, `modelName`, `id`, `snapshot`, `requestType`): `string`; (`this`, `modelName`, `id`, `snapshot`, `requestType`, `query`): `string`; (`this`, `modelName`, `id`, `snapshot`, `requestType`, `query`): `string`; (`this`, `modelName`, `id`, `snapshot`, `requestType`): `string`; (`this`, `modelName`, `id`, `snapshot`, `requestType`): `string`; (`this`, `modelName`, `id`, `snapshot`, `requestType`): `string`; (`this`, `modelName`, `id`, `snapshot`, `requestType`): `string`; (`this`, `modelName`, `id`, `snapshot`, `requestType`): `string`; (`this`, `modelName`, `id`, `snapshot`, `requestType`): `string`; (`this`, `modelName`, `id`, `snapshot`): `string`; } | (`store`, `snapshot`) => `boolean` | (`store`, `snapshotRecordArray`) => `boolean` | (`store`, `snapshot`) => `boolean` | (`store`, `snapshotRecordArray`) => `boolean` | () => `string` | { } | () => `void` | `FastBoot` | (`store`, `type`, `id`, `snapshot`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | (`store`, `type`, `sinceToken`, `snapshotRecordArray`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | (`store`, `type`, `query`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | (`store`, `type`, `query`, `adapterOptions`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | (`store`, `type`, `snapshot`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | (`store`, `schema`, `snapshot`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | (`store`, `snapshots`) => `Snapshot`<`unknown`>\[]\[] | (`obj`) => `Record`<`string`, `unknown`> | (`status`, `_headers`, `_payload`) => `boolean` | (`status`, `_headers`, `_payload`) => `boolean` | { } | { } | (`options`) => `Promise`<`Response`> | { } | (`url`) => `string` | (`store`, `snapshot`) => `string` | (`store`, `type`, `ids`, `snapshots`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | (`store`, `schema`, `snapshot`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | { } | (`snapshot`) => [`QueryState`](../../rest/type-aliases/QueryState.md) | (`modelName`) => `string` | (`snapshot`, `options`) => `Record`<`string`, `unknown`> | (`store`, `snapshot`, `url`, `relationship`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | (`store`, `snapshot`, `url`, `relationship`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | (`status`, `headers`, `payload`, `requestData`) => `Payload` | *typeof* `_AdapterError` | { } | (`options`) => `void` | { } | (...`args`) => `this` | (`_properties`) => `void` | () => `this` | { <`K`> (`key`): `JSONAPIAdapter`\[`K`]; (`key`): `unknown`; } | { <`L`> (`list`): `{ [Key in keyof JSONAPIAdapter]: JSONAPIAdapter[Key] }`; <`L`> (...`list`): `{ [Key in keyof JSONAPIAdapter]: JSONAPIAdapter[Key] }`; <`L`> (`list`): `{ [Key in string]: unknown }`; <`L`> (...`list`): `{ [Key in string]: unknown }`; } | { <`K`, `T`> (`key`, `value`): `T`; <`T`> (`key`, `value`): `T`; } | { <`K`, `P`> (`hash`): `P`; <`T`> (`hash`): `T`; } | (`keyName`) => `this` | { <`Target`> (`key`, `target`, `method`): `this`; (`key`, `method`): `this`; } | { <`Target`> (`key`, `target`, `method`): `this`; (`key`, `method`): `this`; } | (`keyName`, `increment?`) => `number` | (`keyName`, `decrement?`) => `number` | (`keyName`) => `boolean` | <`K`>(`key`) => `unknown` ##### Parameters ###### key `K` ###### value `T` The value to set or `null`. ##### Returns `T` The passed value ##### Method set ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`set`](../../rest/classes/RESTAdapter.md#set) #### Call Signature ```ts set(key, value): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:209 ##### Type Parameters ###### T `T` ##### Parameters ###### key `string` ###### value `T` ##### Returns `T` ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`set`](../../rest/classes/RESTAdapter.md#set) *** ### setProperties() #### Call Signature ```ts setProperties(hash): P; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:224 Sets a list of properties at once. These properties are set inside a single `beginPropertyChanges` and `endPropertyChanges` batch, so observers will be buffered. ```javascript record.setProperties({ firstName: 'Charles', lastName: 'Jolley' }); ``` ##### Type Parameters ###### K `K` *extends* keyof `JSONAPIAdapter` ###### P `P` *extends* `{ [Key in keyof JSONAPIAdapter]: JSONAPIAdapter[Key] }` ##### Parameters ###### hash `P` the hash of keys and values to set ##### Returns `P` The passed in hash ##### Method setProperties ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`setProperties`](../../rest/classes/RESTAdapter.md#setproperties) #### Call Signature ```ts setProperties(hash): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:232 ##### Type Parameters ###### T `T` *extends* `Record`<`string`, `unknown`> ##### Parameters ###### hash `T` ##### Returns `T` ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`setProperties`](../../rest/classes/RESTAdapter.md#setproperties) *** ### shouldBackgroundReloadAll() ```ts shouldBackgroundReloadAll(store, snapshotRecordArray): boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:887](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L887) This method is used by the store to determine if the store should reload a record array after the `store.findAll` method resolves with a cached record array. This method is *only* checked by the store when the store is returning a cached record array. If this method returns `true` the store will re-fetch all records from the adapter. For example, if you do not want to fetch complex data over a mobile connection, or if the network is down, you can implement `shouldBackgroundReloadAll` as follows: ```javascript shouldBackgroundReloadAll(store, snapshotArray) { let { downlink, effectiveType } = navigator.connection; return downlink > 0 && effectiveType === '4g'; } ``` By default this method returns `true`, indicating that a background reload should always be triggered. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### snapshotRecordArray `SnapshotRecordArray` #### Returns `boolean` #### Since 1.13.0 #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`shouldBackgroundReloadAll`](../../rest/classes/RESTAdapter.md#shouldbackgroundreloadall) *** ### shouldBackgroundReloadRecord() ```ts shouldBackgroundReloadRecord(store, snapshot): boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:851](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L851) This method is used by the store to determine if the store should reload a record after the `store.findRecord` method resolves a cached record. This method is *only* checked by the store when the store is returning a cached record. If this method returns `true` the store will re-fetch a record from the adapter. For example, if you do not want to fetch complex data over a mobile connection, or if the network is down, you can implement `shouldBackgroundReloadRecord` as follows: ```javascript shouldBackgroundReloadRecord(store, snapshot) { let { downlink, effectiveType } = navigator.connection; return downlink > 0 && effectiveType === '4g'; } ``` By default, this hook returns `true` so the data for the record is updated in the background. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### snapshot `Snapshot` #### Returns `boolean` #### Since 1.13.0 #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`shouldBackgroundReloadRecord`](../../rest/classes/RESTAdapter.md#shouldbackgroundreloadrecord) *** ### shouldReloadAll() ```ts shouldReloadAll(store, snapshotRecordArray): boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:815](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L815) This method is used by the store to determine if the store should reload all records from the adapter when records are requested by `store.findAll`. If this method returns `true`, the store will re-fetch all records from the adapter. If this method returns `false`, the store will resolve immediately using the cached records. For example, if you are building an events ticketing system, in which users can only reserve tickets for 20 minutes at a time, and want to ensure that in each route you have data that is no more than 20 minutes old you could write: ```javascript shouldReloadAll(store, snapshotArray) { let snapshots = snapshotArray.snapshots(); return snapshots.any((ticketSnapshot) => { let lastAccessedAt = ticketSnapshot.attr('lastAccessedAt'); let timeDiff = moment().diff(lastAccessedAt, 'minutes'); if (timeDiff > 20) { return true; } else { return false; } }); } ``` This method would ensure that whenever you do `store.findAll('ticket')` you will always get a list of tickets that are no more than 20 minutes old. In case a cached version is more than 20 minutes old, `findAll` will not resolve until you fetched the latest versions. By default, this method returns `true` if the passed `snapshotRecordArray` is empty (meaning that there are no records locally available yet), otherwise, it returns `false`. Note that, with default settings, `shouldBackgroundReloadAll` will always re-fetch all the records in the background even if `shouldReloadAll` returns `false`. You can override `shouldBackgroundReloadAll` if this does not suit your use case. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### snapshotRecordArray `SnapshotRecordArray` #### Returns `boolean` #### Since 1.13.0 #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`shouldReloadAll`](../../rest/classes/RESTAdapter.md#shouldreloadall) *** ### shouldReloadRecord() ```ts shouldReloadRecord(store, snapshot): boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:760](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L760) This method is used by the store to determine if the store should reload a record from the adapter when a record is requested by `store.findRecord`. If this method returns `true`, the store will re-fetch a record from the adapter. If this method returns `false`, the store will resolve immediately using the cached record. For example, if you are building an events ticketing system, in which users can only reserve tickets for 20 minutes at a time, and want to ensure that in each route you have data that is no more than 20 minutes old you could write: ```javascript shouldReloadRecord(store, ticketSnapshot) { let lastAccessedAt = ticketSnapshot.attr('lastAccessedAt'); let timeDiff = moment().diff(lastAccessedAt, 'minutes'); if (timeDiff > 20) { return true; } else { return false; } } ``` This method would ensure that whenever you do `store.findRecord('ticket', id)` you will always get a ticket that is no more than 20 minutes old. In case the cached version is more than 20 minutes old, `findRecord` will not resolve until you fetched the latest version. By default this hook returns `false`, as most UIs should not block user interactions while waiting on data update. Note that, with default settings, `shouldBackgroundReloadRecord` will always re-fetch the records in the background even if `shouldReloadRecord` returns `false`. You can override `shouldBackgroundReloadRecord` if this does not suit your use case. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### snapshot `Snapshot` #### Returns `boolean` #### Since 1.13.0 #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`shouldReloadRecord`](../../rest/classes/RESTAdapter.md#shouldreloadrecord) *** ### sortQueryParams() ```ts sortQueryParams(obj): Record; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:375](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L375) By default, the RESTAdapter will send the query params sorted alphabetically to the server. For example: ```js store.query('posts', { sort: 'price', category: 'pets' }); ``` will generate a requests like this `/posts?category=pets&sort=price`, even if the parameters were specified in a different order. That way the generated URL will be deterministic and that simplifies caching mechanisms in the backend. Setting `sortQueryParams` to a falsey value will respect the original order. In case you want to sort the query parameters with a different criteria, set `sortQueryParams` to your custom sort function. ```js [app/adapters/application.js] import { RESTAdapter } from '@warp-drive/legacy/adapter/rest'; export default class ApplicationAdapter extends RESTAdapter { sortQueryParams(params) { let sortedKeys = Object.keys(params).sort().reverse(); let len = sortedKeys.length, newParams = {}; for (let i = 0; i < len; i++) { newParams[sortedKeys[i]] = params[sortedKeys[i]]; } return newParams; } } ``` #### Parameters ##### obj `Record`<`string`, `unknown`> #### Returns `Record`<`string`, `unknown`> #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`sortQueryParams`](../../rest/classes/RESTAdapter.md#sortqueryparams) *** ### toggleProperty() ```ts toggleProperty(keyName): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:401 Set the value of a boolean property to the opposite of its current value. ```javascript starship.toggleProperty('warpDriveEngaged'); ``` #### Parameters ##### keyName keyof `JSONAPIAdapter` The name of the property to toggle #### Returns `boolean` The new property value #### Method toggleProperty #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`toggleProperty`](../../rest/classes/RESTAdapter.md#toggleproperty) *** ### toString() ```ts toString(): string; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:347 Returns a string representation which attempts to provide more information than Javascript's `toString` typically does, in a generic way for all Ember objects. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend(); person = Person.create(); person.toString(); //=> "" ``` If the object's class is not defined on an Ember namespace, it will indicate it is a subclass of the registered superclass: ```javascript const Student = Person.extend(); let student = Student.create(); student.toString(); //=> "<(subclass of Person):ember1025>" ``` If the method `toStringExtension` is defined, its return value will be included in the output. ```javascript const Teacher = Person.extend({ toStringExtension() { return this.get('fullName'); } }); teacher = Teacher.create(); teacher.toString(); //=> "" ``` #### Returns `string` string representation #### Method toString #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`toString`](../../rest/classes/RESTAdapter.md#tostring) *** ### updateRecord() ```ts updateRecord( store, schema, snapshot): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/json-api.ts:256](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/json-api.ts#L256) Called by the store when an existing record is saved via the `save` method on a model record instance. The `updateRecord` method serializes the record and makes an Ajax (HTTP PUT) request to a URL computed by `buildURL`. See `serialize` for information on how to customize the serialized form of a record. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### schema [`ModelSchema`](../../../../core-types/index/interfaces/ModelSchema.md) ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise #### Overrides [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`updateRecord`](../../rest/classes/RESTAdapter.md#updaterecord) *** ### urlForCreateRecord() ```ts urlForCreateRecord( this, modelName, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:99](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L99) #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`urlForCreateRecord`](../../rest/classes/RESTAdapter.md#urlforcreaterecord) *** ### urlForDeleteRecord() ```ts urlForDeleteRecord( this, id, modelName, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:101](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L101) #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`urlForDeleteRecord`](../../rest/classes/RESTAdapter.md#urlfordeleterecord) *** ### urlForFindAll() ```ts urlForFindAll( this, modelName, snapshots): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:93](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L93) #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `string` ##### snapshots `SnapshotRecordArray` #### Returns `string` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`urlForFindAll`](../../rest/classes/RESTAdapter.md#urlforfindall) *** ### urlForFindBelongsTo() ```ts urlForFindBelongsTo( this, id, modelName, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:98](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L98) #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`urlForFindBelongsTo`](../../rest/classes/RESTAdapter.md#urlforfindbelongsto) *** ### urlForFindHasMany() ```ts urlForFindHasMany( this, id, modelName, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:97](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L97) #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`urlForFindHasMany`](../../rest/classes/RESTAdapter.md#urlforfindhasmany) *** ### urlForFindMany() ```ts urlForFindMany( this, ids, modelName, snapshots): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:96](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L96) #### Parameters ##### this `MixtBuildURLMixin` ##### ids `string`\[] ##### modelName `string` ##### snapshots `Snapshot`<`unknown`>\[] #### Returns `string` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`urlForFindMany`](../../rest/classes/RESTAdapter.md#urlforfindmany) *** ### urlForFindRecord() ```ts urlForFindRecord( this, id, modelName, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:92](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L92) #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`urlForFindRecord`](../../rest/classes/RESTAdapter.md#urlforfindrecord) *** ### urlForQuery() ```ts urlForQuery( this, query, modelName): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:95](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L95) #### Parameters ##### this `MixtBuildURLMixin` ##### query `Record`<`string`, `unknown`> ##### modelName `string` #### Returns `string` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`urlForQuery`](../../rest/classes/RESTAdapter.md#urlforquery) *** ### urlForQueryRecord() ```ts urlForQueryRecord( this, query, modelName): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:94](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L94) #### Parameters ##### this `MixtBuildURLMixin` ##### query `Record`<`string`, `unknown`> ##### modelName `string` #### Returns `string` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`urlForQueryRecord`](../../rest/classes/RESTAdapter.md#urlforqueryrecord) *** ### urlForUpdateRecord() ```ts urlForUpdateRecord( this, id, modelName, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:100](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L100) #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`urlForUpdateRecord`](../../rest/classes/RESTAdapter.md#urlforupdaterecord) *** ### urlPrefix() ```ts urlPrefix( this, path?, parentURL?): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:102](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L102) #### Parameters ##### this `MixtBuildURLMixin` ##### path? `null` | `string` ##### parentURL? `string` #### Returns `string` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`urlPrefix`](../../rest/classes/RESTAdapter.md#urlprefix) *** ### willDestroy() ```ts willDestroy(): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:307 Override to implement teardown. #### Returns `void` #### Method willDestroy #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`willDestroy`](../../rest/classes/RESTAdapter.md#willdestroy) *** ### create() #### Call Signature ```ts readonly static create(this): InstanceType; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:487 Creates an instance of a class. Accepts either no arguments, or an object containing values to initialize the newly instantiated object with. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ helloWorld() { alert(`Hi, my name is ${this.get('name')}`); } }); let tom = Person.create({ name: 'Tom Dale' }); tom.helloWorld(); // alerts "Hi, my name is Tom Dale". ``` `create` will call the `init` function if defined during `AnyObject.extend` If no arguments are passed to `create`, it will not set values to the new instance during initialization: ```javascript let noName = Person.create(); noName.helloWorld(); // alerts undefined ``` NOTE: For performance reasons, you cannot declare methods or computed properties during `create`. You should instead declare methods and computed properties when using `extend`. ##### Type Parameters ###### C `C` *extends* *typeof* `CoreObject` ##### Parameters ###### this `C` ##### Returns `InstanceType`<`C`> ##### Method create ##### For @ember/object ##### Static ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`create`](../../rest/classes/RESTAdapter.md#create) #### Call Signature ```ts readonly static create(this, ...args): InstanceType & MergeArray; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:488 Creates an instance of a class. Accepts either no arguments, or an object containing values to initialize the newly instantiated object with. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ helloWorld() { alert(`Hi, my name is ${this.get('name')}`); } }); let tom = Person.create({ name: 'Tom Dale' }); tom.helloWorld(); // alerts "Hi, my name is Tom Dale". ``` `create` will call the `init` function if defined during `AnyObject.extend` If no arguments are passed to `create`, it will not set values to the new instance during initialization: ```javascript let noName = Person.create(); noName.helloWorld(); // alerts undefined ``` NOTE: For performance reasons, you cannot declare methods or computed properties during `create`. You should instead declare methods and computed properties when using `extend`. ##### Type Parameters ###### C `C` *extends* *typeof* `CoreObject` ###### I `I` *extends* `CoreObject` ###### K `K` *extends* `string` | `number` | `symbol` ###### Args `Args` *extends* `Partial`<{ \[Key in string | number | symbol]: I\[Key] }>\[] ##### Parameters ###### this `C` ###### args ...`Args` ##### Returns `InstanceType`<`C`> & `MergeArray`<`Args`> ##### Method create ##### For @ember/object ##### Static ##### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`create`](../../rest/classes/RESTAdapter.md#create) *** ### detectInstance() ```ts readonly static detectInstance(obj): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:600 #### Parameters ##### obj `unknown` #### Returns `boolean` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`detectInstance`](../../rest/classes/RESTAdapter.md#detectinstance) *** ### extend() ```ts readonly static extend(this, ...mixins?): Readonly & EmberClassConstructor & MergeArray; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:442 Creates a new subclass. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ say(thing) { alert(thing); } }); ``` This defines a new subclass of EmberObject: `Person`. It contains one method: `say()`. You can also create a subclass from any existing class by calling its `extend()` method. For example, you might want to create a subclass of Ember's built-in `Component` class: ```javascript import Component from '@ember/component'; const PersonComponent = Component.extend({ tagName: 'li', classNameBindings: ['isAdministrator'] }); ``` When defining a subclass, you can override methods but still access the implementation of your parent class by calling the special `_super()` method: ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ say(thing) { let name = this.get('name'); alert(`${name} says: ${thing}`); } }); const Soldier = Person.extend({ say(thing) { this._super(`${thing}, sir!`); }, march(numberOfHours) { alert(`${this.get('name')} marches for ${numberOfHours} hours.`); } }); let yehuda = Soldier.create({ name: 'Yehuda Katz' }); yehuda.say('Yes'); // alerts "Yehuda Katz says: Yes, sir!" ``` The `create()` on line #17 creates an *instance* of the `Soldier` class. The `extend()` on line #8 creates a *subclass* of `Person`. Any instance of the `Person` class will *not* have the `march()` method. You can also pass `Mixin` classes to add additional properties to the subclass. ```javascript import EmberObject from '@ember/object'; import Mixin from '@ember/object/mixin'; const Person = EmberObject.extend({ say(thing) { alert(`${this.get('name')} says: ${thing}`); } }); const SingingMixin = Mixin.create({ sing(thing) { alert(`${this.get('name')} sings: la la la ${thing}`); } }); const BroadwayStar = Person.extend(SingingMixin, { dance() { alert(`${this.get('name')} dances: tap tap tap tap `); } }); ``` The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. #### Type Parameters ##### Statics `Statics` ##### Instance `Instance` ##### M `M` *extends* `unknown`\[] #### Parameters ##### this `Statics` & `EmberClassConstructor`<`Instance`> ##### mixins? ...`M` One or more Mixin classes #### Returns `Readonly`<`Statics`> & `EmberClassConstructor`<`Instance`> & `MergeArray`<`M`> #### Method extend #### Static #### For @ember/object #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`extend`](../../rest/classes/RESTAdapter.md#extend) *** ### proto() ```ts readonly static proto(): CoreObject; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:649 #### Returns `CoreObject` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`proto`](../../rest/classes/RESTAdapter.md#proto) *** ### reopenClass() ```ts readonly static reopenClass(this, ...mixins): C; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:595 Augments a constructor's own properties and functions: ```javascript import EmberObject from '@ember/object'; const MyObject = EmberObject.extend({ name: 'an object' }); MyObject.reopenClass({ canBuild: false }); MyObject.canBuild; // false o = MyObject.create(); ``` In other words, this creates static properties and functions for the class. These are only available on the class and not on any instance of that class. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ name: '', sayHello() { alert(`Hello. My name is ${this.get('name')}`); } }); Person.reopenClass({ species: 'Homo sapiens', createPerson(name) { return Person.create({ name }); } }); let tom = Person.create({ name: 'Tom Dale' }); let yehuda = Person.createPerson('Yehuda Katz'); tom.sayHello(); // "Hello. My name is Tom Dale" yehuda.sayHello(); // "Hello. My name is Yehuda Katz" alert(Person.species); // "Homo sapiens" ``` Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` variables. They are only valid on `Person`. To add functions and properties to instances of a constructor by extending the constructor's prototype see `reopen` #### Type Parameters ##### C `C` *extends* *typeof* `CoreObject` #### Parameters ##### this `C` ##### mixins ...(`Record`<`string`, `unknown`> | `Mixin`)\[] #### Returns `C` #### Method reopenClass #### For @ember/object #### Static #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`reopenClass`](../../rest/classes/RESTAdapter.md#reopenclass) *** ### toString() ```ts static toString(): string; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:650 #### Returns `string` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`toString`](../../rest/classes/RESTAdapter.md#tostring-2) *** ### willReopen() ```ts readonly static willReopen(): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:533 #### Returns `void` #### Inherited from [`RESTAdapter`](../../rest/classes/RESTAdapter.md).[`willReopen`](../../rest/classes/RESTAdapter.md#willreopen) --- --- url: /api/@warp-drive/legacy/adapter/rest/classes/RESTAdapter.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/rest](../index.md) / RESTAdapter Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:300](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L300) The REST adapter allows your store to communicate with an HTTP server by transmitting JSON via XHR. This adapter is designed around the idea that the JSON exchanged with the server should be conventional. It builds URLs in a manner that follows the structure of most common REST-style web services. ## Success and failure The REST adapter will consider a success any response with a status code of the 2xx family ("Success"), as well as 304 ("Not Modified"). Any other status code will be considered a failure. On success, the request promise will be resolved with the full response payload. Failed responses with status code 422 ("Unprocessable Entity") will be considered "invalid". The response will be discarded, except for the `errors` key. The request promise will be rejected with a `InvalidError`. This error object will encapsulate the saved `errors` value. Any other status codes will be treated as an "adapter error". The request promise will be rejected, similarly to the "invalid" case, but with an instance of `AdapterError` instead. ## JSON Structure The REST adapter expects the JSON returned from your server to follow these conventions. ### Object Root The JSON payload should be an object that contains the record inside a root property. For example, in response to a `GET` request for `/posts/1`, the JSON should look like this: ```js { "posts": { "id": 1, "title": "I'm Running to Reform the W3C", "author": "Yehuda Katz" } } ``` Similarly, in response to a `GET` request for `/posts`, the JSON should look like this: ```js { "posts": [ { "id": 1, "title": "I'm Running to Reform the W3C", "author": "Yehuda Katz" }, { "id": 2, "title": "Rails is omakase", "author": "D2H" } ] } ``` Note that the object root can be pluralized for both a single-object response and an array response: the REST adapter is not strict on this. Further, if the HTTP server responds to a `GET` request to `/posts/1` (e.g. the response to a `findRecord` query) with more than one object in the array, Ember Data will only display the object with the matching ID. ### Conventional Names Attribute names in your JSON payload should be the camelCased versions of the attributes in your Ember.js models. For example, if you have a `Person` model: ```js [app/models/person.js] import { Model, attr } from '@warp-drive/legacy/model'; export default Model.extend({ firstName: attr('string'), lastName: attr('string'), occupation: attr('string') }); ``` The JSON returned should look like this: ```js { "people": { "id": 5, "firstName": "Zaphod", "lastName": "Beeblebrox", "occupation": "President" } } ``` #### Relationships Relationships are usually represented by ids to the record in the relationship. The related records can then be sideloaded in the response under a key for the type. ```js { "posts": { "id": 5, "title": "I'm Running to Reform the W3C", "author": "Yehuda Katz", "comments": [1, 2] }, "comments": [{ "id": 1, "author": "User 1", "message": "First!", }, { "id": 2, "author": "User 2", "message": "Good Luck!", }] } ``` If the records in the relationship are not known when the response is serialized it's also possible to represent the relationship as a URL using the `links` key in the response. Ember Data will fetch this URL to resolve the relationship when it is accessed for the first time. ```js { "posts": { "id": 5, "title": "I'm Running to Reform the W3C", "author": "Yehuda Katz", "links": { "comments": "/posts/5/comments" } } } ``` ### Errors If a response is considered a failure, the JSON payload is expected to include a top-level key `errors`, detailing any specific issues. For example: ```js { "errors": { "msg": "Something went wrong" } } ``` This adapter does not make any assumptions as to the format of the `errors` object. It will simply be passed along as is, wrapped in an instance of `InvalidError` or `AdapterError`. The serializer can interpret it afterwards. ## Customization ### Endpoint path customization Endpoint paths can be prefixed with a `namespace` by setting the namespace property on the adapter: ```js [app/adapters/application.js] import { RESTAdapter } from '@warp-drive/legacy/adapter/rest'; export default class ApplicationAdapter extends RESTAdapter { namespace = 'api/1'; } ``` Requests for the `Person` model would now target `/api/1/people/1`. ### Host customization An adapter can target other hosts by setting the `host` property. ```js [app/adapters/application.js] import { RESTAdapter } from '@warp-drive/legacy/adapter/rest'; export default class ApplicationAdapter extends RESTAdapter { host = 'https://api.example.com'; } ``` ### Headers customization Some APIs require HTTP headers, e.g. to provide an API key. Arbitrary headers can be set as key/value pairs on the `RESTAdapter`'s `headers` object and WarpDrive will send them along with each ajax request. ```js [app/adapters/application.js] import { RESTAdapter } from '@warp-drive/legacy/adapter/rest'; export default class ApplicationAdapter extends RESTAdapter { get headers() { return { 'API_KEY': 'secret key', 'ANOTHER_HEADER': 'Some header value' }; } } ``` RESTAdapter ## Uses BuildURLMixin ## Extends * [`Adapter`](../../classes/Adapter.md)<`this`>.`MixtBuildURLMixin` ## Extended by * [`JSONAPIAdapter`](../../json-api/classes/JSONAPIAdapter.md) ## Constructors ### Constructor ```ts new RESTAdapter(owner?): RESTAdapter; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:8 #### Parameters ##### owner? `Owner` #### Returns `RESTAdapter` #### Inherited from [`Adapter`](../../classes/Adapter.md).[`constructor`](../../classes/Adapter.md#constructor) ## Properties ### \_coalesceFindRequests ```ts _coalesceFindRequests: boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:302](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L302) #### Overrides [`Adapter`](../../classes/Adapter.md).[`_coalesceFindRequests`](../../classes/Adapter.md#_coalescefindrequests) *** ### \_defaultContentType ```ts _defaultContentType: string = 'application/json; charset=utf-8'; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:316](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L316) *** ### \_fastboot ```ts _fastboot: FastBoot; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:301](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L301) *** ### concatenatedProperties? ```ts optional concatenatedProperties: string | string[]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:655 #### Inherited from [`Adapter`](../../classes/Adapter.md).[`concatenatedProperties`](../../classes/Adapter.md#concatenatedproperties) *** ### headers ```ts headers: undefined | Record; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:511](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L511) Some APIs require HTTP headers, e.g. to provide an API key. Arbitrary headers can be set as key/value pairs on the `RESTAdapter`'s `headers` object and Ember Data will send them along with each ajax request. For dynamic headers see [headers customization](/ember-data/release/classes/RESTAdapter). ```js [app/adapters/application.js] import { RESTAdapter } from '@warp-drive/legacy/adapter/rest'; export default class ApplicationAdapter extends RESTAdapter { get headers() { return { 'API_KEY': 'secret key', 'ANOTHER_HEADER': 'Some header value' }; } } ``` *** ### host ```ts host: null | string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:303](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L303) *** ### maxURLLength ```ts maxURLLength: number = 2048; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:867](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L867) *** ### mergedProperties? ```ts optional mergedProperties: unknown[]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:656 #### Inherited from [`Adapter`](../../classes/Adapter.md).[`mergedProperties`](../../classes/Adapter.md#mergedproperties) *** ### namespace ```ts namespace: null | string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:304](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L304) *** ### store ```ts store: default; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:258](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L258) #### Inherited from [`Adapter`](../../classes/Adapter.md).[`store`](../../classes/Adapter.md#store) *** ### useFetch ```ts useFetch: boolean = true; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:314](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L314) This property allows ajax to still be used instead when `false`. #### Default ```ts true @public ``` *** ### \_lazyInjections()? ```ts readonly static optional _lazyInjections: () => void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:654 #### Returns `void` #### Inherited from [`Adapter`](../../classes/Adapter.md).[`_lazyInjections`](../../classes/Adapter.md#_lazyinjections) *** ### \_onLookup()? ```ts readonly static optional _onLookup: (debugContainerKey) => void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:653 #### Parameters ##### debugContainerKey `string` #### Returns `void` #### Inherited from [`Adapter`](../../classes/Adapter.md).[`_onLookup`](../../classes/Adapter.md#_onlookup) *** ### \[INIT\_FACTORY]? ```ts static optional [INIT_FACTORY]: null; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/mixin.d.ts:116 #### Inherited from [`Adapter`](../../classes/Adapter.md).[`[INIT_FACTORY]`](../../classes/Adapter.md#init_factory) *** ### isClass ```ts readonly static isClass: boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:651 #### Inherited from [`Adapter`](../../classes/Adapter.md).[`isClass`](../../classes/Adapter.md#isclass) *** ### isMethod ```ts readonly static isMethod: boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:652 #### Inherited from [`Adapter`](../../classes/Adapter.md).[`isMethod`](../../classes/Adapter.md#ismethod) *** ### PrototypeMixin ```ts static PrototypeMixin: any; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:647 #### Inherited from [`Adapter`](../../classes/Adapter.md).[`PrototypeMixin`](../../classes/Adapter.md#prototypemixin) *** ### superclass ```ts static superclass: any; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:648 #### Inherited from [`Adapter`](../../classes/Adapter.md).[`superclass`](../../classes/Adapter.md#superclass) ## Accessors ### \_debugContainerKey #### Get Signature ```ts get _debugContainerKey(): false | `${string}:${string}`; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/index.d.ts:34 ##### Returns `false` | `` `${string}:${string}` `` #### Inherited from [`Adapter`](../../classes/Adapter.md).[`_debugContainerKey`](../../classes/Adapter.md#_debugcontainerkey) *** ### coalesceFindRequests #### Get Signature ```ts get coalesceFindRequests(): boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:438](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L438) By default the RESTAdapter will send each find request coming from a `store.find` or from accessing a relationship separately to the server. If your server supports passing ids as a query string, you can set coalesceFindRequests to true to coalesce all find requests within a single runloop. For example, if you have an initial payload of: ```javascript { post: { id: 1, comments: [1, 2] } } ``` By default calling `post.comments` will trigger the following requests(assuming the comments haven't been loaded before): ``` GET /comments/1 GET /comments/2 ``` If you set coalesceFindRequests to `true` it will instead trigger the following request: ``` GET /comments?ids[]=1&ids[]=2 ``` Setting coalesceFindRequests to `true` also works for `store.find` requests and `belongsTo` relationships accessed within the same runloop. If you set `coalesceFindRequests: true` ```javascript store.findRecord('comment', 1); store.findRecord('comment', 2); ``` will also send a request to: `GET /comments?ids[]=1&ids[]=2` Note: Requests coalescing rely on URL building strategy. So if you override `buildURL` in your app `groupRecordsForFindMany` more likely should be overridden as well in order for coalescing to work. ##### Returns `boolean` #### Set Signature ```ts set coalesceFindRequests(value): void; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:446](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L446) By default the store will try to coalesce all `findRecord` calls within the same runloop into as few requests as possible by calling groupRecordsForFindMany and passing it into a findMany call. You can opt out of this behaviour by either not implementing the findMany hook or by setting coalesceFindRequests to false. ##### Parameters ###### value `boolean` ##### Returns `void` **`Optional`** If your adapter implements `findMany`, setting this to `true` will cause `findRecord` requests triggered within the same `runloop` to be coalesced into one or more calls to `adapter.findMany`. The number of calls made and the records contained in each call can be tuned by your adapter's `groupRecordsForHasMany` method. Implementing coalescing using this flag and the associated methods does not always offer the right level of correctness, timing control or granularity. If your application would be better suited coalescing across multiple types, coalescing for longer than a single runloop, or with a more custom request structure, coalescing within your application adapter may prove more effective. #### Overrides [`Adapter`](../../classes/Adapter.md).[`coalesceFindRequests`](../../classes/Adapter.md#coalescefindrequests) *** ### fastboot #### Get Signature ```ts get fastboot(): FastBoot; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:319](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L319) ##### Returns `FastBoot` #### Set Signature ```ts set fastboot(value): void; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:329](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L329) ##### Parameters ###### value `FastBoot` ##### Returns `void` *** ### isDestroyed #### Get Signature ```ts get isDestroyed(): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:272 Destroyed object property flag. if this property is `true` the observers and bindings were already removed by the effect of calling the `destroy()` method. ##### Default ```ts false @public ``` ##### Returns `boolean` #### Set Signature ```ts set isDestroyed(_value): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:273 ##### Parameters ###### \_value `boolean` ##### Returns `void` #### Inherited from [`Adapter`](../../classes/Adapter.md).[`isDestroyed`](../../classes/Adapter.md#isdestroyed) *** ### isDestroying #### Get Signature ```ts get isDestroying(): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:284 Destruction scheduled flag. The `destroy()` method has been called. The object stays intact until the end of the run loop at which point the `isDestroyed` flag is set. ##### Default ```ts false @public ``` ##### Returns `boolean` #### Set Signature ```ts set isDestroying(_value): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:285 ##### Parameters ###### \_value `boolean` ##### Returns `void` #### Inherited from [`Adapter`](../../classes/Adapter.md).[`isDestroying`](../../classes/Adapter.md#isdestroying) ## Methods ### \_ajax() ```ts _ajax(options): void; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:1068](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L1068) #### Parameters ##### options [`FetchRequestInit`](../interfaces/FetchRequestInit.md) | [`JQueryRequestInit`](../interfaces/JQueryRequestInit.md) #### Returns `void` *** ### \_ajaxURL() ```ts _ajaxURL(url): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:1132](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L1132) #### Parameters ##### url `string` #### Returns `string` *** ### \_buildURL() ```ts _buildURL( this, modelName, id?): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:91](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L91) #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `undefined` | `null` | `string` ##### id? `null` | `string` #### Returns `string` *** ### \_fetchRequest() ```ts _fetchRequest(options): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:1062](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L1062) #### Parameters ##### options [`FetchRequestInit`](../interfaces/FetchRequestInit.md) #### Returns `Promise`<`Response`> *** ### \_stripIDFromURL() ```ts _stripIDFromURL(store, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:839](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L839) #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### snapshot `Snapshot` #### Returns `string` *** ### addObserver() #### Call Signature ```ts addObserver( key, target, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:333 Adds an observer on a property. This is the core method used to register an observer for a property. Once you call this method, any time the key's value is set, your observer will be notified. Note that the observers are triggered any time the value is set, regardless of whether it has actually changed. Your observer should be prepared to handle that. There are two common invocation patterns for `.addObserver()`: * Passing two arguments: * the name of the property to observe (as a string) * the function to invoke (an actual function) * Passing three arguments: * the name of the property to observe (as a string) * the target object (will be used to look up and invoke a function on) * the name of the function to invoke on the target object (as a string). ```app/components/my-component.js import Component from '@ember/component'; export default Component.extend({ init() { this._super(...arguments); // the following are equivalent: // using three arguments this.addObserver('foo', this, 'fooDidChange'); // using two arguments this.addObserver('foo', (...args) => { this.fooDidChange(...args); }); }, fooDidChange() { // your custom logic code } }); ``` ### Observer Methods Observer methods have the following signature: ```app/components/my-component.js import Component from '@ember/component'; export default Component.extend({ init() { this._super(...arguments); this.addObserver('foo', this, 'fooDidChange'); }, fooDidChange(sender, key, value, rev) { // your code } }); ``` The `sender` is the object that changed. The `key` is the property that changes. The `value` property is currently reserved and unused. The `rev` is the last property revision of the object when it changed, which you can use to detect if the key value has really changed or not. Usually you will not need the value or revision parameters at the end. In this case, it is common to write observer methods that take only a sender and key value as parameters or, if you aren't interested in any of these values, to write an observer that has no parameters at all. ##### Type Parameters ###### Target `Target` ##### Parameters ###### key keyof `RESTAdapter` The key to observe ###### target `Target` The target object to invoke ###### method `ObserverMethod`<`Target`, `RESTAdapter`> The method to invoke ##### Returns `this` ##### Method addObserver ##### Inherited from [`Adapter`](../../classes/Adapter.md).[`addObserver`](../../classes/Adapter.md#addobserver) #### Call Signature ```ts addObserver(key, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:338 ##### Parameters ###### key keyof `RESTAdapter` ###### method `ObserverMethod`<`RESTAdapter`, `RESTAdapter`> ##### Returns `this` ##### Inherited from [`Adapter`](../../classes/Adapter.md).[`addObserver`](../../classes/Adapter.md#addobserver) *** ### buildQuery() ```ts buildQuery(snapshot): QueryState; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:1249](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L1249) Used by `findAll` and `findRecord` to build the query's `data` hash supplied to the ajax method. #### Parameters ##### snapshot `Snapshot`<`unknown`> | `SnapshotRecordArray` #### Returns [`QueryState`](../type-aliases/QueryState.md) #### Since 2.5.0 *** ### buildURL() #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:18](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L18) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"findRecord"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:25](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L25) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` ###### snapshot `SnapshotRecordArray` ###### requestType `"findAll"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType, query): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:32](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L32) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` ###### snapshot `null` ###### requestType `"query"` ###### query `Record`<`string`, `unknown`> ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType, query): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:40](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L40) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` ###### snapshot `null` ###### requestType `"queryRecord"` ###### query `Record`<`string`, `unknown`> ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:48](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L48) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string`\[] ###### snapshot `Snapshot`<`unknown`>\[] ###### requestType `"findMany"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:55](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L55) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"findHasMany"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:62](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L62) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"findBelongsTo"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:69](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L69) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `null` | `string` ###### snapshot `Snapshot` ###### requestType `"createRecord"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:76](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L76) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"updateRecord"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot, requestType): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:83](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L83) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ###### requestType `"deleteRecord"` ##### Returns `string` #### Call Signature ```ts buildURL( this, modelName, id, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:90](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L90) ##### Parameters ###### this `MixtBuildURLMixin` ###### modelName `string` ###### id `string` ###### snapshot `Snapshot` ##### Returns `string` *** ### cacheFor() ```ts cacheFor(key): unknown; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:413 Returns the cached value of a computed property, if it exists. This allows you to inspect the value of a computed property without accidentally invoking it if it is intended to be generated lazily. #### Type Parameters ##### K `K` *extends* keyof `RESTAdapter` #### Parameters ##### key `K` #### Returns `unknown` The cached value of the computed property, if any #### Method cacheFor #### Inherited from [`Adapter`](../../classes/Adapter.md).[`cacheFor`](../../classes/Adapter.md#cachefor) *** ### createRecord() ```ts createRecord( store, type, snapshot): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:786](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L786) Called by the store when a newly created record is saved via the `save` method on a model record instance. The `createRecord` method serializes the record and makes an Ajax (HTTP POST) request to a URL computed by `buildURL`. See `serialize` for information on how to customize the serialized form of a record. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### type [`ModelSchema`](../../../../core-types/index/interfaces/ModelSchema.md) ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise #### Overrides [`Adapter`](../../classes/Adapter.md).[`createRecord`](../../classes/Adapter.md#createrecord) *** ### decrementProperty() ```ts decrementProperty(keyName, decrement?): number; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:387 Set the value of a property to the current value minus some amount. ```javascript player.decrementProperty('lives'); orc.decrementProperty('health', 5); ``` #### Parameters ##### keyName keyof `RESTAdapter` The name of the property to decrement ##### decrement? `number` The amount to decrement by. Defaults to 1 #### Returns `number` The new property value #### Method decrementProperty #### Inherited from [`Adapter`](../../classes/Adapter.md).[`decrementProperty`](../../classes/Adapter.md#decrementproperty) *** ### deleteRecord() ```ts deleteRecord( store, schema, snapshot): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:831](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L831) Called by the store when a record is deleted. The `deleteRecord` method makes an Ajax (HTTP DELETE) request to a URL computed by `buildURL`. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### schema [`ModelSchema`](../../../../core-types/index/interfaces/ModelSchema.md) ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise #### Overrides [`Adapter`](../../classes/Adapter.md).[`deleteRecord`](../../classes/Adapter.md#deleterecord) *** ### destroy() ```ts destroy(): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:300 Destroys an object by setting the `isDestroyed` flag and removing its metadata, which effectively destroys observers and bindings. If you try to set a property on a destroyed object, an exception will be raised. Note that destruction is scheduled for the end of the run loop and does not happen immediately. It will set an isDestroying flag immediately. #### Returns `this` receiver #### Method destroy #### Inherited from [`Adapter`](../../classes/Adapter.md).[`destroy`](../../classes/Adapter.md#destroy) *** ### findAll() ```ts findAll( store, type, sinceToken, snapshotRecordArray): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:551](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L551) Called by the store in order to fetch a JSON array for all of the records for a given type. The `findAll` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a promise for the resulting payload. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### type [`ModelSchema`](../../../../core-types/index/interfaces/ModelSchema.md) ##### sinceToken `null` ##### snapshotRecordArray `SnapshotRecordArray` #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise #### Overrides [`Adapter`](../../classes/Adapter.md).[`findAll`](../../classes/Adapter.md#findall) *** ### findBelongsTo() ```ts findBelongsTo( store, snapshot, url, relationship): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:758](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L758) Called by the store in order to fetch the JSON for the unloaded record in a belongs-to relationship that was originally specified as a URL (inside of `links`). For example, if your original payload looks like this: ```js { "person": { "id": 1, "name": "Tom Dale", "links": { "group": "/people/1/group" } } } ``` This method will be called with the parent record and `/people/1/group`. The `findBelongsTo` method will make an Ajax (HTTP GET) request to the originally specified URL. The format of your `links` value will influence the final request URL via the `urlPrefix` method: * Links beginning with `//`, `http://`, `https://`, will be used as is, with no further manipulation. * Links beginning with a single `/` will have the current adapter's `host` value prepended to it. * Links with no beginning `/` will have a parentURL prepended to it, via the current adapter's `buildURL`. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### snapshot `Snapshot` ##### url `string` ##### relationship `any` meta object describing the relationship #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise *** ### findHasMany() ```ts findHasMany( store, snapshot, url, relationship): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:704](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L704) Called by the store in order to fetch a JSON array for the unloaded records in a has-many relationship that were originally specified as a URL (inside of `links`). For example, if your original payload looks like this: ```js { "post": { "id": 1, "title": "Rails is omakase", "links": { "comments": "/posts/1/comments" } } } ``` This method will be called with the parent record and `/posts/1/comments`. The `findHasMany` method will make an Ajax (HTTP GET) request to the originally specified URL. The format of your `links` value will influence the final request URL via the `urlPrefix` method: * Links beginning with `//`, `http://`, `https://`, will be used as is, with no further manipulation. * Links beginning with a single `/` will have the current adapter's `host` value prepended to it. * Links with no beginning `/` will have a parentURL prepended to it, via the current adapter's `buildURL`. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### snapshot `Snapshot` ##### url `string` ##### relationship `Record`<`string`, `unknown`> meta object describing the relationship #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise *** ### findMany() ```ts findMany( store, type, ids, snapshots): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:663](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L663) Called by the store in order to fetch several records together if `coalesceFindRequests` is true For example, if the original payload looks like: ```js { "id": 1, "title": "Rails is omakase", "comments": [ 1, 2, 3 ] } ``` The IDs will be passed as a URL-encoded Array of IDs, in this form: ``` ids[]=1&ids[]=2&ids[]=3 ``` Many servers, such as Rails and PHP, will automatically convert this URL-encoded array into an Array for you on the server-side. If you want to encode the IDs, differently, just override this (one-line) method. The `findMany` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a promise for the resulting payload. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### type [`ModelSchema`](../../../../core-types/index/interfaces/ModelSchema.md) ##### ids `string`\[] ##### snapshots `Snapshot`<`unknown`>\[] #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise *** ### findRecord() ```ts findRecord( store, type, id, snapshot): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:530](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L530) Called by the store in order to fetch the JSON for a given type and ID. The `findRecord` method makes an Ajax request to a URL computed by `buildURL`, and returns a promise for the resulting payload. This method performs an HTTP `GET` request with the id provided as part of the query string. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### type [`ModelSchema`](../../../../core-types/index/interfaces/ModelSchema.md) ##### id `string` ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise #### Since 1.13.0 #### Overrides [`Adapter`](../../classes/Adapter.md).[`findRecord`](../../classes/Adapter.md#findrecord) *** ### get() #### Call Signature ```ts get(key): RESTAdapter[K]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:121 Retrieves the value of a property from the object. This method is usually similar to using `object[keyName]` or `object.keyName`, however it supports both computed properties and the unknownProperty handler. Because `get` unifies the syntax for accessing all these kinds of properties, it can make many refactorings easier, such as replacing a simple property with a computed property, or vice versa. ### Computed Properties Computed properties are methods defined with the `property` modifier declared at the end, such as: ```javascript import { computed } from '@ember/object'; fullName: computed('firstName', 'lastName', function() { return this.get('firstName') + ' ' + this.get('lastName'); }) ``` When you call `get` on a computed property, the function will be called and the return value will be returned instead of the function itself. ### Unknown Properties Likewise, if you try to call `get` on a property whose value is `undefined`, the `unknownProperty()` method will be called on the object. If this method returns any value other than `undefined`, it will be returned instead. This allows you to implement "virtual" properties that are not defined upfront. ##### Type Parameters ###### K `K` *extends* keyof `RESTAdapter` ##### Parameters ###### key `K` ##### Returns `RESTAdapter`\[`K`] The property value or undefined. ##### Method get ##### Inherited from [`Adapter`](../../classes/Adapter.md).[`get`](../../classes/Adapter.md#get) #### Call Signature ```ts get(key): unknown; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:122 ##### Parameters ###### key `string` ##### Returns `unknown` ##### Inherited from [`Adapter`](../../classes/Adapter.md).[`get`](../../classes/Adapter.md#get) *** ### getProperties() #### Call Signature ```ts getProperties(list): { [Key in keyof RESTAdapter]: RESTAdapter[Key] }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:144 To get the values of multiple properties at once, call `getProperties` with a list of strings or an array: ```javascript record.getProperties('firstName', 'lastName', 'zipCode'); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } ``` is equivalent to: ```javascript record.getProperties(['firstName', 'lastName', 'zipCode']); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } ``` ##### Type Parameters ###### L `L` *extends* keyof `RESTAdapter`\[] ##### Parameters ###### list `L` of keys to get ##### Returns `{ [Key in keyof RESTAdapter]: RESTAdapter[Key] }` ##### Method getProperties ##### Inherited from [`Adapter`](../../classes/Adapter.md).[`getProperties`](../../classes/Adapter.md#getproperties) #### Call Signature ```ts getProperties(...list): { [Key in keyof RESTAdapter]: RESTAdapter[Key] }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:149 ##### Type Parameters ###### L `L` *extends* keyof `RESTAdapter`\[] ##### Parameters ###### list ...`L` ##### Returns `{ [Key in keyof RESTAdapter]: RESTAdapter[Key] }` ##### Inherited from [`Adapter`](../../classes/Adapter.md).[`getProperties`](../../classes/Adapter.md#getproperties) #### Call Signature ```ts getProperties(list): { [Key in string]: unknown }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:154 ##### Type Parameters ###### L `L` *extends* `string`\[] ##### Parameters ###### list `L` ##### Returns `{ [Key in string]: unknown }` ##### Inherited from [`Adapter`](../../classes/Adapter.md).[`getProperties`](../../classes/Adapter.md#getproperties) #### Call Signature ```ts getProperties(...list): { [Key in string]: unknown }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:159 ##### Type Parameters ###### L `L` *extends* `string`\[] ##### Parameters ###### list ...`L` ##### Returns `{ [Key in string]: unknown }` ##### Inherited from [`Adapter`](../../classes/Adapter.md).[`getProperties`](../../classes/Adapter.md#getproperties) *** ### groupRecordsForFindMany() ```ts groupRecordsForFindMany(store, snapshots): Snapshot[][]; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:891](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L891) Organize records into groups, each of which is to be passed to separate calls to `findMany`. This implementation groups together records that have the same base URL but differing ids. For example `/comments/1` and `/comments/2` will be grouped together because we know findMany can coalesce them together as `/comments?ids[]=1&ids[]=2` It also supports urls where ids are passed as a query param, such as `/comments?id=1` but not those where there is more than 1 query param such as `/comments?id=2&name=David` Currently only the query param of `id` is supported. If you need to support others, please override this or the `_stripIDFromURL` method. It does not group records that have differing base urls, such as for example: `/posts/1/comments/2` and `/posts/2/comments/3` #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### snapshots `Snapshot`<`unknown`>\[] #### Returns `Snapshot`<`unknown`>\[]\[] an array of arrays of records, each of which is to be loaded separately by `findMany`. #### Overrides [`Adapter`](../../classes/Adapter.md).[`groupRecordsForFindMany`](../../classes/Adapter.md#grouprecordsforfindmany) *** ### handleResponse() ```ts handleResponse( status, headers, payload, requestData): Payload | typeof _AdapterError; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:944](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L944) Takes an ajax response, and returns the json payload or an error. By default this hook just returns the json payload passed to it. You might want to override it in two cases: 1. Your API might return useful results in the response headers. Response headers are passed in as the second argument. 2. Your API might return errors as successful responses with status code 200 and an Errors text or object. You can return a `InvalidError` or a `AdapterError` (or a sub class) from this hook and it will automatically reject the promise and put your record into the invalid or error state. Returning a `InvalidError` from this method will cause the record to transition into the `invalid` state and make the `errors` object available on the record. When returning an `InvalidError` the store will attempt to normalize the error data returned from the server using the serializer's `extractErrors` method. #### Parameters ##### status `number` ##### headers `Record`<`string`, `string`> ##### payload `Payload` ##### requestData [`RequestData`](../type-aliases/RequestData.md) the original request information #### Returns `Payload` | *typeof* `_AdapterError` response #### Since 1.13.0 *** ### incrementProperty() ```ts incrementProperty(keyName, increment?): number; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:372 Set the value of a property to the current value plus some amount. ```javascript person.incrementProperty('age'); team.incrementProperty('score', 2); ``` #### Parameters ##### keyName keyof `RESTAdapter` The name of the property to increment ##### increment? `number` The amount to increment by. Defaults to 1 #### Returns `number` The new property value #### Method incrementProperty #### Inherited from [`Adapter`](../../classes/Adapter.md).[`incrementProperty`](../../classes/Adapter.md#incrementproperty) *** ### init() ```ts init(_properties): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:114 An overridable method called when objects are instantiated. By default, does nothing unless it is overridden during class definition. Example: ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ init() { alert(`Name is ${this.get('name')}`); } }); let steve = Person.create({ name: 'Steve' }); // alerts 'Name is Steve'. ``` NOTE: If you do override `init` for a framework class like `Component` from `@ember/component`, be sure to call `this._super(...arguments)` in your `init` declaration! If you don't, Ember may not have an opportunity to do important setup work, and you'll see strange behavior in your application. #### Parameters ##### \_properties `undefined` | `object` #### Returns `void` #### Method init #### Inherited from [`Adapter`](../../classes/Adapter.md).[`init`](../../classes/Adapter.md#init) *** ### isInvalid() ```ts isInvalid( status, _headers, _payload): boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:1003](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L1003) Default `handleResponse` implementation uses this hook to decide if the response is an invalid error. #### Parameters ##### status `number` ##### \_headers `Record`<`string`, `unknown`> ##### \_payload `Payload` #### Returns `boolean` #### Since 1.13.0 *** ### isSuccess() ```ts isSuccess( status, _headers, _payload): boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:988](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L988) Default `handleResponse` implementation uses this hook to decide if the response is a success. #### Parameters ##### status `number` ##### \_headers `Record`<`string`, `unknown`> ##### \_payload `Payload` #### Returns `boolean` #### Since 1.13.0 *** ### notifyPropertyChange() ```ts notifyPropertyChange(keyName): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:249 Convenience method to call `propertyWillChange` and `propertyDidChange` in succession. Notify the observer system that a property has just changed. Sometimes you need to change a value directly or indirectly without actually calling `get()` or `set()` on it. In this case, you can use this method instead. Calling this method will notify all observers that the property has potentially changed value. #### Parameters ##### keyName `string` The property key to be notified about. #### Returns `this` #### Method notifyPropertyChange #### Inherited from [`Adapter`](../../classes/Adapter.md).[`notifyPropertyChange`](../../classes/Adapter.md#notifypropertychange) *** ### pathForType() ```ts pathForType(this, modelName): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:103](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L103) #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `string` #### Returns `string` *** ### query() ```ts query( store, type, query): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:586](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L586) Called by the store in order to fetch a JSON array for the records that match a particular query. The `query` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a promise for the resulting payload. The `query` argument is a simple JavaScript object that will be passed directly to the server as parameters. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### type [`ModelSchema`](../../../../core-types/index/interfaces/ModelSchema.md) ##### query `Record`<`string`, `unknown`> #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise #### Overrides [`Adapter`](../../classes/Adapter.md).[`query`](../../classes/Adapter.md#query) *** ### queryRecord() ```ts queryRecord( store, type, query, adapterOptions): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:615](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L615) Called by the store in order to fetch a JSON object for the record that matches a particular query. The `queryRecord` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a promise for the resulting payload. The `query` argument is a simple JavaScript object that will be passed directly to the server as parameters. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### type [`ModelSchema`](../../../../core-types/index/interfaces/ModelSchema.md) ##### query `Record`<`string`, `unknown`> ##### adapterOptions `Record`<`string`, `unknown`> #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise #### Since 1.13.0 #### Overrides [`Adapter`](../../classes/Adapter.md).[`queryRecord`](../../classes/Adapter.md#queryrecord) *** ### removeObserver() #### Call Signature ```ts removeObserver( key, target, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:352 Remove an observer you have previously registered on this object. Pass the same key, target, and method you passed to `addObserver()` and your target will no longer receive notifications. ##### Type Parameters ###### Target `Target` ##### Parameters ###### key keyof `RESTAdapter` The key to observe ###### target `Target` The target object to invoke ###### method `ObserverMethod`<`Target`, `RESTAdapter`> The method to invoke ##### Returns `this` ##### Method removeObserver ##### Inherited from [`Adapter`](../../classes/Adapter.md).[`removeObserver`](../../classes/Adapter.md#removeobserver) #### Call Signature ```ts removeObserver(key, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:357 ##### Parameters ###### key keyof `RESTAdapter` ###### method `ObserverMethod`<`RESTAdapter`, `RESTAdapter`> ##### Returns `this` ##### Inherited from [`Adapter`](../../classes/Adapter.md).[`removeObserver`](../../classes/Adapter.md#removeobserver) *** ### reopen() ```ts reopen(...args): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:81 #### Parameters ##### args ...(`Record`<`string`, `unknown`> | `Mixin`)\[] #### Returns `this` #### Inherited from [`Adapter`](../../classes/Adapter.md).[`reopen`](../../classes/Adapter.md#reopen) *** ### serialize() ```ts serialize(snapshot, options): Record; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:476](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L476) Proxies to the serializer's `serialize` method. Example ```js [app/adapters/application.js] import { Adapter } from '@warp-drive/legacy/adapter'; export default class ApplicationAdapter extends Adapter { createRecord(store, type, snapshot) { let data = this.serialize(snapshot, { includeId: true }); let url = `/${type.modelName}`; // ... } } ``` #### Parameters ##### snapshot `Snapshot` ##### options [`SerializerOptions`](../../../compat/type-aliases/SerializerOptions.md) #### Returns `Record`<`string`, `unknown`> serialized snapshot #### Inherited from [`Adapter`](../../classes/Adapter.md).[`serialize`](../../classes/Adapter.md#serialize) *** ### set() #### Call Signature ```ts set(key, value): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:208 Sets the provided key or path to the value. ```javascript record.set("key", value); ``` This method is generally very similar to calling `object["key"] = value` or `object.key = value`, except that it provides support for computed properties, the `setUnknownProperty()` method and property observers. ### Computed Properties If you try to set a value on a key that has a computed property handler defined (see the `get()` method for an example), then `set()` will call that method, passing both the value and key instead of simply changing the value itself. This is useful for those times when you need to implement a property that is composed of one or more member properties. ### Unknown Properties If you try to set a value on a key that is undefined in the target object, then the `setUnknownProperty()` handler will be called instead. This gives you an opportunity to implement complex "virtual" properties that are not predefined on the object. If `setUnknownProperty()` returns undefined, then `set()` will simply set the value on the object. ### Property Observers In addition to changing the property, `set()` will also register a property change with the object. Unless you have placed this call inside of a `beginPropertyChanges()` and `endPropertyChanges(),` any "local" observers (i.e. observer methods declared on the same object), will be called immediately. Any "remote" observers (i.e. observer methods declared on another object) will be placed in a queue and called at a later time in a coalesced manner. ##### Type Parameters ###### K `K` *extends* keyof `RESTAdapter` ###### T `T` *extends* | `undefined` | `null` | `string` | `number` | `boolean` | `Record`<`string`, `unknown`> | `unknown`\[] | [`default`](../../../../../@ember-data/store/index/classes/default.md) | `string`\[] | `Owner` | (`this`, `id`, `modelName`, `snapshot`) => `string` | (`this`, `modelName`, `snapshots`) => `string` | (`this`, `query`, `modelName`) => `string` | (`this`, `query`, `modelName`) => `string` | (`this`, `ids`, `modelName`, `snapshots`) => `string` | (`this`, `id`, `modelName`, `snapshot`) => `string` | (`this`, `id`, `modelName`, `snapshot`) => `string` | (`this`, `modelName`, `snapshot`) => `string` | (`this`, `id`, `modelName`, `snapshot`) => `string` | (`this`, `id`, `modelName`, `snapshot`) => `string` | (`this`, `modelName`, `id?`) => `string` | (`this`, `path?`, `parentURL?`) => `string` | (`this`, `modelName`) => `string` | { (`this`, `modelName`, `id`, `snapshot`, `requestType`): `string`; (`this`, `modelName`, `id`, `snapshot`, `requestType`): `string`; (`this`, `modelName`, `id`, `snapshot`, `requestType`, `query`): `string`; (`this`, `modelName`, `id`, `snapshot`, `requestType`, `query`): `string`; (`this`, `modelName`, `id`, `snapshot`, `requestType`): `string`; (`this`, `modelName`, `id`, `snapshot`, `requestType`): `string`; (`this`, `modelName`, `id`, `snapshot`, `requestType`): `string`; (`this`, `modelName`, `id`, `snapshot`, `requestType`): `string`; (`this`, `modelName`, `id`, `snapshot`, `requestType`): `string`; (`this`, `modelName`, `id`, `snapshot`, `requestType`): `string`; (`this`, `modelName`, `id`, `snapshot`): `string`; } | (`store`, `snapshot`) => `boolean` | (`store`, `snapshotRecordArray`) => `boolean` | (`store`, `snapshot`) => `boolean` | (`store`, `snapshotRecordArray`) => `boolean` | () => `string` | { } | () => `void` | `FastBoot` | (`store`, `type`, `id`, `snapshot`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | (`store`, `type`, `sinceToken`, `snapshotRecordArray`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | (`store`, `type`, `query`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | (`store`, `type`, `query`, `adapterOptions`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | (`store`, `type`, `snapshot`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | (`store`, `schema`, `snapshot`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | (`store`, `schema`, `snapshot`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | (`store`, `snapshots`) => `Snapshot`<`unknown`>\[]\[] | (...`args`) => `this` | (`_properties`) => `void` | () => `this` | { <`K`> (`key`): `RESTAdapter`\[`K`]; (`key`): `unknown`; } | { <`L`> (`list`): `{ [Key in keyof RESTAdapter]: RESTAdapter[Key] }`; <`L`> (...`list`): `{ [Key in keyof RESTAdapter]: RESTAdapter[Key] }`; <`L`> (`list`): `{ [Key in string]: unknown }`; <`L`> (...`list`): `{ [Key in string]: unknown }`; } | { <`K`, `T`> (`key`, `value`): `T`; <`T`> (`key`, `value`): `T`; } | { <`K`, `P`> (`hash`): `P`; <`T`> (`hash`): `T`; } | (`keyName`) => `this` | { <`Target`> (`key`, `target`, `method`): `this`; (`key`, `method`): `this`; } | { <`Target`> (`key`, `target`, `method`): `this`; (`key`, `method`): `this`; } | (`keyName`, `increment?`) => `number` | (`keyName`, `decrement?`) => `number` | (`keyName`) => `boolean` | <`K`>(`key`) => `unknown` | (`obj`) => `Record`<`string`, `unknown`> | (`status`, `_headers`, `_payload`) => `boolean` | (`status`, `_headers`, `_payload`) => `boolean` | { } | { } | (`options`) => `Promise`<`Response`> | { } | (`url`) => `string` | (`status`, `headers`, `payload`, `requestData`) => `Payload` | *typeof* `_AdapterError` | { } | { } | (`options`) => `void` | (`store`, `snapshot`) => `string` | (`store`, `type`, `ids`, `snapshots`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | (`snapshot`, `options`) => `Record`<`string`, `unknown`> | (`store`, `snapshot`, `url`, `relationship`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | (`store`, `snapshot`, `url`, `relationship`) => `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> | { } | (`snapshot`) => [`QueryState`](../type-aliases/QueryState.md) ##### Parameters ###### key `K` ###### value `T` The value to set or `null`. ##### Returns `T` The passed value ##### Method set ##### Inherited from [`Adapter`](../../classes/Adapter.md).[`set`](../../classes/Adapter.md#set) #### Call Signature ```ts set(key, value): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:209 ##### Type Parameters ###### T `T` ##### Parameters ###### key `string` ###### value `T` ##### Returns `T` ##### Inherited from [`Adapter`](../../classes/Adapter.md).[`set`](../../classes/Adapter.md#set) *** ### setProperties() #### Call Signature ```ts setProperties(hash): P; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:224 Sets a list of properties at once. These properties are set inside a single `beginPropertyChanges` and `endPropertyChanges` batch, so observers will be buffered. ```javascript record.setProperties({ firstName: 'Charles', lastName: 'Jolley' }); ``` ##### Type Parameters ###### K `K` *extends* keyof `RESTAdapter` ###### P `P` *extends* `{ [Key in keyof RESTAdapter]: RESTAdapter[Key] }` ##### Parameters ###### hash `P` the hash of keys and values to set ##### Returns `P` The passed in hash ##### Method setProperties ##### Inherited from [`Adapter`](../../classes/Adapter.md).[`setProperties`](../../classes/Adapter.md#setproperties) #### Call Signature ```ts setProperties(hash): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:232 ##### Type Parameters ###### T `T` *extends* `Record`<`string`, `unknown`> ##### Parameters ###### hash `T` ##### Returns `T` ##### Inherited from [`Adapter`](../../classes/Adapter.md).[`setProperties`](../../classes/Adapter.md#setproperties) *** ### shouldBackgroundReloadAll() ```ts shouldBackgroundReloadAll(store, snapshotRecordArray): boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:887](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L887) This method is used by the store to determine if the store should reload a record array after the `store.findAll` method resolves with a cached record array. This method is *only* checked by the store when the store is returning a cached record array. If this method returns `true` the store will re-fetch all records from the adapter. For example, if you do not want to fetch complex data over a mobile connection, or if the network is down, you can implement `shouldBackgroundReloadAll` as follows: ```javascript shouldBackgroundReloadAll(store, snapshotArray) { let { downlink, effectiveType } = navigator.connection; return downlink > 0 && effectiveType === '4g'; } ``` By default this method returns `true`, indicating that a background reload should always be triggered. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### snapshotRecordArray `SnapshotRecordArray` #### Returns `boolean` #### Since 1.13.0 #### Inherited from [`Adapter`](../../classes/Adapter.md).[`shouldBackgroundReloadAll`](../../classes/Adapter.md#shouldbackgroundreloadall) *** ### shouldBackgroundReloadRecord() ```ts shouldBackgroundReloadRecord(store, snapshot): boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:851](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L851) This method is used by the store to determine if the store should reload a record after the `store.findRecord` method resolves a cached record. This method is *only* checked by the store when the store is returning a cached record. If this method returns `true` the store will re-fetch a record from the adapter. For example, if you do not want to fetch complex data over a mobile connection, or if the network is down, you can implement `shouldBackgroundReloadRecord` as follows: ```javascript shouldBackgroundReloadRecord(store, snapshot) { let { downlink, effectiveType } = navigator.connection; return downlink > 0 && effectiveType === '4g'; } ``` By default, this hook returns `true` so the data for the record is updated in the background. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### snapshot `Snapshot` #### Returns `boolean` #### Since 1.13.0 #### Inherited from [`Adapter`](../../classes/Adapter.md).[`shouldBackgroundReloadRecord`](../../classes/Adapter.md#shouldbackgroundreloadrecord) *** ### shouldReloadAll() ```ts shouldReloadAll(store, snapshotRecordArray): boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:815](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L815) This method is used by the store to determine if the store should reload all records from the adapter when records are requested by `store.findAll`. If this method returns `true`, the store will re-fetch all records from the adapter. If this method returns `false`, the store will resolve immediately using the cached records. For example, if you are building an events ticketing system, in which users can only reserve tickets for 20 minutes at a time, and want to ensure that in each route you have data that is no more than 20 minutes old you could write: ```javascript shouldReloadAll(store, snapshotArray) { let snapshots = snapshotArray.snapshots(); return snapshots.any((ticketSnapshot) => { let lastAccessedAt = ticketSnapshot.attr('lastAccessedAt'); let timeDiff = moment().diff(lastAccessedAt, 'minutes'); if (timeDiff > 20) { return true; } else { return false; } }); } ``` This method would ensure that whenever you do `store.findAll('ticket')` you will always get a list of tickets that are no more than 20 minutes old. In case a cached version is more than 20 minutes old, `findAll` will not resolve until you fetched the latest versions. By default, this method returns `true` if the passed `snapshotRecordArray` is empty (meaning that there are no records locally available yet), otherwise, it returns `false`. Note that, with default settings, `shouldBackgroundReloadAll` will always re-fetch all the records in the background even if `shouldReloadAll` returns `false`. You can override `shouldBackgroundReloadAll` if this does not suit your use case. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### snapshotRecordArray `SnapshotRecordArray` #### Returns `boolean` #### Since 1.13.0 #### Inherited from [`Adapter`](../../classes/Adapter.md).[`shouldReloadAll`](../../classes/Adapter.md#shouldreloadall) *** ### shouldReloadRecord() ```ts shouldReloadRecord(store, snapshot): boolean; ``` Defined in: [warp-drive-packages/legacy/src/adapter.ts:760](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter.ts#L760) This method is used by the store to determine if the store should reload a record from the adapter when a record is requested by `store.findRecord`. If this method returns `true`, the store will re-fetch a record from the adapter. If this method returns `false`, the store will resolve immediately using the cached record. For example, if you are building an events ticketing system, in which users can only reserve tickets for 20 minutes at a time, and want to ensure that in each route you have data that is no more than 20 minutes old you could write: ```javascript shouldReloadRecord(store, ticketSnapshot) { let lastAccessedAt = ticketSnapshot.attr('lastAccessedAt'); let timeDiff = moment().diff(lastAccessedAt, 'minutes'); if (timeDiff > 20) { return true; } else { return false; } } ``` This method would ensure that whenever you do `store.findRecord('ticket', id)` you will always get a ticket that is no more than 20 minutes old. In case the cached version is more than 20 minutes old, `findRecord` will not resolve until you fetched the latest version. By default this hook returns `false`, as most UIs should not block user interactions while waiting on data update. Note that, with default settings, `shouldBackgroundReloadRecord` will always re-fetch the records in the background even if `shouldReloadRecord` returns `false`. You can override `shouldBackgroundReloadRecord` if this does not suit your use case. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### snapshot `Snapshot` #### Returns `boolean` #### Since 1.13.0 #### Inherited from [`Adapter`](../../classes/Adapter.md).[`shouldReloadRecord`](../../classes/Adapter.md#shouldreloadrecord) *** ### sortQueryParams() ```ts sortQueryParams(obj): Record; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:375](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L375) By default, the RESTAdapter will send the query params sorted alphabetically to the server. For example: ```js store.query('posts', { sort: 'price', category: 'pets' }); ``` will generate a requests like this `/posts?category=pets&sort=price`, even if the parameters were specified in a different order. That way the generated URL will be deterministic and that simplifies caching mechanisms in the backend. Setting `sortQueryParams` to a falsey value will respect the original order. In case you want to sort the query parameters with a different criteria, set `sortQueryParams` to your custom sort function. ```js [app/adapters/application.js] import { RESTAdapter } from '@warp-drive/legacy/adapter/rest'; export default class ApplicationAdapter extends RESTAdapter { sortQueryParams(params) { let sortedKeys = Object.keys(params).sort().reverse(); let len = sortedKeys.length, newParams = {}; for (let i = 0; i < len; i++) { newParams[sortedKeys[i]] = params[sortedKeys[i]]; } return newParams; } } ``` #### Parameters ##### obj `Record`<`string`, `unknown`> #### Returns `Record`<`string`, `unknown`> *** ### toggleProperty() ```ts toggleProperty(keyName): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:401 Set the value of a boolean property to the opposite of its current value. ```javascript starship.toggleProperty('warpDriveEngaged'); ``` #### Parameters ##### keyName keyof `RESTAdapter` The name of the property to toggle #### Returns `boolean` The new property value #### Method toggleProperty #### Inherited from [`Adapter`](../../classes/Adapter.md).[`toggleProperty`](../../classes/Adapter.md#toggleproperty) *** ### toString() ```ts toString(): string; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:347 Returns a string representation which attempts to provide more information than Javascript's `toString` typically does, in a generic way for all Ember objects. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend(); person = Person.create(); person.toString(); //=> "" ``` If the object's class is not defined on an Ember namespace, it will indicate it is a subclass of the registered superclass: ```javascript const Student = Person.extend(); let student = Student.create(); student.toString(); //=> "<(subclass of Person):ember1025>" ``` If the method `toStringExtension` is defined, its return value will be included in the output. ```javascript const Teacher = Person.extend({ toStringExtension() { return this.get('fullName'); } }); teacher = Teacher.create(); teacher.toString(); //=> "" ``` #### Returns `string` string representation #### Method toString #### Inherited from [`Adapter`](../../classes/Adapter.md).[`toString`](../../classes/Adapter.md#tostring) *** ### updateRecord() ```ts updateRecord( store, schema, snapshot): Promise; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:810](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L810) Called by the store when an existing record is saved via the `save` method on a model record instance. The `updateRecord` method serializes the record and makes an Ajax (HTTP PUT) request to a URL computed by `buildURL`. See `serialize` for information on how to customize the serialized form of a record. #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### schema [`ModelSchema`](../../../../core-types/index/interfaces/ModelSchema.md) ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../../../compat/type-aliases/AdapterPayload.md)> promise #### Overrides [`Adapter`](../../classes/Adapter.md).[`updateRecord`](../../classes/Adapter.md#updaterecord) *** ### urlForCreateRecord() ```ts urlForCreateRecord( this, modelName, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:99](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L99) #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` *** ### urlForDeleteRecord() ```ts urlForDeleteRecord( this, id, modelName, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:101](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L101) #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` *** ### urlForFindAll() ```ts urlForFindAll( this, modelName, snapshots): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:93](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L93) #### Parameters ##### this `MixtBuildURLMixin` ##### modelName `string` ##### snapshots `SnapshotRecordArray` #### Returns `string` *** ### urlForFindBelongsTo() ```ts urlForFindBelongsTo( this, id, modelName, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:98](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L98) #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` *** ### urlForFindHasMany() ```ts urlForFindHasMany( this, id, modelName, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:97](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L97) #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` *** ### urlForFindMany() ```ts urlForFindMany( this, ids, modelName, snapshots): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:96](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L96) #### Parameters ##### this `MixtBuildURLMixin` ##### ids `string`\[] ##### modelName `string` ##### snapshots `Snapshot`<`unknown`>\[] #### Returns `string` *** ### urlForFindRecord() ```ts urlForFindRecord( this, id, modelName, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:92](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L92) #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` *** ### urlForQuery() ```ts urlForQuery( this, query, modelName): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:95](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L95) #### Parameters ##### this `MixtBuildURLMixin` ##### query `Record`<`string`, `unknown`> ##### modelName `string` #### Returns `string` *** ### urlForQueryRecord() ```ts urlForQueryRecord( this, query, modelName): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:94](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L94) #### Parameters ##### this `MixtBuildURLMixin` ##### query `Record`<`string`, `unknown`> ##### modelName `string` #### Returns `string` *** ### urlForUpdateRecord() ```ts urlForUpdateRecord( this, id, modelName, snapshot): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:100](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L100) #### Parameters ##### this `MixtBuildURLMixin` ##### id `string` ##### modelName `string` ##### snapshot `Snapshot` #### Returns `string` *** ### urlPrefix() ```ts urlPrefix( this, path?, parentURL?): string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:102](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L102) #### Parameters ##### this `MixtBuildURLMixin` ##### path? `null` | `string` ##### parentURL? `string` #### Returns `string` *** ### willDestroy() ```ts willDestroy(): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:307 Override to implement teardown. #### Returns `void` #### Method willDestroy #### Inherited from [`Adapter`](../../classes/Adapter.md).[`willDestroy`](../../classes/Adapter.md#willdestroy) *** ### create() #### Call Signature ```ts readonly static create(this): InstanceType; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:487 Creates an instance of a class. Accepts either no arguments, or an object containing values to initialize the newly instantiated object with. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ helloWorld() { alert(`Hi, my name is ${this.get('name')}`); } }); let tom = Person.create({ name: 'Tom Dale' }); tom.helloWorld(); // alerts "Hi, my name is Tom Dale". ``` `create` will call the `init` function if defined during `AnyObject.extend` If no arguments are passed to `create`, it will not set values to the new instance during initialization: ```javascript let noName = Person.create(); noName.helloWorld(); // alerts undefined ``` NOTE: For performance reasons, you cannot declare methods or computed properties during `create`. You should instead declare methods and computed properties when using `extend`. ##### Type Parameters ###### C `C` *extends* *typeof* `CoreObject` ##### Parameters ###### this `C` ##### Returns `InstanceType`<`C`> ##### Method create ##### For @ember/object ##### Static ##### Inherited from [`Adapter`](../../classes/Adapter.md).[`create`](../../classes/Adapter.md#create) #### Call Signature ```ts readonly static create(this, ...args): InstanceType & MergeArray; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:488 Creates an instance of a class. Accepts either no arguments, or an object containing values to initialize the newly instantiated object with. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ helloWorld() { alert(`Hi, my name is ${this.get('name')}`); } }); let tom = Person.create({ name: 'Tom Dale' }); tom.helloWorld(); // alerts "Hi, my name is Tom Dale". ``` `create` will call the `init` function if defined during `AnyObject.extend` If no arguments are passed to `create`, it will not set values to the new instance during initialization: ```javascript let noName = Person.create(); noName.helloWorld(); // alerts undefined ``` NOTE: For performance reasons, you cannot declare methods or computed properties during `create`. You should instead declare methods and computed properties when using `extend`. ##### Type Parameters ###### C `C` *extends* *typeof* `CoreObject` ###### I `I` *extends* `CoreObject` ###### K `K` *extends* `string` | `number` | `symbol` ###### Args `Args` *extends* `Partial`<{ \[Key in string | number | symbol]: I\[Key] }>\[] ##### Parameters ###### this `C` ###### args ...`Args` ##### Returns `InstanceType`<`C`> & `MergeArray`<`Args`> ##### Method create ##### For @ember/object ##### Static ##### Inherited from [`Adapter`](../../classes/Adapter.md).[`create`](../../classes/Adapter.md#create) *** ### detectInstance() ```ts readonly static detectInstance(obj): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:600 #### Parameters ##### obj `unknown` #### Returns `boolean` #### Inherited from [`Adapter`](../../classes/Adapter.md).[`detectInstance`](../../classes/Adapter.md#detectinstance) *** ### extend() ```ts readonly static extend(this, ...mixins?): Readonly & EmberClassConstructor & MergeArray; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:442 Creates a new subclass. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ say(thing) { alert(thing); } }); ``` This defines a new subclass of EmberObject: `Person`. It contains one method: `say()`. You can also create a subclass from any existing class by calling its `extend()` method. For example, you might want to create a subclass of Ember's built-in `Component` class: ```javascript import Component from '@ember/component'; const PersonComponent = Component.extend({ tagName: 'li', classNameBindings: ['isAdministrator'] }); ``` When defining a subclass, you can override methods but still access the implementation of your parent class by calling the special `_super()` method: ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ say(thing) { let name = this.get('name'); alert(`${name} says: ${thing}`); } }); const Soldier = Person.extend({ say(thing) { this._super(`${thing}, sir!`); }, march(numberOfHours) { alert(`${this.get('name')} marches for ${numberOfHours} hours.`); } }); let yehuda = Soldier.create({ name: 'Yehuda Katz' }); yehuda.say('Yes'); // alerts "Yehuda Katz says: Yes, sir!" ``` The `create()` on line #17 creates an *instance* of the `Soldier` class. The `extend()` on line #8 creates a *subclass* of `Person`. Any instance of the `Person` class will *not* have the `march()` method. You can also pass `Mixin` classes to add additional properties to the subclass. ```javascript import EmberObject from '@ember/object'; import Mixin from '@ember/object/mixin'; const Person = EmberObject.extend({ say(thing) { alert(`${this.get('name')} says: ${thing}`); } }); const SingingMixin = Mixin.create({ sing(thing) { alert(`${this.get('name')} sings: la la la ${thing}`); } }); const BroadwayStar = Person.extend(SingingMixin, { dance() { alert(`${this.get('name')} dances: tap tap tap tap `); } }); ``` The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. #### Type Parameters ##### Statics `Statics` ##### Instance `Instance` ##### M `M` *extends* `unknown`\[] #### Parameters ##### this `Statics` & `EmberClassConstructor`<`Instance`> ##### mixins? ...`M` One or more Mixin classes #### Returns `Readonly`<`Statics`> & `EmberClassConstructor`<`Instance`> & `MergeArray`<`M`> #### Method extend #### Static #### For @ember/object #### Inherited from [`Adapter`](../../classes/Adapter.md).[`extend`](../../classes/Adapter.md#extend) *** ### proto() ```ts readonly static proto(): CoreObject; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:649 #### Returns `CoreObject` #### Inherited from [`Adapter`](../../classes/Adapter.md).[`proto`](../../classes/Adapter.md#proto) *** ### reopenClass() ```ts readonly static reopenClass(this, ...mixins): C; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:595 Augments a constructor's own properties and functions: ```javascript import EmberObject from '@ember/object'; const MyObject = EmberObject.extend({ name: 'an object' }); MyObject.reopenClass({ canBuild: false }); MyObject.canBuild; // false o = MyObject.create(); ``` In other words, this creates static properties and functions for the class. These are only available on the class and not on any instance of that class. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ name: '', sayHello() { alert(`Hello. My name is ${this.get('name')}`); } }); Person.reopenClass({ species: 'Homo sapiens', createPerson(name) { return Person.create({ name }); } }); let tom = Person.create({ name: 'Tom Dale' }); let yehuda = Person.createPerson('Yehuda Katz'); tom.sayHello(); // "Hello. My name is Tom Dale" yehuda.sayHello(); // "Hello. My name is Yehuda Katz" alert(Person.species); // "Homo sapiens" ``` Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` variables. They are only valid on `Person`. To add functions and properties to instances of a constructor by extending the constructor's prototype see `reopen` #### Type Parameters ##### C `C` *extends* *typeof* `CoreObject` #### Parameters ##### this `C` ##### mixins ...(`Record`<`string`, `unknown`> | `Mixin`)\[] #### Returns `C` #### Method reopenClass #### For @ember/object #### Static #### Inherited from [`Adapter`](../../classes/Adapter.md).[`reopenClass`](../../classes/Adapter.md#reopenclass) *** ### toString() ```ts static toString(): string; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:650 #### Returns `string` #### Inherited from [`Adapter`](../../classes/Adapter.md).[`toString`](../../classes/Adapter.md#tostring-2) *** ### willReopen() ```ts readonly static willReopen(): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:533 #### Returns `void` #### Inherited from [`Adapter`](../../classes/Adapter.md).[`willReopen`](../../classes/Adapter.md#willreopen) --- --- url: /api/@warp-drive/legacy/adapter/rest.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / adapter/rest ## Classes * [RESTAdapter](classes/RESTAdapter.md) ## Interfaces * [FetchRequestInit](interfaces/FetchRequestInit.md) * [JQueryRequestInit](interfaces/JQueryRequestInit.md) ## Type Aliases * [QueryState](type-aliases/QueryState.md) * [RequestData](type-aliases/RequestData.md) --- --- url: /api/@warp-drive/legacy/adapter/rest/interfaces/FetchRequestInit.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/rest](../index.md) / FetchRequestInit Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:46](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L46) ## Extends * `RequestInit` ## Properties ### body? ```ts optional body: null | BodyInit; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1922 A BodyInit object or null to set request's body. #### Inherited from ```ts RequestInit.body ``` *** ### cache? ```ts optional cache: RequestCache; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1924 A string indicating how the request will interact with the browser's cache to set request's cache. #### Inherited from ```ts RequestInit.cache ``` *** ### credentials? ```ts optional credentials: RequestCredentials; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1926 A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials. #### Inherited from ```ts RequestInit.credentials ``` *** ### headers? ```ts optional headers: HeadersInit; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1928 A Headers object, an object literal, or an array of two-item arrays to set request's headers. #### Inherited from ```ts RequestInit.headers ``` *** ### integrity? ```ts optional integrity: string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1930 A cryptographic hash of the resource to be fetched by request. Sets request's integrity. #### Inherited from ```ts RequestInit.integrity ``` *** ### keepalive? ```ts optional keepalive: boolean; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1932 A boolean to set request's keepalive. #### Inherited from ```ts RequestInit.keepalive ``` *** ### method ```ts method: HTTPMethod; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:48](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L48) A string to set request's method. #### Overrides ```ts RequestInit.method ``` *** ### mode? ```ts optional mode: RequestMode; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1936 A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode. #### Inherited from ```ts RequestInit.mode ``` *** ### priority? ```ts optional priority: RequestPriority; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1937 #### Inherited from ```ts RequestInit.priority ``` *** ### redirect? ```ts optional redirect: RequestRedirect; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1939 A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. #### Inherited from ```ts RequestInit.redirect ``` *** ### referrer? ```ts optional referrer: string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1941 A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer. #### Inherited from ```ts RequestInit.referrer ``` *** ### referrerPolicy? ```ts optional referrerPolicy: ReferrerPolicy; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1943 A referrer policy to set request's referrerPolicy. #### Inherited from ```ts RequestInit.referrerPolicy ``` *** ### signal? ```ts optional signal: null | AbortSignal; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1945 An AbortSignal to set request's signal. #### Inherited from ```ts RequestInit.signal ``` *** ### type ```ts type: HTTPMethod; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:49](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L49) *** ### url ```ts url: string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:47](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L47) *** ### window? ```ts optional window: null; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.dom.d.ts:1947 Can only be null. Used to disassociate request from any Window. #### Inherited from ```ts RequestInit.window ``` --- --- url: /api/@warp-drive/legacy/adapter/rest/interfaces/JQueryRequestInit.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/rest](../index.md) / JQueryRequestInit Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:52](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L52) ## Extends * `JQueryAjaxSettings` ## Properties ### accepts? ```ts optional accepts: PlainObject; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:90 A set of key/value pairs that map a given dataType to its MIME type, which gets sent in the Accept request header. This header tells the server what kind of response it will accept in return. #### Inherited from ```ts JQueryAjaxSettings.accepts ``` *** ### async? ```ts optional async: boolean; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:94 By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active. As of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you must use the success/error/complete callback options instead of the corresponding methods of the jqXHR object such as jqXHR.done(). #### Inherited from ```ts JQueryAjaxSettings.async ``` *** ### cache? ```ts optional cache: boolean; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:103 If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "\_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET. #### Inherited from ```ts JQueryAjaxSettings.cache ``` *** ### complete? ```ts optional complete: TypeOrArray>; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:107 A function to be called when the request finishes (after success and error callbacks are executed). The function gets passed two arguments: The jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object and a string categorizing the status of the request ("success", "notmodified", "nocontent", "error", "timeout", "abort", or "parsererror"). As of jQuery 1.5, the complete setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event. #### Inherited from ```ts JQueryAjaxSettings.complete ``` *** ### contents? ```ts optional contents: PlainObject; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:111 An object of string/regular-expression pairs that determine how jQuery will parse the response, given its content type. #### Inherited from ```ts JQueryAjaxSettings.contents ``` *** ### contentType? ```ts optional contentType: string | false; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:115 When sending data to the server, use this content type. Default is "application/x-www-form-urlencoded; charset=UTF-8", which is fine for most cases. If you explicitly pass in a content-type to $.ajax(), then it is always sent to the server (even if no data is sent). As of jQuery 1.6 you can pass false to tell jQuery to not set any content type header. Note: The W3C XMLHttpRequest specification dictates that the charset is always UTF-8; specifying another charset will not force the browser to change the encoding. Note: For cross-domain requests, setting the content type to anything other than application/x-www-form-urlencoded, multipart/form-data, or text/plain will trigger the browser to send a preflight OPTIONS request to the server. #### Inherited from ```ts JQueryAjaxSettings.contentType ``` *** ### context? ```ts optional context: any; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:119 This object will be the context of all Ajax-related callbacks. By default, the context is an object that represents the Ajax settings used in the call ($.ajaxSettings merged with the settings passed to $.ajax). #### Inherited from ```ts JQueryAjaxSettings.context ``` *** ### converters? ```ts optional converters: PlainObject any>; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:123 An object containing dataType-to-dataType converters. Each converter's value is a function that returns the transformed value of the response. #### Inherited from ```ts JQueryAjaxSettings.converters ``` *** ### crossDomain? ```ts optional crossDomain: boolean; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:127 If you wish to force a crossDomain request (such as JSONP) on the same domain, set the value of crossDomain to true. This allows, for example, server-side redirection to another domain. #### Inherited from ```ts JQueryAjaxSettings.crossDomain ``` *** ### data? ```ts optional data: string | PlainObject; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:131 Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be Key/Value pairs. If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting (described below). #### Inherited from ```ts JQueryAjaxSettings.data ``` *** ### dataType? ```ts optional dataType: string; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:153 The type of data that you're expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string). The available types (and the result passed as the first argument to your success callback) are: "xml": Returns a XML document that can be processed via jQuery. "html": Returns HTML as plain text; included script tags are evaluated when inserted in the DOM. "script": Evaluates the response as JavaScript and returns it as plain text. Disables caching by appending a query string parameter, \_=\[TIMESTAMP], to the URL unless the cache option is set to true. Note: This will turn POSTs into GETs for remote-domain requests. "json": Evaluates the response as JSON and returns a JavaScript object. Cross-domain "json" requests are converted to "jsonp" unless the request includes jsonp: false in its request options. The JSON data is parsed in a strict manner; any malformed JSON is rejected and a parse error is thrown. As of jQuery 1.9, an empty response is also rejected; the server should return a response of null or {} instead. (See json.org for more information on proper JSON formatting.) "jsonp": Loads in a JSON block using JSONP. Adds an extra "?callback=?" to the end of your URL to specify the callback. Disables caching by appending a query string parameter, "\_=\[TIMESTAMP]", to the URL unless the cache option is set to true. "text": A plain text string. multiple, space-separated values: As of jQuery 1.5, jQuery can convert a dataType from what it received in the Content-Type header to what you require. For example, if you want a text response to be treated as XML, use "text xml" for the dataType. You can also make a JSONP request, have it received as text, and interpreted by jQuery as XML: "jsonp text xml". Similarly, a shorthand string such as "jsonp xml" will first attempt to convert from jsonp to xml, and, failing that, convert from jsonp to text, and then from text to xml. #### Inherited from ```ts JQueryAjaxSettings.dataType ``` *** ### enctype? ```ts optional enctype: | "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain"; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:163 The MIME type of content that is used to submit the form to the server. Possible values are: "application/x-www-form-urlencoded": The initial default type. "multipart/form-data": The type that allows file element(s) to upload file data. "text/plain": A type introduced in HTML5. #### Inherited from ```ts JQueryAjaxSettings.enctype ``` *** ### error? ```ts optional error: TypeOrArray>; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:167 A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror". When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." As of jQuery 1.5, the error setting can accept an array of functions. Each function will be called in turn. Note: This handler is not called for cross-domain script and cross-domain JSONP requests. This is an Ajax Event. #### Inherited from ```ts JQueryAjaxSettings.error ``` *** ### global? ```ts optional global: boolean; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:171 Whether to trigger global Ajax event handlers for this request. The default is true. Set to false to prevent the global handlers like ajaxStart or ajaxStop from being triggered. This can be used to control various Ajax Events. #### Inherited from ```ts JQueryAjaxSettings.global ``` *** ### headers? ```ts optional headers: PlainObject; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:175 An object of additional header key/value pairs to send along with requests using the XMLHttpRequest transport. The header X-Requested-With: XMLHttpRequest is always added, but its default XMLHttpRequest value can be changed here. Values in the headers setting can also be overwritten from within the beforeSend function. #### Inherited from ```ts JQueryAjaxSettings.headers ``` *** ### ifModified? ```ts optional ifModified: boolean; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:179 Allow the request to be successful only if the response has changed since the last request. This is done by checking the Last-Modified header. Default value is false, ignoring the header. In jQuery 1.4 this technique also checks the 'etag' specified by the server to catch unmodified data. #### Inherited from ```ts JQueryAjaxSettings.ifModified ``` *** ### isLocal? ```ts optional isLocal: boolean; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:183 Allow the current environment to be recognized as "local," (e.g. the filesystem), even if jQuery does not recognize it as such by default. The following protocols are currently recognized as local: file, \*-extension, and widget. If the isLocal setting needs modification, it is recommended to do so once in the $.ajaxSetup() method. #### Inherited from ```ts JQueryAjaxSettings.isLocal ``` *** ### jsonp? ```ts optional jsonp: string | false; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:187 Override the callback function name in a JSONP request. This value will be used instead of 'callback' in the 'callback=?' part of the query string in the url. So {jsonp:'onJSONPLoad'} would result in 'onJSONPLoad=?' passed to the server. As of jQuery 1.5, setting the jsonp option to false prevents jQuery from adding the "?callback" string to the URL or attempting to use "=?" for transformation. In this case, you should also explicitly set the jsonpCallback setting. For example, { jsonp: false, jsonpCallback: "callbackName" }. If you don't trust the target of your Ajax requests, consider setting the jsonp property to false for security reasons. #### Inherited from ```ts JQueryAjaxSettings.jsonp ``` *** ### jsonpCallback? ```ts optional jsonpCallback: string | (this) => string; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:191 Specify the callback function name for a JSONP request. This value will be used instead of the random name automatically generated by jQuery. It is preferable to let jQuery generate a unique name as it'll make it easier to manage the requests and provide callbacks and error handling. You may want to specify the callback when you want to enable better browser caching of GET requests. As of jQuery 1.5, you can also use a function for this setting, in which case the value of jsonpCallback is set to the return value of that function. #### Inherited from ```ts JQueryAjaxSettings.jsonpCallback ``` *** ### method ```ts method: HTTPMethod; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:54](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L54) The HTTP method to use for the request (e.g. "POST", "GET", "PUT"). #### Overrides ```ts JQueryAjaxSettings.method ``` *** ### mimeType? ```ts optional mimeType: string; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:199 A mime type to override the XHR mime type. #### Inherited from ```ts JQueryAjaxSettings.mimeType ``` *** ### password? ```ts optional password: string; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:203 A password to be used with XMLHttpRequest in response to an HTTP access authentication request. #### Inherited from ```ts JQueryAjaxSettings.password ``` *** ### processData? ```ts optional processData: boolean; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:207 By default, data passed in to the data option as an object (technically, anything other than a string) will be processed and transformed into a query string, fitting to the default content-type "application/x-www-form-urlencoded". If you want to send a DOMDocument, or other non-processed data, set this option to false. #### Inherited from ```ts JQueryAjaxSettings.processData ``` *** ### scriptCharset? ```ts optional scriptCharset: string; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:211 Only applies when the "script" transport is used (e.g., cross-domain requests with "jsonp" or "script" dataType and "GET" type). Sets the charset attribute on the script tag used in the request. Used when the character set on the local page is not the same as the one on the remote script. #### Inherited from ```ts JQueryAjaxSettings.scriptCharset ``` *** ### statusCode? ```ts optional statusCode: StatusCodeCallbacks; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:217 An object of numeric HTTP codes and functions to be called when the response has the corresponding code. If the request is successful, the status code functions take the same parameters as the success callback; if it results in an error (including 3xx redirect), they take the same parameters as the error callback. #### Inherited from ```ts JQueryAjaxSettings.statusCode ``` *** ### success? ```ts optional success: TypeOrArray>; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:221 A function to be called if the request succeeds. The function gets passed three arguments: The data returned from the server, formatted according to the dataType parameter or the dataFilter callback function, if specified; a string describing the status; and the jqXHR (in jQuery 1.4.x, XMLHttpRequest) object. As of jQuery 1.5, the success setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event. #### Inherited from ```ts JQueryAjaxSettings.success ``` *** ### timeout? ```ts optional timeout: number; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:225 Set a timeout (in milliseconds) for the request. A value of 0 means there will be no timeout. This will override any global timeout set with $.ajaxSetup(). The timeout period starts at the point the $.ajax call is made; if several other requests are in progress and the browser has no connections available, it is possible for a request to time out before it can be sent. In jQuery 1.4.x and below, the XMLHttpRequest object will be in an invalid state if the request times out; accessing any object members may throw an exception. In Firefox 3.0+ only, script and JSONP requests cannot be cancelled by a timeout; the script will run even if it arrives after the timeout period. #### Inherited from ```ts JQueryAjaxSettings.timeout ``` *** ### traditional? ```ts optional traditional: boolean; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:229 Set this to true if you wish to use the traditional style of param serialization. #### Inherited from ```ts JQueryAjaxSettings.traditional ``` *** ### type ```ts type: HTTPMethod; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:55](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L55) An alias for method. You should use type if you're using versions of jQuery prior to 1.9.0. #### Overrides ```ts JQueryAjaxSettings.type ``` *** ### url ```ts url: string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:53](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L53) A string containing the URL to which the request is sent. #### Overrides ```ts JQueryAjaxSettings.url ``` *** ### username? ```ts optional username: string; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:237 A username to be used with XMLHttpRequest in response to an HTTP access authentication request. #### Inherited from ```ts JQueryAjaxSettings.username ``` *** ### xhrFields? ```ts optional xhrFields: XHRFields; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:248 An object of fieldName-fieldValue pairs to set on the native XHR object. In jQuery 1.5, the withCredentials property was not propagated to the native XHR and thus CORS requests requiring it would ignore this flag. For this reason, we recommend using jQuery 1.5.1+ should you require the use of it. #### Inherited from ```ts JQueryAjaxSettings.xhrFields ``` ## Methods ### beforeSend()? ```ts optional beforeSend( this, jqXHR, settings): false | void; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:99 A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object before it is sent. Use this to set custom headers, etc. The jqXHR and settings objects are passed as arguments. This is an Ajax Event. Returning false in the beforeSend function will cancel the request. As of jQuery 1.5, the beforeSend option will be called regardless of the type of request. #### Parameters ##### this `any` ##### jqXHR `jqXHR` ##### settings `this` #### Returns `false` | `void` #### Inherited from ```ts JQueryAjaxSettings.beforeSend ``` *** ### dataFilter()? ```ts optional dataFilter(data, type): any; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:135 A function to be used to handle the raw response data of XMLHttpRequest. This is a pre-filtering function to sanitize the response. You should return the sanitized data. The function accepts two arguments: The raw data returned from the server and the 'dataType' parameter. #### Parameters ##### data `string` ##### type `string` #### Returns `any` #### Inherited from ```ts JQueryAjaxSettings.dataFilter ``` *** ### xhr()? ```ts optional xhr(): XMLHttpRequest; ``` Defined in: node\_modules/.pnpm/@types+jquery@3.5.32/node\_modules/@types/jquery/misc.d.ts:242 Callback for creating the XMLHttpRequest object. Defaults to the ActiveXObject when available (IE), the XMLHttpRequest otherwise. Override to provide your own implementation for XMLHttpRequest or enhancements to the factory. #### Returns `XMLHttpRequest` #### Inherited from ```ts JQueryAjaxSettings.xhr ``` --- --- url: /api/@warp-drive/legacy/adapter/rest/type-aliases/QueryState.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/rest](../index.md) / QueryState ```ts type QueryState = object; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:41](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L41) ## Properties ### include? ```ts optional include: unknown; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:42](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L42) *** ### since? ```ts optional since: unknown; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:43](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L43) --- --- url: /api/@warp-drive/legacy/adapter/rest/type-aliases/RequestData.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [adapter/rest](../index.md) / RequestData ```ts type RequestData = object; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:58](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L58) ## Indexable ```ts [key: string]: unknown ``` ## Properties ### method ```ts method: HTTPMethod; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:60](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L60) *** ### url ```ts url: string; ``` Defined in: [warp-drive-packages/legacy/src/adapter/rest.ts:59](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/rest.ts#L59) --- --- url: /api/@warp-drive/legacy/adapter/variables/BuildURLMixin.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [adapter](../index.md) / BuildURLMixin ```ts BuildURLMixin: Mixin; ``` Defined in: [warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts:17](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/adapter/-private/build-url-mixin.ts#L17) --- --- url: /api/@warp-drive/legacy/compat/builders/functions/findAll.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [compat/builders](../index.md) / findAll ## Call Signature ```ts function findAll(type, options?): FindAllRequestInput, T[]>; ``` Defined in: [warp-drive-packages/legacy/src/compat/builders/find-all.ts:37](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/builders/find-all.ts#L37) This function builds a request config to perform a `findAll` request for the given type. When passed to `store.request`, this config will result in the same behavior as a `store.findAll` request. Additionally, it takes the same options as `store.findAll`. All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../../../../core-types/record/interfaces/TypedRecordInstance.md) ### Parameters #### type [`TypeFromInstance`](../../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`> the name of the resource #### options? `FindAllBuilderOptions`<`T`> optional, may include `adapterOptions` hash which will be passed to adapter.findAll ### Returns `FindAllRequestInput`<[`TypeFromInstance`](../../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`>, `T`\[]> request config ### Deprecated ## Call Signature ```ts function findAll(type, options?): FindAllRequestInput; ``` Defined in: [warp-drive-packages/legacy/src/compat/builders/find-all.ts:41](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/builders/find-all.ts#L41) This function builds a request config to perform a `findAll` request for the given type. When passed to `store.request`, this config will result in the same behavior as a `store.findAll` request. Additionally, it takes the same options as `store.findAll`. All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Parameters #### type `string` the name of the resource #### options? `FindAllBuilderOptions`<`unknown`> optional, may include `adapterOptions` hash which will be passed to adapter.findAll ### Returns `FindAllRequestInput` request config ### Deprecated --- --- url: /api/@warp-drive/legacy/compat/builders/functions/findRecord.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [compat/builders](../index.md) / findRecord ## Call Signature ```ts function findRecord( type, id, options?): FindRecordRequestInput, T>; ``` Defined in: [warp-drive-packages/legacy/src/compat/builders/find-record.ts:57](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/builders/find-record.ts#L57) This function builds a request config to find the record for a given identifier or type and id combination. When passed to `store.request`, this config will result in the same behavior as a `store.findRecord` request. Additionally, it takes the same options as `store.findRecord`, with the exception of `preload` (which is unsupported). **Example 1** ```ts import { findRecord } from '@ember-data/legacy-compat/builders'; const { content: post } = await store.request(findRecord('post', '1')); ``` **Example 2** `findRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) ```ts import { findRecord } from '@ember-data/legacy-compat/builders'; const { content: post } = await store.request(findRecord({ type: 'post', id })); ``` All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../../../../core-types/record/interfaces/TypedRecordInstance.md) ### Parameters #### type [`TypeFromInstance`](../../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`> #### id `string` optional object with options for the request only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved #### options? `FindRecordBuilderOptions` if the first param is a string this will be the optional options for the request. See examples for available options. ### Returns `FindRecordRequestInput`<[`TypeFromInstance`](../../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`>, `T`> request config ### Deprecated ## Call Signature ```ts function findRecord( type, id, options?): FindRecordRequestInput; ``` Defined in: [warp-drive-packages/legacy/src/compat/builders/find-record.ts:62](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/builders/find-record.ts#L62) This function builds a request config to find the record for a given identifier or type and id combination. When passed to `store.request`, this config will result in the same behavior as a `store.findRecord` request. Additionally, it takes the same options as `store.findRecord`, with the exception of `preload` (which is unsupported). **Example 1** ```ts import { findRecord } from '@ember-data/legacy-compat/builders'; const { content: post } = await store.request(findRecord('post', '1')); ``` **Example 2** `findRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) ```ts import { findRecord } from '@ember-data/legacy-compat/builders'; const { content: post } = await store.request(findRecord({ type: 'post', id })); ``` All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Parameters #### type `string` #### id `string` optional object with options for the request only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved #### options? `FindRecordBuilderOptions` if the first param is a string this will be the optional options for the request. See examples for available options. ### Returns `FindRecordRequestInput` request config ### Deprecated ## Call Signature ```ts function findRecord(resource, options?): FindRecordRequestInput, T>; ``` Defined in: [warp-drive-packages/legacy/src/compat/builders/find-record.ts:63](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/builders/find-record.ts#L63) This function builds a request config to find the record for a given identifier or type and id combination. When passed to `store.request`, this config will result in the same behavior as a `store.findRecord` request. Additionally, it takes the same options as `store.findRecord`, with the exception of `preload` (which is unsupported). **Example 1** ```ts import { findRecord } from '@ember-data/legacy-compat/builders'; const { content: post } = await store.request(findRecord('post', '1')); ``` **Example 2** `findRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) ```ts import { findRecord } from '@ember-data/legacy-compat/builders'; const { content: post } = await store.request(findRecord({ type: 'post', id })); ``` All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../../../../core-types/record/interfaces/TypedRecordInstance.md) ### Parameters #### resource [`ResourceIdentifierObject`](../../../../core-types/spec/json-api-raw/type-aliases/ResourceIdentifierObject.md)<[`TypeFromInstance`](../../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`>> either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record #### options? `FindRecordBuilderOptions` if the first param is a string this will be the optional options for the request. See examples for available options. ### Returns `FindRecordRequestInput`<[`TypeFromInstance`](../../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`>, `T`> request config ### Deprecated ## Call Signature ```ts function findRecord(resource, options?): FindRecordRequestInput; ``` Defined in: [warp-drive-packages/legacy/src/compat/builders/find-record.ts:67](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/builders/find-record.ts#L67) This function builds a request config to find the record for a given identifier or type and id combination. When passed to `store.request`, this config will result in the same behavior as a `store.findRecord` request. Additionally, it takes the same options as `store.findRecord`, with the exception of `preload` (which is unsupported). **Example 1** ```ts import { findRecord } from '@ember-data/legacy-compat/builders'; const { content: post } = await store.request(findRecord('post', '1')); ``` **Example 2** `findRecord` can be called with a single identifier argument instead of the combination of `type` (modelName) and `id` as separate arguments. You may recognize this combo as the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification) ```ts import { findRecord } from '@ember-data/legacy-compat/builders'; const { content: post } = await store.request(findRecord({ type: 'post', id })); ``` All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Parameters #### resource [`ResourceIdentifierObject`](../../../../core-types/spec/json-api-raw/type-aliases/ResourceIdentifierObject.md) either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record #### options? `FindRecordBuilderOptions` if the first param is a string this will be the optional options for the request. See examples for available options. ### Returns `FindRecordRequestInput` request config ### Deprecated --- --- url: /api/@warp-drive/legacy/compat/builders/functions/query.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [compat/builders](../index.md) / query ## Call Signature ```ts function query( type, query, options?): QueryRequestInput, T[]>; ``` Defined in: [warp-drive-packages/legacy/src/compat/builders/query.ts:38](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/builders/query.ts#L38) This function builds a request config for a given type and query object. When passed to `store.request`, this config will result in the same behavior as a `store.query` request. Additionally, it takes the same options as `store.query`. All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../../../../core-types/record/interfaces/TypedRecordInstance.md) ### Parameters #### type [`TypeFromInstance`](../../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`> the name of the resource #### query [`LegacyResourceQuery`](../../../../core-types/index/type-aliases/LegacyResourceQuery.md)<`T`> a query to be used by the adapter #### options? [`QueryOptions`](../../../../core-types/index/type-aliases/QueryOptions.md) optional, may include `adapterOptions` hash which will be passed to adapter.query ### Returns `QueryRequestInput`<[`TypeFromInstance`](../../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`>, `T`\[]> request config ### Deprecated ## Call Signature ```ts function query( type, query, options?): QueryRequestInput; ``` Defined in: [warp-drive-packages/legacy/src/compat/builders/query.ts:43](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/builders/query.ts#L43) This function builds a request config for a given type and query object. When passed to `store.request`, this config will result in the same behavior as a `store.query` request. Additionally, it takes the same options as `store.query`. All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Parameters #### type `string` the name of the resource #### query [`LegacyResourceQuery`](../../../../core-types/index/type-aliases/LegacyResourceQuery.md) a query to be used by the adapter #### options? [`QueryOptions`](../../../../core-types/index/type-aliases/QueryOptions.md) optional, may include `adapterOptions` hash which will be passed to adapter.query ### Returns `QueryRequestInput` request config ### Deprecated --- --- url: /api/@warp-drive/legacy/compat/builders/functions/queryRecord.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [compat/builders](../index.md) / queryRecord ## Call Signature ```ts function queryRecord( type, query, options?): QueryRecordRequestInput, null | T>; ``` Defined in: [warp-drive-packages/legacy/src/compat/builders/query.ts:97](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/builders/query.ts#L97) This function builds a request config for a given type and query object. When passed to `store.request`, this config will result in the same behavior as a `store.queryRecord` request. Additionally, it takes the same options as `store.queryRecord`. All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../../../../core-types/record/interfaces/TypedRecordInstance.md) ### Parameters #### type [`TypeFromInstance`](../../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`> the name of the resource #### query [`LegacyResourceQuery`](../../../../core-types/index/type-aliases/LegacyResourceQuery.md)<`T`> a query to be used by the adapter #### options? [`QueryOptions`](../../../../core-types/index/type-aliases/QueryOptions.md) optional, may include `adapterOptions` hash which will be passed to adapter.query ### Returns `QueryRecordRequestInput`<[`TypeFromInstance`](../../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`>, `null` | `T`> request config ### Deprecated ## Call Signature ```ts function queryRecord( type, query, options?): QueryRecordRequestInput; ``` Defined in: [warp-drive-packages/legacy/src/compat/builders/query.ts:102](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/builders/query.ts#L102) This function builds a request config for a given type and query object. When passed to `store.request`, this config will result in the same behavior as a `store.queryRecord` request. Additionally, it takes the same options as `store.queryRecord`. All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ### Parameters #### type `string` the name of the resource #### query [`LegacyResourceQuery`](../../../../core-types/index/type-aliases/LegacyResourceQuery.md) a query to be used by the adapter #### options? [`QueryOptions`](../../../../core-types/index/type-aliases/QueryOptions.md) optional, may include `adapterOptions` hash which will be passed to adapter.query ### Returns `QueryRecordRequestInput` request config ### Deprecated --- --- url: /api/@warp-drive/legacy/compat/builders/functions/saveRecord.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [compat/builders](../index.md) / saveRecord ```ts function saveRecord(record, options): SaveRecordRequestInput, T>; ``` Defined in: [warp-drive-packages/legacy/src/compat/builders/save-record.ts:46](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/builders/save-record.ts#L46) This function builds a request config for saving the given record (e.g. creating, updating, or deleting the record). When passed to `store.request`, this config will result in the same behavior as a legacy `store.saveRecord` request. Additionally, it takes the same options as `store.saveRecord`. All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ## Type Parameters ### T `T` *extends* [`TypedRecordInstance`](../../../../core-types/record/interfaces/TypedRecordInstance.md) ## Parameters ### record `T` a record to save ### options `Record`<`string`, `unknown`> = `{}` optional, may include `adapterOptions` hash which will be passed to adapter.saveRecord ## Returns `SaveRecordRequestInput`<[`TypeFromInstance`](../../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`>, `T`> request config ## Deprecated --- --- url: /api/@warp-drive/legacy/compat/functions/adapterFor.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [compat](../index.md) / adapterFor ## Call Signature ```ts function adapterFor(this, modelName): MinimumAdapterInterface; ``` Defined in: [warp-drive-packages/legacy/src/compat.ts:52](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat.ts#L52) Returns an instance of the adapter for a given type. For example, `adapterFor('person')` will return an instance of the adapter located at `app/adapters/person.js` If no `person` adapter is found, this method will look for an `application` adapter (the default adapter for your entire application). ### Parameters #### this [`default`](../../../../@ember-data/store/index/classes/default.md) #### modelName `string` ### Returns [`MinimumAdapterInterface`](../interfaces/MinimumAdapterInterface.md) ## Call Signature ```ts function adapterFor( this, modelName, _allowMissing): | undefined | MinimumAdapterInterface; ``` Defined in: [warp-drive-packages/legacy/src/compat.ts:53](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat.ts#L53) Returns an instance of the adapter for a given type. For example, `adapterFor('person')` will return an instance of the adapter located at `app/adapters/person.js` If no `person` adapter is found, this method will look for an `application` adapter (the default adapter for your entire application). ### Parameters #### this [`default`](../../../../@ember-data/store/index/classes/default.md) #### modelName `string` #### \_allowMissing `true` ### Returns | `undefined` | [`MinimumAdapterInterface`](../interfaces/MinimumAdapterInterface.md) --- --- url: /api/@warp-drive/legacy/compat/functions/cleanup.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [compat](../index.md) / cleanup ```ts function cleanup(this): void; ``` Defined in: [warp-drive-packages/legacy/src/compat.ts:283](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat.ts#L283) ## Parameters ### this [`default`](../../../../@ember-data/store/index/classes/default.md) ## Returns `void` --- --- url: /api/@warp-drive/legacy/compat/functions/normalize.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [compat](../index.md) / normalize ```ts function normalize( this, modelName, payload): SingleResourceDocument; ``` Defined in: [warp-drive-packages/legacy/src/compat.ts:177](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat.ts#L177) `normalize` converts a json payload into the normalized form that [push](../methods/push?anchor=push) expects. Example ```js socket.on('message', function(message) { let modelName = message.model; let data = message.data; store.push(store.normalize(modelName, data)); }); ``` ## Parameters ### this [`default`](../../../../@ember-data/store/index/classes/default.md) ### modelName `string` The name of the model type for this payload ### payload [`ObjectValue`](../../../core-types/json/raw/interfaces/ObjectValue.md) ## Returns [`SingleResourceDocument`](../../../core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md) The normalized payload --- --- url: /api/@warp-drive/legacy/compat/builders.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / compat/builders Builders for migrating from `store` methods to `store.request`. These builders enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data. ## Deprecated ## Functions * [~~findAll~~](functions/findAll.md) * [~~findRecord~~](functions/findRecord.md) * [~~query~~](functions/query.md) * [~~queryRecord~~](functions/queryRecord.md) * [~~saveRecord~~](functions/saveRecord.md) --- --- url: /api/@warp-drive/legacy/compat/functions/pushPayload.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [compat](../index.md) / pushPayload ```ts function pushPayload( this, modelName, inputPayload): void; ``` Defined in: [warp-drive-packages/legacy/src/compat.ts:254](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat.ts#L254) Push some raw data into the store. This method can be used both to push in brand new records, as well as to update existing records. You can push in more than one type of object at once. All objects should be in the format expected by the serializer. ```js [app/serializers/application.js] import RESTSerializer from '@ember-data/serializer/rest'; export default class ApplicationSerializer extends RESTSerializer; ``` ```js let pushData = { posts: [ { id: 1, postTitle: "Great post", commentIds: [2] } ], comments: [ { id: 2, commentBody: "Insightful comment" } ] } store.pushPayload(pushData); ``` By default, the data will be deserialized using a default serializer (the application serializer if it exists). Alternatively, `pushPayload` will accept a model type which will determine which serializer will process the payload. ```js [app/serializers/application.js] import RESTSerializer from '@ember-data/serializer/rest'; export default class ApplicationSerializer extends RESTSerializer; ``` ```js [app/serializers/post.js] import JSONSerializer from '@ember-data/serializer/json'; export default JSONSerializer; ``` ```js store.pushPayload(pushData); // Will use the application serializer store.pushPayload('post', pushData); // Will use the post serializer ``` ## Parameters ### this [`default`](../../../../@ember-data/store/index/classes/default.md) ### modelName `string` Optionally, a model type used to determine which serializer will be used ### inputPayload [`ObjectValue`](../../../core-types/json/raw/interfaces/ObjectValue.md) ## Returns `void` --- --- url: /api/@warp-drive/legacy/compat/functions/serializeRecord.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [compat](../index.md) / serializeRecord ```ts function serializeRecord( this, record, options?): unknown; ``` Defined in: [warp-drive-packages/legacy/src/compat.ts:273](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat.ts#L273) ## Parameters ### this [`default`](../../../../@ember-data/store/index/classes/default.md) ### record `unknown` ### options? [`SerializerOptions`](../type-aliases/SerializerOptions.md) ## Returns `unknown` --- --- url: /api/@warp-drive/legacy/compat/functions/serializerFor.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [compat](../index.md) / serializerFor ```ts function serializerFor(this, modelName): | null | MinimumSerializerInterface; ``` Defined in: [warp-drive-packages/legacy/src/compat.ts:115](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat.ts#L115) Returns an instance of the serializer for a given type. For example, `serializerFor('person')` will return an instance of `App.PersonSerializer`. If no `App.PersonSerializer` is found, this method will look for an `App.ApplicationSerializer` (the default serializer for your entire application). If a serializer cannot be found on the adapter, it will fall back to an instance of `JSONSerializer`. ## Parameters ### this [`default`](../../../../@ember-data/store/index/classes/default.md) ### modelName `string` the record to serialize ## Returns | `null` | [`MinimumSerializerInterface`](../interfaces/MinimumSerializerInterface.md) --- --- url: /api/@warp-drive/legacy/compat.md --- [Documentation](../../../index.md) / [@warp-drive/legacy](../index.md) / compat ## Interfaces * [MinimumAdapterInterface](interfaces/MinimumAdapterInterface.md) * [MinimumSerializerInterface](interfaces/MinimumSerializerInterface.md) ## Type Aliases * [AdapterPayload](type-aliases/AdapterPayload.md) * [CompatStore](type-aliases/CompatStore.md) * [LegacyStoreCompat](type-aliases/LegacyStoreCompat.md) * [SerializerOptions](type-aliases/SerializerOptions.md) ## Variables * [LegacyNetworkHandler](variables/LegacyNetworkHandler.md) ## Functions * [adapterFor](functions/adapterFor.md) * [cleanup](functions/cleanup.md) * [normalize](functions/normalize.md) * [pushPayload](functions/pushPayload.md) * [serializeRecord](functions/serializeRecord.md) * [serializerFor](functions/serializerFor.md) --- --- url: /api/@warp-drive/legacy/compat/interfaces/MinimumAdapterInterface.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [compat](../index.md) / MinimumAdapterInterface Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:35](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L35) The following documentation describes the methods an adapter should implement with descriptions around when an application might expect these methods to be called. Methods that are not required are marked as **optional**. (Interface) Adapter ## Properties ### coalesceFindRequests? ```ts optional coalesceFindRequests: boolean; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:437](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L437) **`Optional`** If your adapter implements `findMany`, setting this to `true` will cause `findRecord` requests triggered within the same `runloop` to be coalesced into one or more calls to `adapter.findMany`. The number of calls made and the records contained in each call can be tuned by your adapter's `groupRecordsForHasMany` method. Implementing coalescing using this flag and the associated methods does not always offer the right level of correctness, timing control or granularity. If your application would be better suited coalescing across multiple types, coalescing for longer than a single runloop, or with a more custom request structure, coalescing within your application adapter may prove more effective. ## Methods ### createRecord() ```ts createRecord( store, schema, snapshot): Promise; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:217](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L217) `adapter.createRecord` takes a request to create a resource of a given `type` and should return a `Promise` which fulfills with data for the newly created resource. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `createRecord`, which should return a `JSON:API` document. The final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing data for the record. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. If the adapter rejects or throws an error the record will enter an error state and the attributes that had attempted to be saved will still be considered dirty. ### InvalidErrors When rejecting a `createRecord` request due to validation issues during save (typically a 422 status code), you may throw an `InvalidError`. Throwing an `InvalidError` makes per-attribute errors available for records to use in the UI as needed. Records can also use this information to mark themselves as being in an `invalid` state. For more reading [see the RecordData Errors RFC](https://emberjs.github.io/rfcs/0465-record-data-errors.html) ```js let error = new Error(errorMessage); // these two properties combined // alert EmberData to this error being for // invalid properties on the record during // the request error.isAdapterError = true; error.code = 'InvalidError'; // A JSON:API formatted array of errors // See https://jsonapi.org/format/#errors error.errors = []; throw error; ``` #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) The store service that initiated the request being normalized ##### schema [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> a promise resolving with resource data to feed to the associated serializer *** ### deleteRecord() ```ts deleteRecord( store, schema, snapshot): Promise; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:295](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L295) `adapter.deleteRecord` takes a request to delete a resource of a given `type` and should return a `Promise` which resolves when that deletion is complete. Usually the response will be empty, but you may include additional updates in the response. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `deleteRecord`, which should return a `JSON:API` document. The final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing data. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. If the adapter rejects or errors the record will need to be saved again once the reason for the error is addressed in order to persist the deleted state. #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) The store service that initiated the request being normalized ##### schema [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### snapshot `Snapshot` A Snapshot containing the record's current data #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> *** ### destroy()? ```ts optional destroy(): void; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:571](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L571) **`Optional`** In some situations the adapter may need to perform cleanup when destroyed, that cleanup can be done in `destroy`. If not implemented, the store does not inform the adapter of destruction. #### Returns `void` *** ### findAll() ```ts findAll( store, schema, sinceToken, snapshotRecordArray): Promise; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:93](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L93) `adapter.findAll` takes a request for resources of a given `type` and should return a `Promise` which fulfills with a collection of resource data matching that `type`. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `findAll`, which should return a `JSON:API` document. The final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing records for `type`. Existing records for the `type` will not be removed. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. `adapter.findAll` is called whenever `store.findAll` is asked to reload or backgroundReload. The records in the response are merged with the contents of the store. Existing records for the `type` will not be removed. See also `shouldReloadAll` and `shouldBackgroundReloadAll` #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) The store service that initiated the request being normalized ##### schema [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### sinceToken `null` This parameter is no longer used and will always be null. ##### snapshotRecordArray `SnapshotRecordArray` an object containing any passed in options, adapterOptions, and the ability to access a snapshot for each existing record of the type. #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> a promise resolving with resource data to feed to the associated serializer *** ### findBelongsTo()? ```ts optional findBelongsTo( store, snapshot, relatedLink, relationship): Promise; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:326](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L326) **`Optional`** `adapter.findBelongsTo` takes a request to fetch a related resource located at a `relatedLink` and should return a `Promise` which fulfills with data for a single resource. ⚠️ This method is only called if the store previously received relationship information for a resource containing a [related link](https://jsonapi.org/format/#document-resource-object-related-resource-links). If the cache does not have a `link` for the relationship then `findRecord` will be used if a `type` and `id` for the related resource is known. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `findBelongsTo`, which should return a `JSON:API` document. The final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing data. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) The store service that initiated the request being normalized ##### snapshot `Snapshot` A Snapshot containing the parent record's current data ##### relatedLink `string` The link at which the associated resource might be found ##### relationship [`LegacyRelationshipField`](../../../core-types/schema/fields/type-aliases/LegacyRelationshipField.md) #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> a promise resolving with resource data to feed to the associated serializer *** ### findHasMany()? ```ts optional findHasMany( store, snapshot, relatedLink, relationship): Promise; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:363](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L363) **`Optional`** `adapter.findHasMany` takes a request to fetch a related resource collection located at a `relatedLink` and should return a `Promise` which fulfills with data for that collection. ⚠️ This method is only called if the store previously received relationship information for a resource containing a [related link](https://jsonapi.org/format/#document-resource-object-related-resource-links). If the cache does not have a `link` for the relationship but the `type` and `id` of related resources are known then `findRecord` will be used for each individual related resource. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `findHasMany`, which should return a `JSON:API` document. The final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing data. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) The store service that initiated the request being normalized ##### snapshot `Snapshot` A Snapshot containing the parent record's current data ##### relatedLink `string` The link at which the associated resource collection might be found ##### relationship [`LegacyRelationshipField`](../../../core-types/schema/fields/type-aliases/LegacyRelationshipField.md) #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> a promise resolving with resource data to feed to the associated serializer *** ### findMany()? ```ts optional findMany( store, schema, ids, snapshots): Promise; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:398](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L398) **`Optional`** ⚠️ This Method is only called if `coalesceFindRequests` is `true`. The array passed to it is determined by the adapter's `groupRecordsForFindMany` method, and will be called once per group returned. `adapter.findMany` takes a request to fetch a collection of resources and should return a `Promise` which fulfills with data for that collection. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `findMany`, which should return a `JSON:API` document. The final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing data. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. See also `groupRecordsForFindMany` and `coalesceFindRequests` #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) The store service that initiated the request being normalized ##### schema [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### ids `string`\[] An array of the ids of the resources to fetch ##### snapshots `Snapshot`<`unknown`>\[] An array of snapshots of the available data for the resources to fetch #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> a promise resolving with resource data to feed to the associated serializer *** ### findRecord() ```ts findRecord( store, schema, id, snapshot): Promise; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:62](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L62) `adapter.findRecord` takes a request for a resource of a given `type` and `id` combination and should return a `Promise` which fulfills with data for a single resource matching that `type` and `id`. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `findRecord`, which should return a `JSON:API` document. The final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing data for the record. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. `adapter.findRecord` is called whenever the `store` needs to load, reload, or backgroundReload the resource data for a given `type` and `id`. #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) The store service that initiated the request being normalized ##### schema [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### id `string` ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> a promise resolving with resource data to feed to the associated serializer *** ### generateIdForRecord()? ```ts optional generateIdForRecord( store, type, properties): string; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:418](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L418) **`Optional`** This method provides the ability to generate an ID to assign to a new record whenever `store.createRecord` is called if no `id` was provided. Alternatively you can pass an id into the call to `store.createRecord` directly. ```js let id = generateNewId(type); let newRecord = store.createRecord(type, { id }); ``` #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) The store service that initiated the request being normalized ##### type `string` The type (or modelName) of record being created ##### properties `unknown` the properties passed as the second arg to `store.createRecord` #### Returns `string` a string ID that should be unique (no other models of `type` in the cache should have this `id`) *** ### groupRecordsForFindMany()? ```ts optional groupRecordsForFindMany(store, snapshots): Group[]; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:460](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L460) **`Optional`** ⚠️ This Method is only called if `coalesceFindRequests` is `true`. This method allows for you to split pending requests for records into multiple `findMany` requests. It receives an array of snapshots where each snapshot represents a unique record requested via `store.findRecord` during the most recent `runloop` that was not found in the cache or needs to be reloaded. It should return an array of groups. A group is an array of snapshots meant to be fetched together by a single `findMany` request. By default if this method is not implemented EmberData will call `findMany` once with all requested records as a single group when `coalesceFindRequests` is `true`. See also `findMany` and `coalesceFindRequests` #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) The store service that initiated the request being normalized ##### snapshots `Snapshot`<`unknown`>\[] An array of snapshots #### Returns `Group`\[] An array of Snapshot arrays *** ### query() ```ts query( store, schema, query, recordArray, options): Promise; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:130](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L130) `adapter.query` takes a request for resources of a given `type` and should return a `Promise` which fulfills with a collection of resource data matching that `type`. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `query`, which should return a `JSON:API` document. As with `findAll`, the final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing records for `type`. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. `adapter.query` is called whenever `store.query` is called or a previous query result is asked to reload. Existing records for the `type` will not be removed. The key difference is in the result returned by the `store`. For `findAll` the result is all known records of the `type`, while for `query` it will only be the records returned from `adapter.query`. #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) The store service that initiated the request being normalized ##### schema [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### query `Record`<`string`, `unknown`> ##### recordArray `Collection` ##### options ###### adapterOptions? `unknown` #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> a promise resolving with resource data to feed to the associated serializer *** ### queryRecord() ```ts queryRecord( store, schema, query, options): Promise; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:160](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L160) `adapter.queryRecord` takes a request for resource of a given `type` and should return a `Promise` which fulfills with data for a single resource matching that `type`. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `queryRecord`, which should return a `JSON:API` document. The final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing data for the returned record. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) The store service that initiated the request being normalized ##### schema [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### query `Record`<`string`, `unknown`> ##### options ###### adapterOptions? `unknown` #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> a promise resolving with resource data to feed to the associated serializer *** ### shouldBackgroundReloadAll()? ```ts optional shouldBackgroundReloadAll(store, snapshotArray): boolean; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:560](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L560) **`Optional`** When `store.findAll()` is called and a `reload` is not initiated, the adapter is presented the opportunity to trigger a new non-blocking (background) request for records of that type Users may explicitly declare that this background request should/should not occur by passing `backgroundReload: true` or `backgroundReload: false` as an option to the request respectively. ```js store.findAll('user', { backgroundReload: false }) ``` The default behavior if this method is not implemented and the option is not specified is to perform a reload, the same as a return of `true`. #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) The store service that initiated the request being normalized ##### snapshotArray `SnapshotRecordArray` #### Returns `boolean` true if the a new request for all records of the type in SnapshotRecordArray should be made in the background, false otherwise *** ### shouldBackgroundReloadRecord()? ```ts optional shouldBackgroundReloadRecord(store, snapshot): boolean; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:537](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L537) **`Optional`** When a record is already available in the store and is requested again via `store.findRecord`, and the record does not need to be reloaded prior to return, this method provides the ability to specify whether a refresh of the data for the reload should be scheduled to occur in the background. Users may explicitly declare a record should/should not be background reloaded by passing `backgroundReload: true` or `backgroundReload: false` as an option to the request respectively. ```js store.findRecord('user', '1', { backgroundReload: false }) ``` If the `backgroundReload` option is not present, this method will be called to determine whether a backgroundReload should be performed. The default behavior if this method is not implemented and the option was not specified is to background reload, the same as a return of `true`. #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) The store service that initiated the request being normalized ##### snapshot `Snapshot` A Snapshot containing the record's current data #### Returns `boolean` true if the record should be reloaded in the background, false otherwise *** ### shouldReloadAll()? ```ts optional shouldReloadAll(store, snapshotArray): boolean; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:511](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L511) **`Optional`** When `store.findAll()` is called without a `reload` option, the adapter is presented the opportunity to trigger a new request for records of that type. If `reload` is specified as an option in the request (`true` or `false`) this method will not be called. ```js store.findAll('user', { reload: false }) ``` The default behavior if this method is not implemented and the option is not specified is to not reload, the same as a return of `false`. Note: the Promise returned by `store.findAll` resolves to the same LiveArray instance returned by `store.peekAll` for that type, and will include all records in the store for the given type, including any previously existing records not returned by the reload request. #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) The store service that initiated the request being normalized ##### snapshotArray `SnapshotRecordArray` #### Returns `boolean` true if the a new request for all records of the type in SnapshotRecordArray should be made immediately, false otherwise *** ### shouldReloadRecord()? ```ts optional shouldReloadRecord(store, snapshot): boolean; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:485](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L485) **`Optional`** When a record is already available in the store and is requested again via `store.findRecord`, and `reload` is not specified as an option in the request, this method is called to determine whether the record should be reloaded prior to returning the result. If `reload` is specified as an option in the request (`true` or `false`) this method will not be called. ```js store.findRecord('user', '1', { reload: false }) ``` The default behavior if this method is not implemented and the option is not specified is to not reload, the same as a return of `false`. See also the documentation for `shouldBackgroundReloadRecord` which defaults to `true`. #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) The store service that initiated the request being normalized ##### snapshot `Snapshot` A Snapshot containing the record's current data #### Returns `boolean` true if the record should be reloaded immediately, false otherwise *** ### updateRecord() ```ts updateRecord( store, schema, snapshot): Promise; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:268](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L268) `adapter.updateRecord` takes a request to update a resource of a given `type` and should return a `Promise` which fulfills with the updated data for the resource. The response will be fed to the associated serializer's `normalizeResponse` method with the `requestType` set to `updateRecord`, which should return a `JSON:API` document. The final result after normalization to `JSON:API` will be added to store via `store.push` where it will merge with any existing data for the record. ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse` call will NOT be made. In this scenario you may need to do at least a minimum amount of response processing within the adapter. If the adapter rejects or throws an error the record will enter an error state and the attributes that had attempted to be saved will still be considered dirty. ### InvalidErrors When rejecting a `createRecord` request due to validation issues during save (typically a 422 status code), you may throw an `InvalidError`. Throwing an `InvalidError` makes per-attribute errors available for records to use in the UI as needed. Records can also use this information to mark themselves as being in an `invalid` state. For more reading [see the RecordData Errors RFC](https://emberjs.github.io/rfcs/0465-record-data-errors.html) ```js let error = new Error(errorMessage); // these two properties combined // alert EmberData to this error being for // invalid properties on the record during // the request error.isAdapterError = true; error.code = 'InvalidError'; // A JSON:API formatted array of errors // See https://jsonapi.org/format/#errors error.errors = []; throw error; ``` #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) The store service that initiated the request being normalized ##### schema [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### snapshot `Snapshot` #### Returns `Promise`<[`AdapterPayload`](../type-aliases/AdapterPayload.md)> --- --- url: /api/@warp-drive/legacy/compat/interfaces/MinimumSerializerInterface.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [compat](../index.md) / MinimumSerializerInterface Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-serializer-interface.ts:40](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-serializer-interface.ts#L40) The following documentation describes the methods an application serializer should implement with descriptions around when an application might expect these methods to be called. Methods that are not required are marked as **optional**. (Interface) Serializer ## Methods ### destroy()? ```ts optional destroy(): void; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-serializer-interface.ts:254](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-serializer-interface.ts#L254) **`Optional`** In some situations the serializer may need to perform cleanup when destroyed, that cleanup can be done in `destroy`. If not implemented, the store does not inform the serializer of destruction. #### Returns `void` *** ### normalize()? ```ts optional normalize( schema, rawPayload, prop?): SingleResourceDocument; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-serializer-interface.ts:159](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-serializer-interface.ts#L159) **`Optional`** This method is intended to normalize data into a [JSON:API Document](https://jsonapi.org/format/#document-structure) with a data member containing a single [Resource](https://jsonapi.org/format/#document-resource-objects). * `type` should be formatted in the singular, dasherized and lowercase form * `members` (the property names of attributes and relationships) should be formatted to match their definition in the corresponding `Model` definition. Typically this will be `camelCase`. * [`lid`](https://github.com/emberjs/rfcs/blob/main/text/0403-ember-data-identifiers.md) is a valid optional sibling to `id` and `type` in both [Resources](https://jsonapi.org/format/#document-resource-objects) and [Resource Identifier Objects](https://jsonapi.org/format/#document-resource-identifier-objects) This method is called by the `Store` when `store.normalize(modelName, payload)` is called. It is recommended to use `store.serializerFor(modelName).normalizeResponse` over `store.normalize`. This method may be called when also using the `RESTSerializer` when `serializer.pushPayload` is called by `store.pushPayload`. However, it is recommended to use `store.push` over `store.pushPayload` after normalizing the payload directly. Example: ```js function pushPayload(store, modelName, rawPayload) { const ModelClass = store.modelFor(modelName); const serializer = store.serializerFor(modelName); const jsonApiPayload = serializer.normalizeResponse(store, ModelClass, rawPayload, null, 'query'); return store.push(jsonApiPayload); } ``` This method may be called when also using the `JSONAPISerializer` when normalizing included records. If mixing serializer usage in this way we recommend implementing this method, but caution that it may lead to unexpected mixing of formats. This method may also be called when normalizing embedded relationships when using the `EmbeddedRecordsMixin`. If using this mixin in a serializer in your application we recommend implementing this method, but caution that it may lead to unexpected mixing of formats. #### Parameters ##### schema [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### rawPayload [`ObjectValue`](../../../core-types/json/raw/interfaces/ObjectValue.md) Some raw JSON data to be normalized into a JSON:API Resource. ##### prop? `string` When called by the EmbeddedRecordsMixin this param will be the property at which the object provided as rawPayload was found. #### Returns [`SingleResourceDocument`](../../../core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md) A JSON:API Document containing a single JSON:API Resource as its primary data. *** ### normalizeResponse() ```ts normalizeResponse( store, schema, rawPayload, id, requestType): JsonApiDocument; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-serializer-interface.ts:70](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-serializer-interface.ts#L70) This method is responsible for normalizing the value resolved from the promise returned by an Adapter request into the format expected by the `Store`. The output should be a [JSON:API Document](https://jsonapi.org/format/#document-structure) with the following additional restrictions: * `type` should be formatted in the `singular` `dasherized` `lowercase` form * `members` (the property names of attributes and relationships) should be formatted to match their definition in the corresponding `Model` definition. Typically this will be `camelCase`. * [`lid`](https://github.com/emberjs/rfcs/blob/main/text/0403-ember-data-identifiers.md) is a valid optional sibling to `id` and `type` in both [Resources](https://jsonapi.org/format/#document-resource-objects) and [Resource Identifier Objects](https://jsonapi.org/format/#document-resource-identifier-objects) #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) The store service that initiated the request being normalized ##### schema [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### rawPayload [`AdapterPayload`](../type-aliases/AdapterPayload.md) The raw JSON response data returned from an API request. This correlates to the value the promise returned by the adapter method that performed the request resolved to. ##### id For a findRecord request, this is the id initially provided in the call to store.findRecord. Else this value is null. `null` | `string` ##### requestType The type of request the Adapter had been asked to perform. `"findRecord"` | `"queryRecord"` | `"findAll"` | `"findBelongsTo"` | `"findHasMany"` | `"findMany"` | `"query"` | `"createRecord"` | `"deleteRecord"` | `"updateRecord"` #### Returns `JsonApiDocument` a document following the structure of a JSON:API Document. *** ### pushPayload()? ```ts optional pushPayload(store, rawPayload): void; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-serializer-interface.ts:243](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-serializer-interface.ts#L243) **`Optional`** This method allows for normalization of data when `store.pushPayload` is called and should be implemented if you want to use that method. The method is responsible for pushing new data to the store using `store.push` once any necessary normalization has occurred, and no data in the store will be updated unless it does so. The normalized form pushed to the store should be a [JSON:API Document](https://jsonapi.org/format/#document-structure) with the following additional restrictions: * `type` should be formatted in the singular, dasherized and lowercase form * `members` (the property names of attributes and relationships) should be formatted to match their definition in the corresponding `Model` definition. Typically this will be `camelCase`. * [`lid`](https://github.com/emberjs/rfcs/blob/main/text/0403-ember-data-identifiers.md) is a valid optional sibling to `id` and `type` in both [Resources](https://jsonapi.org/format/#document-resource-objects) and [Resource Identifier Objects](https://jsonapi.org/format/#document-resource-identifier-objects) If you need better control over normalization or want access to the records being added or updated in the store, we recommended using `store.push` over `store.pushPayload` after normalizing the payload directly. This can even take advantage of an existing serializer for the format the data is in, for example: ```js function pushPayload(store, modelName, rawPayload) { const ModelClass = store.modelFor(modelName); const serializer = store.serializerFor(modelName); const jsonApiPayload = serializer.normalizeResponse(store, ModelClass, rawPayload, null, 'query'); return store.push(jsonApiPayload); } ``` #### Parameters ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) The store service that initiated the request being normalized ##### rawPayload [`ObjectValue`](../../../core-types/json/raw/interfaces/ObjectValue.md) The raw JSON response data returned from an API request. This JSON should be in the API format expected by the serializer. #### Returns `void` *** ### serialize() ```ts serialize(snapshot, options?): ObjectValue; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-serializer-interface.ts:104](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-serializer-interface.ts#L104) This method is responsible for serializing an individual record via a [Snapshot](Snapshot) into the format expected by the API. This method is called by `snapshot.serialize()`. When using `Model`, this method is called by `record.serialize()`. When using `JSONAPIAdapter` or `RESTAdapter` this method is called by `updateRecord` and `createRecord` if `Serializer.serializeIntoHash` is not implemented. #### Parameters ##### snapshot `Snapshot` A Snapshot for the record to serialize ##### options? [`SerializerOptions`](../type-aliases/SerializerOptions.md) #### Returns [`ObjectValue`](../../../core-types/json/raw/interfaces/ObjectValue.md) *** ### serializeIntoHash()? ```ts optional serializeIntoHash( hash, schema, snapshot, options?): void; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-serializer-interface.ts:200](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-serializer-interface.ts#L200) **`Optional`** When using `JSONAPIAdapter` or `RESTAdapter` this method is called by `adapter.updateRecord` and `adapter.createRecord` if `serializer.serializeIntoHash` is implemented. If this method is not implemented, `serializer.serialize` will be called in this case. You can use this method to customize the root keys serialized into the payload. The hash property should be modified by reference. For instance, your API may expect resources to be keyed by underscored type in the payload: ```js { _user: { type: 'user', id: '1' } } ``` Which when using these adapters can be achieved by implementing this method similar to the following: ```js serializeIntoHash(hash, ModelClass, snapshot, options) { hash[`_${snapshot.modelName}`] = this.serialize(snapshot, options).data; } ``` #### Parameters ##### hash `object` A top most object of the request payload onto which to append the serialized record ##### schema [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md) An object with methods for accessing information about the type, attributes and relationships of the primary type associated with the request. ##### snapshot `Snapshot` A Snapshot for the record to serialize ##### options? [`SerializerOptions`](../type-aliases/SerializerOptions.md) #### Returns `void` --- --- url: /api/@warp-drive/legacy/compat/type-aliases/AdapterPayload.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [compat](../index.md) / AdapterPayload ```ts type AdapterPayload = Record | unknown[]; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts:15](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-adapter-interface.ts#L15) --- --- url: /api/@warp-drive/legacy/compat/type-aliases/CompatStore.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [compat](../index.md) / CompatStore ```ts type CompatStore = default & LegacyStoreCompat; ``` Defined in: [warp-drive-packages/legacy/src/compat.ts:37](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat.ts#L37) --- --- url: /api/@warp-drive/legacy/compat/type-aliases/LegacyStoreCompat.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [compat](../index.md) / LegacyStoreCompat ```ts type LegacyStoreCompat = object; ``` Defined in: [warp-drive-packages/legacy/src/compat.ts:22](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat.ts#L22) ## Properties ### \_adapterCache ```ts _adapterCache: Record; ``` Defined in: [warp-drive-packages/legacy/src/compat.ts:33](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat.ts#L33) *** ### \_fetchManager ```ts _fetchManager: FetchManager; ``` Defined in: [warp-drive-packages/legacy/src/compat.ts:23](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat.ts#L23) *** ### \_serializerCache ```ts _serializerCache: Record; ``` Defined in: [warp-drive-packages/legacy/src/compat.ts:34](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat.ts#L34) ## Methods ### adapterFor() #### Call Signature ```ts adapterFor(this, modelName): MinimumAdapterInterface; ``` Defined in: [warp-drive-packages/legacy/src/compat.ts:24](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat.ts#L24) ##### Parameters ###### this [`default`](../../../../@ember-data/store/index/classes/default.md) ###### modelName `string` ##### Returns [`MinimumAdapterInterface`](../interfaces/MinimumAdapterInterface.md) #### Call Signature ```ts adapterFor( this, modelName, _allowMissing): | undefined | MinimumAdapterInterface; ``` Defined in: [warp-drive-packages/legacy/src/compat.ts:25](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat.ts#L25) ##### Parameters ###### this [`default`](../../../../@ember-data/store/index/classes/default.md) ###### modelName `string` ###### \_allowMissing `true` ##### Returns | `undefined` | [`MinimumAdapterInterface`](../interfaces/MinimumAdapterInterface.md) *** ### normalize() ```ts normalize(modelName, payload): ObjectValue; ``` Defined in: [warp-drive-packages/legacy/src/compat.ts:29](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat.ts#L29) #### Parameters ##### modelName `string` ##### payload [`ObjectValue`](../../../core-types/json/raw/interfaces/ObjectValue.md) #### Returns [`ObjectValue`](../../../core-types/json/raw/interfaces/ObjectValue.md) *** ### pushPayload() ```ts pushPayload(modelName, payload): void; ``` Defined in: [warp-drive-packages/legacy/src/compat.ts:30](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat.ts#L30) #### Parameters ##### modelName `string` ##### payload [`ObjectValue`](../../../core-types/json/raw/interfaces/ObjectValue.md) #### Returns `void` *** ### serializeRecord() ```ts serializeRecord(record, options?): unknown; ``` Defined in: [warp-drive-packages/legacy/src/compat.ts:31](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat.ts#L31) #### Parameters ##### record `unknown` ##### options? [`SerializerOptions`](SerializerOptions.md) #### Returns `unknown` *** ### serializerFor() ```ts serializerFor(modelName, _allowMissing?): | null | MinimumSerializerInterface; ``` Defined in: [warp-drive-packages/legacy/src/compat.ts:27](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat.ts#L27) #### Type Parameters ##### K `K` *extends* `string` #### Parameters ##### modelName `K` ##### \_allowMissing? `boolean` #### Returns | `null` | [`MinimumSerializerInterface`](../interfaces/MinimumSerializerInterface.md) --- --- url: /api/@warp-drive/legacy/compat/utils/functions/configureMismatchReporter.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [compat/utils](../index.md) / configureMismatchReporter ```ts function configureMismatchReporter(fn): void; ``` Defined in: [warp-drive-packages/legacy/src/compat/utils.ts:42](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/utils.ts#L42) Configure a function to be called when an id or type changes during normalization. This is useful for instrumenting to discover places where usage in the app is not consistent. ## Parameters ### fn `Reporter` ## Returns `void` --- --- url: /api/@warp-drive/legacy/compat/utils/functions/configureAssertFn.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [compat/utils](../index.md) / configureAssertFn ```ts function configureAssertFn(fn): void; ``` Defined in: [warp-drive-packages/legacy/src/compat/utils.ts:54](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/utils.ts#L54) Configure a function to be called when an id or type fails validation. This is useful for instrumenting to discover places where usage in the app is not consistent. ## Parameters ### fn (`message`, `condition`) => `void` ## Returns `void` --- --- url: /api/@warp-drive/legacy/compat/type-aliases/SerializerOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [compat](../index.md) / SerializerOptions ```ts type SerializerOptions = object; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-serializer-interface.ts:9](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-serializer-interface.ts#L9) ## Properties ### includeId? ```ts optional includeId: boolean; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-serializer-interface.ts:9](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/minimum-serializer-interface.ts#L9) --- --- url: /api/@warp-drive/legacy/compat/utils/functions/configureTypeNormalization.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [compat/utils](../index.md) / configureTypeNormalization ```ts function configureTypeNormalization(fn): void; ``` Defined in: [warp-drive-packages/legacy/src/compat/utils.ts:71](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/utils.ts#L71) Configure a function to be called to normalize a resource type string. Used by both formattedType and isEquivType to ensure consistent normalization during comparison. If validation fails or the type turns out be unnormalized the configured mismatch reporter and assert functions will be called. ## Parameters ### fn (`type`) => `string` ## Returns `void` --- --- url: /api/@warp-drive/legacy/compat/utils/functions/expectId.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [compat/utils](../index.md) / expectId ## Call Signature ```ts function expectId(id): string; ``` Defined in: [warp-drive-packages/legacy/src/compat/utils.ts:167](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/utils.ts#L167) ### Parameters #### id `string` | `number` ### Returns `string` ## Call Signature ```ts function expectId(id): never; ``` Defined in: [warp-drive-packages/legacy/src/compat/utils.ts:168](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/utils.ts#L168) ### Parameters #### id `null` ### Returns `never` --- --- url: /api/@warp-drive/legacy/compat/utils/functions/formattedType.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [compat/utils](../index.md) / formattedType ```ts function formattedType(type): T; ``` Defined in: [warp-drive-packages/legacy/src/compat/utils.ts:106](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/utils.ts#L106) Converts a potentially unnormalized type into the format expected by our EmberData Cache. Currently this is singular-dasherized. you should not rely on this function to give you an exact format for display purposes. Formatting for display should be handled differently if the exact format matters. Asserts invalid types (undefined, null, '') in dev. **Usage** ```js import formattedType from 'soxhub-client/helpers/formatted-type'; formattedType('post'); // => 'post' formattedType('posts'); // => 'post' formattedType('Posts'); // => 'post' formattedType('post-comment'); // => 'post-comment' formattedType('post-comments'); // => 'post-comment' formattedType('post_comment'); // => 'post-comment' formattedType('postComment'); // => 'post-comment' formattedType('PostComment'); // => 'post-comment' ``` ## Type Parameters ### T `T` *extends* `string` ## Parameters ### type the potentially un-normalized type `string` | `T` ## Returns `T` the normalized type --- --- url: /api/@warp-drive/legacy/compat/utils/functions/formattedId.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [compat/utils](../index.md) / formattedId ## Call Signature ```ts function formattedId(id): string; ``` Defined in: [warp-drive-packages/legacy/src/compat/utils.ts:145](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/utils.ts#L145) Format an id to the format expected by the EmberData Cache. Currently this means that id should be `string | null`. Asserts invalid IDs (undefined, '', 0, '0') in dev. **Usage** ````js import formattedId from 'client/utils/formatted-id'; formattedId('1'); // => '1' formattedId(1); // => '1' formattedId(null); // => null ``` ### Parameters #### id the potentially un-normalized id `string` | `number` ### Returns `string` the normalized id ## Call Signature ```ts function formattedId(id): null; ```` Defined in: [warp-drive-packages/legacy/src/compat/utils.ts:146](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/utils.ts#L146) Format an id to the format expected by the EmberData Cache. Currently this means that id should be `string | null`. Asserts invalid IDs (undefined, '', 0, '0') in dev. **Usage** ````js import formattedId from 'client/utils/formatted-id'; formattedId('1'); // => '1' formattedId(1); // => '1' formattedId(null); // => null ``` ### Parameters #### id `null` the potentially un-normalized id ### Returns `null` the normalized id ## Call Signature ```ts function formattedId(id): null | string; ```` Defined in: [warp-drive-packages/legacy/src/compat/utils.ts:147](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/utils.ts#L147) Format an id to the format expected by the EmberData Cache. Currently this means that id should be `string | null`. Asserts invalid IDs (undefined, '', 0, '0') in dev. **Usage** ````js import formattedId from 'client/utils/formatted-id'; formattedId('1'); // => '1' formattedId(1); // => '1' formattedId(null); // => null ``` ### Parameters #### id the potentially un-normalized id `null` | `string` | `number` ### Returns `null` \| `string` the normalized id ```` --- --- url: /api/@warp-drive/legacy/compat/utils/functions/isEquivId.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [compat/utils](../index.md) / isEquivId ```ts function isEquivId(expected, actual): boolean; ``` Defined in: [warp-drive-packages/legacy/src/compat/utils.ts:235](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/utils.ts#L235) Compares two IDs for strict equality, converting them to the format expected by the EmberData Cache to ensure differences in format are accounted for in the comparison. Asserts when expected or actual are invalid IDs in dev. Expected may never be null. ```js isEquivId('1', 1); // true isEquivId('2', '2'); // true isEquivId(3, '3'); // true isEquivId(4, '3'); // false isEquivId(1, null); // false ``` ## Parameters ### expected a potentially un-normalized id to match against `string` | `number` ### actual a potentially un-normalized id to match against `null` | `string` | `number` ## Returns `boolean` true if the ids are equivalent --- --- url: /api/@warp-drive/legacy/compat/utils.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / compat/utils Utilities for helping to migrate to stricter and more consistent use of IDs and types. ## Deprecated ## Functions * [~~configureAssertFn~~](functions/configureAssertFn.md) * [~~configureMismatchReporter~~](functions/configureMismatchReporter.md) * [~~configureTypeNormalization~~](functions/configureTypeNormalization.md) * [~~expectId~~](functions/expectId.md) * [~~formattedId~~](functions/formattedId.md) * [~~formattedType~~](functions/formattedType.md) * [~~isEquivId~~](functions/isEquivId.md) * [~~isEquivType~~](functions/isEquivType.md) --- --- url: /api/@warp-drive/legacy/compat/variables/LegacyNetworkHandler.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [compat](../index.md) / LegacyNetworkHandler ```ts const LegacyNetworkHandler: Handler; ``` Defined in: [warp-drive-packages/legacy/src/compat/legacy-network-handler/legacy-network-handler.ts:49](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/legacy-network-handler/legacy-network-handler.ts#L49) --- --- url: /api/@warp-drive/legacy/compat/utils/functions/isEquivType.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [compat/utils](../index.md) / isEquivType ```ts function isEquivType(expected, actual): boolean; ``` Defined in: [warp-drive-packages/legacy/src/compat/utils.ts:200](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/compat/utils.ts#L200) Compares two types for strict equality, converting them to the format expected by the EmberData Cache to ensure differences in format are accounted for in the comparison. Asserts when expected or actual are invalid types in dev. Expected may never be null. ```js isEquivType('posts', 'post'); // true isEquivType('post', 'post'); // true isEquivType('posts', 'posts'); // true isEquivType('post-comment', 'postComment'); // true isEquivType('post-comment', 'PostComment'); // true isEquivType('post-comment', 'post_comment'); // true isEquivType('post-comment', 'post-comment'); // true isEquivType('post-comment', 'post'); // false isEquivType('posts', null); // false ``` ## Parameters ### expected `string` a potentially unnormalized type to match against ### actual `string` a potentially unnormalized type to match against ## Returns `boolean` true if the types are equivalent --- --- url: /api/@warp-drive/legacy.md --- [Documentation](../../index.md) / @warp-drive/legacy ## Modules * [adapter](adapter/index.md) * [adapter/error](adapter/error/index.md) * [adapter/json-api](adapter/json-api/index.md) * [adapter/rest](adapter/rest/index.md) * [compat](compat/index.md) * [~~compat/builders~~](compat/builders/index.md) * [~~compat/utils~~](compat/utils/index.md) * [model](model/index.md) * [model/migration-support](model/migration-support/index.md) * [serializer](serializer/index.md) * [serializer/json](serializer/json/index.md) * [serializer/json-api](serializer/json-api/index.md) * [serializer/rest](serializer/rest/index.md) * [serializer/transform](serializer/transform/index.md) --- --- url: /api/@warp-drive/legacy/model/classes/AsyncHasMany.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [model](../index.md) / AsyncHasMany Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:30](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L30) This class is returned as the result of accessing an async hasMany relationship on an instance of a Model extending from `@ember-data/model`. A PromiseManyArray is an iterable proxy that allows templates to consume related ManyArrays and update once their contents are no longer pending. In your JS code you should resolve the promise first. ```js const comments = await post.comments; ``` PromiseManyArray ## Type Parameters ### T `T` = `unknown` ## Constructors ### Constructor ```ts new AsyncHasMany(promise, content?): PromiseManyArray; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:35](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L35) #### Parameters ##### promise `Promise`<[`ManyArray`](ManyArray.md)<`T`>> ##### content? [`ManyArray`](ManyArray.md)<`T`> #### Returns `PromiseManyArray`<`T`> ## Properties ### \[LegacyPromiseProxy] ```ts [LegacyPromiseProxy]: true; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:208](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L208) *** ### content ```ts content: null | ManyArray; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:33](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L33) *** ### isDestroyed ```ts isDestroyed: boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:32](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L32) *** ### isFulfilled ```ts isFulfilled: boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:121](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L121) Whether the loading promise succeeded *** ### isPending ```ts isPending: boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:105](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L105) Whether the loading promise is still pending *** ### isRejected ```ts isRejected: boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:113](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L113) Whether the loading promise rejected *** ### isSettled ```ts isSettled: boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:129](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L129) Whether the loading promise completed (resolved or rejected) *** ### promise ```ts promise: null | Promise>; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:31](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L31) ## Accessors ### \[] #### Get Signature ```ts get : undefined | 0 | ManyArray; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:60](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L60) ##### Returns `undefined` | `0` | [`ManyArray`](ManyArray.md)<`T`> *** ### length #### Get Signature ```ts get length(): number; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:46](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L46) Retrieve the length of the content ##### Returns `number` *** ### links #### Get Signature ```ts get links(): | undefined | null | Links; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:180](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L180) Retrieve the links for this relationship ##### Returns | `undefined` | `null` | [`Links`](../../../core-types/spec/json-api-raw/interfaces/Links.md) *** ### meta #### Get Signature ```ts get meta(): undefined | null | Record; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:190](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L190) Retrieve the meta for this relationship ##### Returns `undefined` | `null` | `Record`<`string`, `unknown`> ## Methods ### \_update() ```ts _update(promise, content?): void; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:196](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L196) #### Parameters ##### promise `Promise`<[`ManyArray`](ManyArray.md)<`T`>> ##### content? [`ManyArray`](ManyArray.md)<`T`> #### Returns `void` *** ### catch() ```ts catch(cb): Promise; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:149](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L149) catch errors thrown by this promise #### Parameters ##### cb `undefined` | `null` | (`reason`) => `unknown` #### Returns `Promise`<`unknown`> *** ### destroy() ```ts destroy(): void; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:166](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L166) #### Returns `void` *** ### finally() ```ts finally(cb): Promise>; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:160](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L160) run cleanup after this promise completes #### Parameters ##### cb `undefined` | `null` | () => `void` #### Returns `Promise`<[`ManyArray`](ManyArray.md)<`T`>> *** ### reload() ```ts reload(options): PromiseManyArray; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:90](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L90) Reload the relationship #### Parameters ##### options `Omit`<[`BaseFinderOptions`](../../../core-types/index/interfaces/BaseFinderOptions.md)<`unknown`>, `""`> #### Returns `PromiseManyArray`<`T`> *** ### then() ```ts then(s, f?): Promise; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:139](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L139) chain this promise #### Parameters ##### s `undefined` | `null` | (`value`) => `unknown` ##### f? `null` | (`reason`) => `unknown` #### Returns `Promise`<`unknown`> *** ### create() ```ts static create(__namedParameters): PromiseManyArray; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/promise-many-array.ts:204](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/promise-many-array.ts#L204) #### Type Parameters ##### T `T` #### Parameters ##### \_\_namedParameters `HasManyProxyCreateArgs`<`T`> #### Returns `PromiseManyArray`<`T`> --- --- url: /api/@warp-drive/legacy/model/classes/ManyArray.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [model](../index.md) / ManyArray Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:69 A `ManyArray` is a `MutableArray` that represents the contents of a has-many relationship. The `ManyArray` is instantiated lazily the first time the relationship is requested. This class is not intended to be directly instantiated by consuming applications. ### Inverses Often, the relationships in Ember Data applications will have an inverse. For example, imagine the following models are defined: ```js [app/models/post.js] import Model, { hasMany } from '@ember-data/model'; export default class PostModel extends Model { @hasMany('comment') comments; } ``` ```js [app/models/comment.js] import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class CommentModel extends Model { @belongsTo('post') post; } ``` If you created a new instance of `Post` and added a `Comment` record to its `comments` has-many relationship, you would expect the comment's `post` property to be set to the post that contained the has-many. We call the record to which a relationship belongs-to the relationship's *owner*. ManyArray ## Extends * `IdentifierArray`<`T`> ## Type Parameters ### T `T` = `unknown` ## Indexable ```ts [key: number]: T ``` ## Constructors ### Constructor ```ts new ManyArray(options): RelatedCollection; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:142 #### Parameters ##### options `ManyArrayCreateArgs`<`T`> #### Returns `RelatedCollection`<`T`> #### Overrides ```ts IdentifierArray.constructor ``` ## Properties ### \_\_\_(unique) Symbol(#\[]) ```ts ___(unique) Symbol(#[]): WarpDriveSignal; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:73 #### Inherited from ```ts IdentifierArray.___(unique) Symbol(#[]) ``` *** ### \_\_\_(unique) Symbol(#source) ```ts ___(unique) Symbol(#source): StableRecordIdentifier[]; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:74 #### Inherited from ```ts IdentifierArray.___(unique) Symbol(#source) ``` *** ### \_\_\_(unique) Symbol(IS\_COLLECTION) ```ts ___(unique) Symbol(IS_COLLECTION): boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:72 #### Inherited from ```ts IdentifierArray.___(unique) Symbol(IS_COLLECTION) ``` *** ### \_inverseIsAsync ```ts _inverseIsAsync: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:87 *** ### \_manager ```ts _manager: MinimumManager; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:137 #### Overrides ```ts IdentifierArray._manager ``` *** ### \_updatingPromise ```ts _updatingPromise: null | Promise>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:70 #### Inherited from ```ts IdentifierArray._updatingPromise ``` *** ### \[unscopables] ```ts readonly [unscopables]: object; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:97 Is an object whose properties have the value 'true' when they will be absent when used in a 'with' statement. #### Index Signature ```ts [key: number]: undefined | boolean ``` #### \[iterator]? ```ts optional [iterator]: boolean; ``` #### \[unscopables]? ```ts readonly optional [unscopables]: boolean; ``` Is an object whose properties have the value 'true' when they will be absent when used in a 'with' statement. #### at? ```ts optional at: boolean; ``` #### concat? ```ts optional concat: boolean; ``` #### copyWithin? ```ts optional copyWithin: boolean; ``` #### entries? ```ts optional entries: boolean; ``` #### every? ```ts optional every: boolean; ``` #### fill? ```ts optional fill: boolean; ``` #### filter? ```ts optional filter: boolean; ``` #### find? ```ts optional find: boolean; ``` #### findIndex? ```ts optional findIndex: boolean; ``` #### findLast? ```ts optional findLast: boolean; ``` #### findLastIndex? ```ts optional findLastIndex: boolean; ``` #### flat? ```ts optional flat: boolean; ``` #### flatMap? ```ts optional flatMap: boolean; ``` #### forEach? ```ts optional forEach: boolean; ``` #### includes? ```ts optional includes: boolean; ``` #### indexOf? ```ts optional indexOf: boolean; ``` #### join? ```ts optional join: boolean; ``` #### keys? ```ts optional keys: boolean; ``` #### lastIndexOf? ```ts optional lastIndexOf: boolean; ``` #### length? ```ts optional length: boolean; ``` Gets or sets the length of the array. This is a number one higher than the highest index in the array. #### map? ```ts optional map: boolean; ``` #### pop? ```ts optional pop: boolean; ``` #### push? ```ts optional push: boolean; ``` #### reduce? ```ts optional reduce: boolean; ``` #### reduceRight? ```ts optional reduceRight: boolean; ``` #### reverse? ```ts optional reverse: boolean; ``` #### shift? ```ts optional shift: boolean; ``` #### slice? ```ts optional slice: boolean; ``` #### some? ```ts optional some: boolean; ``` #### sort? ```ts optional sort: boolean; ``` #### splice? ```ts optional splice: boolean; ``` #### toLocaleString? ```ts optional toLocaleString: boolean; ``` #### toReversed? ```ts optional toReversed: boolean; ``` #### toSorted? ```ts optional toSorted: boolean; ``` #### toSpliced? ```ts optional toSpliced: boolean; ``` #### toString? ```ts optional toString: boolean; ``` #### unshift? ```ts optional unshift: boolean; ``` #### values? ```ts optional values: boolean; ``` #### with? ```ts optional with: boolean; ``` #### Inherited from ```ts IdentifierArray.[unscopables] ``` *** ### cache ```ts cache: Cache; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:136 *** ### DEPRECATED\_CLASS\_NAME ```ts DEPRECATED_CLASS_NAME: string; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:52 #### Inherited from ```ts IdentifierArray.DEPRECATED_CLASS_NAME ``` *** ### identifier ```ts identifier: StableRecordIdentifier; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:135 #### Overrides ```ts IdentifierArray.identifier ``` *** ### isAsync ```ts isAsync: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:70 *** ### isDestroyed ```ts isDestroyed: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:69 #### Inherited from ```ts IdentifierArray.isDestroyed ``` *** ### isDestroying ```ts isDestroying: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:68 #### Inherited from ```ts IdentifierArray.isDestroying ``` *** ### isLoaded ```ts isLoaded: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:78 The loading state of this array #### Overrides ```ts IdentifierArray.isLoaded ``` *** ### isUpdating ```ts isUpdating: boolean; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:66 The flag to signal a `RecordArray` is currently loading data. Example ```javascript let people = store.peekAll('person'); people.isUpdating; // false people.update(); people.isUpdating; // true ``` #### Inherited from ```ts IdentifierArray.isUpdating ``` *** ### key ```ts key: string; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:139 *** ### length ```ts length: number; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1326 Gets or sets the length of the array. This is a number one higher than the highest index in the array. #### Inherited from ```ts IdentifierArray.length ``` *** ### links ```ts links: | null | Links | PaginationLinks; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:134 Retrieve the links for this relationship #### Overrides ```ts IdentifierArray.links ``` *** ### meta ```ts meta: null | Record; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:126 Metadata associated with the request for async hasMany relationships. Example Given that the server returns the following JSON payload when fetching a hasMany relationship: ```js { "comments": [{ "id": 1, "comment": "This is the first comment", }, { // ... }], "meta": { "page": 1, "total": 5 } } ``` You can then access the meta data via the `meta` property: ```js let comments = await post.comments; let meta = comments.meta; // meta.page => 1 // meta.total => 5 ``` #### Overrides ```ts IdentifierArray.meta ``` *** ### modelName ```ts modelName: T extends TypedRecordInstance ? TypeFromInstance> : string; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:141 #### Overrides ```ts IdentifierArray.modelName ``` *** ### save() ```ts save: () => Promise>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:195 Saves all of the records in the `ManyArray`. Note: this API can only be used in legacy mode with a configured Adapter. Example ```javascript const { content: { data: inbox } } = await store.request(findRecord({ type: 'inbox', id: '1' })); let messages = await inbox.messages; messages.forEach((message) => { message.isRead = true; }); messages.save(); ``` #### Returns `Promise`<`IdentifierArray`<`T`>> promise #### Overrides ```ts IdentifierArray.save ``` *** ### type ```ts type: ModelSchema; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:140 ## Methods ### \_\_\_(unique) Symbol(#update)() ```ts ___(unique) Symbol(#update)( target, receiver, prop, args, _SIGNAL): unknown; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:143 #### Parameters ##### target [`StableRecordIdentifier`](../../../core-types/identifier/type-aliases/StableRecordIdentifier.md)\[] ##### receiver *typeof* `NativeProxy` ##### prop `string` ##### args `unknown`\[] ##### \_SIGNAL `WarpDriveSignal` #### Returns `unknown` #### Overrides ```ts IdentifierArray.___(unique) Symbol(#update) ``` *** ### \_update() ```ts _update(): Promise>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:109 #### Returns `Promise`<`IdentifierArray`<`T`>> #### Inherited from ```ts IdentifierArray._update ``` *** ### \[iterator]\() ```ts iterator: ArrayIterator; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.iterable.d.ts:78 Iterator #### Returns `ArrayIterator`<`T`> #### Inherited from ```ts IdentifierArray.[iterator] ``` *** ### at() ```ts at(index): undefined | T; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2022.array.d.ts:24 Returns the item located at the specified index. #### Parameters ##### index `number` The zero-based index of the desired code unit. A negative index will count back from the last item. #### Returns `undefined` | `T` #### Inherited from ```ts IdentifierArray.at ``` *** ### concat() #### Call Signature ```ts concat(...items): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1350 Combines two or more arrays. This method returns a new array without modifying any existing arrays. ##### Parameters ###### items ...`ConcatArray`<`T`>\[] Additional arrays and/or items to add to the end of the array. ##### Returns `T`\[] ##### Inherited from ```ts IdentifierArray.concat ``` #### Call Signature ```ts concat(...items): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1356 Combines two or more arrays. This method returns a new array without modifying any existing arrays. ##### Parameters ###### items ...(`T` | `ConcatArray`<`T`>)\[] Additional arrays and/or items to add to the end of the array. ##### Returns `T`\[] ##### Inherited from ```ts IdentifierArray.concat ``` *** ### copyWithin() ```ts copyWithin( target, start, end?): this; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.core.d.ts:62 Returns the this object after copying a section of the array identified by start and end to the same array starting at position target #### Parameters ##### target `number` If target is negative, it is treated as length+target where length is the length of the array. ##### start `number` If start is negative, it is treated as length+start. If end is negative, it is treated as length+end. ##### end? `number` If not specified, length of the this object is used as its default value. #### Returns `this` #### Inherited from ```ts IdentifierArray.copyWithin ``` *** ### createRecord() ```ts createRecord(hash): T; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:174 Create a child record within the owner #### Parameters ##### hash `CreateRecordProperties`<`T`> #### Returns `T` record *** ### entries() ```ts entries(): ArrayIterator<[number, T]>; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.iterable.d.ts:83 Returns an iterable of key, value pairs for every entry in the array #### Returns `ArrayIterator`<\[`number`, `T`]> #### Inherited from ```ts IdentifierArray.entries ``` *** ### every() #### Call Signature ```ts every(predicate, thisArg?): this is S[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1433 Determines whether all the members of an array satisfy the specified test. ##### Type Parameters ###### S `S` ##### Parameters ###### predicate (`value`, `index`, `array`) => `value is S` A function that accepts up to three arguments. The every method calls the predicate function for each element in the array until the predicate returns a value which is coercible to the Boolean value false, or until the end of the array. ###### thisArg? `any` An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. ##### Returns `this is S[]` ##### Inherited from ```ts IdentifierArray.every ``` #### Call Signature ```ts every(predicate, thisArg?): boolean; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1442 Determines whether all the members of an array satisfy the specified test. ##### Parameters ###### predicate (`value`, `index`, `array`) => `unknown` A function that accepts up to three arguments. The every method calls the predicate function for each element in the array until the predicate returns a value which is coercible to the Boolean value false, or until the end of the array. ###### thisArg? `any` An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. ##### Returns `boolean` ##### Inherited from ```ts IdentifierArray.every ``` *** ### fill() ```ts fill( value, start?, end?): this; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.core.d.ts:51 Changes all array elements from `start` to `end` index to a static `value` and returns the modified array #### Parameters ##### value `T` value to fill array section with ##### start? `number` index to start filling the array at. If start is negative, it is treated as length+start where length is the length of the array. ##### end? `number` index to stop filling the array at. If end is negative, it is treated as length+end. #### Returns `this` #### Inherited from ```ts IdentifierArray.fill ``` *** ### filter() #### Call Signature ```ts filter(predicate, thisArg?): S[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1469 Returns the elements of an array that meet the condition specified in a callback function. ##### Type Parameters ###### S `S` ##### Parameters ###### predicate (`value`, `index`, `array`) => `value is S` A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. ###### thisArg? `any` An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. ##### Returns `S`\[] ##### Inherited from ```ts IdentifierArray.filter ``` #### Call Signature ```ts filter(predicate, thisArg?): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1475 Returns the elements of an array that meet the condition specified in a callback function. ##### Parameters ###### predicate (`value`, `index`, `array`) => `unknown` A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array. ###### thisArg? `any` An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. ##### Returns `T`\[] ##### Inherited from ```ts IdentifierArray.filter ``` *** ### find() #### Call Signature ```ts find(predicate, thisArg?): undefined | S; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.core.d.ts:29 Returns the value of the first element in the array where predicate is true, and undefined otherwise. ##### Type Parameters ###### S `S` ##### Parameters ###### predicate (`value`, `index`, `obj`) => `value is S` find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns that element value. Otherwise, find returns undefined. ###### thisArg? `any` If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead. ##### Returns `undefined` | `S` ##### Inherited from ```ts IdentifierArray.find ``` #### Call Signature ```ts find(predicate, thisArg?): undefined | T; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.core.d.ts:30 ##### Parameters ###### predicate (`value`, `index`, `obj`) => `unknown` ###### thisArg? `any` ##### Returns `undefined` | `T` ##### Inherited from ```ts IdentifierArray.find ``` *** ### findIndex() ```ts findIndex(predicate, thisArg?): number; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.core.d.ts:41 Returns the index of the first element in the array where predicate is true, and -1 otherwise. #### Parameters ##### predicate (`value`, `index`, `obj`) => `unknown` find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, findIndex immediately returns that element index. Otherwise, findIndex returns -1. ##### thisArg? `any` If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead. #### Returns `number` #### Inherited from ```ts IdentifierArray.findIndex ``` *** ### findLast() #### Call Signature ```ts findLast(predicate, thisArg?): undefined | S; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2023.array.d.ts:29 Returns the value of the last element in the array where predicate is true, and undefined otherwise. ##### Type Parameters ###### S `S` ##### Parameters ###### predicate (`value`, `index`, `array`) => `value is S` findLast calls predicate once for each element of the array, in descending order, until it finds one where predicate returns true. If such an element is found, findLast immediately returns that element value. Otherwise, findLast returns undefined. ###### thisArg? `any` If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead. ##### Returns `undefined` | `S` ##### Inherited from ```ts IdentifierArray.findLast ``` #### Call Signature ```ts findLast(predicate, thisArg?): undefined | T; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2023.array.d.ts:30 ##### Parameters ###### predicate (`value`, `index`, `array`) => `unknown` ###### thisArg? `any` ##### Returns `undefined` | `T` ##### Inherited from ```ts IdentifierArray.findLast ``` *** ### findLastIndex() ```ts findLastIndex(predicate, thisArg?): number; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2023.array.d.ts:41 Returns the index of the last element in the array where predicate is true, and -1 otherwise. #### Parameters ##### predicate (`value`, `index`, `array`) => `unknown` findLastIndex calls predicate once for each element of the array, in descending order, until it finds one where predicate returns true. If such an element is found, findLastIndex immediately returns that element index. Otherwise, findLastIndex returns -1. ##### thisArg? `any` If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead. #### Returns `number` #### Inherited from ```ts IdentifierArray.findLastIndex ``` *** ### flat() ```ts flat(this, depth?): FlatArray[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2019.array.d.ts:75 Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth. #### Type Parameters ##### A `A` ##### D `D` *extends* `number` = `1` #### Parameters ##### this `A` ##### depth? `D` The maximum recursion depth #### Returns `FlatArray`<`A`, `D`>\[] #### Inherited from ```ts IdentifierArray.flat ``` *** ### flatMap() ```ts flatMap(callback, thisArg?): U[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2019.array.d.ts:64 Calls a defined callback function on each element of an array. Then, flattens the result into a new array. This is identical to a map followed by flat with depth 1. #### Type Parameters ##### U `U` ##### This `This` = `undefined` #### Parameters ##### callback (`this`, `value`, `index`, `array`) => `U` | readonly `U`\[] A function that accepts up to three arguments. The flatMap method calls the callback function one time for each element in the array. ##### thisArg? `This` An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used as the this value. #### Returns `U`\[] #### Inherited from ```ts IdentifierArray.flatMap ``` *** ### forEach() ```ts forEach(callbackfn, thisArg?): void; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1457 Performs the specified action for each element in an array. #### Parameters ##### callbackfn (`value`, `index`, `array`) => `void` A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. ##### thisArg? `any` An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. #### Returns `void` #### Inherited from ```ts IdentifierArray.forEach ``` *** ### includes() ```ts includes(searchElement, fromIndex?): boolean; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2016.array.include.d.ts:25 Determines whether an array includes a certain element, returning true or false as appropriate. #### Parameters ##### searchElement `T` The element to search for. ##### fromIndex? `number` The position in this array at which to begin searching for searchElement. #### Returns `boolean` #### Inherited from ```ts IdentifierArray.includes ``` *** ### indexOf() ```ts indexOf(searchElement, fromIndex?): number; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1418 Returns the index of the first occurrence of a value in an array, or -1 if it is not present. #### Parameters ##### searchElement `T` The value to locate in the array. ##### fromIndex? `number` The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. #### Returns `number` #### Inherited from ```ts IdentifierArray.indexOf ``` *** ### join() ```ts join(separator?): string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1361 Adds all the elements of an array into a string, separated by the specified separator string. #### Parameters ##### separator? `string` A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma. #### Returns `string` #### Inherited from ```ts IdentifierArray.join ``` *** ### keys() ```ts keys(): ArrayIterator; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.iterable.d.ts:88 Returns an iterable of keys in the array #### Returns `ArrayIterator`<`number`> #### Inherited from ```ts IdentifierArray.keys ``` *** ### lastIndexOf() ```ts lastIndexOf(searchElement, fromIndex?): number; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1424 Returns the index of the last occurrence of a specified value in an array, or -1 if it is not present. #### Parameters ##### searchElement `T` The value to locate in the array. ##### fromIndex? `number` The array index at which to begin searching backward. If fromIndex is omitted, the search starts at the last index in the array. #### Returns `number` #### Inherited from ```ts IdentifierArray.lastIndexOf ``` *** ### map() ```ts map(callbackfn, thisArg?): U[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1463 Calls a defined callback function on each element of an array, and returns an array that contains the results. #### Type Parameters ##### U `U` #### Parameters ##### callbackfn (`value`, `index`, `array`) => `U` A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. ##### thisArg? `any` An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. #### Returns `U`\[] #### Inherited from ```ts IdentifierArray.map ``` *** ### notify() ```ts notify(): void; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:144 #### Returns `void` *** ### pop() ```ts pop(): undefined | T; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1339 Removes the last element from an array and returns it. If the array is empty, undefined is returned and the array is not modified. #### Returns `undefined` | `T` #### Inherited from ```ts IdentifierArray.pop ``` *** ### push() ```ts push(...items): number; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1344 Appends new elements to the end of an array, and returns the new length of the array. #### Parameters ##### items ...`T`\[] New elements to add to the array. #### Returns `number` #### Inherited from ```ts IdentifierArray.push ``` *** ### reduce() #### Call Signature ```ts reduce(callbackfn): T; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1481 Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. ##### Parameters ###### callbackfn (`previousValue`, `currentValue`, `currentIndex`, `array`) => `T` A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. ##### Returns `T` ##### Inherited from ```ts IdentifierArray.reduce ``` #### Call Signature ```ts reduce(callbackfn, initialValue): T; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1482 ##### Parameters ###### callbackfn (`previousValue`, `currentValue`, `currentIndex`, `array`) => `T` ###### initialValue `T` ##### Returns `T` ##### Inherited from ```ts IdentifierArray.reduce ``` #### Call Signature ```ts reduce(callbackfn, initialValue): U; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1488 Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. ##### Type Parameters ###### U `U` ##### Parameters ###### callbackfn (`previousValue`, `currentValue`, `currentIndex`, `array`) => `U` A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. ###### initialValue `U` If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. ##### Returns `U` ##### Inherited from ```ts IdentifierArray.reduce ``` *** ### reduceRight() #### Call Signature ```ts reduceRight(callbackfn): T; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1494 Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. ##### Parameters ###### callbackfn (`previousValue`, `currentValue`, `currentIndex`, `array`) => `T` A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. ##### Returns `T` ##### Inherited from ```ts IdentifierArray.reduceRight ``` #### Call Signature ```ts reduceRight(callbackfn, initialValue): T; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1495 ##### Parameters ###### callbackfn (`previousValue`, `currentValue`, `currentIndex`, `array`) => `T` ###### initialValue `T` ##### Returns `T` ##### Inherited from ```ts IdentifierArray.reduceRight ``` #### Call Signature ```ts reduceRight(callbackfn, initialValue): U; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1501 Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. ##### Type Parameters ###### U `U` ##### Parameters ###### callbackfn (`previousValue`, `currentValue`, `currentIndex`, `array`) => `U` A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. ###### initialValue `U` If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. ##### Returns `U` ##### Inherited from ```ts IdentifierArray.reduceRight ``` *** ### reload() ```ts reload(options?): Promise>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/many-array.d.ts:166 Reloads all of the records in the manyArray. If the manyArray holds a relationship that was originally fetched using a links url WarpDrive will revisit the original links url to repopulate the relationship. If the ManyArray holds the result of a `store.query()` reload will re-run the original query. Example ```javascript let user = store.peekRecord('user', '1') await login(user); let permissions = await user.permissions; await permissions.reload(); ``` #### Parameters ##### options? [`BaseFinderOptions`](../../../core-types/index/interfaces/BaseFinderOptions.md)<`unknown`> #### Returns `Promise`<`RelatedCollection`<`T`>> *** ### reverse() ```ts reverse(): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1366 Reverses the elements in an array in place. This method mutates the array and returns a reference to the same array. #### Returns `T`\[] #### Inherited from ```ts IdentifierArray.reverse ``` *** ### shift() ```ts shift(): undefined | T; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1371 Removes the first element from an array and returns it. If the array is empty, undefined is returned and the array is not modified. #### Returns `undefined` | `T` #### Inherited from ```ts IdentifierArray.shift ``` *** ### slice() ```ts slice(start?, end?): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1381 Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array. #### Parameters ##### start? `number` The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0. ##### end? `number` The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array. #### Returns `T`\[] #### Inherited from ```ts IdentifierArray.slice ``` *** ### some() ```ts some(predicate, thisArg?): boolean; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1451 Determines whether the specified callback function returns true for any element of an array. #### Parameters ##### predicate (`value`, `index`, `array`) => `unknown` A function that accepts up to three arguments. The some method calls the predicate function for each element in the array until the predicate returns a value which is coercible to the Boolean value true, or until the end of the array. ##### thisArg? `any` An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value. #### Returns `boolean` #### Inherited from ```ts IdentifierArray.some ``` *** ### sort() ```ts sort(compareFn?): this; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1392 Sorts an array in place. This method mutates the array and returns a reference to the same array. #### Parameters ##### compareFn? (`a`, `b`) => `number` Function used to determine the order of the elements. It is expected to return a negative value if the first argument is less than the second argument, zero if they're equal, and a positive value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order. ```ts [11,2,22,1].sort((a, b) => a - b) ``` #### Returns `this` #### Inherited from ```ts IdentifierArray.sort ``` *** ### splice() #### Call Signature ```ts splice(start, deleteCount?): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1399 Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. ##### Parameters ###### start `number` The zero-based location in the array from which to start removing elements. ###### deleteCount? `number` The number of elements to remove. ##### Returns `T`\[] An array containing the elements that were deleted. ##### Inherited from ```ts IdentifierArray.splice ``` #### Call Signature ```ts splice( start, deleteCount, ... items): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1407 Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. ##### Parameters ###### start `number` The zero-based location in the array from which to start removing elements. ###### deleteCount `number` The number of elements to remove. ###### items ...`T`\[] Elements to insert into the array in place of the deleted elements. ##### Returns `T`\[] An array containing the elements that were deleted. ##### Inherited from ```ts IdentifierArray.splice ``` *** ### toLocaleString() #### Call Signature ```ts toLocaleString(): string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1334 Returns a string representation of an array. The elements are converted to string using their toLocaleString methods. ##### Returns `string` ##### Inherited from ```ts IdentifierArray.toLocaleString ``` #### Call Signature ```ts toLocaleString(locales, options?): string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.core.d.ts:64 ##### Parameters ###### locales `string` | `string`\[] ###### options? `NumberFormatOptions` & `DateTimeFormatOptions` ##### Returns `string` ##### Inherited from ```ts IdentifierArray.toLocaleString ``` *** ### toReversed() ```ts toReversed(): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2023.array.d.ts:46 Returns a copy of an array with its elements reversed. #### Returns `T`\[] #### Inherited from ```ts IdentifierArray.toReversed ``` *** ### toSorted() ```ts toSorted(compareFn?): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2023.array.d.ts:57 Returns a copy of an array with its elements sorted. #### Parameters ##### compareFn? (`a`, `b`) => `number` Function used to determine the order of the elements. It is expected to return a negative value if the first argument is less than the second argument, zero if they're equal, and a positive value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order. ```ts [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22] ``` #### Returns `T`\[] #### Inherited from ```ts IdentifierArray.toSorted ``` *** ### toSpliced() #### Call Signature ```ts toSpliced( start, deleteCount, ... items): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2023.array.d.ts:66 Copies an array and removes elements and, if necessary, inserts new elements in their place. Returns the copied array. ##### Parameters ###### start `number` The zero-based location in the array from which to start removing elements. ###### deleteCount `number` The number of elements to remove. ###### items ...`T`\[] Elements to insert into the copied array in place of the deleted elements. ##### Returns `T`\[] The copied array. ##### Inherited from ```ts IdentifierArray.toSpliced ``` #### Call Signature ```ts toSpliced(start, deleteCount?): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2023.array.d.ts:74 Copies an array and removes elements while returning the remaining elements. ##### Parameters ###### start `number` The zero-based location in the array from which to start removing elements. ###### deleteCount? `number` The number of elements to remove. ##### Returns `T`\[] A copy of the original array with the remaining elements. ##### Inherited from ```ts IdentifierArray.toSpliced ``` *** ### toString() ```ts toString(): string; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1330 Returns a string representation of an array. #### Returns `string` #### Inherited from ```ts IdentifierArray.toString ``` *** ### unshift() ```ts unshift(...items): number; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es5.d.ts:1412 Inserts new elements at the start of an array, and returns the new length of the array. #### Parameters ##### items ...`T`\[] Elements to insert at the start of the array. #### Returns `number` #### Inherited from ```ts IdentifierArray.unshift ``` *** ### update() ```ts update(): Promise>; ``` Defined in: warp-drive-packages/core/declarations/store/-private/record-arrays/identifier-array.d.ts:108 Used to get the latest version of all of the records in this array from the adapter. Example ```javascript let people = store.peekAll('person'); people.isUpdating; // false people.update().then(function() { people.isUpdating; // false }); people.isUpdating; // true ``` #### Returns `Promise`<`IdentifierArray`<`T`>> #### Inherited from ```ts IdentifierArray.update ``` *** ### values() ```ts values(): ArrayIterator; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2015.iterable.d.ts:93 Returns an iterable of values in the array #### Returns `ArrayIterator`<`T`> #### Inherited from ```ts IdentifierArray.values ``` *** ### with() ```ts with(index, value): T[]; ``` Defined in: node\_modules/.pnpm/typescript@5.8.3/node\_modules/typescript/lib/lib.es2023.array.d.ts:85 Copies an array, then overwrites the value at the provided index with the given value. If the index is negative, then it replaces from the end of the array. #### Parameters ##### index `number` The index of the value to overwrite. If the index is negative, then it replaces from the end of the array. ##### value `T` The value to write into the copied array. #### Returns `T`\[] The copied array with the updated value. #### Inherited from ```ts IdentifierArray.with ``` --- --- url: /api/@warp-drive/legacy/model/classes/Model.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [model](../index.md) / Model Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:97](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L97) Base class from which Models can be defined. ::: code-group ```js [app/models/user.js] import { Model, attr, belongsTo, hasMany } from '@warp-drive/legacy/model'; export default class User extends Model { @attr name; @attr('number') age; @hasMany('post', { async: true, inverse: null }) posts; @belongsTo('group', { async: false, inverse: 'users' }) group; } ``` ```ts [app/models/user.ts] import { Model, attr, belongsTo, hasMany, type AsyncHasMany } from '@warp-drive/legacy/model'; import type { NumberTransform } from '@ember-data/serializer/transform'; import type Group from './group'; import type Post from './post'; export default class User extends Model { @attr declare name: string; @attr('number') declare age: number; @hasMany('post', { async: true, inverse: null }) declare posts: AsyncHasMany; @belongsTo('group', { async: false, inverse: 'users' }) declare group: Group | null; } ``` ::: Models both define the schema for a resource type and provide the class to use as the reactive object for data of resource of that type. ## Extends * `EmberObject` ## Implements * `MinimalLegacyRecord` ## Constructors ### Constructor ```ts new Model(owner?): Model; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/index.d.ts:31 #### Parameters ##### owner? `Owner` #### Returns `Model` ## Properties ### concatenatedProperties? ```ts optional concatenatedProperties: string | string[]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:655 *** ### isReloading ```ts readonly isReloading: boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:824](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L824) If `true` the store is attempting to reload the record from the adapter. Example ```javascript record.isReloading; // false record.reload(); record.isReloading; // true ``` *** ### mergedProperties? ```ts optional mergedProperties: unknown[]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:656 *** ### store ```ts store: default; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:498](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L498) The store service instance which created this record instance *** ### \_lazyInjections()? ```ts readonly static optional _lazyInjections: () => void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:654 #### Returns `void` *** ### \_onLookup()? ```ts readonly static optional _onLookup: (debugContainerKey) => void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:653 #### Parameters ##### debugContainerKey `string` #### Returns `void` *** ### \[INIT\_FACTORY]? ```ts static optional [INIT_FACTORY]: null; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/mixin.d.ts:116 *** ### isClass ```ts readonly static isClass: boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:651 *** ### isMethod ```ts readonly static isMethod: boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:652 *** ### modelName ```ts readonly static modelName: string; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1115](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1115) Represents the model's class name as a string. This can be used to look up the model's class name through `Store`'s modelFor method. `modelName` is generated for you by EmberData. It will be a lowercased, dasherized string. For example: ```javascript store.modelFor('post').modelName; // 'post' store.modelFor('blog-post').modelName; // 'blog-post' ``` The most common place you'll want to access `modelName` is in your serializer's `payloadKeyFromModelName` method. For example, to change payload keys to underscore (instead of dasherized), you might use the following code: ```javascript import RESTSerializer from '@ember-data/serializer/rest'; import { underscore } from '/utils/string-utils'; export default const PostSerializer = RESTSerializer.extend({ payloadKeyFromModelName(modelName) { return underscore(modelName); } }); ``` *** ### PrototypeMixin ```ts static PrototypeMixin: any; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:647 *** ### superclass ```ts static superclass: any; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:648 ## Accessors ### \_debugContainerKey #### Get Signature ```ts get _debugContainerKey(): false | `${string}:${string}`; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/index.d.ts:34 ##### Returns `false` | `` `${string}:${string}` `` *** ### adapterError #### Get Signature ```ts get adapterError(): unknown; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:973](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L973) This property holds the `AdapterError` object with which last adapter operation was rejected. ##### Returns `unknown` #### Set Signature ```ts set adapterError(v): void; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:976](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L976) ##### Parameters ###### v `unknown` ##### Returns `void` *** ### currentState #### Set Signature ```ts set currentState(_v): void; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:896](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L896) ##### Parameters ###### \_v `RecordState` ##### Returns `void` *** ### dirtyType #### Get Signature ```ts get dirtyType(): "" | "updated" | "deleted" | "created"; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:776](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L776) If the record is in the dirty state this property will report what kind of change has caused it to move into the dirty state. Possible values are: * `created` The record has been created by the client and not yet saved to the adapter. * `updated` The record has been updated by the client and not yet saved to the adapter. * `deleted` The record has been deleted by the client and not yet saved to the adapter. Example ```javascript let record = store.createRecord('model'); record.dirtyType; // 'created' ``` ##### Returns `""` | `"updated"` | `"deleted"` | `"created"` *** ### errors #### Get Signature ```ts get errors(): Errors; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:959](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L959) When the record is in the `invalid` state this object will contain any errors returned by the adapter. When present the errors hash contains keys corresponding to the invalid property names and values which are arrays of Javascript objects with two keys: * `message` A string containing the error message from the backend * `attribute` The name of the property associated with this error message ```javascript record.errors.length; // 0 record.set('foo', 'invalid value'); record.save().catch(function() { record.errors.foo; // [{message: 'foo should be a number.', attribute: 'foo'}] }); ``` The `errors` property is useful for displaying error messages to the user. ```handlebars {{#each @model.errors.username as |error|}}

{{error.message}}
{{/each}} {{#each @model.errors.email as |error|}}
{{error.message}}
{{/each}} ``` You can also access the special `messages` property on the error object to get an array of all the error strings. ```handlebars {{#each @model.errors.messages as |message|}}
{{message}}
{{/each}} ``` ##### Returns `Errors` *** ### hasDirtyAttributes #### Get Signature ```ts get hasDirtyAttributes(): boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:641](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L641) If this property is `true` the record is in the `dirty` state. The record has local changes that have not yet been saved by the adapter. This includes records that have been created (but not yet saved) or deleted. Example ```javascript let record = store.createRecord('model'); record.hasDirtyAttributes; // true const { content: { data: model } } = await store.request(findRecord({ type: 'model', id: '1' })); model.hasDirtyAttributes; // false model.foo = 'some value'; model.hasDirtyAttributes; // true ``` ##### Since 1.13.0 ##### Returns `boolean` *** ### id #### Get Signature ```ts get id(): null | string; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:845](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L845) All ember models have an id property. This is an identifier managed by an external source. These are always coerced to be strings before being used internally. Note when declaring the attributes for a model it is an error to declare an id attribute. ```javascript let record = store.createRecord('model'); record.id; // null const { content: { data: model } } = await store.request(findRecord({ type: 'model', id: '1' })); model.id; // '1' ``` ##### Returns `null` | `string` #### Set Signature ```ts set id(id): void; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:858](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L858) ##### Parameters ###### id `null` | `string` ##### Returns `void` *** ### isDeleted #### Get Signature ```ts get isDeleted(): boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:710](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L710) If this property is `true` the record is in the `deleted` state and has been marked for deletion. When `isDeleted` is true and `hasDirtyAttributes` is true, the record is deleted locally but the deletion was not yet persisted. When `isSaving` is true, the change is in-flight. When both `hasDirtyAttributes` and `isSaving` are false, the change has persisted. Example ```javascript let record = store.createRecord('model'); record.isDeleted; // false record.deleteRecord(); // Locally deleted record.isDeleted; // true record.hasDirtyAttributes; // true record.isSaving; // false // Persisting the deletion let promise = record.save(); record.isDeleted; // true record.isSaving; // true // Deletion Persisted promise.then(function() { record.isDeleted; // true record.isSaving; // false record.hasDirtyAttributes; // false }); ``` ##### Returns `boolean` *** ### isDestroyed #### Get Signature ```ts get isDestroyed(): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:272 Destroyed object property flag. if this property is `true` the observers and bindings were already removed by the effect of calling the `destroy()` method. ##### Default ```ts false @public ``` ##### Returns `boolean` #### Set Signature ```ts set isDestroyed(_value): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:273 ##### Parameters ###### \_value `boolean` ##### Returns `void` *** ### isDestroying #### Get Signature ```ts get isDestroying(): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:284 Destruction scheduled flag. The `destroy()` method has been called. The object stays intact until the end of the run loop at which point the `isDestroyed` flag is set. ##### Default ```ts false @public ``` ##### Returns `boolean` #### Set Signature ```ts set isDestroying(_value): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:285 ##### Parameters ###### \_value `boolean` ##### Returns `void` *** ### isEmpty #### Get Signature ```ts get isEmpty(): boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:572](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L572) If this property is `true` the record is in the `empty` state. Empty is the first state all records enter after they have been created. Most records created by the store will quickly transition to the `loading` state if data needs to be fetched from the server or the `created` state if the record is created on the client. A record can also enter the empty state if the adapter is unable to locate the record. ##### Returns `boolean` *** ### isError #### Get Signature ```ts get isError(): boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:800](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L800) If `true` the adapter reported that it was unable to save local changes to the backend for any reason other than a server-side validation error. Example ```javascript record.isError; // false record.set('foo', 'valid value'); record.save().then(null, function() { record.isError; // true }); ``` ##### Returns `boolean` *** ### isLoaded #### Get Signature ```ts get isLoaded(): boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:612](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L612) If this property is `true` the record is in the `loaded` state. A record enters this state when its data is populated. Most of a record's lifecycle is spent inside substates of the `loaded` state. Example ```javascript let record = store.createRecord('model'); record.isLoaded; // true const { content: { data: model } } = await store.request(findRecord({ type: 'model', id: '1' })); model.isLoaded; ``` ##### Returns `boolean` *** ### isLoading #### Get Signature ```ts get isLoading(): boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:587](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L587) If this property is `true` the record is in the `loading` state. A record enters this state when the store asks the adapter for its data. It remains in this state until the adapter provides the requested data. ##### Returns `boolean` *** ### isNew #### Get Signature ```ts get isNew(): boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:736](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L736) If this property is `true` the record is in the `new` state. A record will be in the `new` state when it has been created on the client and the adapter has not yet report that it was successfully saved. Example ```javascript let record = store.createRecord('model'); record.isNew; // true record.save().then(function(model) { model.isNew; // false }); ``` ##### Returns `boolean` *** ### isSaving #### Get Signature ```ts get isSaving(): boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:668](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L668) If this property is `true` the record is in the `saving` state. A record enters the saving state when `save` is called, but the adapter has not yet acknowledged that the changes have been persisted to the backend. Example ```javascript let record = store.createRecord('model'); record.isSaving; // false let promise = record.save(); record.isSaving; // true promise.then(function() { record.isSaving; // false }); ``` ##### Returns `boolean` *** ### isValid #### Get Signature ```ts get isValid(): boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:751](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L751) If this property is `true` the record is in the `valid` state. A record will be in the `valid` state when the adapter did not report any server-side validation failures. ##### Returns `boolean` *** ### attributes #### Get Signature ```ts get static attributes(): Map; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1696](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1696) A map whose keys are the attributes of the model (properties described by attr) and whose values are the meta object for the property. Example ```js [app/models/person.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PersonModel extends Model { @attr('string') firstName; @attr('string') lastName; @attr('date') birthday; } ``` ```javascript import Person from 'app/models/person' let attributes = Person.attributes attributes.forEach(function(meta, name) { // do thing }); // prints: // firstName {type: "string", kind: 'attribute', options: Object, parentType: function, name: "firstName"} // lastName {type: "string", kind: 'attribute', options: Object, parentType: function, name: "lastName"} // birthday {type: "date", kind: 'attribute', options: Object, parentType: function, name: "birthday"} ``` ##### Returns `Map`<`string`, [`LegacyAttributeField`](../../../core-types/schema/fields/interfaces/LegacyAttributeField.md)> *** ### fields #### Get Signature ```ts get static fields(): Map; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1557](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1557) A map whose keys are the fields of the model and whose values are strings describing the kind of the field. A model's fields are the union of all of its attributes and relationships. For example: ```js [app/models/blog.js] import { Model, attr, belongsTo, hasMany } from '@warp-drive/legacy/model'; export default class BlogModel extends Model { @hasMany('user') users; @belongsTo('user') owner; @hasMany('post') posts; @attr('string') title; } ``` ```js import Blog from 'app/models/blog' let fields = Blog.fields; fields.forEach(function(kind, field) { // do thing }); // prints: // users, hasMany // owner, belongsTo // posts, hasMany // title, attribute ``` ##### Returns `Map`<`string`, `"belongsTo"` | `"hasMany"` | `"attribute"`> *** ### inverseMap #### Get Signature ```ts get static inverseMap(): Record; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1165](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1165) ##### Returns `Record`<`string`, | `null` | [`LegacyRelationshipField`](../../../core-types/schema/fields/type-aliases/LegacyRelationshipField.md)> *** ### relatedTypes #### Get Signature ```ts get static relatedTypes(): string[]; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1410](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1410) An array of types directly related to a model. Each type will be included once, regardless of the number of relationships it has with the model. For example, given a model with this definition: ```js [app/models/blog.js] import { Model, belongsTo, hasMany } from '@warp-drive/legacy/model'; export default class BlogModel extends Model { @hasMany('user') users; @belongsTo('user') owner; @hasMany('post') posts; } ``` This property would contain the following: ```javascript import Blog from 'app/models/blog'; let relatedTypes = Blog.relatedTypes'); //=> ['user', 'post'] ``` ##### Returns `string`\[] *** ### relationshipNames #### Get Signature ```ts get static relationshipNames(): object; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1359](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1359) A hash containing lists of the model's relationships, grouped by the relationship kind. For example, given a model with this definition: ```js [app/models/blog.js] import { Model, belongsTo, hasMany } from '@warp-drive/legacy/model'; export default class BlogModel extends Model { @hasMany('user') users; @belongsTo('user') owner; @hasMany('post') posts; } ``` This property would contain the following: ```javascript import Blog from 'app/models/blog'; let relationshipNames = Blog.relationshipNames; relationshipNames.hasMany; //=> ['users', 'posts'] relationshipNames.belongsTo; //=> ['owner'] ``` ##### Returns `object` ###### belongsTo ```ts belongsTo: string[]; ``` ###### hasMany ```ts hasMany: string[]; ``` *** ### relationships #### Get Signature ```ts get static relationships(): Map; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1303](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1303) The model's relationships as a map, keyed on the type of the relationship. The value of each entry is an array containing a descriptor for each relationship with that type, describing the name of the relationship as well as the type. For example, given the following model definition: ```js [app/models/blog.js] import { Model, belongsTo, hasMany } from '@warp-drive/legacy/model'; export default class BlogModel extends Model { @hasMany('user') users; @belongsTo('user') owner; @hasMany('post') posts; } ``` This computed property would return a map describing these relationships, like this: ```javascript import Blog from 'app/models/blog'; import User from 'app/models/user'; import Post from 'app/models/post'; let relationships = Blog.relationships; relationships.user; //=> [ { name: 'users', kind: 'hasMany' }, // { name: 'owner', kind: 'belongsTo' } ] relationships.post; //=> [ { name: 'posts', kind: 'hasMany' } ] ``` ##### Returns `Map`<`string`, [`LegacyRelationshipField`](../../../core-types/schema/fields/type-aliases/LegacyRelationshipField.md)\[]> *** ### relationshipsByName #### Get Signature ```ts get static relationshipsByName(): Map; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1471](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1471) A map whose keys are the relationships of a model and whose values are relationship descriptors. For example, given a model with this definition: ```js [app/models/blog.js] import { Model, belongsTo, hasMany } from '@warp-drive/legacy/model'; export default class BlogModel extends Model { @hasMany('user') users; @belongsTo('user') owner; @hasMany('post') posts; } ``` This property would contain the following: ```javascript import Blog from 'app/models/blog'; let relationshipsByName = Blog.relationshipsByName; relationshipsByName.users; //=> { name: 'users', kind: 'hasMany', type: 'user', options: Object } relationshipsByName.owner; //=> { name: 'owner', kind: 'belongsTo', type: 'user', options: Object } ``` ##### Returns `Map`<`string`, [`LegacyRelationshipField`](../../../core-types/schema/fields/type-aliases/LegacyRelationshipField.md)> *** ### relationshipsObject #### Get Signature ```ts get static relationshipsObject(): Record; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1491](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1491) ##### Returns `Record`<`string`, [`LegacyRelationshipField`](../../../core-types/schema/fields/type-aliases/LegacyRelationshipField.md)> *** ### transformedAttributes #### Get Signature ```ts get static transformedAttributes(): Map; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1759](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1759) A map whose keys are the attributes of the model (properties described by attr) and whose values are type of transformation applied to each attribute. This map does not include any attributes that do not have an transformation type. Example ```js [app/models/person.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PersonModel extends Model { @attr firstName; @attr('string') lastName; @attr('date') birthday; } ``` ```javascript import Person from 'app/models/person'; let transformedAttributes = Person.transformedAttributes transformedAttributes.forEach(function(field, type) { // do thing }); // prints: // lastName string // birthday date ``` ##### Returns `Map`<`string`, `string`> ## Methods ### addObserver() #### Call Signature ```ts addObserver( key, target, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:333 Adds an observer on a property. This is the core method used to register an observer for a property. Once you call this method, any time the key's value is set, your observer will be notified. Note that the observers are triggered any time the value is set, regardless of whether it has actually changed. Your observer should be prepared to handle that. There are two common invocation patterns for `.addObserver()`: * Passing two arguments: * the name of the property to observe (as a string) * the function to invoke (an actual function) * Passing three arguments: * the name of the property to observe (as a string) * the target object (will be used to look up and invoke a function on) * the name of the function to invoke on the target object (as a string). ```app/components/my-component.js import Component from '@ember/component'; export default Component.extend({ init() { this._super(...arguments); // the following are equivalent: // using three arguments this.addObserver('foo', this, 'fooDidChange'); // using two arguments this.addObserver('foo', (...args) => { this.fooDidChange(...args); }); }, fooDidChange() { // your custom logic code } }); ``` ### Observer Methods Observer methods have the following signature: ```app/components/my-component.js import Component from '@ember/component'; export default Component.extend({ init() { this._super(...arguments); this.addObserver('foo', this, 'fooDidChange'); }, fooDidChange(sender, key, value, rev) { // your code } }); ``` The `sender` is the object that changed. The `key` is the property that changes. The `value` property is currently reserved and unused. The `rev` is the last property revision of the object when it changed, which you can use to detect if the key value has really changed or not. Usually you will not need the value or revision parameters at the end. In this case, it is common to write observer methods that take only a sender and key value as parameters or, if you aren't interested in any of these values, to write an observer that has no parameters at all. ##### Type Parameters ###### Target `Target` ##### Parameters ###### key keyof `Model` The key to observe ###### target `Target` The target object to invoke ###### method `ObserverMethod`<`Target`, `Model`> The method to invoke ##### Returns `this` ##### Method addObserver #### Call Signature ```ts addObserver(key, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:338 ##### Parameters ###### key keyof `Model` ###### method `ObserverMethod`<`Model`, `Model`> ##### Returns `this` *** ### belongsTo() ```ts belongsTo(this, prop): BelongsToReference; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:362](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L362) Get the reference for the specified belongsTo relationship. For instance, given the following model ```js [app/models/blog-post.js] import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class BlogPost extends Model { @belongsTo('user', { async: true, inverse: null }) author; } ``` Then the reference for the author relationship would be retrieved from a record instance like so: ```js blogPost.belongsTo('author'); ``` A `BelongsToReference` is a low-level API that allows access and manipulation of a belongsTo relationship. It is especially useful when you're dealing with `async` relationships as it allows synchronous access to the relationship data if loaded, as well as APIs for loading, reloading the data or accessing available information without triggering a load. It may also be useful when using `sync` relationships that need to be loaded/reloaded with more precise timing than marking the relationship as `async` and relying on autofetch would have allowed. However,keep in mind that marking a relationship as `async: false` will introduce bugs into your application if the data is not always guaranteed to be available by the time the relationship is accessed. Ergo, it is recommended when using this approach to utilize `links` for unloaded relationship state instead of identifiers. Reference APIs are entangled with the relationship's underlying state, thus any getters or cached properties that utilize these will properly invalidate if the relationship state changes. References are "stable", meaning that multiple calls to retrieve the reference for a given relationship will always return the same HasManyReference. #### Type Parameters ##### T `T` *extends* `Model` ##### K `K` *extends* `string` #### Parameters ##### this `T` ##### prop `K` & `K` *extends* `_MaybeBelongsToFields`<`T`> ? `K`<`K`> : `never` #### Returns `BelongsToReference`<`T`, `K`> reference for this relationship #### Since 2.5.0 *** ### cacheFor() ```ts cacheFor(key): unknown; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:413 Returns the cached value of a computed property, if it exists. This allows you to inspect the value of a computed property without accidentally invoking it if it is intended to be generated lazily. #### Type Parameters ##### K `K` *extends* keyof `Model` #### Parameters ##### key `K` #### Returns `unknown` The cached value of the computed property, if any #### Method cacheFor *** ### changedAttributes() ```ts changedAttributes(this): ChangedAttributesHash; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:211](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L211) Returns an object, whose keys are changed properties, and value is an \[oldProp, newProp] array. The array represents the diff of the canonical state with the local state of the model. Note: if the model is created locally, the canonical state is empty since the adapter hasn't acknowledged the attributes yet: Example ```js [app/models/mascot.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class MascotModel extends Model { @attr('string') name; @attr('boolean', { defaultValue: false }) isAdmin; } ``` ```javascript let mascot = store.createRecord('mascot'); mascot.changedAttributes(); // {} mascot.set('name', 'Tomster'); mascot.changedAttributes(); // { name: [undefined, 'Tomster'] } mascot.set('isAdmin', true); mascot.changedAttributes(); // { isAdmin: [undefined, true], name: [undefined, 'Tomster'] } mascot.save().then(function() { mascot.changedAttributes(); // {} mascot.set('isAdmin', false); mascot.changedAttributes(); // { isAdmin: [true, false] } }); ``` #### Type Parameters ##### T `T` *extends* `MinimalLegacyRecord` #### Parameters ##### this `T` #### Returns `ChangedAttributesHash` an object, whose keys are changed properties, and value is an \[oldProp, newProp] array. *** ### decrementProperty() ```ts decrementProperty(keyName, decrement?): number; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:387 Set the value of a property to the current value minus some amount. ```javascript player.decrementProperty('lives'); orc.decrementProperty('health', 5); ``` #### Parameters ##### keyName keyof `Model` The name of the property to decrement ##### decrement? `number` The amount to decrement by. Defaults to 1 #### Returns `number` The new property value #### Method decrementProperty *** ### deleteRecord() ```ts deleteRecord(this): void; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:446](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L446) Marks the record as deleted but does not save it. You must call `save` afterwards if you want to persist it. You might use this method if you want to allow the user to still `rollbackAttributes()` after a delete was made. Example ```js import Component from '@glimmer/component'; export default class extends Component { softDelete = () => { this.args.model.deleteRecord(); } confirm = () => { this.args.model.save(); } undo = () => { this.args.model.rollbackAttributes(); } } ``` #### Type Parameters ##### T `T` *extends* `MinimalLegacyRecord` #### Parameters ##### this `T` #### Returns `void` *** ### destroyRecord() ```ts destroyRecord(this, options?): Promise; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:156](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L156) Same as `deleteRecord`, but saves the record immediately. Example ```js import Component from '@glimmer/component'; export default class extends Component { delete = () => { this.args.model.destroyRecord().then(function() { this.transitionToRoute('model.index'); }); } } ``` If you pass an object on the `adapterOptions` property of the options argument it will be passed to your adapter via the snapshot ```js record.destroyRecord({ adapterOptions: { subscribe: false } }); ``` ```js [app/adapters/post.js] import MyCustomAdapter from './custom-adapter'; export default class PostAdapter extends MyCustomAdapter { deleteRecord(store, type, snapshot) { if (snapshot.adapterOptions.subscribe) { // ... } // ... } } ``` #### Type Parameters ##### T `T` *extends* `MinimalLegacyRecord` #### Parameters ##### this `T` ##### options? `Record`<`string`, `unknown`> #### Returns `Promise`<`Model`> a promise that will be resolved when the adapter returns successfully or rejected if the adapter returns with an error. *** ### eachAttribute() ```ts eachAttribute(callback, binding?): void; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1070](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1070) #### Type Parameters ##### T `T` #### Parameters ##### callback (`this`, `key`, `meta`) => `void` ##### binding? `T` #### Returns `void` *** ### eachRelationship() ```ts eachRelationship(callback, binding?): void; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1055](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1055) Given a callback, iterates over each of the relationships in the model, invoking the callback with the name of each relationship and its relationship descriptor. The callback method you provide should have the following signature (all parameters are optional): ```javascript function(name, descriptor); ``` * `name` the name of the current property in the iteration * `descriptor` the meta object that describes this relationship The relationship descriptor argument is an object with the following properties. * **name** String the name of this relationship on the Model * **kind** String "hasMany" or "belongsTo" * **options** Object the original options hash passed when the relationship was declared * **parentType** Model the type of the Model that owns this relationship * **type** String the type name of the related Model Note that in addition to a callback, you can also pass an optional target object that will be set as `this` on the context. Example ```js [app/serializers/application.js] import JSONSerializer from '@ember-data/serializer/json'; export default class ApplicationSerializer extends JSONSerializer { serialize(record, options) { let json = {}; record.eachRelationship(function(name, descriptor) { if (descriptor.kind === 'hasMany') { let serializedHasManyName = name.toUpperCase() + '_IDS'; json[serializedHasManyName] = record.get(name).map(r => r.id); } }); return json; } } ``` #### Type Parameters ##### T `T` #### Parameters ##### callback (`this`, `key`, `meta`) => `void` the callback to invoke ##### binding? `T` the value to which the callback's `this` should be bound #### Returns `void` *** ### get() #### Call Signature ```ts get(key): Model[K]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:121 Retrieves the value of a property from the object. This method is usually similar to using `object[keyName]` or `object.keyName`, however it supports both computed properties and the unknownProperty handler. Because `get` unifies the syntax for accessing all these kinds of properties, it can make many refactorings easier, such as replacing a simple property with a computed property, or vice versa. ### Computed Properties Computed properties are methods defined with the `property` modifier declared at the end, such as: ```javascript import { computed } from '@ember/object'; fullName: computed('firstName', 'lastName', function() { return this.get('firstName') + ' ' + this.get('lastName'); }) ``` When you call `get` on a computed property, the function will be called and the return value will be returned instead of the function itself. ### Unknown Properties Likewise, if you try to call `get` on a property whose value is `undefined`, the `unknownProperty()` method will be called on the object. If this method returns any value other than `undefined`, it will be returned instead. This allows you to implement "virtual" properties that are not defined upfront. ##### Type Parameters ###### K `K` *extends* keyof `Model` ##### Parameters ###### key `K` ##### Returns `Model`\[`K`] The property value or undefined. ##### Method get #### Call Signature ```ts get(key): unknown; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:122 ##### Parameters ###### key `string` ##### Returns `unknown` *** ### getProperties() #### Call Signature ```ts getProperties(list): { [Key in keyof Model]: Model[Key] }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:144 To get the values of multiple properties at once, call `getProperties` with a list of strings or an array: ```javascript record.getProperties('firstName', 'lastName', 'zipCode'); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } ``` is equivalent to: ```javascript record.getProperties(['firstName', 'lastName', 'zipCode']); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } ``` ##### Type Parameters ###### L `L` *extends* keyof `Model`\[] ##### Parameters ###### list `L` of keys to get ##### Returns `{ [Key in keyof Model]: Model[Key] }` ##### Method getProperties #### Call Signature ```ts getProperties(...list): { [Key in keyof Model]: Model[Key] }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:149 ##### Type Parameters ###### L `L` *extends* keyof `Model`\[] ##### Parameters ###### list ...`L` ##### Returns `{ [Key in keyof Model]: Model[Key] }` #### Call Signature ```ts getProperties(list): { [Key in string]: unknown }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:154 ##### Type Parameters ###### L `L` *extends* `string`\[] ##### Parameters ###### list `L` ##### Returns `{ [Key in string]: unknown }` #### Call Signature ```ts getProperties(...list): { [Key in string]: unknown }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:159 ##### Type Parameters ###### L `L` *extends* `string`\[] ##### Parameters ###### list ...`L` ##### Returns `{ [Key in string]: unknown }` *** ### hasMany() ```ts hasMany(this, prop): HasManyReference; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:416](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L416) Get the reference for the specified hasMany relationship. For instance, given the following model ```js [app/models/blog-post.js] import { Model, hasMany } from '@warp-drive/legacy/model'; export default class BlogPost extends Model { @hasMany('comment', { async: true, inverse: null }) comments; } ``` Then the reference for the comments relationship would be retrieved from a record instance like so: ```js blogPost.hasMany('comments'); ``` A `HasManyReference` is a low-level API that allows access and manipulation of a hasMany relationship. It is especially useful when you are dealing with `async` relationships as it allows synchronous access to the relationship data if loaded, as well as APIs for loading, reloading the data or accessing available information without triggering a load. It may also be useful when using `sync` relationships with `@ember-data/model` that need to be loaded/reloaded with more precise timing than marking the relationship as `async` and relying on autofetch would have allowed. However,keep in mind that marking a relationship as `async: false` will introduce bugs into your application if the data is not always guaranteed to be available by the time the relationship is accessed. Ergo, it is recommended when using this approach to utilize `links` for unloaded relationship state instead of identifiers. Reference APIs are entangled with the relationship's underlying state, thus any getters or cached properties that utilize these will properly invalidate if the relationship state changes. References are "stable", meaning that multiple calls to retrieve the reference for a given relationship will always return the same HasManyReference. #### Type Parameters ##### T `T` *extends* `MinimalLegacyRecord` ##### K `K` *extends* `string` #### Parameters ##### this `T` ##### prop `K` #### Returns `HasManyReference`<`T`, `K`> reference for this relationship #### Since 2.5.0 *** ### incrementProperty() ```ts incrementProperty(keyName, increment?): number; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:372 Set the value of a property to the current value plus some amount. ```javascript person.incrementProperty('age'); team.incrementProperty('score', 2); ``` #### Parameters ##### keyName keyof `Model` The name of the property to increment ##### increment? `number` The amount to increment by. Defaults to 1 #### Returns `number` The new property value #### Method incrementProperty *** ### inverseFor() ```ts inverseFor(name): | null | LegacyRelationshipField; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1066](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1066) #### Parameters ##### name `string` #### Returns | `null` | [`LegacyRelationshipField`](../../../core-types/schema/fields/type-aliases/LegacyRelationshipField.md) *** ### notifyPropertyChange() ```ts notifyPropertyChange(prop): this; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:989](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L989) Convenience method to call `propertyWillChange` and `propertyDidChange` in succession. Notify the observer system that a property has just changed. Sometimes you need to change a value directly or indirectly without actually calling `get()` or `set()` on it. In this case, you can use this method instead. Calling this method will notify all observers that the property has potentially changed value. #### Parameters ##### prop `string` #### Returns `this` #### Method notifyPropertyChange *** ### relationshipFor() ```ts relationshipFor(name): | undefined | LegacyRelationshipField; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1062](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1062) #### Parameters ##### name `string` #### Returns | `undefined` | [`LegacyRelationshipField`](../../../core-types/schema/fields/type-aliases/LegacyRelationshipField.md) *** ### reload() ```ts reload(this, options?): Promise; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:306](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L306) Reload the record from the adapter. This will only work if the record has already finished loading. Example ```js import Component from '@glimmer/component'; export default class extends Component { async reload = () => { await this.args.model.reload(); // do something with the reloaded model } } ``` #### Type Parameters ##### T `T` *extends* `MinimalLegacyRecord` #### Parameters ##### this `T` ##### options? `Record`<`string`, `unknown`> optional, may include `adapterOptions` hash which will be passed to adapter request #### Returns `Promise`<`T`> a promise that will be resolved with the record when the adapter returns successfully or rejected if the adapter returns with an error. *** ### removeObserver() #### Call Signature ```ts removeObserver( key, target, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:352 Remove an observer you have previously registered on this object. Pass the same key, target, and method you passed to `addObserver()` and your target will no longer receive notifications. ##### Type Parameters ###### Target `Target` ##### Parameters ###### key keyof `Model` The key to observe ###### target `Target` The target object to invoke ###### method `ObserverMethod`<`Target`, `Model`> The method to invoke ##### Returns `this` ##### Method removeObserver #### Call Signature ```ts removeObserver(key, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:357 ##### Parameters ###### key keyof `Model` ###### method `ObserverMethod`<`Model`, `Model`> ##### Returns `this` *** ### reopen() ```ts reopen(...args): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:81 #### Parameters ##### args ...(`Record`<`string`, `unknown`> | `Mixin`)\[] #### Returns `this` *** ### rollbackAttributes() ```ts rollbackAttributes(this): void; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:230](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L230) If the model `hasDirtyAttributes` this function will discard any unsaved changes. If the model `isNew` it will be removed from the store. Example ```javascript record.name; // 'Untitled Document' record.set('name', 'Doc 1'); record.name; // 'Doc 1' record.rollbackAttributes(); record.name; // 'Untitled Document' ``` #### Type Parameters ##### T `T` *extends* `MinimalLegacyRecord` #### Parameters ##### this `T` #### Returns `void` #### Since 1.13.0 *** ### save() ```ts save(this, options?): Promise; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:278](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L278) Save the record and persist any changes to the record to an external source via the adapter. Example ```javascript record.set('name', 'Tomster'); record.save().then(function() { // Success callback }, function() { // Error callback }); ``` If you pass an object using the `adapterOptions` property of the options argument it will be passed to your adapter via the snapshot. ```js record.save({ adapterOptions: { subscribe: false } }); ``` ```js [app/adapters/post.js] import MyCustomAdapter from './custom-adapter'; export default class PostAdapter extends MyCustomAdapter { updateRecord(store, type, snapshot) { if (snapshot.adapterOptions.subscribe) { // ... } // ... } } ``` #### Type Parameters ##### T `T` *extends* `MinimalLegacyRecord` #### Parameters ##### this `T` ##### options? `Record`<`string`, `unknown`> #### Returns `Promise`<`Model`> a promise that will be resolved when the adapter returns successfully or rejected if the adapter returns with an error. *** ### serialize() ```ts serialize(this, options?): unknown; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:112](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L112) Create a JSON representation of the record, using the serialization strategy of the store's adapter. `serialize` takes an optional hash as a parameter, currently supported options are: * `includeId`: `true` if the record's ID should be included in the JSON representation. #### Type Parameters ##### T `T` *extends* `MinimalLegacyRecord` #### Parameters ##### this `T` ##### options? `Record`<`string`, `unknown`> #### Returns `unknown` an object whose values are primitive JSON values only *** ### set() #### Call Signature ```ts set(key, value): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:208 Sets the provided key or path to the value. ```javascript record.set("key", value); ``` This method is generally very similar to calling `object["key"] = value` or `object.key = value`, except that it provides support for computed properties, the `setUnknownProperty()` method and property observers. ### Computed Properties If you try to set a value on a key that has a computed property handler defined (see the `get()` method for an example), then `set()` will call that method, passing both the value and key instead of simply changing the value itself. This is useful for those times when you need to implement a property that is composed of one or more member properties. ### Unknown Properties If you try to set a value on a key that is undefined in the target object, then the `setUnknownProperty()` handler will be called instead. This gives you an opportunity to implement complex "virtual" properties that are not predefined on the object. If `setUnknownProperty()` returns undefined, then `set()` will simply set the value on the object. ### Property Observers In addition to changing the property, `set()` will also register a property change with the object. Unless you have placed this call inside of a `beginPropertyChanges()` and `endPropertyChanges(),` any "local" observers (i.e. observer methods declared on the same object), will be called immediately. Any "remote" observers (i.e. observer methods declared on another object) will be placed in a queue and called at a later time in a coalesced manner. ##### Type Parameters ###### K `K` *extends* keyof `Model` ###### T `T` *extends* `unknown` ##### Parameters ###### key `K` ###### value `T` The value to set or `null`. ##### Returns `T` The passed value ##### Method set #### Call Signature ```ts set(key, value): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:209 ##### Type Parameters ###### T `T` ##### Parameters ###### key `string` ###### value `T` ##### Returns `T` *** ### setProperties() #### Call Signature ```ts setProperties(hash): P; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:224 Sets a list of properties at once. These properties are set inside a single `beginPropertyChanges` and `endPropertyChanges` batch, so observers will be buffered. ```javascript record.setProperties({ firstName: 'Charles', lastName: 'Jolley' }); ``` ##### Type Parameters ###### K `K` *extends* keyof `Model` ###### P `P` *extends* `{ [Key in keyof Model]: Model[Key] }` ##### Parameters ###### hash `P` the hash of keys and values to set ##### Returns `P` The passed in hash ##### Method setProperties #### Call Signature ```ts setProperties(hash): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:232 ##### Type Parameters ###### T `T` *extends* `Record`<`string`, `unknown`> ##### Parameters ###### hash `T` ##### Returns `T` *** ### toggleProperty() ```ts toggleProperty(keyName): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:401 Set the value of a boolean property to the opposite of its current value. ```javascript starship.toggleProperty('warpDriveEngaged'); ``` #### Parameters ##### keyName keyof `Model` The name of the property to toggle #### Returns `boolean` The new property value #### Method toggleProperty *** ### toString() ```ts toString(): string; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:873](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L873) Returns a string representation which attempts to provide more information than Javascript's `toString` typically does, in a generic way for all Ember objects. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend(); person = Person.create(); person.toString(); //=> "" ``` If the object's class is not defined on an Ember namespace, it will indicate it is a subclass of the registered superclass: ```javascript const Student = Person.extend(); let student = Student.create(); student.toString(); //=> "<(subclass of Person):ember1025>" ``` If the method `toStringExtension` is defined, its return value will be included in the output. ```javascript const Teacher = Person.extend({ toStringExtension() { return this.get('fullName'); } }); teacher = Teacher.create(); teacher.toString(); //=> "" ``` #### Returns `string` string representation #### Method toString *** ### unloadRecord() ```ts unloadRecord(this): void; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:164](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L164) Unloads the record from the store. This will not send a delete request to your server, it just unloads the record from memory. #### Type Parameters ##### T `T` *extends* `MinimalLegacyRecord` #### Parameters ##### this `T` #### Returns `void` *** ### willDestroy() ```ts willDestroy(): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:307 Override to implement teardown. #### Returns `void` #### Method willDestroy *** ### \_findInverseFor() ```ts static _findInverseFor(name, store): | null | LegacyRelationshipField; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1220](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1220) #### Parameters ##### name `string` ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) #### Returns | `null` | [`LegacyRelationshipField`](../../../core-types/schema/fields/type-aliases/LegacyRelationshipField.md) *** ### create() #### Call Signature ```ts readonly static create(this): InstanceType; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:487 Creates an instance of a class. Accepts either no arguments, or an object containing values to initialize the newly instantiated object with. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ helloWorld() { alert(`Hi, my name is ${this.get('name')}`); } }); let tom = Person.create({ name: 'Tom Dale' }); tom.helloWorld(); // alerts "Hi, my name is Tom Dale". ``` `create` will call the `init` function if defined during `AnyObject.extend` If no arguments are passed to `create`, it will not set values to the new instance during initialization: ```javascript let noName = Person.create(); noName.helloWorld(); // alerts undefined ``` NOTE: For performance reasons, you cannot declare methods or computed properties during `create`. You should instead declare methods and computed properties when using `extend`. ##### Type Parameters ###### C `C` *extends* *typeof* `CoreObject` ##### Parameters ###### this `C` ##### Returns `InstanceType`<`C`> ##### Method create ##### For @ember/object ##### Static #### Call Signature ```ts readonly static create(this, ...args): InstanceType & MergeArray; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:488 Creates an instance of a class. Accepts either no arguments, or an object containing values to initialize the newly instantiated object with. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ helloWorld() { alert(`Hi, my name is ${this.get('name')}`); } }); let tom = Person.create({ name: 'Tom Dale' }); tom.helloWorld(); // alerts "Hi, my name is Tom Dale". ``` `create` will call the `init` function if defined during `AnyObject.extend` If no arguments are passed to `create`, it will not set values to the new instance during initialization: ```javascript let noName = Person.create(); noName.helloWorld(); // alerts undefined ``` NOTE: For performance reasons, you cannot declare methods or computed properties during `create`. You should instead declare methods and computed properties when using `extend`. ##### Type Parameters ###### C `C` *extends* *typeof* `CoreObject` ###### I `I` *extends* `CoreObject` ###### K `K` *extends* `string` | `number` | `symbol` ###### Args `Args` *extends* `Partial`<{ \[Key in string | number | symbol]: I\[Key] }>\[] ##### Parameters ###### this `C` ###### args ...`Args` ##### Returns `InstanceType`<`C`> & `MergeArray`<`Args`> ##### Method create ##### For @ember/object ##### Static *** ### detectInstance() ```ts readonly static detectInstance(obj): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:600 #### Parameters ##### obj `unknown` #### Returns `boolean` *** ### eachAttribute() ```ts static eachAttribute(callback, binding?): void; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1818](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1818) Iterates through the attributes of the model, calling the passed function on each attribute. The callback method you provide should have the following signature (all parameters are optional): ```javascript function(name, meta); ``` * `name` the name of the current property in the iteration * `meta` the meta object for the attribute property in the iteration Note that in addition to a callback, you can also pass an optional target object that will be set as `this` on the context. Example ```javascript import { Model, attr } from '@warp-drive/legacy/model'; class PersonModel extends Model { @attr('string') firstName; @attr('string') lastName; @attr('date') birthday; } PersonModel.eachAttribute(function(name, meta) { // do thing }); // prints: // firstName {type: "string", kind: 'attribute', options: Object, parentType: function, name: "firstName"} // lastName {type: "string", kind: 'attribute', options: Object, parentType: function, name: "lastName"} // birthday {type: "date", kind: 'attribute', options: Object, parentType: function, name: "birthday"} ``` #### Type Parameters ##### T `T` ##### Schema `Schema` *extends* `Model` #### Parameters ##### callback (`this`, `key`, `attribute`) => `void` The callback to execute ##### binding? `T` the value to which the callback's `this` should be bound #### Returns `void` *** ### eachRelatedType() ```ts static eachRelatedType(callback, binding?): void; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1612](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1612) Given a callback, iterates over each of the types related to a model, invoking the callback with the related type's class. Each type will be returned just once, regardless of how many different relationships it has with a model. #### Type Parameters ##### T `T` #### Parameters ##### callback (`this`, `type`) => `void` the callback to invoke ##### binding? `T` the value to which the callback's `this` should be bound #### Returns `void` *** ### eachRelationship() ```ts static eachRelationship(callback, binding?): void; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1584](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1584) Given a callback, iterates over each of the relationships in the model, invoking the callback with the name of each relationship and its relationship descriptor. #### Type Parameters ##### T `T` ##### Schema `Schema` *extends* `Model` #### Parameters ##### callback (`this`, `key`, `relationship`) => `void` the callback to invoke ##### binding? `T` the value to which the callback's `this` should be bound #### Returns `void` *** ### eachTransformedAttribute() ```ts static eachTransformedAttribute(callback, binding?): void; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1875](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1875) Iterates through the transformedAttributes of the model, calling the passed function on each attribute. Note the callback will not be called for any attributes that do not have an transformation type. The callback method you provide should have the following signature (all parameters are optional): ```javascript function(name, type); ``` * `name` the name of the current property in the iteration * `type` a string containing the name of the type of transformed applied to the attribute Note that in addition to a callback, you can also pass an optional target object that will be set as `this` on the context. Example ```javascript import { Model, attr } from '@warp-drive/legacy/model'; let Person = Model.extend({ firstName: attr(), lastName: attr('string'), birthday: attr('date') }); Person.eachTransformedAttribute(function(name, type) { // do thing }); // prints: // lastName string // birthday date ``` #### Type Parameters ##### T `T` ##### Schema `Schema` *extends* `Model` #### Parameters ##### callback (`this`, `key`, `type`) => `void` The callback to execute ##### binding? `T` the value to which the callback's `this` should be bound #### Returns `void` *** ### extend() ```ts readonly static extend(this, ...mixins?): Readonly & EmberClassConstructor & MergeArray; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:442 Creates a new subclass. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ say(thing) { alert(thing); } }); ``` This defines a new subclass of EmberObject: `Person`. It contains one method: `say()`. You can also create a subclass from any existing class by calling its `extend()` method. For example, you might want to create a subclass of Ember's built-in `Component` class: ```javascript import Component from '@ember/component'; const PersonComponent = Component.extend({ tagName: 'li', classNameBindings: ['isAdministrator'] }); ``` When defining a subclass, you can override methods but still access the implementation of your parent class by calling the special `_super()` method: ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ say(thing) { let name = this.get('name'); alert(`${name} says: ${thing}`); } }); const Soldier = Person.extend({ say(thing) { this._super(`${thing}, sir!`); }, march(numberOfHours) { alert(`${this.get('name')} marches for ${numberOfHours} hours.`); } }); let yehuda = Soldier.create({ name: 'Yehuda Katz' }); yehuda.say('Yes'); // alerts "Yehuda Katz says: Yes, sir!" ``` The `create()` on line #17 creates an *instance* of the `Soldier` class. The `extend()` on line #8 creates a *subclass* of `Person`. Any instance of the `Person` class will *not* have the `march()` method. You can also pass `Mixin` classes to add additional properties to the subclass. ```javascript import EmberObject from '@ember/object'; import Mixin from '@ember/object/mixin'; const Person = EmberObject.extend({ say(thing) { alert(`${this.get('name')} says: ${thing}`); } }); const SingingMixin = Mixin.create({ sing(thing) { alert(`${this.get('name')} sings: la la la ${thing}`); } }); const BroadwayStar = Person.extend(SingingMixin, { dance() { alert(`${this.get('name')} dances: tap tap tap tap `); } }); ``` The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. #### Type Parameters ##### Statics `Statics` ##### Instance `Instance` ##### M `M` *extends* `unknown`\[] #### Parameters ##### this `Statics` & `EmberClassConstructor`<`Instance`> ##### mixins? ...`M` One or more Mixin classes #### Returns `Readonly`<`Statics`> & `EmberClassConstructor`<`Instance`> & `MergeArray`<`M`> #### Method extend #### Static #### For @ember/object *** ### inverseFor() ```ts static inverseFor(name, store): | null | LegacyRelationshipField; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1204](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1204) Find the relationship which is the inverse of the one asked for. For example, if you define models like this: ```js [app/models/post.js] import { Model, hasMany } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @hasMany('message') comments; } ``` ```js [app/models/message.js] import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class MessageModel extends Model { @belongsTo('post') owner; } ``` ```js store.modelFor('post').inverseFor('comments', store) // { type: 'message', name: 'owner', kind: 'belongsTo' } store.modelFor('message').inverseFor('owner', store) // { type: 'post', name: 'comments', kind: 'hasMany' } ``` #### Parameters ##### name `string` the name of the relationship ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) #### Returns | `null` | [`LegacyRelationshipField`](../../../core-types/schema/fields/type-aliases/LegacyRelationshipField.md) the inverse relationship, or null *** ### proto() ```ts readonly static proto(): CoreObject; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:649 #### Returns `CoreObject` *** ### reopenClass() ```ts readonly static reopenClass(this, ...mixins): C; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:595 Augments a constructor's own properties and functions: ```javascript import EmberObject from '@ember/object'; const MyObject = EmberObject.extend({ name: 'an object' }); MyObject.reopenClass({ canBuild: false }); MyObject.canBuild; // false o = MyObject.create(); ``` In other words, this creates static properties and functions for the class. These are only available on the class and not on any instance of that class. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ name: '', sayHello() { alert(`Hello. My name is ${this.get('name')}`); } }); Person.reopenClass({ species: 'Homo sapiens', createPerson(name) { return Person.create({ name }); } }); let tom = Person.create({ name: 'Tom Dale' }); let yehuda = Person.createPerson('Yehuda Katz'); tom.sayHello(); // "Hello. My name is Tom Dale" yehuda.sayHello(); // "Hello. My name is Yehuda Katz" alert(Person.species); // "Homo sapiens" ``` Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` variables. They are only valid on `Person`. To add functions and properties to instances of a constructor by extending the constructor's prototype see `reopen` #### Type Parameters ##### C `C` *extends* *typeof* `CoreObject` #### Parameters ##### this `C` ##### mixins ...(`Record`<`string`, `unknown`> | `Mixin`)\[] #### Returns `C` #### Method reopenClass #### For @ember/object #### Static *** ### toString() ```ts static toString(): string; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1894](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1894) Returns the name of the model class. #### Returns `string` *** ### typeForRelationship() ```ts static typeForRelationship(name, store): | undefined | ModelSchema; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/model.ts:1154](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/model.ts#L1154) For a given relationship name, returns the model type of the relationship. For example, if you define a model like this: ```js [app/models/post.js] import { Model, hasMany } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @hasMany('comment') comments; } ``` Calling `store.modelFor('post').typeForRelationship('comments', store)` will return `Comment`. #### Parameters ##### name `string` the name of the relationship ##### store [`default`](../../../../@ember-data/store/index/classes/default.md) an instance of Store #### Returns | `undefined` | [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md)<`unknown`> the type of the relationship, or undefined *** ### willReopen() ```ts readonly static willReopen(): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:533 #### Returns `void` --- --- url: /api/@warp-drive/legacy/model/functions/attr.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [model](../index.md) / attr ## Call Signature ```ts function attr(): DataDecorator; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/attr.ts:269](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/attr.ts#L269) `attr` defines an attribute on a [Model](/ember-data/release/classes/Model). By default, attributes are passed through as-is, however you can specify an optional type to have the value automatically transformed. EmberData ships with four basic transform types: `string`, `number`, `boolean` and `date`. You can define your own transforms by subclassing [Transform](/ember-data/release/classes/Transform). Note that you cannot use `attr` to define an attribute of `id`. `attr` takes an optional hash as a second parameter, currently supported options are: * `defaultValue`: Pass a string or a function to be called to set the attribute to a default value if and only if the key is absent from the payload response. Example ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr('boolean', { defaultValue: false }) verified; } ``` Default value can also be a function. This is useful it you want to return a new object for each attribute. ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr({ defaultValue() { return {}; } }) settings; } ``` The `options` hash is passed as second argument to a transforms' `serialize` and `deserialize` method. This allows to configure a transformation and adapt the corresponding value, based on the config: ```js [app/models/post.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @attr('text', { uppercase: true }) text; } ``` ```js [app/transforms/text.js] export default class TextTransform { serialize(value, options) { if (options.uppercase) { return value.toUpperCase(); } return value; } deserialize(value) { return value; } static create() { return new this(); } } ``` ### Returns `DataDecorator` ## Call Signature ```ts function attr(type): DataDecorator; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/attr.ts:270](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/attr.ts#L270) `attr` defines an attribute on a [Model](/ember-data/release/classes/Model). By default, attributes are passed through as-is, however you can specify an optional type to have the value automatically transformed. EmberData ships with four basic transform types: `string`, `number`, `boolean` and `date`. You can define your own transforms by subclassing [Transform](/ember-data/release/classes/Transform). Note that you cannot use `attr` to define an attribute of `id`. `attr` takes an optional hash as a second parameter, currently supported options are: * `defaultValue`: Pass a string or a function to be called to set the attribute to a default value if and only if the key is absent from the payload response. Example ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr('boolean', { defaultValue: false }) verified; } ``` Default value can also be a function. This is useful it you want to return a new object for each attribute. ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr({ defaultValue() { return {}; } }) settings; } ``` The `options` hash is passed as second argument to a transforms' `serialize` and `deserialize` method. This allows to configure a transformation and adapt the corresponding value, based on the config: ```js [app/models/post.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @attr('text', { uppercase: true }) text; } ``` ```js [app/transforms/text.js] export default class TextTransform { serialize(value, options) { if (options.uppercase) { return value.toUpperCase(); } return value; } deserialize(value) { return value; } static create() { return new this(); } } ``` ### Type Parameters #### T `T` ### Parameters #### type `TypeFromInstance`<`T`> the attribute type ### Returns `DataDecorator` ## Call Signature ```ts function attr(type): DataDecorator; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/attr.ts:271](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/attr.ts#L271) `attr` defines an attribute on a [Model](/ember-data/release/classes/Model). By default, attributes are passed through as-is, however you can specify an optional type to have the value automatically transformed. EmberData ships with four basic transform types: `string`, `number`, `boolean` and `date`. You can define your own transforms by subclassing [Transform](/ember-data/release/classes/Transform). Note that you cannot use `attr` to define an attribute of `id`. `attr` takes an optional hash as a second parameter, currently supported options are: * `defaultValue`: Pass a string or a function to be called to set the attribute to a default value if and only if the key is absent from the payload response. Example ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr('boolean', { defaultValue: false }) verified; } ``` Default value can also be a function. This is useful it you want to return a new object for each attribute. ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr({ defaultValue() { return {}; } }) settings; } ``` The `options` hash is passed as second argument to a transforms' `serialize` and `deserialize` method. This allows to configure a transformation and adapt the corresponding value, based on the config: ```js [app/models/post.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @attr('text', { uppercase: true }) text; } ``` ```js [app/transforms/text.js] export default class TextTransform { serialize(value, options) { if (options.uppercase) { return value.toUpperCase(); } return value; } deserialize(value) { return value; } static create() { return new this(); } } ``` ### Parameters #### type `string` the attribute type ### Returns `DataDecorator` ## Call Signature ```ts function attr(options): DataDecorator; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/attr.ts:272](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/attr.ts#L272) `attr` defines an attribute on a [Model](/ember-data/release/classes/Model). By default, attributes are passed through as-is, however you can specify an optional type to have the value automatically transformed. EmberData ships with four basic transform types: `string`, `number`, `boolean` and `date`. You can define your own transforms by subclassing [Transform](/ember-data/release/classes/Transform). Note that you cannot use `attr` to define an attribute of `id`. `attr` takes an optional hash as a second parameter, currently supported options are: * `defaultValue`: Pass a string or a function to be called to set the attribute to a default value if and only if the key is absent from the payload response. Example ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr('boolean', { defaultValue: false }) verified; } ``` Default value can also be a function. This is useful it you want to return a new object for each attribute. ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr({ defaultValue() { return {}; } }) settings; } ``` The `options` hash is passed as second argument to a transforms' `serialize` and `deserialize` method. This allows to configure a transformation and adapt the corresponding value, based on the config: ```js [app/models/post.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @attr('text', { uppercase: true }) text; } ``` ```js [app/transforms/text.js] export default class TextTransform { serialize(value, options) { if (options.uppercase) { return value.toUpperCase(); } return value; } deserialize(value) { return value; } static create() { return new this(); } } ``` ### Parameters #### options `AttrOptions` a hash of options ### Returns `DataDecorator` ## Call Signature ```ts function attr(type, options?): DataDecorator; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/attr.ts:273](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/attr.ts#L273) `attr` defines an attribute on a [Model](/ember-data/release/classes/Model). By default, attributes are passed through as-is, however you can specify an optional type to have the value automatically transformed. EmberData ships with four basic transform types: `string`, `number`, `boolean` and `date`. You can define your own transforms by subclassing [Transform](/ember-data/release/classes/Transform). Note that you cannot use `attr` to define an attribute of `id`. `attr` takes an optional hash as a second parameter, currently supported options are: * `defaultValue`: Pass a string or a function to be called to set the attribute to a default value if and only if the key is absent from the payload response. Example ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr('boolean', { defaultValue: false }) verified; } ``` Default value can also be a function. This is useful it you want to return a new object for each attribute. ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr({ defaultValue() { return {}; } }) settings; } ``` The `options` hash is passed as second argument to a transforms' `serialize` and `deserialize` method. This allows to configure a transformation and adapt the corresponding value, based on the config: ```js [app/models/post.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @attr('text', { uppercase: true }) text; } ``` ```js [app/transforms/text.js] export default class TextTransform { serialize(value, options) { if (options.uppercase) { return value.toUpperCase(); } return value; } deserialize(value) { return value; } static create() { return new this(); } } ``` ### Type Parameters #### T `T` ### Parameters #### type `TypeFromInstance`<`T`> the attribute type #### options? `OptionsFromInstance`<`T`> a hash of options ### Returns `DataDecorator` ## Call Signature ```ts function attr(type, options?): DataDecorator; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/attr.ts:274](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/attr.ts#L274) `attr` defines an attribute on a [Model](/ember-data/release/classes/Model). By default, attributes are passed through as-is, however you can specify an optional type to have the value automatically transformed. EmberData ships with four basic transform types: `string`, `number`, `boolean` and `date`. You can define your own transforms by subclassing [Transform](/ember-data/release/classes/Transform). Note that you cannot use `attr` to define an attribute of `id`. `attr` takes an optional hash as a second parameter, currently supported options are: * `defaultValue`: Pass a string or a function to be called to set the attribute to a default value if and only if the key is absent from the payload response. Example ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr('boolean', { defaultValue: false }) verified; } ``` Default value can also be a function. This is useful it you want to return a new object for each attribute. ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr({ defaultValue() { return {}; } }) settings; } ``` The `options` hash is passed as second argument to a transforms' `serialize` and `deserialize` method. This allows to configure a transformation and adapt the corresponding value, based on the config: ```js [app/models/post.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @attr('text', { uppercase: true }) text; } ``` ```js [app/transforms/text.js] export default class TextTransform { serialize(value, options) { if (options.uppercase) { return value.toUpperCase(); } return value; } deserialize(value) { return value; } static create() { return new this(); } } ``` ### Parameters #### type `string` the attribute type #### options? `AttrOptions`< | `object` | `unknown`\[] | [`PrimitiveValue`](../../../core-types/json/raw/type-aliases/PrimitiveValue.md)> & `object` a hash of options ### Returns `DataDecorator` ## Call Signature ```ts function attr( target, key, desc?): void; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/attr.ts:275](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/attr.ts#L275) `attr` defines an attribute on a [Model](/ember-data/release/classes/Model). By default, attributes are passed through as-is, however you can specify an optional type to have the value automatically transformed. EmberData ships with four basic transform types: `string`, `number`, `boolean` and `date`. You can define your own transforms by subclassing [Transform](/ember-data/release/classes/Transform). Note that you cannot use `attr` to define an attribute of `id`. `attr` takes an optional hash as a second parameter, currently supported options are: * `defaultValue`: Pass a string or a function to be called to set the attribute to a default value if and only if the key is absent from the payload response. Example ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr('boolean', { defaultValue: false }) verified; } ``` Default value can also be a function. This is useful it you want to return a new object for each attribute. ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') username; @attr('string') email; @attr({ defaultValue() { return {}; } }) settings; } ``` The `options` hash is passed as second argument to a transforms' `serialize` and `deserialize` method. This allows to configure a transformation and adapt the corresponding value, based on the config: ```js [app/models/post.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class PostModel extends Model { @attr('text', { uppercase: true }) text; } ``` ```js [app/transforms/text.js] export default class TextTransform { serialize(value, options) { if (options.uppercase) { return value.toUpperCase(); } return value; } deserialize(value) { return value; } static create() { return new this(); } } ``` ### Parameters #### target `object` #### key `string` | `symbol` #### desc? `PropertyDescriptor` ### Returns `void` --- --- url: /api/@warp-drive/legacy/model/functions/belongsTo.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [model](../index.md) / belongsTo ## Call Signature ```ts function belongsTo(): never; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/belongs-to.ts:272](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/belongs-to.ts#L272) `belongsTo` is used to define One-To-One and One-To-Many, and One-To-None relationships on a [Model](/ember-data/release/classes/Model). `belongsTo` takes a configuration hash as a second parameter, currently supported options are: * `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship. * `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`. * `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic * `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism. ### Examples To declare a **one-to-many** (or many-to-many) relationship, use `belongsTo` in combination with `hasMany`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('post', { async: false, inverse: 'comments' }) post; } // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'post' }) comments; } ``` To declare a **one-to-one** relationship with managed inverses, use `belongsTo` for both sides: ```js // app/models/author.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Author extends Model { @belongsTo('address', { async: true, inverse: 'owner' }) address; } // app/models/address.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Address extends Model { @belongsTo('author', { async: true, inverse: 'address' }) owner; } ``` To declare a **one-to-one** relationship without managed inverses, use `belongsTo` for both sides with `null` as the inverse: ```js // app/models/author.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Author extends Model { @belongsTo('address', { async: true, inverse: null }) address; } // app/models/address.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Address extends Model { @belongsTo('author', { async: true, inverse: null }) owner; } ``` To declare a one-to-none relationship between two models, use `belongsTo` with inverse set to `null` on just one side:: ```js // app/models/person.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Person extends Model { @belongsTo('person', { async: false, inverse: null }) bestFriend; } ``` #### Sync vs Async Relationships EmberData fulfills relationships using resource data available in the cache. Sync relationships point directly to the known related resources. When a relationship is declared as async, if any of the known related resources have not been loaded, they will be fetched. The property on the record when accessed provides a promise that resolves once all resources are loaded. Async relationships may take advantage of links. On access, if the related link has not been loaded, or if any known resources are not available in the cache, the fresh state will be fetched using the link. In contrast to async relationship, accessing a sync relationship will error on access when any of the known related resources have not been loaded. If you are using `links` with sync relationships, you have to use the BelongsTo reference API to fetch or refresh related resources that aren't loaded. For instance, for a `bestFriend` relationship: ```js person.belongsTo('bestFriend').reload(); ``` #### Polymorphic Relationships To declare a polymorphic relationship, use `hasMany` with the `polymorphic` option set to `true`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent; } ``` `'commentable'` here is referred to as the "abstract type" for the polymorphic relationship. Polymorphic relationships with `inverse: null` will accept any type of record as their content. Polymorphic relationships with `inverse` set to a string will only accept records with a matching inverse relationships declaring itself as satisfying the abstract type. Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable' for this relationship. ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments; } ``` Note: every Model that declares an inverse to a polymorphic relationship must declare itself exactly the same. This is because polymorphism is based on structural traits. Polymorphic to polymorphic relationships are supported. Both sides of the relationship must be declared as polymorphic, and the `as` option must be used to declare the abstract type each record satisfies on both sides. ### Returns `never` relationship ## Call Signature ```ts function belongsTo(type): never; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/belongs-to.ts:273](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/belongs-to.ts#L273) `belongsTo` is used to define One-To-One and One-To-Many, and One-To-None relationships on a [Model](/ember-data/release/classes/Model). `belongsTo` takes a configuration hash as a second parameter, currently supported options are: * `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship. * `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`. * `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic * `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism. ### Examples To declare a **one-to-many** (or many-to-many) relationship, use `belongsTo` in combination with `hasMany`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('post', { async: false, inverse: 'comments' }) post; } // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'post' }) comments; } ``` To declare a **one-to-one** relationship with managed inverses, use `belongsTo` for both sides: ```js // app/models/author.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Author extends Model { @belongsTo('address', { async: true, inverse: 'owner' }) address; } // app/models/address.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Address extends Model { @belongsTo('author', { async: true, inverse: 'address' }) owner; } ``` To declare a **one-to-one** relationship without managed inverses, use `belongsTo` for both sides with `null` as the inverse: ```js // app/models/author.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Author extends Model { @belongsTo('address', { async: true, inverse: null }) address; } // app/models/address.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Address extends Model { @belongsTo('author', { async: true, inverse: null }) owner; } ``` To declare a one-to-none relationship between two models, use `belongsTo` with inverse set to `null` on just one side:: ```js // app/models/person.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Person extends Model { @belongsTo('person', { async: false, inverse: null }) bestFriend; } ``` #### Sync vs Async Relationships EmberData fulfills relationships using resource data available in the cache. Sync relationships point directly to the known related resources. When a relationship is declared as async, if any of the known related resources have not been loaded, they will be fetched. The property on the record when accessed provides a promise that resolves once all resources are loaded. Async relationships may take advantage of links. On access, if the related link has not been loaded, or if any known resources are not available in the cache, the fresh state will be fetched using the link. In contrast to async relationship, accessing a sync relationship will error on access when any of the known related resources have not been loaded. If you are using `links` with sync relationships, you have to use the BelongsTo reference API to fetch or refresh related resources that aren't loaded. For instance, for a `bestFriend` relationship: ```js person.belongsTo('bestFriend').reload(); ``` #### Polymorphic Relationships To declare a polymorphic relationship, use `hasMany` with the `polymorphic` option set to `true`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent; } ``` `'commentable'` here is referred to as the "abstract type" for the polymorphic relationship. Polymorphic relationships with `inverse: null` will accept any type of record as their content. Polymorphic relationships with `inverse` set to a string will only accept records with a matching inverse relationships declaring itself as satisfying the abstract type. Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable' for this relationship. ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments; } ``` Note: every Model that declares an inverse to a polymorphic relationship must declare itself exactly the same. This is because polymorphism is based on structural traits. Polymorphic to polymorphic relationships are supported. Both sides of the relationship must be declared as polymorphic, and the `as` option must be used to declare the abstract type each record satisfies on both sides. ### Parameters #### type `string` (optional) the name of the related resource ### Returns `never` relationship ## Call Signature ```ts function belongsTo(type, options): RelationshipDecorator; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/belongs-to.ts:274](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/belongs-to.ts#L274) `belongsTo` is used to define One-To-One and One-To-Many, and One-To-None relationships on a [Model](/ember-data/release/classes/Model). `belongsTo` takes a configuration hash as a second parameter, currently supported options are: * `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship. * `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`. * `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic * `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism. ### Examples To declare a **one-to-many** (or many-to-many) relationship, use `belongsTo` in combination with `hasMany`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('post', { async: false, inverse: 'comments' }) post; } // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'post' }) comments; } ``` To declare a **one-to-one** relationship with managed inverses, use `belongsTo` for both sides: ```js // app/models/author.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Author extends Model { @belongsTo('address', { async: true, inverse: 'owner' }) address; } // app/models/address.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Address extends Model { @belongsTo('author', { async: true, inverse: 'address' }) owner; } ``` To declare a **one-to-one** relationship without managed inverses, use `belongsTo` for both sides with `null` as the inverse: ```js // app/models/author.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Author extends Model { @belongsTo('address', { async: true, inverse: null }) address; } // app/models/address.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Address extends Model { @belongsTo('author', { async: true, inverse: null }) owner; } ``` To declare a one-to-none relationship between two models, use `belongsTo` with inverse set to `null` on just one side:: ```js // app/models/person.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Person extends Model { @belongsTo('person', { async: false, inverse: null }) bestFriend; } ``` #### Sync vs Async Relationships EmberData fulfills relationships using resource data available in the cache. Sync relationships point directly to the known related resources. When a relationship is declared as async, if any of the known related resources have not been loaded, they will be fetched. The property on the record when accessed provides a promise that resolves once all resources are loaded. Async relationships may take advantage of links. On access, if the related link has not been loaded, or if any known resources are not available in the cache, the fresh state will be fetched using the link. In contrast to async relationship, accessing a sync relationship will error on access when any of the known related resources have not been loaded. If you are using `links` with sync relationships, you have to use the BelongsTo reference API to fetch or refresh related resources that aren't loaded. For instance, for a `bestFriend` relationship: ```js person.belongsTo('bestFriend').reload(); ``` #### Polymorphic Relationships To declare a polymorphic relationship, use `hasMany` with the `polymorphic` option set to `true`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent; } ``` `'commentable'` here is referred to as the "abstract type" for the polymorphic relationship. Polymorphic relationships with `inverse: null` will accept any type of record as their content. Polymorphic relationships with `inverse` set to a string will only accept records with a matching inverse relationships declaring itself as satisfying the abstract type. Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable' for this relationship. ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments; } ``` Note: every Model that declares an inverse to a polymorphic relationship must declare itself exactly the same. This is because polymorphism is based on structural traits. Polymorphic to polymorphic relationships are supported. Both sides of the relationship must be declared as polymorphic, and the `as` option must be used to declare the abstract type each record satisfies on both sides. ### Type Parameters #### T `T` ### Parameters #### type [`TypeFromInstance`](../../../core-types/record/type-aliases/TypeFromInstance.md)<`Exclude`<`T`, `null`>> (optional) the name of the related resource #### options `RelationshipOptions`<`T`, `boolean`> (optional) a hash of options ### Returns `RelationshipDecorator`<`T`> relationship ## Call Signature ```ts function belongsTo(type, options): RelationshipDecorator; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/belongs-to.ts:282](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/belongs-to.ts#L282) `belongsTo` is used to define One-To-One and One-To-Many, and One-To-None relationships on a [Model](/ember-data/release/classes/Model). `belongsTo` takes a configuration hash as a second parameter, currently supported options are: * `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship. * `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`. * `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic * `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism. ### Examples To declare a **one-to-many** (or many-to-many) relationship, use `belongsTo` in combination with `hasMany`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('post', { async: false, inverse: 'comments' }) post; } // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'post' }) comments; } ``` To declare a **one-to-one** relationship with managed inverses, use `belongsTo` for both sides: ```js // app/models/author.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Author extends Model { @belongsTo('address', { async: true, inverse: 'owner' }) address; } // app/models/address.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Address extends Model { @belongsTo('author', { async: true, inverse: 'address' }) owner; } ``` To declare a **one-to-one** relationship without managed inverses, use `belongsTo` for both sides with `null` as the inverse: ```js // app/models/author.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Author extends Model { @belongsTo('address', { async: true, inverse: null }) address; } // app/models/address.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Address extends Model { @belongsTo('author', { async: true, inverse: null }) owner; } ``` To declare a one-to-none relationship between two models, use `belongsTo` with inverse set to `null` on just one side:: ```js // app/models/person.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Person extends Model { @belongsTo('person', { async: false, inverse: null }) bestFriend; } ``` #### Sync vs Async Relationships EmberData fulfills relationships using resource data available in the cache. Sync relationships point directly to the known related resources. When a relationship is declared as async, if any of the known related resources have not been loaded, they will be fetched. The property on the record when accessed provides a promise that resolves once all resources are loaded. Async relationships may take advantage of links. On access, if the related link has not been loaded, or if any known resources are not available in the cache, the fresh state will be fetched using the link. In contrast to async relationship, accessing a sync relationship will error on access when any of the known related resources have not been loaded. If you are using `links` with sync relationships, you have to use the BelongsTo reference API to fetch or refresh related resources that aren't loaded. For instance, for a `bestFriend` relationship: ```js person.belongsTo('bestFriend').reload(); ``` #### Polymorphic Relationships To declare a polymorphic relationship, use `hasMany` with the `polymorphic` option set to `true`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent; } ``` `'commentable'` here is referred to as the "abstract type" for the polymorphic relationship. Polymorphic relationships with `inverse: null` will accept any type of record as their content. Polymorphic relationships with `inverse` set to a string will only accept records with a matching inverse relationships declaring itself as satisfying the abstract type. Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable' for this relationship. ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments; } ``` Note: every Model that declares an inverse to a polymorphic relationship must declare itself exactly the same. This is because polymorphism is based on structural traits. Polymorphic to polymorphic relationships are supported. Both sides of the relationship must be declared as polymorphic, and the `as` option must be used to declare the abstract type each record satisfies on both sides. ### Parameters #### type `string` (optional) the name of the related resource #### options `RelationshipOptions`<`unknown`, `boolean`> (optional) a hash of options ### Returns `RelationshipDecorator`<`unknown`> relationship --- --- url: /api/@warp-drive/legacy/model/functions/buildSchema.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [model](../index.md) / buildSchema ```ts function buildSchema(store): SchemaService; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/schema-provider.ts:227](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/schema-provider.ts#L227) ## Parameters ### store [`default`](../../../../@ember-data/store/index/classes/default.md) ## Returns [`SchemaService`](../../../core-types/index/interfaces/SchemaService.md) --- --- url: /api/@warp-drive/legacy/model/functions/hasMany.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [model](../index.md) / hasMany ## Call Signature ```ts function hasMany(): never; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/has-many.ts:248](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/has-many.ts#L248) `hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None relationships on a [Model](/ember-data/release/classes/Model). `hasMany` takes a configuration hash as a second parameter, currently supported options are: * `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship. * `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`. * `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic * `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism. ### Examples To declare a **many-to-one** (or one-to-many) relationship, use `belongsTo` in combination with `hasMany`: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'post' }) comments; } // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('post', { async: false, inverse: 'comments' }) post; } ``` To declare a **many-to-many** relationship with managed inverses, use `hasMany` for both sides: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('tag', { async: true, inverse: 'posts' }) tags; } // app/models/tag.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Tag extends Model { @hasMany('post', { async: true, inverse: 'tags' }) posts; } ``` To declare a **many-to-many** relationship without managed inverses, use `hasMany` for both sides with `null` as the inverse: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('tag', { async: true, inverse: null }) tags; } // app/models/tag.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Tag extends Model { @hasMany('post', { async: true, inverse: null }) posts; } ``` To declare a many-to-none relationship between two models, use `hasMany` with inverse set to `null` on just one side:: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('category', { async: true, inverse: null }) categories; } ``` #### Sync vs Async Relationships EmberData fulfills relationships using resource data available in the cache. Sync relationships point directly to the known related resources. When a relationship is declared as async, if any of the known related resources have not been loaded, they will be fetched. The property on the record when accessed provides a promise that resolves once all resources are loaded. Async relationships may take advantage of links. On access, if the related link has not been loaded, or if any known resources are not available in the cache, the fresh state will be fetched using the link. In contrast to async relationship, accessing a sync relationship will error on access when any of the known related resources have not been loaded. If you are using `links` with sync relationships, you have to use the HasMany reference API to fetch or refresh related resources that aren't loaded. For instance, for a `comments` relationship: ```js post.hasMany('comments').reload(); ``` #### Polymorphic Relationships To declare a polymorphic relationship, use `hasMany` with the `polymorphic` option set to `true`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent; } ``` `'commentable'` here is referred to as the "abstract type" for the polymorphic relationship. Polymorphic relationships with `inverse: null` will accept any type of record as their content. Polymorphic relationships with `inverse` set to a string will only accept records with a matching inverse relationships declaring itself as satisfying the abstract type. Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable' for this relationship. ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments; } ``` Note: every Model that declares an inverse to a polymorphic relationship must declare itself exactly the same. This is because polymorphism is based on structural traits. Polymorphic to polymorphic relationships are supported. Both sides of the relationship must be declared as polymorphic, and the `as` option must be used to declare the abstract type each record satisfies on both sides. ### Returns `never` relationship ## Call Signature ```ts function hasMany(type): never; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/has-many.ts:249](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/has-many.ts#L249) `hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None relationships on a [Model](/ember-data/release/classes/Model). `hasMany` takes a configuration hash as a second parameter, currently supported options are: * `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship. * `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`. * `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic * `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism. ### Examples To declare a **many-to-one** (or one-to-many) relationship, use `belongsTo` in combination with `hasMany`: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'post' }) comments; } // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('post', { async: false, inverse: 'comments' }) post; } ``` To declare a **many-to-many** relationship with managed inverses, use `hasMany` for both sides: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('tag', { async: true, inverse: 'posts' }) tags; } // app/models/tag.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Tag extends Model { @hasMany('post', { async: true, inverse: 'tags' }) posts; } ``` To declare a **many-to-many** relationship without managed inverses, use `hasMany` for both sides with `null` as the inverse: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('tag', { async: true, inverse: null }) tags; } // app/models/tag.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Tag extends Model { @hasMany('post', { async: true, inverse: null }) posts; } ``` To declare a many-to-none relationship between two models, use `hasMany` with inverse set to `null` on just one side:: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('category', { async: true, inverse: null }) categories; } ``` #### Sync vs Async Relationships EmberData fulfills relationships using resource data available in the cache. Sync relationships point directly to the known related resources. When a relationship is declared as async, if any of the known related resources have not been loaded, they will be fetched. The property on the record when accessed provides a promise that resolves once all resources are loaded. Async relationships may take advantage of links. On access, if the related link has not been loaded, or if any known resources are not available in the cache, the fresh state will be fetched using the link. In contrast to async relationship, accessing a sync relationship will error on access when any of the known related resources have not been loaded. If you are using `links` with sync relationships, you have to use the HasMany reference API to fetch or refresh related resources that aren't loaded. For instance, for a `comments` relationship: ```js post.hasMany('comments').reload(); ``` #### Polymorphic Relationships To declare a polymorphic relationship, use `hasMany` with the `polymorphic` option set to `true`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent; } ``` `'commentable'` here is referred to as the "abstract type" for the polymorphic relationship. Polymorphic relationships with `inverse: null` will accept any type of record as their content. Polymorphic relationships with `inverse` set to a string will only accept records with a matching inverse relationships declaring itself as satisfying the abstract type. Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable' for this relationship. ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments; } ``` Note: every Model that declares an inverse to a polymorphic relationship must declare itself exactly the same. This is because polymorphism is based on structural traits. Polymorphic to polymorphic relationships are supported. Both sides of the relationship must be declared as polymorphic, and the `as` option must be used to declare the abstract type each record satisfies on both sides. ### Parameters #### type `string` (optional) the name of the related resource ### Returns `never` relationship ## Call Signature ```ts function hasMany(type, options): RelationshipDecorator; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/has-many.ts:250](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/has-many.ts#L250) `hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None relationships on a [Model](/ember-data/release/classes/Model). `hasMany` takes a configuration hash as a second parameter, currently supported options are: * `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship. * `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`. * `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic * `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism. ### Examples To declare a **many-to-one** (or one-to-many) relationship, use `belongsTo` in combination with `hasMany`: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'post' }) comments; } // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('post', { async: false, inverse: 'comments' }) post; } ``` To declare a **many-to-many** relationship with managed inverses, use `hasMany` for both sides: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('tag', { async: true, inverse: 'posts' }) tags; } // app/models/tag.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Tag extends Model { @hasMany('post', { async: true, inverse: 'tags' }) posts; } ``` To declare a **many-to-many** relationship without managed inverses, use `hasMany` for both sides with `null` as the inverse: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('tag', { async: true, inverse: null }) tags; } // app/models/tag.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Tag extends Model { @hasMany('post', { async: true, inverse: null }) posts; } ``` To declare a many-to-none relationship between two models, use `hasMany` with inverse set to `null` on just one side:: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('category', { async: true, inverse: null }) categories; } ``` #### Sync vs Async Relationships EmberData fulfills relationships using resource data available in the cache. Sync relationships point directly to the known related resources. When a relationship is declared as async, if any of the known related resources have not been loaded, they will be fetched. The property on the record when accessed provides a promise that resolves once all resources are loaded. Async relationships may take advantage of links. On access, if the related link has not been loaded, or if any known resources are not available in the cache, the fresh state will be fetched using the link. In contrast to async relationship, accessing a sync relationship will error on access when any of the known related resources have not been loaded. If you are using `links` with sync relationships, you have to use the HasMany reference API to fetch or refresh related resources that aren't loaded. For instance, for a `comments` relationship: ```js post.hasMany('comments').reload(); ``` #### Polymorphic Relationships To declare a polymorphic relationship, use `hasMany` with the `polymorphic` option set to `true`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent; } ``` `'commentable'` here is referred to as the "abstract type" for the polymorphic relationship. Polymorphic relationships with `inverse: null` will accept any type of record as their content. Polymorphic relationships with `inverse` set to a string will only accept records with a matching inverse relationships declaring itself as satisfying the abstract type. Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable' for this relationship. ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments; } ``` Note: every Model that declares an inverse to a polymorphic relationship must declare itself exactly the same. This is because polymorphism is based on structural traits. Polymorphic to polymorphic relationships are supported. Both sides of the relationship must be declared as polymorphic, and the `as` option must be used to declare the abstract type each record satisfies on both sides. ### Type Parameters #### T `T` ### Parameters #### type [`TypeFromInstance`](../../../core-types/record/type-aliases/TypeFromInstance.md)<`NoNull`<`T`>> (optional) the name of the related resource #### options `RelationshipOptions`<`T`, `boolean`> (optional) a hash of options ### Returns `RelationshipDecorator`<`T`> relationship ## Call Signature ```ts function hasMany(type, options): RelationshipDecorator; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/has-many.ts:258](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/has-many.ts#L258) `hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None relationships on a [Model](/ember-data/release/classes/Model). `hasMany` takes a configuration hash as a second parameter, currently supported options are: * `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship. * `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`. * `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic * `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism. ### Examples To declare a **many-to-one** (or one-to-many) relationship, use `belongsTo` in combination with `hasMany`: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'post' }) comments; } // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('post', { async: false, inverse: 'comments' }) post; } ``` To declare a **many-to-many** relationship with managed inverses, use `hasMany` for both sides: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('tag', { async: true, inverse: 'posts' }) tags; } // app/models/tag.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Tag extends Model { @hasMany('post', { async: true, inverse: 'tags' }) posts; } ``` To declare a **many-to-many** relationship without managed inverses, use `hasMany` for both sides with `null` as the inverse: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('tag', { async: true, inverse: null }) tags; } // app/models/tag.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Tag extends Model { @hasMany('post', { async: true, inverse: null }) posts; } ``` To declare a many-to-none relationship between two models, use `hasMany` with inverse set to `null` on just one side:: ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('category', { async: true, inverse: null }) categories; } ``` #### Sync vs Async Relationships EmberData fulfills relationships using resource data available in the cache. Sync relationships point directly to the known related resources. When a relationship is declared as async, if any of the known related resources have not been loaded, they will be fetched. The property on the record when accessed provides a promise that resolves once all resources are loaded. Async relationships may take advantage of links. On access, if the related link has not been loaded, or if any known resources are not available in the cache, the fresh state will be fetched using the link. In contrast to async relationship, accessing a sync relationship will error on access when any of the known related resources have not been loaded. If you are using `links` with sync relationships, you have to use the HasMany reference API to fetch or refresh related resources that aren't loaded. For instance, for a `comments` relationship: ```js post.hasMany('comments').reload(); ``` #### Polymorphic Relationships To declare a polymorphic relationship, use `hasMany` with the `polymorphic` option set to `true`: ```js // app/models/comment.js import { Model, belongsTo } from '@warp-drive/legacy/model'; export default class Comment extends Model { @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent; } ``` `'commentable'` here is referred to as the "abstract type" for the polymorphic relationship. Polymorphic relationships with `inverse: null` will accept any type of record as their content. Polymorphic relationships with `inverse` set to a string will only accept records with a matching inverse relationships declaring itself as satisfying the abstract type. Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable' for this relationship. ```js // app/models/post.js import { Model, hasMany } from '@warp-drive/legacy/model'; export default class Post extends Model { @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments; } ``` Note: every Model that declares an inverse to a polymorphic relationship must declare itself exactly the same. This is because polymorphism is based on structural traits. Polymorphic to polymorphic relationships are supported. Both sides of the relationship must be declared as polymorphic, and the `as` option must be used to declare the abstract type each record satisfies on both sides. ### Parameters #### type `string` (optional) the name of the related resource #### options `RelationshipOptions`<`unknown`, `boolean`> (optional) a hash of options ### Returns `RelationshipDecorator`<`unknown`> relationship --- --- url: /api/@warp-drive/legacy/model/functions/instantiateRecord.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [model](../index.md) / instantiateRecord ```ts function instantiateRecord( this, identifier, createRecordArgs): Model; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/hooks.ts:15](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/hooks.ts#L15) ## Parameters ### this [`default`](../../../../@ember-data/store/index/classes/default.md) ### identifier [`StableRecordIdentifier`](../../../core-types/identifier/type-aliases/StableRecordIdentifier.md) ### createRecordArgs ## Returns [`Model`](../classes/Model.md) --- --- url: /api/@warp-drive/legacy/model/functions/teardownRecord.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [model](../index.md) / teardownRecord ```ts function teardownRecord(record): void; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/hooks.ts:45](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/hooks.ts#L45) ## Parameters ### record [`Model`](../classes/Model.md) ## Returns `void` --- --- url: /api/@warp-drive/legacy/model/functions/modelFor.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [model](../index.md) / modelFor ## Call Signature ```ts function modelFor(type): void | typeof Model; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/hooks.ts:53](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/hooks.ts#L53) ### Type Parameters #### T `T` ### Parameters #### type [`TypeFromInstance`](../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`> ### Returns `void` | *typeof* [`Model`](../classes/Model.md) ## Call Signature ```ts function modelFor(type): void | typeof Model; ``` Defined in: [warp-drive-packages/legacy/src/model/-private/hooks.ts:54](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/-private/hooks.ts#L54) ### Parameters #### type `string` ### Returns `void` | *typeof* [`Model`](../classes/Model.md) --- --- url: /api/@warp-drive/legacy/model.md --- [Documentation](../../../index.md) / [@warp-drive/legacy](../index.md) / model This package provides a Presentation Model for resource data in an WarpDrive Cache. Models are defined as classes extending from `import Model from '@ember-data/model';` and the attributes and relationships on these classes are parsed at runtime to supply static "schema" to WarpDrive's SchemaService. Resource data for individual resources fetched from your API is presented to the UI via instances of the `Model`s you define. An instantiated `Model` is referred to as a `record`. When we refer to the `ModelClass` as opposed to a `Model` or `Record` we are referring specifically to the class definition and the static schema methods present on it. When we refer to a `record` we refer to a specific class instance presenting the resource data for a given `type` and `id`. ### Defining a Model ```js [app/models/person.js] import Model, { attr, belongsTo, hasMany } from '@ember-data/model'; export default class PersonModel extends Model { @attr name; @belongsTo('pet', { inverse: 'owners', async: false }) dog; @hasMany('person', { inverse: 'friends', async: true }) friends; } ``` ### modelName convention By convention, the name of a given model (its `type`) matches the name of the file in the `app/models` folder and should be lowercase, singular and dasherized. ## Classes * [AsyncHasMany](classes/AsyncHasMany.md) * [ManyArray](classes/ManyArray.md) * [Model](classes/Model.md) ## Functions * [attr](functions/attr.md) * [belongsTo](functions/belongsTo.md) * [buildSchema](functions/buildSchema.md) * [hasMany](functions/hasMany.md) * [instantiateRecord](functions/instantiateRecord.md) * [modelFor](functions/modelFor.md) * [teardownRecord](functions/teardownRecord.md) ## References ### default Renames and re-exports [Model](classes/Model.md) *** ### HasMany Renames and re-exports [ManyArray](classes/ManyArray.md) --- --- url: >- /api/@warp-drive/legacy/model/migration-support/classes/DelegatingSchemaService.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [model/migration-support](../index.md) / DelegatingSchemaService Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:437](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L437) The SchemaService provides the ability to query for information about the structure of any resource type. Applications can provide any implementation of the SchemaService they please so long as it conforms to this interface. The design of the service means that schema information could be lazily populated, derived-on-demand, or progressively enhanced during the course of an application's runtime. The primary requirement is merely that any information the service needs to correctly respond to an inquest is available by the time it is asked. The `@ember-data/model` package provides an implementation of this service which makes use of your model classes as the source of information to respond to queries about resource schema. While this is useful, this may not be ideal for your application. For instance, Schema information could be sideloaded or pre-flighted for API calls, resulting in no need to bundle and ship potentially large and expensive JSON or large Javascript based Models to pull information from. To register a custom schema implementation, implement the store's `createSchemaService` hook to return an instance of your service. ```ts import Store from '@ember-data/store'; import CustomSchemas from './custom-schemas'; export default class extends Store { createSchemaService() { return new CustomSchemas(); } } ``` At runtime, both the `Store` and the `CacheCapabilitiesManager` provide access to this service via the `schema` property. ```ts export default class extends Component { @service store; get fields() { return this.store .schema .fields(this.args.dataType); } } ``` (Interface) SchemaService ## Implements * [`SchemaService`](../../../../core-types/index/interfaces/SchemaService.md) ## Constructors ### Constructor ```ts new DelegatingSchemaService(store, schema): DelegatingSchemaService; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:446](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L446) #### Parameters ##### store [`default`](../../../../../@ember-data/store/index/classes/default.md) ##### schema [`SchemaService`](../../../../core-types/index/interfaces/SchemaService.md) #### Returns `DelegatingSchemaService` ## Properties ### \_preferred ```ts _preferred: SchemaService; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:443](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L443) *** ### \_secondary ```ts _secondary: SchemaService; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:444](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L444) ## Methods ### ~~attributesDefinitionFor()?~~ ```ts optional attributesDefinitionFor(resource): AttributesSchema; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:438](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L438) DEPRECATED - use `fields` instead Returns definitions for all properties of the specified resource that are considered "attributes". Generally these are properties that are not related to book-keeping state on the client and do not represent a linkage to another resource. The return value should be a dictionary of key:value pairs where the `key` is the attribute or property's name and `value` is an object with at least the property `name` which should also match `key`. Optionally, this object may also specify `type`, which should be a string reference to a `transform`, and `options` which should be dictionary in which any key:value pairs are permissable. For instance, when using `@ember-data/model`, the following attribute definition: ```ts class extends Model { @attr('string', { defaultValue: 'hello' }) greeting; @attr('date') birthday; @attr firstName; } ``` Would be returned as: ```js { greeting: { name: 'greeting', type: 'string', options: { defaultValue: 'hello' } }, birthday: { name: 'birthday', type: 'date' }, firstName: { name: 'firstName' } } ``` #### Parameters ##### resource [`StableRecordIdentifier`](../../../../core-types/identifier/type-aliases/StableRecordIdentifier.md) | { `type`: `string`; } #### Returns `AttributesSchema` #### Deprecated *** ### derivation() ```ts derivation(field): Derivation; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:486](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L486) Returns the derivation registered with the name provided by `field.type`. Validates that the field is a valid DerivedField. #### Parameters ##### field [`DerivedField`](../../../../core-types/schema/fields/interfaces/DerivedField.md) | { `type`: `string`; } #### Returns [`Derivation`](../../../../core-types/schema/concepts/type-aliases/Derivation.md) *** ### ~~doesTypeExist()?~~ ```ts optional doesTypeExist(type): boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:440](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L440) DEPRECATED - use `hasResource` instead Queries whether the SchemaService recognizes `type` as a resource type #### Parameters ##### type `string` #### Returns `boolean` #### Deprecated *** ### fields() ```ts fields(resource): Map; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:474](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L474) Queries for the fields of a given resource type or resource identity. Should error if the resource type is not recognized. #### Parameters ##### resource [`StableRecordIdentifier`](../../../../core-types/identifier/type-aliases/StableRecordIdentifier.md) | { `type`: `string`; } #### Returns `Map`<`string`, [`FieldSchema`](../../../../core-types/schema/fields/type-aliases/FieldSchema.md)> *** ### hashFn() ```ts hashFn(field): HashFn; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:483](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L483) Returns the hash function registered with the name provided by `field.type`. Validates that the field is a valid HashField. #### Parameters ##### field [`HashField`](../../../../core-types/schema/fields/interfaces/HashField.md) | { `type`: `string`; } #### Returns [`HashFn`](../../../../core-types/schema/concepts/type-aliases/HashFn.md) *** ### hasResource() ```ts hasResource(resource): boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:459](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L459) Queries whether the SchemaService recognizes `type` as a resource type #### Parameters ##### resource [`StableRecordIdentifier`](../../../../core-types/identifier/type-aliases/StableRecordIdentifier.md) | { `type`: `string`; } #### Returns `boolean` *** ### hasTrait() ```ts hasTrait(type): boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:462](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L462) Queries whether the SchemaService recognizes `type` as a resource trait #### Parameters ##### type `string` #### Returns `boolean` *** ### isDelegated() ```ts isDelegated(resource): boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:451](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L451) #### Parameters ##### resource [`StableRecordIdentifier`](../../../../core-types/identifier/type-aliases/StableRecordIdentifier.md) | { `type`: `string`; } #### Returns `boolean` *** ### registerDerivation() ```ts registerDerivation(derivation): void; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:504](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L504) Enables registration of a derivation. The derivation can later be retrieved by the name attached to it's `[Type]` property. #### Type Parameters ##### R `R` ##### T `T` ##### FM `FM` *extends* | `null` | [`ObjectValue`](../../../../core-types/json/raw/interfaces/ObjectValue.md) #### Parameters ##### derivation [`Derivation`](../../../../core-types/schema/concepts/type-aliases/Derivation.md)<`R`, `T`, `FM`> #### Returns `void` *** ### registerHashFn() ```ts registerHashFn(hashFn): void; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:507](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L507) Enables registration of a hashing function The hashing function can later be retrieved by the name attached to it's `[Type]` property. #### Parameters ##### hashFn [`HashFn`](../../../../core-types/schema/concepts/type-aliases/HashFn.md) #### Returns `void` *** ### registerResource() ```ts registerResource(schema): void; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:498](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L498) Enables registration of a single Schema representing either a resource in PolarisMode or LegacyMode or an ObjectSchema representing an embedded structure in other schemas. This can be useful for either pre-loading schema information or for registering schema information delivered by API calls or other sources just-in-time. #### Parameters ##### schema [`ResourceSchema`](../../../../core-types/schema/fields/type-aliases/ResourceSchema.md) | [`ObjectSchema`](../../../../core-types/schema/fields/interfaces/ObjectSchema.md) #### Returns `void` *** ### registerResources() ```ts registerResources(schemas): void; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:495](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L495) Enables registration of multiple Schemas at once. This can be useful for either pre-loading schema information or for registering schema information delivered by API calls or other sources just-in-time. #### Parameters ##### schemas ( | [`ResourceSchema`](../../../../core-types/schema/fields/type-aliases/ResourceSchema.md) | [`ObjectSchema`](../../../../core-types/schema/fields/interfaces/ObjectSchema.md))\[] #### Returns `void` *** ### registerTransformation() ```ts registerTransformation(transform): void; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:501](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L501) Enables registration of a transformation. The transformation can later be retrieved by the name attached to it's `[Type]` property. #### Parameters ##### transform [`Transformation`](../../../../core-types/schema/concepts/type-aliases/Transformation.md) #### Returns `void` *** ### ~~relationshipsDefinitionFor()?~~ ```ts optional relationshipsDefinitionFor(resource): RelationshipsSchema; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:439](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L439) DEPRECATED - use `fields` instead Returns definitions for all properties of the specified resource that are considered "relationships". Generally these are properties that represent a linkage to another resource. The return value should be a dictionary of key:value pairs where the `key` is the relationship or property's name and `value` is an object with at least the following properties: * `name` which should also match the `key` used in the dictionary. * `kind` which should be either `belongsTo` or `hasMany` * `type` which should be the related resource's string "type" * `options` which should be a dictionary allowing any key but with at least the below keys present. * `options.async` a boolean representing whether data for this relationship is typically loaded on-demand. * `options.inverse` a string or null representing the field name / key of the corresponding relationship on the inverse resource. Additionally the following options properties are optional. See [Polymorphic Relationships](https://rfcs.emberjs.com/id/0793-polymporphic-relations-without-inheritance) * `options.polymorphic` a boolean representing whether multiple resource types can be used to satisfy this relationship. * `options.as` a string representing the abstract type that the concrete side of a relationship must specify when fulfilling a polymorphic inverse. For example, the following Model using @ember-data/model would generate this relationships definition by default: ```js class User extends Model { @belongsTo('user', { async: false, inverse: null }) bestFriend; @hasMany('user', { async: true, inverse: 'friends' }) friends; @hasMany('pet', { async: false, polymorphic: true, inverse: 'owner' }) pets; } ``` Which would be returned as ```js { bestFriend: { name: 'bestFriend', kind: 'belongsTo', type: 'user', options: { async: false, inverse: null } }, friends: { name: 'friends', kind: 'hasMany', type: 'user', options: { async: true, inverse: 'friends' } }, pets: { name: 'pets', kind: 'hasMany', type: 'pet', options: { async: false, polymorphic: true, inverse: 'owner' } }, } ``` #### Parameters ##### resource [`StableRecordIdentifier`](../../../../core-types/identifier/type-aliases/StableRecordIdentifier.md) | { `type`: `string`; } #### Returns `RelationshipsSchema` #### Deprecated *** ### resource() ```ts resource(resource): | ResourceSchema | ObjectSchema; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:489](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L489) Returns the schema for the provided resource type. #### Parameters ##### resource [`StableRecordIdentifier`](../../../../core-types/identifier/type-aliases/StableRecordIdentifier.md) | { `type`: `string`; } #### Returns | [`ResourceSchema`](../../../../core-types/schema/fields/type-aliases/ResourceSchema.md) | [`ObjectSchema`](../../../../core-types/schema/fields/interfaces/ObjectSchema.md) *** ### resourceHasTrait() ```ts resourceHasTrait(resource, trait): boolean; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:468](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L468) Queries whether the given resource has the given trait #### Parameters ##### resource [`StableRecordIdentifier`](../../../../core-types/identifier/type-aliases/StableRecordIdentifier.md) | { `type`: `string`; } ##### trait `string` #### Returns `boolean` *** ### resourceTypes() ```ts resourceTypes(): readonly string[]; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:455](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L455) Returns all known resource types #### Returns readonly `string`\[] *** ### transformation() ```ts transformation(field): Transformation; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:480](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L480) Returns the transformation registered with the name provided by `field.type`. Validates that the field is a valid transformable. #### Parameters ##### field [`GenericField`](../../../../core-types/schema/fields/interfaces/GenericField.md) | [`ObjectField`](../../../../core-types/schema/fields/interfaces/ObjectField.md) | [`ArrayField`](../../../../core-types/schema/fields/interfaces/ArrayField.md) | { `type`: `string`; } #### Returns [`Transformation`](../../../../core-types/schema/concepts/type-aliases/Transformation.md) --- --- url: >- /api/@warp-drive/legacy/model/migration-support/functions/registerDerivations.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [model/migration-support](../index.md) / registerDerivations ```ts function registerDerivations(schema): void; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:356](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L356) A function which registers the necessary derivations to support the LegacyMode features of @ember-data/model while migrating to WarpDrive. This must be called in order to use the fields added by: ```ts import { withDefaults } from '@ember-data/model/migration-support'; ``` ## Parameters ### schema [`SchemaService`](../../../../core-types/index/interfaces/SchemaService.md) The schema service to register the derivations with. ## Returns `void` --- --- url: /api/@warp-drive/legacy/model/migration-support/functions/withDefaults.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [model/migration-support](../index.md) / withDefaults ```ts function withDefaults(schema): LegacyResourceSchema; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:310](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L310) A function which adds the necessary fields to a schema and marks it as being in LegacyMode. This is used to support the legacy features of @ember-data/model while migrating to WarpDrive. Example: ```ts import { withDefaults, WithLegacy } from '@ember-data/model/migration-support'; import { Type } from '@warp-drive/core-types/symbols'; import type { HasMany } from '@ember-data/model'; export const UserSchema = withDefaults({ type: 'user', fields: [ { name: 'firstName', kind: 'attribute' }, { name: 'lastName', kind: 'attribute' }, { name: 'age', kind: 'attribute' }, { name: 'friends', kind: 'hasMany', type: 'user', options: { inverse: 'friends', async: false } }, { name: 'bestFriend', kind: 'belongsTo', type: 'user', options: { inverse: null, async: false } }, ], }); export type User = WithLegacy<{ firstName: string; lastName: string; age: number; friends: HasMany; bestFriend: User | null; [Type]: 'user'; }> ``` Using this function require registering the derivations it requires with the schema service. ```ts import { registerDerivations } from '@ember-data/model/migration-support'; registerDerivations(schema); ``` ## Parameters ### schema [`WithPartial`](../../../../core-types/utils/type-aliases/WithPartial.md)<[`LegacyResourceSchema`](../../../../core-types/schema/fields/interfaces/LegacyResourceSchema.md), `"identity"` | `"legacy"`> The schema to add legacy support to. ## Returns [`LegacyResourceSchema`](../../../../core-types/schema/fields/interfaces/LegacyResourceSchema.md) The schema with legacy support added. --- --- url: /api/@warp-drive/legacy/model/migration-support.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / model/migration-support This module provides support for migrating away from @ember-data/model to @warp-drive/schema-record. It includes: * A `withDefaults` function to assist in creating a schema in LegacyMode * A `registerDerivations` function to register the derivations necessary to support LegacyMode * A `DelegatingSchemaService` that can be used to provide a schema service that works with both @ember-data/model and @warp-drive/schema-record simultaneously for migration purposes. * A `WithLegacy` type util that can be used to create a type that includes the legacy properties and methods of a record. Using LegacyMode features on a SchemaRecord *requires* the use of these derivations and schema additions. LegacyMode is not intended to be a long-term solution, but rather a stepping stone to assist in more rapidly adopting modern WarpDrive features. ## Classes * [DelegatingSchemaService](classes/DelegatingSchemaService.md) ## Type Aliases * [WithLegacy](type-aliases/WithLegacy.md) * [WithLegacyDerivations](type-aliases/WithLegacyDerivations.md) ## Functions * [registerDerivations](functions/registerDerivations.md) * [withDefaults](functions/withDefaults.md) --- --- url: /api/@warp-drive/legacy/model/migration-support/type-aliases/WithLegacy.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [model/migration-support](../index.md) / WithLegacy ```ts type WithLegacy = T & LegacyModeRecord; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:182](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L182) A Type utility that enables quickly adding type information for the fields defined by `import { withDefaults } from '@ember-data/model/migration-support'`. Example: ```ts import { withDefaults, WithLegacy } from '@ember-data/model/migration-support'; import { Type } from '@warp-drive/core-types/symbols'; import type { HasMany } from '@ember-data/model'; export const UserSchema = withDefaults({ type: 'user', fields: [ { name: 'firstName', kind: 'attribute' }, { name: 'lastName', kind: 'attribute' }, { name: 'age', kind: 'attribute' }, { name: 'friends', kind: 'hasMany', type: 'user', options: { inverse: 'friends', async: false } }, { name: 'bestFriend', kind: 'belongsTo', type: 'user', options: { inverse: null, async: false } }, ], }); export type User = WithLegacy<{ firstName: string; lastName: string; age: number; friends: HasMany; bestFriend: User | null; [Type]: 'user'; }> ``` ## Type Parameters ### T `T` *extends* [`TypedRecordInstance`](../../../../core-types/record/interfaces/TypedRecordInstance.md) --- --- url: >- /api/@warp-drive/legacy/model/migration-support/type-aliases/WithLegacyDerivations.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [model/migration-support](../index.md) / WithLegacyDerivations ```ts type WithLegacyDerivations = T & MinimalLegacyRecord & object; ``` Defined in: [warp-drive-packages/legacy/src/model/migration-support.ts:70](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/model/migration-support.ts#L70) ## Type declaration ### belongsTo ```ts belongsTo: typeof belongsTo; ``` ### hasMany ```ts hasMany: typeof hasMany; ``` ## Type Parameters ### T `T` *extends* [`TypedRecordInstance`](../../../../core-types/record/interfaces/TypedRecordInstance.md) --- --- url: /api/@warp-drive/legacy/serializer/classes/Serializer.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / [serializer](../index.md) / Serializer Defined in: [warp-drive-packages/legacy/src/serializer.ts:140](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer.ts#L140) > ⚠️ CAUTION you likely want the docs for MinimumSerializerInterface > as extending this abstract class is unnecessary. `Serializer` is an abstract base class that you may override in your application to customize it for your backend. The minimum set of methods that you should implement is: * `normalizeResponse()` * `serialize()` And you can optionally override the following methods: * `normalize()` For an example implementation, see [JSONSerializer](JSONSerializer), the included JSON serializer. Serializer ## Extends * `EmberObject` ## Constructors ### Constructor ```ts new Serializer(owner?): Serializer; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/index.d.ts:31 #### Parameters ##### owner? `Owner` #### Returns `Serializer` #### Inherited from ```ts EmberObject.constructor ``` ## Properties ### concatenatedProperties? ```ts optional concatenatedProperties: string | string[]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:655 #### Inherited from ```ts EmberObject.concatenatedProperties ``` *** ### mergedProperties? ```ts optional mergedProperties: unknown[]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:656 #### Inherited from ```ts EmberObject.mergedProperties ``` *** ### store ```ts store: default; ``` Defined in: [warp-drive-packages/legacy/src/serializer.ts:141](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer.ts#L141) *** ### \_lazyInjections()? ```ts readonly static optional _lazyInjections: () => void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:654 #### Returns `void` #### Inherited from ```ts EmberObject._lazyInjections ``` *** ### \_onLookup()? ```ts readonly static optional _onLookup: (debugContainerKey) => void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:653 #### Parameters ##### debugContainerKey `string` #### Returns `void` #### Inherited from ```ts EmberObject._onLookup ``` *** ### \[INIT\_FACTORY]? ```ts static optional [INIT_FACTORY]: null; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/mixin.d.ts:116 #### Inherited from ```ts EmberObject.[INIT_FACTORY] ``` *** ### isClass ```ts readonly static isClass: boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:651 #### Inherited from ```ts EmberObject.isClass ``` *** ### isMethod ```ts readonly static isMethod: boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:652 #### Inherited from ```ts EmberObject.isMethod ``` *** ### PrototypeMixin ```ts static PrototypeMixin: any; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:647 #### Inherited from ```ts EmberObject.PrototypeMixin ``` *** ### superclass ```ts static superclass: any; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:648 #### Inherited from ```ts EmberObject.superclass ``` ## Accessors ### \_debugContainerKey #### Get Signature ```ts get _debugContainerKey(): false | `${string}:${string}`; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/index.d.ts:34 ##### Returns `false` | `` `${string}:${string}` `` #### Inherited from ```ts EmberObject._debugContainerKey ``` *** ### isDestroyed #### Get Signature ```ts get isDestroyed(): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:272 Destroyed object property flag. if this property is `true` the observers and bindings were already removed by the effect of calling the `destroy()` method. ##### Default ```ts false @public ``` ##### Returns `boolean` #### Set Signature ```ts set isDestroyed(_value): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:273 ##### Parameters ###### \_value `boolean` ##### Returns `void` #### Inherited from ```ts EmberObject.isDestroyed ``` *** ### isDestroying #### Get Signature ```ts get isDestroying(): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:284 Destruction scheduled flag. The `destroy()` method has been called. The object stays intact until the end of the run loop at which point the `isDestroyed` flag is set. ##### Default ```ts false @public ``` ##### Returns `boolean` #### Set Signature ```ts set isDestroying(_value): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:285 ##### Parameters ###### \_value `boolean` ##### Returns `void` #### Inherited from ```ts EmberObject.isDestroying ``` ## Methods ### addObserver() #### Call Signature ```ts addObserver( key, target, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:333 Adds an observer on a property. This is the core method used to register an observer for a property. Once you call this method, any time the key's value is set, your observer will be notified. Note that the observers are triggered any time the value is set, regardless of whether it has actually changed. Your observer should be prepared to handle that. There are two common invocation patterns for `.addObserver()`: * Passing two arguments: * the name of the property to observe (as a string) * the function to invoke (an actual function) * Passing three arguments: * the name of the property to observe (as a string) * the target object (will be used to look up and invoke a function on) * the name of the function to invoke on the target object (as a string). ```app/components/my-component.js import Component from '@ember/component'; export default Component.extend({ init() { this._super(...arguments); // the following are equivalent: // using three arguments this.addObserver('foo', this, 'fooDidChange'); // using two arguments this.addObserver('foo', (...args) => { this.fooDidChange(...args); }); }, fooDidChange() { // your custom logic code } }); ``` ### Observer Methods Observer methods have the following signature: ```app/components/my-component.js import Component from '@ember/component'; export default Component.extend({ init() { this._super(...arguments); this.addObserver('foo', this, 'fooDidChange'); }, fooDidChange(sender, key, value, rev) { // your code } }); ``` The `sender` is the object that changed. The `key` is the property that changes. The `value` property is currently reserved and unused. The `rev` is the last property revision of the object when it changed, which you can use to detect if the key value has really changed or not. Usually you will not need the value or revision parameters at the end. In this case, it is common to write observer methods that take only a sender and key value as parameters or, if you aren't interested in any of these values, to write an observer that has no parameters at all. ##### Type Parameters ###### Target `Target` ##### Parameters ###### key keyof `Serializer` The key to observe ###### target `Target` The target object to invoke ###### method `ObserverMethod`<`Target`, `Serializer`> The method to invoke ##### Returns `this` ##### Method addObserver ##### Inherited from ```ts EmberObject.addObserver ``` #### Call Signature ```ts addObserver(key, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:338 ##### Parameters ###### key keyof `Serializer` ###### method `ObserverMethod`<`Serializer`, `Serializer`> ##### Returns `this` ##### Inherited from ```ts EmberObject.addObserver ``` *** ### cacheFor() ```ts cacheFor(key): unknown; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:413 Returns the cached value of a computed property, if it exists. This allows you to inspect the value of a computed property without accidentally invoking it if it is intended to be generated lazily. #### Type Parameters ##### K `K` *extends* keyof `Serializer` #### Parameters ##### key `K` #### Returns `unknown` The cached value of the computed property, if any #### Method cacheFor #### Inherited from ```ts EmberObject.cacheFor ``` *** ### decrementProperty() ```ts decrementProperty(keyName, decrement?): number; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:387 Set the value of a property to the current value minus some amount. ```javascript player.decrementProperty('lives'); orc.decrementProperty('health', 5); ``` #### Parameters ##### keyName keyof `Serializer` The name of the property to decrement ##### decrement? `number` The amount to decrement by. Defaults to 1 #### Returns `number` The new property value #### Method decrementProperty #### Inherited from ```ts EmberObject.decrementProperty ``` *** ### destroy() ```ts destroy(): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:300 Destroys an object by setting the `isDestroyed` flag and removing its metadata, which effectively destroys observers and bindings. If you try to set a property on a destroyed object, an exception will be raised. Note that destruction is scheduled for the end of the run loop and does not happen immediately. It will set an isDestroying flag immediately. #### Returns `this` receiver #### Method destroy #### Inherited from ```ts EmberObject.destroy ``` *** ### get() #### Call Signature ```ts get(key): Serializer[K]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:121 Retrieves the value of a property from the object. This method is usually similar to using `object[keyName]` or `object.keyName`, however it supports both computed properties and the unknownProperty handler. Because `get` unifies the syntax for accessing all these kinds of properties, it can make many refactorings easier, such as replacing a simple property with a computed property, or vice versa. ### Computed Properties Computed properties are methods defined with the `property` modifier declared at the end, such as: ```javascript import { computed } from '@ember/object'; fullName: computed('firstName', 'lastName', function() { return this.get('firstName') + ' ' + this.get('lastName'); }) ``` When you call `get` on a computed property, the function will be called and the return value will be returned instead of the function itself. ### Unknown Properties Likewise, if you try to call `get` on a property whose value is `undefined`, the `unknownProperty()` method will be called on the object. If this method returns any value other than `undefined`, it will be returned instead. This allows you to implement "virtual" properties that are not defined upfront. ##### Type Parameters ###### K `K` *extends* keyof `Serializer` ##### Parameters ###### key `K` ##### Returns `Serializer`\[`K`] The property value or undefined. ##### Method get ##### Inherited from ```ts EmberObject.get ``` #### Call Signature ```ts get(key): unknown; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:122 ##### Parameters ###### key `string` ##### Returns `unknown` ##### Inherited from ```ts EmberObject.get ``` *** ### getProperties() #### Call Signature ```ts getProperties(list): { [Key in keyof Serializer]: Serializer[Key] }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:144 To get the values of multiple properties at once, call `getProperties` with a list of strings or an array: ```javascript record.getProperties('firstName', 'lastName', 'zipCode'); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } ``` is equivalent to: ```javascript record.getProperties(['firstName', 'lastName', 'zipCode']); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } ``` ##### Type Parameters ###### L `L` *extends* keyof `Serializer`\[] ##### Parameters ###### list `L` of keys to get ##### Returns `{ [Key in keyof Serializer]: Serializer[Key] }` ##### Method getProperties ##### Inherited from ```ts EmberObject.getProperties ``` #### Call Signature ```ts getProperties(...list): { [Key in keyof Serializer]: Serializer[Key] }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:149 ##### Type Parameters ###### L `L` *extends* keyof `Serializer`\[] ##### Parameters ###### list ...`L` ##### Returns `{ [Key in keyof Serializer]: Serializer[Key] }` ##### Inherited from ```ts EmberObject.getProperties ``` #### Call Signature ```ts getProperties(list): { [Key in string]: unknown }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:154 ##### Type Parameters ###### L `L` *extends* `string`\[] ##### Parameters ###### list `L` ##### Returns `{ [Key in string]: unknown }` ##### Inherited from ```ts EmberObject.getProperties ``` #### Call Signature ```ts getProperties(...list): { [Key in string]: unknown }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:159 ##### Type Parameters ###### L `L` *extends* `string`\[] ##### Parameters ###### list ...`L` ##### Returns `{ [Key in string]: unknown }` ##### Inherited from ```ts EmberObject.getProperties ``` *** ### incrementProperty() ```ts incrementProperty(keyName, increment?): number; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:372 Set the value of a property to the current value plus some amount. ```javascript person.incrementProperty('age'); team.incrementProperty('score', 2); ``` #### Parameters ##### keyName keyof `Serializer` The name of the property to increment ##### increment? `number` The amount to increment by. Defaults to 1 #### Returns `number` The new property value #### Method incrementProperty #### Inherited from ```ts EmberObject.incrementProperty ``` *** ### init() ```ts init(_properties): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:114 An overridable method called when objects are instantiated. By default, does nothing unless it is overridden during class definition. Example: ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ init() { alert(`Name is ${this.get('name')}`); } }); let steve = Person.create({ name: 'Steve' }); // alerts 'Name is Steve'. ``` NOTE: If you do override `init` for a framework class like `Component` from `@ember/component`, be sure to call `this._super(...arguments)` in your `init` declaration! If you don't, Ember may not have an opportunity to do important setup work, and you'll see strange behavior in your application. #### Parameters ##### \_properties `undefined` | `object` #### Returns `void` #### Method init #### Inherited from ```ts EmberObject.init ``` *** ### normalize() ```ts normalize(_typeClass, hash): | EmptyResourceDocument | SingleResourceDocument; ``` Defined in: [warp-drive-packages/legacy/src/serializer.ts:266](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer.ts#L266) The `normalize` method is used to convert a payload received from your external data source into the normalized form `store.push()` expects. You should override this method, munge the hash and return the normalized payload. Example: ```js Serializer.extend({ normalize(modelClass, resourceHash) { let data = { id: resourceHash.id, type: modelClass.modelName, attributes: resourceHash }; return { data: data }; } }) ``` #### Parameters ##### \_typeClass [`ModelSchema`](../../../core-types/index/interfaces/ModelSchema.md) ##### hash `Record`<`string`, `unknown`> #### Returns | [`EmptyResourceDocument`](../../../core-types/spec/json-api-raw/type-aliases/EmptyResourceDocument.md) | [`SingleResourceDocument`](../../../core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md) *** ### notifyPropertyChange() ```ts notifyPropertyChange(keyName): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:249 Convenience method to call `propertyWillChange` and `propertyDidChange` in succession. Notify the observer system that a property has just changed. Sometimes you need to change a value directly or indirectly without actually calling `get()` or `set()` on it. In this case, you can use this method instead. Calling this method will notify all observers that the property has potentially changed value. #### Parameters ##### keyName `string` The property key to be notified about. #### Returns `this` #### Method notifyPropertyChange #### Inherited from ```ts EmberObject.notifyPropertyChange ``` *** ### removeObserver() #### Call Signature ```ts removeObserver( key, target, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:352 Remove an observer you have previously registered on this object. Pass the same key, target, and method you passed to `addObserver()` and your target will no longer receive notifications. ##### Type Parameters ###### Target `Target` ##### Parameters ###### key keyof `Serializer` The key to observe ###### target `Target` The target object to invoke ###### method `ObserverMethod`<`Target`, `Serializer`> The method to invoke ##### Returns `this` ##### Method removeObserver ##### Inherited from ```ts EmberObject.removeObserver ``` #### Call Signature ```ts removeObserver(key, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:357 ##### Parameters ###### key keyof `Serializer` ###### method `ObserverMethod`<`Serializer`, `Serializer`> ##### Returns `this` ##### Inherited from ```ts EmberObject.removeObserver ``` *** ### reopen() ```ts reopen(...args): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:81 #### Parameters ##### args ...(`Record`<`string`, `unknown`> | `Mixin`)\[] #### Returns `this` #### Inherited from ```ts EmberObject.reopen ``` *** ### set() #### Call Signature ```ts set(key, value): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:208 Sets the provided key or path to the value. ```javascript record.set("key", value); ``` This method is generally very similar to calling `object["key"] = value` or `object.key = value`, except that it provides support for computed properties, the `setUnknownProperty()` method and property observers. ### Computed Properties If you try to set a value on a key that has a computed property handler defined (see the `get()` method for an example), then `set()` will call that method, passing both the value and key instead of simply changing the value itself. This is useful for those times when you need to implement a property that is composed of one or more member properties. ### Unknown Properties If you try to set a value on a key that is undefined in the target object, then the `setUnknownProperty()` handler will be called instead. This gives you an opportunity to implement complex "virtual" properties that are not predefined on the object. If `setUnknownProperty()` returns undefined, then `set()` will simply set the value on the object. ### Property Observers In addition to changing the property, `set()` will also register a property change with the object. Unless you have placed this call inside of a `beginPropertyChanges()` and `endPropertyChanges(),` any "local" observers (i.e. observer methods declared on the same object), will be called immediately. Any "remote" observers (i.e. observer methods declared on another object) will be placed in a queue and called at a later time in a coalesced manner. ##### Type Parameters ###### K `K` *extends* keyof `Serializer` ###### T `T` *extends* | `undefined` | `string` | `boolean` | `unknown`\[] | [`default`](../../../../@ember-data/store/index/classes/default.md) | `string`\[] | `Owner` | () => `string` | { } | () => `void` | (`_typeClass`, `hash`) => | [`EmptyResourceDocument`](../../../core-types/spec/json-api-raw/type-aliases/EmptyResourceDocument.md) | [`SingleResourceDocument`](../../../core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md) | (...`args`) => `this` | (`_properties`) => `void` | () => `this` | { <`K`> (`key`): `Serializer`\[`K`]; (`key`): `unknown`; } | { <`L`> (`list`): `{ [Key in keyof Serializer]: Serializer[Key] }`; <`L`> (...`list`): `{ [Key in keyof Serializer]: Serializer[Key] }`; <`L`> (`list`): `{ [Key in string]: unknown }`; <`L`> (...`list`): `{ [Key in string]: unknown }`; } | { <`K`, `T`> (`key`, `value`): `T`; <`T`> (`key`, `value`): `T`; } | { <`K`, `P`> (`hash`): `P`; <`T`> (`hash`): `T`; } | (`keyName`) => `this` | { <`Target`> (`key`, `target`, `method`): `this`; (`key`, `method`): `this`; } | { <`Target`> (`key`, `target`, `method`): `this`; (`key`, `method`): `this`; } | (`keyName`, `increment?`) => `number` | (`keyName`, `decrement?`) => `number` | (`keyName`) => `boolean` | <`K`>(`key`) => `unknown` ##### Parameters ###### key `K` ###### value `T` The value to set or `null`. ##### Returns `T` The passed value ##### Method set ##### Inherited from ```ts EmberObject.set ``` #### Call Signature ```ts set(key, value): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:209 ##### Type Parameters ###### T `T` ##### Parameters ###### key `string` ###### value `T` ##### Returns `T` ##### Inherited from ```ts EmberObject.set ``` *** ### setProperties() #### Call Signature ```ts setProperties(hash): P; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:224 Sets a list of properties at once. These properties are set inside a single `beginPropertyChanges` and `endPropertyChanges` batch, so observers will be buffered. ```javascript record.setProperties({ firstName: 'Charles', lastName: 'Jolley' }); ``` ##### Type Parameters ###### K `K` *extends* keyof `Serializer` ###### P `P` *extends* `{ [Key in keyof Serializer]: Serializer[Key] }` ##### Parameters ###### hash `P` the hash of keys and values to set ##### Returns `P` The passed in hash ##### Method setProperties ##### Inherited from ```ts EmberObject.setProperties ``` #### Call Signature ```ts setProperties(hash): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:232 ##### Type Parameters ###### T `T` *extends* `Record`<`string`, `unknown`> ##### Parameters ###### hash `T` ##### Returns `T` ##### Inherited from ```ts EmberObject.setProperties ``` *** ### toggleProperty() ```ts toggleProperty(keyName): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:401 Set the value of a boolean property to the opposite of its current value. ```javascript starship.toggleProperty('warpDriveEngaged'); ``` #### Parameters ##### keyName keyof `Serializer` The name of the property to toggle #### Returns `boolean` The new property value #### Method toggleProperty #### Inherited from ```ts EmberObject.toggleProperty ``` *** ### toString() ```ts toString(): string; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:347 Returns a string representation which attempts to provide more information than Javascript's `toString` typically does, in a generic way for all Ember objects. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend(); person = Person.create(); person.toString(); //=> "" ``` If the object's class is not defined on an Ember namespace, it will indicate it is a subclass of the registered superclass: ```javascript const Student = Person.extend(); let student = Student.create(); student.toString(); //=> "<(subclass of Person):ember1025>" ``` If the method `toStringExtension` is defined, its return value will be included in the output. ```javascript const Teacher = Person.extend({ toStringExtension() { return this.get('fullName'); } }); teacher = Teacher.create(); teacher.toString(); //=> "" ``` #### Returns `string` string representation #### Method toString #### Inherited from ```ts EmberObject.toString ``` *** ### willDestroy() ```ts willDestroy(): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:307 Override to implement teardown. #### Returns `void` #### Method willDestroy #### Inherited from ```ts EmberObject.willDestroy ``` *** ### create() #### Call Signature ```ts readonly static create(this): InstanceType; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:487 Creates an instance of a class. Accepts either no arguments, or an object containing values to initialize the newly instantiated object with. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ helloWorld() { alert(`Hi, my name is ${this.get('name')}`); } }); let tom = Person.create({ name: 'Tom Dale' }); tom.helloWorld(); // alerts "Hi, my name is Tom Dale". ``` `create` will call the `init` function if defined during `AnyObject.extend` If no arguments are passed to `create`, it will not set values to the new instance during initialization: ```javascript let noName = Person.create(); noName.helloWorld(); // alerts undefined ``` NOTE: For performance reasons, you cannot declare methods or computed properties during `create`. You should instead declare methods and computed properties when using `extend`. ##### Type Parameters ###### C `C` *extends* *typeof* `CoreObject` ##### Parameters ###### this `C` ##### Returns `InstanceType`<`C`> ##### Method create ##### For @ember/object ##### Static ##### Inherited from ```ts EmberObject.create ``` #### Call Signature ```ts readonly static create(this, ...args): InstanceType & MergeArray; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:488 Creates an instance of a class. Accepts either no arguments, or an object containing values to initialize the newly instantiated object with. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ helloWorld() { alert(`Hi, my name is ${this.get('name')}`); } }); let tom = Person.create({ name: 'Tom Dale' }); tom.helloWorld(); // alerts "Hi, my name is Tom Dale". ``` `create` will call the `init` function if defined during `AnyObject.extend` If no arguments are passed to `create`, it will not set values to the new instance during initialization: ```javascript let noName = Person.create(); noName.helloWorld(); // alerts undefined ``` NOTE: For performance reasons, you cannot declare methods or computed properties during `create`. You should instead declare methods and computed properties when using `extend`. ##### Type Parameters ###### C `C` *extends* *typeof* `CoreObject` ###### I `I` *extends* `CoreObject` ###### K `K` *extends* `string` | `number` | `symbol` ###### Args `Args` *extends* `Partial`<{ \[Key in string | number | symbol]: I\[Key] }>\[] ##### Parameters ###### this `C` ###### args ...`Args` ##### Returns `InstanceType`<`C`> & `MergeArray`<`Args`> ##### Method create ##### For @ember/object ##### Static ##### Inherited from ```ts EmberObject.create ``` *** ### detectInstance() ```ts readonly static detectInstance(obj): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:600 #### Parameters ##### obj `unknown` #### Returns `boolean` #### Inherited from ```ts EmberObject.detectInstance ``` *** ### extend() ```ts readonly static extend(this, ...mixins?): Readonly & EmberClassConstructor & MergeArray; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:442 Creates a new subclass. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ say(thing) { alert(thing); } }); ``` This defines a new subclass of EmberObject: `Person`. It contains one method: `say()`. You can also create a subclass from any existing class by calling its `extend()` method. For example, you might want to create a subclass of Ember's built-in `Component` class: ```javascript import Component from '@ember/component'; const PersonComponent = Component.extend({ tagName: 'li', classNameBindings: ['isAdministrator'] }); ``` When defining a subclass, you can override methods but still access the implementation of your parent class by calling the special `_super()` method: ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ say(thing) { let name = this.get('name'); alert(`${name} says: ${thing}`); } }); const Soldier = Person.extend({ say(thing) { this._super(`${thing}, sir!`); }, march(numberOfHours) { alert(`${this.get('name')} marches for ${numberOfHours} hours.`); } }); let yehuda = Soldier.create({ name: 'Yehuda Katz' }); yehuda.say('Yes'); // alerts "Yehuda Katz says: Yes, sir!" ``` The `create()` on line #17 creates an *instance* of the `Soldier` class. The `extend()` on line #8 creates a *subclass* of `Person`. Any instance of the `Person` class will *not* have the `march()` method. You can also pass `Mixin` classes to add additional properties to the subclass. ```javascript import EmberObject from '@ember/object'; import Mixin from '@ember/object/mixin'; const Person = EmberObject.extend({ say(thing) { alert(`${this.get('name')} says: ${thing}`); } }); const SingingMixin = Mixin.create({ sing(thing) { alert(`${this.get('name')} sings: la la la ${thing}`); } }); const BroadwayStar = Person.extend(SingingMixin, { dance() { alert(`${this.get('name')} dances: tap tap tap tap `); } }); ``` The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. #### Type Parameters ##### Statics `Statics` ##### Instance `Instance` ##### M `M` *extends* `unknown`\[] #### Parameters ##### this `Statics` & `EmberClassConstructor`<`Instance`> ##### mixins? ...`M` One or more Mixin classes #### Returns `Readonly`<`Statics`> & `EmberClassConstructor`<`Instance`> & `MergeArray`<`M`> #### Method extend #### Static #### For @ember/object #### Inherited from ```ts EmberObject.extend ``` *** ### proto() ```ts readonly static proto(): CoreObject; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:649 #### Returns `CoreObject` #### Inherited from ```ts EmberObject.proto ``` *** ### reopenClass() ```ts readonly static reopenClass(this, ...mixins): C; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:595 Augments a constructor's own properties and functions: ```javascript import EmberObject from '@ember/object'; const MyObject = EmberObject.extend({ name: 'an object' }); MyObject.reopenClass({ canBuild: false }); MyObject.canBuild; // false o = MyObject.create(); ``` In other words, this creates static properties and functions for the class. These are only available on the class and not on any instance of that class. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ name: '', sayHello() { alert(`Hello. My name is ${this.get('name')}`); } }); Person.reopenClass({ species: 'Homo sapiens', createPerson(name) { return Person.create({ name }); } }); let tom = Person.create({ name: 'Tom Dale' }); let yehuda = Person.createPerson('Yehuda Katz'); tom.sayHello(); // "Hello. My name is Tom Dale" yehuda.sayHello(); // "Hello. My name is Yehuda Katz" alert(Person.species); // "Homo sapiens" ``` Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` variables. They are only valid on `Person`. To add functions and properties to instances of a constructor by extending the constructor's prototype see `reopen` #### Type Parameters ##### C `C` *extends* *typeof* `CoreObject` #### Parameters ##### this `C` ##### mixins ...(`Record`<`string`, `unknown`> | `Mixin`)\[] #### Returns `C` #### Method reopenClass #### For @ember/object #### Static #### Inherited from ```ts EmberObject.reopenClass ``` *** ### toString() ```ts static toString(): string; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:650 #### Returns `string` #### Inherited from ```ts EmberObject.toString ``` *** ### willReopen() ```ts readonly static willReopen(): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:533 #### Returns `void` #### Inherited from ```ts EmberObject.willReopen ``` --- --- url: /api/@warp-drive/legacy/serializer.md --- [Documentation](../../../index.md) / [@warp-drive/legacy](../index.md) / serializer ## Overview In order to properly manage and present your data, WarpDrive needs to understand the structure of data it receives. `Serializers` convert data between the server's API format and the format WarpDrive understands. Data received from an API response is **normalized** into [JSON:API](https://jsonapi.org/) (the format used internally by WarpDrive), while data sent to an API is **serialized** into the format the API expects. ### Implementing a Serializer There are only two required serializer methods, one for normalizing data from the server API format into JSON:API, and another for serializing records via `Snapshots` into the expected server API format. To implement a serializer, export a class that conforms to the structure described by MinimumSerializerInterface from the `app/serializers/` directory. An example is below. ```ts import EmberObject from '@ember/object'; export default class ApplicationSerializer extends EmberObject { normalizeResponse(store, schema, rawPayload) { return rawPayload; } serialize(snapshot, options) { const serializedResource = { id: snapshot.id, type: snapshot.modelName, attributes: snapshot.attributes() }; return serializedResource; } } ``` ### Serializer Resolution `store.serializerFor(name)` will lookup serializers defined in `app/serializers/` and return an instance. If no serializer is found, an error will be thrown. `serializerFor` first attempts to find a serializer with an exact match on `name`, then falls back to checking for the presence of a serializer named `application`. ```ts store.serializerFor('author'); // lookup paths (in order) => // app/serializers/author.js // app/serializers/application.js ``` Most requests in @warp-drive/legacy are made with respect to a particular `type` (or `modelName`) (e.g., "get me the full collection of **books**" or "get me the **employee** whose id is 37"). We refer to this as the **primary** resource `type`. Typically `serializerFor` will be used to find a serializer with a name matching that of the primary resource `type` for the request, falling back to the `application` serializer for those types that do not have a defined serializer. This is often described as a `per-model` or `per-type` strategy for defining serializers. However, because APIs rarely format payloads per-type but rather per-API-version, this may not be a desired strategy. It is recommended that applications define only a single `application` adapter and serializer where possible. If you have multiple API formats and the per-type strategy is not viable, one strategy is to write an `application` adapter and serializer that make use of `options` to specify the desired format when making a request. ### Using a Serializer Any serializer in `app/serializers/` can be looked up by `name` using `store.serializerFor(name)`. ### Default Serializers For applications whose APIs are *very close to* or *exactly* the **REST** format or **JSON:API** format the `@ember-data/serializer` package contains implementations these applications can extend. It also contains a simple `JSONSerializer` for serializing to/from very basic JSON objects. Many applications will find writing their own serializer to be more performant and less complex than extending these classes even when their API format is very close to that expected by these serializers. It is recommended that apps write their own serializer to best suit the needs of their API and application. ## Classes * [Serializer](classes/Serializer.md) --- --- url: /api/@warp-drive/legacy/serializer/json-api/classes/JSONAPISerializer.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [serializer/json-api](../index.md) / JSONAPISerializer Defined in: [warp-drive-packages/legacy/src/serializer/json-api.js:132](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json-api.js#L132) In EmberData a Serializer is used to serialize and deserialize records when they are transferred in and out of an external source. This process involves normalizing property names, transforming attribute values and serializing relationships. `JSONAPISerializer` supports the http://jsonapi.org/ spec and is the serializer recommended by Ember Data. This serializer normalizes a JSON API payload that looks like: ```js [app/models/player.js] import Model, { attr, belongsTo } from '@ember-data/model'; export default class Player extends Model { @attr('string') name; @attr('string') skill; @attr('number') gamesPlayed; @belongsTo('club') club; } ``` ```js [app/models/club.js] import Model, { attr, hasMany } from '@ember-data/model'; export default class Club extends Model { @attr('string') name; @attr('string') location; @hasMany('player') players; } ``` ```js { "data": [ { "attributes": { "name": "Benfica", "location": "Portugal" }, "id": "1", "relationships": { "players": { "data": [ { "id": "3", "type": "players" } ] } }, "type": "clubs" } ], "included": [ { "attributes": { "name": "Eusebio Silva Ferreira", "skill": "Rocket shot", "games-played": 431 }, "id": "3", "relationships": { "club": { "data": { "id": "1", "type": "clubs" } } }, "type": "players" } ] } ``` to the format that the Ember Data store expects. ### Customizing meta Since a JSON API Document can have meta defined in multiple locations you can use the specific serializer hooks if you need to customize the meta. One scenario would be to camelCase the meta keys of your payload. The example below shows how this could be done using `normalizeArrayResponse` and `extractRelationship`. ```js [app/serializers/application.js] import JSONAPISerializer from '@ember-data/serializer/json-api'; export default class ApplicationSerializer extends JSONAPISerializer { normalizeArrayResponse(store, primaryModelClass, payload, id, requestType) { let normalizedDocument = super.normalizeArrayResponse(...arguments); // Customize document meta normalizedDocument.meta = camelCaseKeys(normalizedDocument.meta); return normalizedDocument; } extractRelationship(relationshipHash) { let normalizedRelationship = super.extractRelationship(...arguments); // Customize relationship meta normalizedRelationship.meta = camelCaseKeys(normalizedRelationship.meta); return normalizedRelationship; } } ``` ## Since 1.13.0 JSONAPISerializer ## Constructors ### Constructor ```ts new JSONAPISerializer(owner?): JSONAPISerializer; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:8 #### Parameters ##### owner? `Owner` #### Returns `JSONAPISerializer` ## Properties ### concatenatedProperties? ```ts optional concatenatedProperties: string | string[]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:655 *** ### mergedProperties? ```ts optional mergedProperties: unknown[]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:656 *** ### store ```ts store: default; ``` Defined in: [warp-drive-packages/legacy/src/serializer.ts:141](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer.ts#L141) *** ### \_lazyInjections()? ```ts readonly static optional _lazyInjections: () => void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:654 #### Returns `void` *** ### \_onLookup()? ```ts readonly static optional _onLookup: (debugContainerKey) => void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:653 #### Parameters ##### debugContainerKey `string` #### Returns `void` *** ### \[INIT\_FACTORY]? ```ts readonly static optional [INIT_FACTORY]: null; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/mixin.d.ts:116 *** ### isClass ```ts readonly static isClass: boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:651 *** ### isMethod ```ts readonly static isMethod: boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:652 *** ### mergedProperties ```ts readonly static mergedProperties: any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:182](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L182) The `attrs` object can be used to declare a simple mapping between property names on `Model` records and payload keys in the serialized JSON object representing the record. An object with the property `key` can also be used to designate the attribute's key on the response payload. Example ```js [app/models/person.js] import Model, { attr } from '@ember-data/model'; export default class PersonModel extends Model { @attr('string') firstName; @attr('string') lastName; @attr('string') occupation; @attr('boolean') admin; } ``` ```js [app/serializers/person.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PersonSerializer extends JSONSerializer { attrs = { admin: 'is_admin', occupation: { key: 'career' } } } ``` You can also remove attributes and relationships by setting the `serialize` key to `false` in your mapping object. Example ```js [app/serializers/person.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { attrs = { admin: { serialize: false }, occupation: { key: 'career' } } } ``` When serialized: ```javascript { "firstName": "Harry", "lastName": "Houdini", "career": "magician" } ``` Note that the `admin` is now not included in the payload. Setting `serialize` to `true` enforces serialization for hasMany relationships even if it's neither a many-to-many nor many-to-none relationship. *** ### primaryKey ```ts readonly static primaryKey: string = 'id'; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:113](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L113) The `primaryKey` is used when serializing and deserializing data. Ember Data always uses the `id` property to store the id of the record. The external source may not always follow this convention. In these cases it is useful to override the `primaryKey` property to match the `primaryKey` of your external store. Example ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class ApplicationSerializer extends JSONSerializer { primaryKey = '_id' } ``` #### Default ```ts 'id' ``` *** ### PrototypeMixin ```ts static PrototypeMixin: any; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:647 *** ### superclass ```ts static superclass: any; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:648 ## Accessors ### \_debugContainerKey #### Get Signature ```ts get _debugContainerKey(): false | `${string}:${string}`; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/index.d.ts:34 ##### Returns `false` | `` `${string}:${string}` `` *** ### isDestroyed #### Get Signature ```ts get isDestroyed(): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:272 Destroyed object property flag. if this property is `true` the observers and bindings were already removed by the effect of calling the `destroy()` method. ##### Default ```ts false @public ``` ##### Returns `boolean` #### Set Signature ```ts set isDestroyed(_value): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:273 ##### Parameters ###### \_value `boolean` ##### Returns `void` *** ### isDestroying #### Get Signature ```ts get isDestroying(): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:284 Destruction scheduled flag. The `destroy()` method has been called. The object stays intact until the end of the run loop at which point the `isDestroyed` flag is set. ##### Default ```ts false @public ``` ##### Returns `boolean` #### Set Signature ```ts set isDestroying(_value): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:285 ##### Parameters ###### \_value `boolean` ##### Returns `void` ## Methods ### addObserver() #### Call Signature ```ts addObserver( key, target, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:333 Adds an observer on a property. This is the core method used to register an observer for a property. Once you call this method, any time the key's value is set, your observer will be notified. Note that the observers are triggered any time the value is set, regardless of whether it has actually changed. Your observer should be prepared to handle that. There are two common invocation patterns for `.addObserver()`: * Passing two arguments: * the name of the property to observe (as a string) * the function to invoke (an actual function) * Passing three arguments: * the name of the property to observe (as a string) * the target object (will be used to look up and invoke a function on) * the name of the function to invoke on the target object (as a string). ```app/components/my-component.js import Component from '@ember/component'; export default Component.extend({ init() { this._super(...arguments); // the following are equivalent: // using three arguments this.addObserver('foo', this, 'fooDidChange'); // using two arguments this.addObserver('foo', (...args) => { this.fooDidChange(...args); }); }, fooDidChange() { // your custom logic code } }); ``` ### Observer Methods Observer methods have the following signature: ```app/components/my-component.js import Component from '@ember/component'; export default Component.extend({ init() { this._super(...arguments); this.addObserver('foo', this, 'fooDidChange'); }, fooDidChange(sender, key, value, rev) { // your code } }); ``` The `sender` is the object that changed. The `key` is the property that changes. The `value` property is currently reserved and unused. The `rev` is the last property revision of the object when it changed, which you can use to detect if the key value has really changed or not. Usually you will not need the value or revision parameters at the end. In this case, it is common to write observer methods that take only a sender and key value as parameters or, if you aren't interested in any of these values, to write an observer that has no parameters at all. ##### Type Parameters ###### Target `Target` ##### Parameters ###### key keyof [`Serializer`](../../classes/Serializer.md) The key to observe ###### target `Target` The target object to invoke ###### method `ObserverMethod`<`Target`, [`Serializer`](../../classes/Serializer.md)> The method to invoke ##### Returns `this` ##### Method addObserver #### Call Signature ```ts addObserver(key, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:338 ##### Parameters ###### key keyof [`Serializer`](../../classes/Serializer.md) ###### method `ObserverMethod`<[`Serializer`](../../classes/Serializer.md), [`Serializer`](../../classes/Serializer.md)> ##### Returns `this` *** ### cacheFor() ```ts cacheFor(key): unknown; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:413 Returns the cached value of a computed property, if it exists. This allows you to inspect the value of a computed property without accidentally invoking it if it is intended to be generated lazily. #### Type Parameters ##### K `K` *extends* keyof [`Serializer`](../../classes/Serializer.md) #### Parameters ##### key `K` #### Returns `unknown` The cached value of the computed property, if any #### Method cacheFor *** ### decrementProperty() ```ts decrementProperty(keyName, decrement?): number; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:387 Set the value of a property to the current value minus some amount. ```javascript player.decrementProperty('lives'); orc.decrementProperty('health', 5); ``` #### Parameters ##### keyName keyof [`Serializer`](../../classes/Serializer.md) The name of the property to decrement ##### decrement? `number` The amount to decrement by. Defaults to 1 #### Returns `number` The new property value #### Method decrementProperty *** ### destroy() ```ts destroy(): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:300 Destroys an object by setting the `isDestroyed` flag and removing its metadata, which effectively destroys observers and bindings. If you try to set a property on a destroyed object, an exception will be raised. Note that destruction is scheduled for the end of the run loop and does not happen immediately. It will set an isDestroying flag immediately. #### Returns `this` receiver #### Method destroy *** ### get() #### Call Signature ```ts get(key): Serializer[K]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:121 Retrieves the value of a property from the object. This method is usually similar to using `object[keyName]` or `object.keyName`, however it supports both computed properties and the unknownProperty handler. Because `get` unifies the syntax for accessing all these kinds of properties, it can make many refactorings easier, such as replacing a simple property with a computed property, or vice versa. ### Computed Properties Computed properties are methods defined with the `property` modifier declared at the end, such as: ```javascript import { computed } from '@ember/object'; fullName: computed('firstName', 'lastName', function() { return this.get('firstName') + ' ' + this.get('lastName'); }) ``` When you call `get` on a computed property, the function will be called and the return value will be returned instead of the function itself. ### Unknown Properties Likewise, if you try to call `get` on a property whose value is `undefined`, the `unknownProperty()` method will be called on the object. If this method returns any value other than `undefined`, it will be returned instead. This allows you to implement "virtual" properties that are not defined upfront. ##### Type Parameters ###### K `K` *extends* keyof [`Serializer`](../../classes/Serializer.md) ##### Parameters ###### key `K` ##### Returns [`Serializer`](../../classes/Serializer.md)\[`K`] The property value or undefined. ##### Method get #### Call Signature ```ts get(key): unknown; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:122 ##### Parameters ###### key `string` ##### Returns `unknown` *** ### getProperties() #### Call Signature ```ts getProperties(list): { [Key in keyof Serializer]: Serializer[Key] }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:144 To get the values of multiple properties at once, call `getProperties` with a list of strings or an array: ```javascript record.getProperties('firstName', 'lastName', 'zipCode'); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } ``` is equivalent to: ```javascript record.getProperties(['firstName', 'lastName', 'zipCode']); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } ``` ##### Type Parameters ###### L `L` *extends* keyof [`Serializer`](../../classes/Serializer.md)\[] ##### Parameters ###### list `L` of keys to get ##### Returns `{ [Key in keyof Serializer]: Serializer[Key] }` ##### Method getProperties #### Call Signature ```ts getProperties(...list): { [Key in keyof Serializer]: Serializer[Key] }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:149 ##### Type Parameters ###### L `L` *extends* keyof [`Serializer`](../../classes/Serializer.md)\[] ##### Parameters ###### list ...`L` ##### Returns `{ [Key in keyof Serializer]: Serializer[Key] }` #### Call Signature ```ts getProperties(list): { [Key in string]: unknown }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:154 ##### Type Parameters ###### L `L` *extends* `string`\[] ##### Parameters ###### list `L` ##### Returns `{ [Key in string]: unknown }` #### Call Signature ```ts getProperties(...list): { [Key in string]: unknown }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:159 ##### Type Parameters ###### L `L` *extends* `string`\[] ##### Parameters ###### list ...`L` ##### Returns `{ [Key in string]: unknown }` *** ### incrementProperty() ```ts incrementProperty(keyName, increment?): number; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:372 Set the value of a property to the current value plus some amount. ```javascript person.incrementProperty('age'); team.incrementProperty('score', 2); ``` #### Parameters ##### keyName keyof [`Serializer`](../../classes/Serializer.md) The name of the property to increment ##### increment? `number` The amount to increment by. Defaults to 1 #### Returns `number` The new property value #### Method incrementProperty *** ### init() ```ts init(_properties): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:114 An overridable method called when objects are instantiated. By default, does nothing unless it is overridden during class definition. Example: ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ init() { alert(`Name is ${this.get('name')}`); } }); let steve = Person.create({ name: 'Steve' }); // alerts 'Name is Steve'. ``` NOTE: If you do override `init` for a framework class like `Component` from `@ember/component`, be sure to call `this._super(...arguments)` in your `init` declaration! If you don't, Ember may not have an opportunity to do important setup work, and you'll see strange behavior in your application. #### Parameters ##### \_properties `undefined` | `object` #### Returns `void` #### Method init *** ### normalize() ```ts normalize(_typeClass, hash): | EmptyResourceDocument | SingleResourceDocument; ``` Defined in: [warp-drive-packages/legacy/src/serializer.ts:266](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer.ts#L266) The `normalize` method is used to convert a payload received from your external data source into the normalized form `store.push()` expects. You should override this method, munge the hash and return the normalized payload. Example: ```js Serializer.extend({ normalize(modelClass, resourceHash) { let data = { id: resourceHash.id, type: modelClass.modelName, attributes: resourceHash }; return { data: data }; } }) ``` #### Parameters ##### \_typeClass [`ModelSchema`](../../../../core-types/index/interfaces/ModelSchema.md) ##### hash `Record`<`string`, `unknown`> #### Returns | [`EmptyResourceDocument`](../../../../core-types/spec/json-api-raw/type-aliases/EmptyResourceDocument.md) | [`SingleResourceDocument`](../../../../core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md) *** ### notifyPropertyChange() ```ts notifyPropertyChange(keyName): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:249 Convenience method to call `propertyWillChange` and `propertyDidChange` in succession. Notify the observer system that a property has just changed. Sometimes you need to change a value directly or indirectly without actually calling `get()` or `set()` on it. In this case, you can use this method instead. Calling this method will notify all observers that the property has potentially changed value. #### Parameters ##### keyName `string` The property key to be notified about. #### Returns `this` #### Method notifyPropertyChange *** ### removeObserver() #### Call Signature ```ts removeObserver( key, target, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:352 Remove an observer you have previously registered on this object. Pass the same key, target, and method you passed to `addObserver()` and your target will no longer receive notifications. ##### Type Parameters ###### Target `Target` ##### Parameters ###### key keyof [`Serializer`](../../classes/Serializer.md) The key to observe ###### target `Target` The target object to invoke ###### method `ObserverMethod`<`Target`, [`Serializer`](../../classes/Serializer.md)> The method to invoke ##### Returns `this` ##### Method removeObserver #### Call Signature ```ts removeObserver(key, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:357 ##### Parameters ###### key keyof [`Serializer`](../../classes/Serializer.md) ###### method `ObserverMethod`<[`Serializer`](../../classes/Serializer.md), [`Serializer`](../../classes/Serializer.md)> ##### Returns `this` *** ### reopen() ```ts reopen(...args): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:81 #### Parameters ##### args ...(`Record`<`string`, `unknown`> | `Mixin`)\[] #### Returns `this` *** ### set() #### Call Signature ```ts set(key, value): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:208 Sets the provided key or path to the value. ```javascript record.set("key", value); ``` This method is generally very similar to calling `object["key"] = value` or `object.key = value`, except that it provides support for computed properties, the `setUnknownProperty()` method and property observers. ### Computed Properties If you try to set a value on a key that has a computed property handler defined (see the `get()` method for an example), then `set()` will call that method, passing both the value and key instead of simply changing the value itself. This is useful for those times when you need to implement a property that is composed of one or more member properties. ### Unknown Properties If you try to set a value on a key that is undefined in the target object, then the `setUnknownProperty()` handler will be called instead. This gives you an opportunity to implement complex "virtual" properties that are not predefined on the object. If `setUnknownProperty()` returns undefined, then `set()` will simply set the value on the object. ### Property Observers In addition to changing the property, `set()` will also register a property change with the object. Unless you have placed this call inside of a `beginPropertyChanges()` and `endPropertyChanges(),` any "local" observers (i.e. observer methods declared on the same object), will be called immediately. Any "remote" observers (i.e. observer methods declared on another object) will be placed in a queue and called at a later time in a coalesced manner. ##### Type Parameters ###### K `K` *extends* keyof [`Serializer`](../../classes/Serializer.md) ###### T `T` *extends* | `undefined` | `string` | `boolean` | `unknown`\[] | [`default`](../../../../../@ember-data/store/index/classes/default.md) | `string`\[] | `Owner` | () => `string` | { } | () => `void` | (`_typeClass`, `hash`) => | [`EmptyResourceDocument`](../../../../core-types/spec/json-api-raw/type-aliases/EmptyResourceDocument.md) | [`SingleResourceDocument`](../../../../core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md) | (...`args`) => `this` | (`_properties`) => `void` | () => `this` | { <`K`> (`key`): [`Serializer`](../../classes/Serializer.md)\[`K`]; (`key`): `unknown`; } | { <`L`> (`list`): `{ [Key in keyof Serializer]: Serializer[Key] }`; <`L`> (...`list`): `{ [Key in keyof Serializer]: Serializer[Key] }`; <`L`> (`list`): `{ [Key in string]: unknown }`; <`L`> (...`list`): `{ [Key in string]: unknown }`; } | { <`K`, `T`> (`key`, `value`): `T`; <`T`> (`key`, `value`): `T`; } | { <`K`, `P`> (`hash`): `P`; <`T`> (`hash`): `T`; } | (`keyName`) => `this` | { <`Target`> (`key`, `target`, `method`): `this`; (`key`, `method`): `this`; } | { <`Target`> (`key`, `target`, `method`): `this`; (`key`, `method`): `this`; } | (`keyName`, `increment?`) => `number` | (`keyName`, `decrement?`) => `number` | (`keyName`) => `boolean` | <`K`>(`key`) => `unknown` ##### Parameters ###### key `K` ###### value `T` The value to set or `null`. ##### Returns `T` The passed value ##### Method set #### Call Signature ```ts set(key, value): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:209 ##### Type Parameters ###### T `T` ##### Parameters ###### key `string` ###### value `T` ##### Returns `T` *** ### setProperties() #### Call Signature ```ts setProperties(hash): P; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:224 Sets a list of properties at once. These properties are set inside a single `beginPropertyChanges` and `endPropertyChanges` batch, so observers will be buffered. ```javascript record.setProperties({ firstName: 'Charles', lastName: 'Jolley' }); ``` ##### Type Parameters ###### K `K` *extends* keyof [`Serializer`](../../classes/Serializer.md) ###### P `P` *extends* `{ [Key in keyof Serializer]: Serializer[Key] }` ##### Parameters ###### hash `P` the hash of keys and values to set ##### Returns `P` The passed in hash ##### Method setProperties #### Call Signature ```ts setProperties(hash): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:232 ##### Type Parameters ###### T `T` *extends* `Record`<`string`, `unknown`> ##### Parameters ###### hash `T` ##### Returns `T` *** ### toggleProperty() ```ts toggleProperty(keyName): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:401 Set the value of a boolean property to the opposite of its current value. ```javascript starship.toggleProperty('warpDriveEngaged'); ``` #### Parameters ##### keyName keyof [`Serializer`](../../classes/Serializer.md) The name of the property to toggle #### Returns `boolean` The new property value #### Method toggleProperty *** ### toString() ```ts toString(): string; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:347 Returns a string representation which attempts to provide more information than Javascript's `toString` typically does, in a generic way for all Ember objects. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend(); person = Person.create(); person.toString(); //=> "" ``` If the object's class is not defined on an Ember namespace, it will indicate it is a subclass of the registered superclass: ```javascript const Student = Person.extend(); let student = Student.create(); student.toString(); //=> "<(subclass of Person):ember1025>" ``` If the method `toStringExtension` is defined, its return value will be included in the output. ```javascript const Teacher = Person.extend({ toStringExtension() { return this.get('fullName'); } }); teacher = Teacher.create(); teacher.toString(); //=> "" ``` #### Returns `string` string representation #### Method toString *** ### willDestroy() ```ts willDestroy(): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:307 Override to implement teardown. #### Returns `void` #### Method willDestroy *** ### create() #### Call Signature ```ts readonly static create(this): InstanceType; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:487 Creates an instance of a class. Accepts either no arguments, or an object containing values to initialize the newly instantiated object with. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ helloWorld() { alert(`Hi, my name is ${this.get('name')}`); } }); let tom = Person.create({ name: 'Tom Dale' }); tom.helloWorld(); // alerts "Hi, my name is Tom Dale". ``` `create` will call the `init` function if defined during `AnyObject.extend` If no arguments are passed to `create`, it will not set values to the new instance during initialization: ```javascript let noName = Person.create(); noName.helloWorld(); // alerts undefined ``` NOTE: For performance reasons, you cannot declare methods or computed properties during `create`. You should instead declare methods and computed properties when using `extend`. ##### Type Parameters ###### C `C` *extends* *typeof* `CoreObject` ##### Parameters ###### this `C` ##### Returns `InstanceType`<`C`> ##### Method create ##### For @ember/object ##### Static #### Call Signature ```ts readonly static create(this, ...args): InstanceType & MergeArray; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:488 Creates an instance of a class. Accepts either no arguments, or an object containing values to initialize the newly instantiated object with. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ helloWorld() { alert(`Hi, my name is ${this.get('name')}`); } }); let tom = Person.create({ name: 'Tom Dale' }); tom.helloWorld(); // alerts "Hi, my name is Tom Dale". ``` `create` will call the `init` function if defined during `AnyObject.extend` If no arguments are passed to `create`, it will not set values to the new instance during initialization: ```javascript let noName = Person.create(); noName.helloWorld(); // alerts undefined ``` NOTE: For performance reasons, you cannot declare methods or computed properties during `create`. You should instead declare methods and computed properties when using `extend`. ##### Type Parameters ###### C `C` *extends* *typeof* `CoreObject` ###### I `I` *extends* `CoreObject` ###### K `K` *extends* `string` | `number` | `symbol` ###### Args `Args` *extends* `Partial`<{ \[Key in string | number | symbol]: I\[Key] }>\[] ##### Parameters ###### this `C` ###### args ...`Args` ##### Returns `InstanceType`<`C`> & `MergeArray`<`Args`> ##### Method create ##### For @ember/object ##### Static *** ### detectInstance() ```ts readonly static detectInstance(obj): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:600 #### Parameters ##### obj `unknown` #### Returns `boolean` *** ### extend() ```ts readonly static extend(this, ...mixins?): Readonly & EmberClassConstructor & MergeArray; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:442 Creates a new subclass. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ say(thing) { alert(thing); } }); ``` This defines a new subclass of EmberObject: `Person`. It contains one method: `say()`. You can also create a subclass from any existing class by calling its `extend()` method. For example, you might want to create a subclass of Ember's built-in `Component` class: ```javascript import Component from '@ember/component'; const PersonComponent = Component.extend({ tagName: 'li', classNameBindings: ['isAdministrator'] }); ``` When defining a subclass, you can override methods but still access the implementation of your parent class by calling the special `_super()` method: ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ say(thing) { let name = this.get('name'); alert(`${name} says: ${thing}`); } }); const Soldier = Person.extend({ say(thing) { this._super(`${thing}, sir!`); }, march(numberOfHours) { alert(`${this.get('name')} marches for ${numberOfHours} hours.`); } }); let yehuda = Soldier.create({ name: 'Yehuda Katz' }); yehuda.say('Yes'); // alerts "Yehuda Katz says: Yes, sir!" ``` The `create()` on line #17 creates an *instance* of the `Soldier` class. The `extend()` on line #8 creates a *subclass* of `Person`. Any instance of the `Person` class will *not* have the `march()` method. You can also pass `Mixin` classes to add additional properties to the subclass. ```javascript import EmberObject from '@ember/object'; import Mixin from '@ember/object/mixin'; const Person = EmberObject.extend({ say(thing) { alert(`${this.get('name')} says: ${thing}`); } }); const SingingMixin = Mixin.create({ sing(thing) { alert(`${this.get('name')} sings: la la la ${thing}`); } }); const BroadwayStar = Person.extend(SingingMixin, { dance() { alert(`${this.get('name')} dances: tap tap tap tap `); } }); ``` The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. #### Type Parameters ##### Statics `Statics` ##### Instance `Instance` ##### M `M` *extends* `unknown`\[] #### Parameters ##### this `Statics` & `EmberClassConstructor`<`Instance`> ##### mixins? ...`M` One or more Mixin classes #### Returns `Readonly`<`Statics`> & `EmberClassConstructor`<`Instance`> & `MergeArray`<`M`> #### Method extend #### Static #### For @ember/object *** ### extractAttributes() Returns the resource's attributes formatted as a JSON-API "attributes object". http://jsonapi.org/format/#document-resource-object-attributes #### Param #### Param #### Call Signature ```ts static extractAttributes(modelClass, resourceHash): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:632](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L632) ##### Parameters ###### modelClass `any` ###### resourceHash `any` ##### Returns `any` #### Call Signature ```ts static extractAttributes(modelClass, resourceHash): object; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json-api.js:243](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json-api.js#L243) ##### Parameters ###### modelClass `any` ###### resourceHash `any` ##### Returns `object` *** ### extractErrors() ```ts readonly static extractErrors( store, typeClass, payload, id): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1436](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1436) `extractErrors` is used to extract model errors when a call to `Model#save` fails with an `InvalidError`. By default Ember Data expects error information to be located on the `errors` property of the payload object. This serializer expects this `errors` object to be an Array similar to the following, compliant with the https://jsonapi.org/format/#errors specification: ```js { "errors": [ { "detail": "This username is already taken!", "source": { "pointer": "data/attributes/username" } }, { "detail": "Doesn't look like a valid email.", "source": { "pointer": "data/attributes/email" } } ] } ``` The key `detail` provides a textual description of the problem. Alternatively, the key `title` can be used for the same purpose. The nested keys `source.pointer` detail which specific element of the request data was invalid. Note that JSON-API also allows for object-level errors to be placed in an object with pointer `data`, signifying that the problem cannot be traced to a specific attribute: ```javascript { "errors": [ { "detail": "Some generic non property error message", "source": { "pointer": "data" } } ] } ``` When turn into a `Errors` object, you can read these errors through the property `base`: ```handlebars {{#each @model.errors.base as |error|}}
{{error.message}}
{{/each}} ``` Example of alternative implementation, overriding the default behavior to deal with a different format of errors: ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { extractErrors(store, typeClass, payload, id) { if (payload && typeof payload === 'object' && payload._problems) { payload = payload._problems; this.normalizeErrors(typeClass, payload); } return payload; } } ``` #### Parameters ##### store `Store` ##### typeClass `Model` ##### payload `any` ##### id `string` | `number` #### Returns `any` json The deserialized errors *** ### extractId() ```ts readonly static extractId(modelClass, resourceHash): string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:616](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L616) Returns the resource's ID. #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `string` *** ### extractMeta() ```ts readonly static extractMeta( store, modelClass, payload): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1343](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1343) `extractMeta` is used to deserialize any meta information in the adapter payload. By default Ember Data expects meta information to be located on the `meta` property of the payload object. Example ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { extractMeta(store, typeClass, payload) { if (payload && payload.hasOwnProperty('_pagination')) { let meta = payload._pagination; delete payload._pagination; return meta; } } } ``` #### Parameters ##### store `Store` ##### modelClass `Model` ##### payload `any` #### Returns `any` *** ### extractPolymorphicRelationship() ```ts readonly static extractPolymorphicRelationship( relationshipModelName, relationshipHash, relationshipOptions): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:699](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L699) Returns a polymorphic relationship formatted as a JSON-API "relationship object". http://jsonapi.org/format/#document-resource-object-relationships `relationshipOptions` is a hash which contains more information about the polymorphic relationship which should be extracted: * `resourceHash` complete hash of the resource the relationship should be extracted from * `relationshipKey` key under which the value for the relationship is extracted from the resourceHash * `relationshipMeta` meta information about the relationship #### Parameters ##### relationshipModelName `any` ##### relationshipHash `any` ##### relationshipOptions `any` #### Returns `any` *** ### extractRelationship() Returns a relationship formatted as a JSON-API "relationship object". http://jsonapi.org/format/#document-resource-object-relationships #### Param #### Param #### Call Signature ```ts static extractRelationship(relationshipModelName, relationshipHash): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:656](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L656) ##### Parameters ###### relationshipModelName `any` ###### relationshipHash `any` ##### Returns `any` #### Call Signature ```ts static extractRelationship(relationshipHash): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json-api.js:275](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json-api.js#L275) Returns a relationship formatted as a JSON-API "relationship object". http://jsonapi.org/format/#document-resource-object-relationships ##### Parameters ###### relationshipHash `any` ##### Returns `any` ##### Param ##### Param *** ### extractRelationships() ```ts static extractRelationships(modelClass, resourceHash): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:713](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L713) Returns the resource's relationships formatted as a JSON-API "relationships object". http://jsonapi.org/format/#document-resource-object-relationships #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `any` *** ### keyForAttribute() ```ts static keyForAttribute(key, method): string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1507](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1507) `keyForAttribute` can be used to define rules for how to convert an attribute name in your model to a key in your JSON. Example ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; import { underscore } from '/utils/string-utils'; export default class ApplicationSerializer extends JSONSerializer { keyForAttribute(attr, method) { return underscore(attr).toUpperCase(); } } ``` #### Parameters ##### key `string` ##### method `string` #### Returns `string` normalized key *** ### keyForLink() ```ts readonly static keyForLink(key, kind): string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1548](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1548) `keyForLink` can be used to define a custom key when deserializing link properties. #### Parameters ##### key `string` ##### kind `string` `belongsTo` or `hasMany` #### Returns `string` normalized key *** ### keyForRelationship() ```ts static keyForRelationship( key, typeClass, method): string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1535](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1535) `keyForRelationship` can be used to define a custom key when serializing and deserializing relationship properties. By default `JSONSerializer` does not provide an implementation of this method. Example ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; import { underscore } from '/utils/string-utils'; export default class PostSerializer extends JSONSerializer { keyForRelationship(key, relationship, method) { return `rel_${underscore(key)}`; } } ``` #### Parameters ##### key `string` ##### typeClass `string` ##### method `string` #### Returns `string` normalized key *** ### modelNameFromPayloadKey() ```ts static modelNameFromPayloadKey(key): string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:781](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L781) Dasherizes the model name in the payload #### Parameters ##### key `string` #### Returns `string` the model's modelName *** ### normalize() Normalizes a part of the JSON payload returned by the server. You should override this method, munge the hash and call super if you have generic normalization to do. It takes the type of the record that is being normalized (as a Model class), the property where the hash was originally found, and the hash to normalize. You can use this method, for example, to normalize underscored keys to camelized or other general-purpose normalizations. Example ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; import { underscore } from '/utils/string-utils'; import { get } from '@ember/object'; export default class ApplicationSerializer extends JSONSerializer { normalize(typeClass, hash) { let fields = typeClass.fields; fields.forEach(function(type, field) { let payloadField = underscore(field); if (field === payloadField) { return; } hash[field] = hash[payloadField]; delete hash[payloadField]; }); return super.normalize(...arguments); } } ``` #### Param #### Param #### Call Signature ```ts static normalize(modelClass, resourceHash): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:582](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L582) ##### Parameters ###### modelClass `any` ###### resourceHash `any` ##### Returns `any` #### Call Signature ```ts static normalize(modelClass, resourceHash): object; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json-api.js:368](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json-api.js#L368) ##### Parameters ###### modelClass `any` ###### resourceHash `any` ##### Returns `object` ###### data ```ts data: object; ``` ###### data.attributes ```ts data.attributes: object; ``` ###### data.id ```ts data.id: any; ``` ###### data.relationships ```ts data.relationships: any; ``` ###### data.type ```ts data.type: string; ``` *** ### normalizeArrayResponse() ```ts readonly static normalizeArrayResponse( store, primaryModelClass, payload, id, requestType): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:489](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L489) normalizeQueryResponse, normalizeFindManyResponse, and normalizeFindHasManyResponse delegate to this method by default. #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeCreateRecordResponse() ```ts readonly static normalizeCreateRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:404](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L404) Called by the default normalizeResponse implementation when the type of request is `createRecord` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeDeleteRecordResponse() ```ts readonly static normalizeDeleteRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:421](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L421) Called by the default normalizeResponse implementation when the type of request is `deleteRecord` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindAllResponse() ```ts readonly static normalizeFindAllResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:319](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L319) Called by the default normalizeResponse implementation when the type of request is `findAll` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindBelongsToResponse() ```ts readonly static normalizeFindBelongsToResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:336](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L336) Called by the default normalizeResponse implementation when the type of request is `findBelongsTo` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindHasManyResponse() ```ts readonly static normalizeFindHasManyResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:353](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L353) Called by the default normalizeResponse implementation when the type of request is `findHasMany` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindManyResponse() ```ts readonly static normalizeFindManyResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:370](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L370) Called by the default normalizeResponse implementation when the type of request is `findMany` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindRecordResponse() ```ts readonly static normalizeFindRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:285](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L285) Called by the default normalizeResponse implementation when the type of request is `findRecord` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeQueryRecordResponse() Called by the default normalizeResponse implementation when the type of request is `queryRecord` #### Since 1.13.0 #### Param #### Param #### Param #### Param #### Param #### Call Signature ```ts static normalizeQueryRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:302](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L302) ##### Parameters ###### store `Store` ###### primaryModelClass `Model` ###### payload `any` ###### id `string` | `number` ###### requestType `string` ###### args ...`any` ##### Returns `any` #### Call Signature ```ts static normalizeQueryRecordResponse(...args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json-api.js:232](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json-api.js#L232) ##### Parameters ###### args ...`any` ##### Returns `any` *** ### normalizeQueryResponse() ```ts readonly static normalizeQueryResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:387](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L387) Called by the default normalizeResponse implementation when the type of request is `query` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeResponse() ```ts readonly static normalizeResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:247](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L247) The `normalizeResponse` method is used to normalize a payload from the server to a JSON-API Document. http://jsonapi.org/format/#document-structure This method delegates to a more specific normalize method based on the `requestType`. To override this method with a custom one, make sure to call `return super.normalizeResponse(store, primaryModelClass, payload, id, requestType)` with your pre-processed data. Here's an example of using `normalizeResponse` manually: ```javascript socket.on('message', function(message) { let data = message.data; let modelClass = store.modelFor(data.modelName); let serializer = store.serializerFor(data.modelName); let normalized = serializer.normalizeSingleResponse(store, modelClass, data, data.id); store.push(normalized); }); ``` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeSaveResponse() ```ts readonly static normalizeSaveResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:455](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L455) normalizeUpdateRecordResponse, normalizeCreateRecordResponse and normalizeDeleteRecordResponse delegate to this method by default. #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeSingleResponse() ```ts readonly static normalizeSingleResponse( store, primaryModelClass, payload, id, requestType): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:472](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L472) normalizeQueryResponse and normalizeFindRecordResponse delegate to this method by default. #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeUpdateRecordResponse() ```ts readonly static normalizeUpdateRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:438](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L438) Called by the default normalizeResponse implementation when the type of request is `updateRecord` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### payloadKeyFromModelName() ```ts static payloadKeyFromModelName(modelName): string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json-api.js:364](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json-api.js#L364) Converts the model name to a pluralized version of the model name. For example `post` would be converted to `posts` and `student-assesment` would be converted to `student-assesments`. #### Parameters ##### modelName `string` #### Returns `string` *** ### proto() ```ts readonly static proto(): CoreObject; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:649 #### Returns `CoreObject` *** ### pushPayload() ```ts static pushPayload(store, payload): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json-api.js:212](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json-api.js#L212) Normalize some data and push it into the store. #### Parameters ##### store `Store` ##### payload `any` #### Returns `void` *** ### reopenClass() ```ts readonly static reopenClass(this, ...mixins): C; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:595 Augments a constructor's own properties and functions: ```javascript import EmberObject from '@ember/object'; const MyObject = EmberObject.extend({ name: 'an object' }); MyObject.reopenClass({ canBuild: false }); MyObject.canBuild; // false o = MyObject.create(); ``` In other words, this creates static properties and functions for the class. These are only available on the class and not on any instance of that class. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ name: '', sayHello() { alert(`Hello. My name is ${this.get('name')}`); } }); Person.reopenClass({ species: 'Homo sapiens', createPerson(name) { return Person.create({ name }); } }); let tom = Person.create({ name: 'Tom Dale' }); let yehuda = Person.createPerson('Yehuda Katz'); tom.sayHello(); // "Hello. My name is Tom Dale" yehuda.sayHello(); // "Hello. My name is Yehuda Katz" alert(Person.species); // "Homo sapiens" ``` Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` variables. They are only valid on `Person`. To add functions and properties to instances of a constructor by extending the constructor's prototype see `reopen` #### Type Parameters ##### C `C` *extends* *typeof* `CoreObject` #### Parameters ##### this `C` ##### mixins ...(`Record`<`string`, `unknown`> | `Mixin`)\[] #### Returns `C` #### Method reopenClass #### For @ember/object #### Static *** ### serialize() Called when a record is saved in order to convert the record into JSON. By default, it creates a JSON object with a key for each attribute and belongsTo relationship. For example, consider this model: ```js [app/models/comment.js] import Model, { attr, belongsTo } from '@ember-data/model'; export default class CommentModel extends Model { @attr title; @attr body; @belongsTo('user') author; } ``` The default serialization would create a JSON object like: ```javascript { "title": "Rails is unagi", "body": "Rails? Omakase? O_O", "author": 12 } ``` By default, attributes are passed through as-is, unless you specified an attribute type (`attr('date')`). If you specify a transform, the JavaScript value will be serialized when inserted into the JSON hash. By default, belongs-to relationships are converted into IDs when inserted into the JSON hash. ## IDs `serialize` takes an options hash with a single option: `includeId`. If this option is `true`, `serialize` will, by default include the ID in the JSON object it builds. The adapter passes in `includeId: true` when serializing a record for `createRecord`, but not for `updateRecord`. ## Customization Your server may expect a different JSON format than the built-in serialization format. In that case, you can implement `serialize` yourself and return a JSON hash of your choosing. ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { serialize(snapshot, options) { let json = { POST_TTL: snapshot.attr('title'), POST_BDY: snapshot.attr('body'), POST_CMS: snapshot.hasMany('comments', { ids: true }) }; if (options.includeId) { json.POST_ID_ = snapshot.id; } return json; } } ``` ## Customizing an App-Wide Serializer If you want to define a serializer for your entire application, you'll probably want to use `eachAttribute` and `eachRelationship` on the record. ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; import { singularize } from '/utils/string-utils'; export default class ApplicationSerializer extends JSONSerializer { serialize(snapshot, options) { let json = {}; snapshot.eachAttribute((name) => { json[serverAttributeName(name)] = snapshot.attr(name); }); snapshot.eachRelationship((name, relationship) => { if (relationship.kind === 'hasMany') { json[serverHasManyName(name)] = snapshot.hasMany(name, { ids: true }); } }); if (options.includeId) { json.ID_ = snapshot.id; } return json; } } function serverAttributeName(attribute) { return attribute.underscore().toUpperCase(); } function serverHasManyName(name) { return serverAttributeName(singularize(name)) + "_IDS"; } ``` This serializer will generate JSON that looks like this: ```javascript { "TITLE": "Rails is omakase", "BODY": "Yep. Omakase.", "COMMENT_IDS": [ "1", "2", "3" ] } ``` ## Tweaking the Default JSON If you just want to do some small tweaks on the default JSON, you can call `super.serialize` first and make the tweaks on the returned JSON. ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { serialize(snapshot, options) { let json = super.serialize(...arguments); json.subject = json.title; delete json.title; return json; } } ``` #### Param #### Param #### Call Signature ```ts static serialize(snapshot, options): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1080](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1080) ##### Parameters ###### snapshot `Snapshot` ###### options `any` ##### Returns `any` #### Call Signature ```ts static serialize( snapshot, options, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json-api.js:623](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json-api.js#L623) Called when a record is saved in order to convert the record into JSON. For example, consider this model: ```js [app/models/comment.js] import Model, { attr, belongsTo } from '@ember-data/model'; export default class CommentModel extends Model { @attr title; @attr body; @belongsTo('user', { async: false, inverse: null }) author; } ``` The default serialization would create a JSON-API resource object like: ```javascript { "data": { "type": "comments", "attributes": { "title": "Rails is unagi", "body": "Rails? Omakase? O_O", }, "relationships": { "author": { "data": { "id": "12", "type": "users" } } } } } ``` By default, attributes are passed through as-is, unless you specified an attribute type (`attr('date')`). If you specify a transform, the JavaScript value will be serialized when inserted into the attributes hash. Belongs-to relationships are converted into JSON-API resource identifier objects. ## IDs `serialize` takes an options hash with a single option: `includeId`. If this option is `true`, `serialize` will, by default include the ID in the JSON object it builds. The JSONAPIAdapter passes in `includeId: true` when serializing a record for `createRecord` or `updateRecord`. ## Customization Your server may expect data in a different format than the built-in serialization format. In that case, you can implement `serialize` yourself and return data formatted to match your API's expectations, or override the invoked adapter method and do the serialization in the adapter directly by using the provided snapshot. If your API's format differs greatly from the JSON:API spec, you should consider authoring your own adapter and serializer instead of extending this class. ```js [app/serializers/post.js] import JSONAPISerializer from '@ember-data/serializer/json-api'; export default class PostSerializer extends JSONAPISerializer { serialize(snapshot, options) { let json = { POST_TTL: snapshot.attr('title'), POST_BDY: snapshot.attr('body'), POST_CMS: snapshot.hasMany('comments', { ids: true }) }; if (options.includeId) { json.POST_ID_ = snapshot.id; } return json; } } ``` ## Customizing an App-Wide Serializer If you want to define a serializer for your entire application, you'll probably want to use `eachAttribute` and `eachRelationship` on the record. ```js [app/serializers/application.js] import JSONAPISerializer from '@ember-data/serializer/json-api'; import { underscore, singularize } from '/utils/string-utils'; export default class ApplicationSerializer extends JSONAPISerializer { serialize(snapshot, options) { let json = {}; snapshot.eachAttribute((name) => { json[serverAttributeName(name)] = snapshot.attr(name); }); snapshot.eachRelationship((name, relationship) => { if (relationship.kind === 'hasMany') { json[serverHasManyName(name)] = snapshot.hasMany(name, { ids: true }); } }); if (options.includeId) { json.ID_ = snapshot.id; } return json; } } function serverAttributeName(attribute) { return underscore(attribute).toUpperCase(); } function serverHasManyName(name) { return serverAttributeName(singularize(name)) + '_IDS'; } ``` This serializer will generate JSON that looks like this: ```javascript { "TITLE": "Rails is omakase", "BODY": "Yep. Omakase.", "COMMENT_IDS": [ "1", "2", "3" ] } ``` ## Tweaking the Default Formatting If you just want to do some small tweaks on the default JSON:API formatted response, you can call `super.serialize` first and make the tweaks on the returned object. ```js [app/serializers/post.js] import JSONAPISerializer from '@ember-data/serializer/json-api'; export default class PostSerializer extends JSONAPISerializer { serialize(snapshot, options) { let json = super.serialize(...arguments); json.data.attributes.subject = json.data.attributes.title; delete json.data.attributes.title; return json; } } ``` ##### Parameters ###### snapshot `Snapshot` ###### options `any` ###### args ...`any` ##### Returns `any` json ##### Param ##### Param *** ### serializeAttribute() `serializeAttribute` can be used to customize how `attr` properties are serialized For example if you wanted to ensure all your attributes were always serialized as properties on an `attributes` object you could write: ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class ApplicationSerializer extends JSONSerializer { serializeAttribute(snapshot, json, key, attributes) { json.attributes = json.attributes || {}; super.serializeAttribute(snapshot, json.attributes, key, attributes); } } ``` #### Param #### Param #### Param #### Param #### Call Signature ```ts static serializeAttribute( snapshot, json, key, attribute): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1162](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1162) ##### Parameters ###### snapshot `Snapshot` ###### json `any` ###### key `string` ###### attribute `any` ##### Returns `void` #### Call Signature ```ts static serializeAttribute( snapshot, json, key, attribute): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json-api.js:630](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json-api.js#L630) ##### Parameters ###### snapshot `any` ###### json `any` ###### key `any` ###### attribute `any` ##### Returns `void` *** ### serializeBelongsTo() `serializeBelongsTo` can be used to customize how `belongsTo` properties are serialized. Example ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { serializeBelongsTo(snapshot, json, relationship) { let key = relationship.name; let belongsTo = snapshot.belongsTo(key); key = this.keyForRelationship ? this.keyForRelationship(key, "belongsTo", "serialize") : key; json[key] = !belongsTo ? null : belongsTo.record.toJSON(); } } ``` #### Param #### Param #### Param #### Call Signature ```ts static serializeBelongsTo( snapshot, json, relationship): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1210](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1210) ##### Parameters ###### snapshot `Snapshot` ###### json `any` ###### relationship `any` ##### Returns `void` #### Call Signature ```ts static serializeBelongsTo( snapshot, json, relationship): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json-api.js:653](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json-api.js#L653) ##### Parameters ###### snapshot `any` ###### json `any` ###### relationship `any` ##### Returns `void` *** ### serializeHasMany() `serializeHasMany` can be used to customize how `hasMany` properties are serialized. Example ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { serializeHasMany(snapshot, json, relationship) { let key = relationship.name; if (key === 'comments') { return; } else { super.serializeHasMany(...arguments); } } } ``` #### Param #### Param #### Param #### Call Signature ```ts static serializeHasMany( snapshot, json, relationship): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1263](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1263) ##### Parameters ###### snapshot `Snapshot` ###### json `any` ###### relationship `any` ##### Returns `void` #### Call Signature ```ts static serializeHasMany( snapshot, json, relationship): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json-api.js:684](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json-api.js#L684) ##### Parameters ###### snapshot `any` ###### json `any` ###### relationship `any` ##### Returns `void` *** ### serializeIntoHash() ```ts readonly static serializeIntoHash( hash, typeClass, snapshot, options): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1133](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1133) You can use this method to customize how a serialized record is added to the complete JSON hash to be sent to the server. By default the JSON Serializer does not namespace the payload and just sends the raw serialized JSON object. If your server expects namespaced keys, you should consider using the RESTSerializer. Otherwise you can override this method to customize how the record is added to the hash. The hash property should be modified by reference. For example, your server may expect underscored root objects. ```js [app/serializers/application.js] import RESTSerializer from '@ember-data/serializer/rest'; import { underscoren} from '/utils/string-utils'; export default class ApplicationSerializer extends RESTSerializer { serializeIntoHash(data, type, snapshot, options) { let root = underscore(type.modelName); data[root] = this.serialize(snapshot, options); } } ``` #### Parameters ##### hash `any` ##### typeClass `Model` ##### snapshot `Snapshot` ##### options `any` #### Returns `void` *** ### serializePolymorphicType() ```ts readonly static serializePolymorphicType(): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1315](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1315) You can use this method to customize how polymorphic objects are serialized. Objects are considered to be polymorphic if `{ polymorphic: true }` is pass as the second argument to the `belongsTo` function. Example ```js [app/serializers/comment.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class CommentSerializer extends JSONSerializer { serializePolymorphicType(snapshot, json, relationship) { let key = relationship.name; let belongsTo = snapshot.belongsTo(key); key = this.keyForAttribute ? this.keyForAttribute(key, 'serialize') : key; if (!belongsTo) { json[key + '_type'] = null; } else { json[key + '_type'] = belongsTo.modelName; } } } ``` #### Returns `void` *** ### shouldSerializeHasMany() ```ts readonly static shouldSerializeHasMany( snapshot, key, relationship): boolean; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:918](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L918) Check if the given hasMany relationship should be serialized By default only many-to-many and many-to-none relationships are serialized. This could be configured per relationship by Serializer's `attrs` object. #### Parameters ##### snapshot `Snapshot` ##### key `string` ##### relationship `RelationshipSchema` #### Returns `boolean` true if the hasMany relationship should be serialized *** ### toString() ```ts readonly static toString(): string; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:650 #### Returns `string` *** ### willReopen() ```ts readonly static willReopen(): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:533 #### Returns `void` --- --- url: /api/@warp-drive/legacy/serializer/json-api.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / serializer/json-api ## Classes * [JSONAPISerializer](classes/JSONAPISerializer.md) --- --- url: /api/@warp-drive/legacy/serializer/json.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / serializer/json ## Classes * [JSONSerializer](classes/JSONSerializer.md) --- --- url: /api/@warp-drive/legacy/serializer/json/classes/JSONSerializer.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [serializer/json](../index.md) / JSONSerializer Defined in: [warp-drive-packages/legacy/src/serializer/json.js:89](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L89) In EmberData a Serializer is used to serialize and deserialize records when they are transferred in and out of an external source. This process involves normalizing property names, transforming attribute values and serializing relationships. By default, EmberData uses and recommends the `JSONAPISerializer`. `JSONSerializer` is useful for simpler or legacy backends that may not support the http://jsonapi.org/ spec. For example, given the following `User` model and JSON payload: ```js [app/models/user.js] import Model, { attr, belongsTo, hasMany } from '@ember-data/model'; export default class UserModel extends Model { @hasMany('user') friends; @belongsTo('location') house; @attr('string') name; } ``` ```js { id: 1, name: 'Sebastian', friends: [3, 4], links: { house: '/houses/lefkada' } } ``` `JSONSerializer` will normalize the JSON payload to the JSON API format that the Ember Data store expects. You can customize how JSONSerializer processes its payload by passing options in the `attrs` hash or by subclassing the `JSONSerializer` and overriding hooks: * To customize how a single record is normalized, use the `normalize` hook. * To customize how `JSONSerializer` normalizes the whole server response, use the `normalizeResponse` hook. * To customize how `JSONSerializer` normalizes a specific response from the server, use one of the many specific `normalizeResponse` hooks. * To customize how `JSONSerializer` normalizes your id, attributes or relationships, use the `extractId`, `extractAttributes` and `extractRelationships` hooks. The `JSONSerializer` normalization process follows these steps: 1. `normalizeResponse` * entry method to the serializer. 2. `normalizeCreateRecordResponse` * a `normalizeResponse` for a specific operation is called. 3. `normalizeSingleResponse`|`normalizeArrayResponse` * for methods like `createRecord` we expect a single record back, while for methods like `findAll` we expect multiple records back. 4. `normalize` * `normalizeArrayResponse` iterates and calls `normalize` for each of its records while `normalizeSingle` calls it once. This is the method you most likely want to subclass. 5. `extractId` | `extractAttributes` | `extractRelationships` * `normalize` delegates to these methods to turn the record payload into the JSON API format. JSONSerializer ## Constructors ### Constructor ```ts new JSONSerializer(owner?): JSONSerializer; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:8 #### Parameters ##### owner? `Owner` #### Returns `JSONSerializer` ## Properties ### concatenatedProperties? ```ts optional concatenatedProperties: string | string[]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:655 *** ### mergedProperties? ```ts optional mergedProperties: unknown[]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:656 *** ### store ```ts store: default; ``` Defined in: [warp-drive-packages/legacy/src/serializer.ts:141](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer.ts#L141) *** ### \_lazyInjections()? ```ts readonly static optional _lazyInjections: () => void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:654 #### Returns `void` *** ### \_onLookup()? ```ts readonly static optional _onLookup: (debugContainerKey) => void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:653 #### Parameters ##### debugContainerKey `string` #### Returns `void` *** ### \[INIT\_FACTORY]? ```ts readonly static optional [INIT_FACTORY]: null; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/mixin.d.ts:116 *** ### isClass ```ts readonly static isClass: boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:651 *** ### isMethod ```ts readonly static isMethod: boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:652 *** ### mergedProperties ```ts static mergedProperties: any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:182](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L182) The `attrs` object can be used to declare a simple mapping between property names on `Model` records and payload keys in the serialized JSON object representing the record. An object with the property `key` can also be used to designate the attribute's key on the response payload. Example ```js [app/models/person.js] import Model, { attr } from '@ember-data/model'; export default class PersonModel extends Model { @attr('string') firstName; @attr('string') lastName; @attr('string') occupation; @attr('boolean') admin; } ``` ```js [app/serializers/person.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PersonSerializer extends JSONSerializer { attrs = { admin: 'is_admin', occupation: { key: 'career' } } } ``` You can also remove attributes and relationships by setting the `serialize` key to `false` in your mapping object. Example ```js [app/serializers/person.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { attrs = { admin: { serialize: false }, occupation: { key: 'career' } } } ``` When serialized: ```javascript { "firstName": "Harry", "lastName": "Houdini", "career": "magician" } ``` Note that the `admin` is now not included in the payload. Setting `serialize` to `true` enforces serialization for hasMany relationships even if it's neither a many-to-many nor many-to-none relationship. *** ### primaryKey ```ts static primaryKey: string = 'id'; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:113](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L113) The `primaryKey` is used when serializing and deserializing data. Ember Data always uses the `id` property to store the id of the record. The external source may not always follow this convention. In these cases it is useful to override the `primaryKey` property to match the `primaryKey` of your external store. Example ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class ApplicationSerializer extends JSONSerializer { primaryKey = '_id' } ``` #### Default ```ts 'id' ``` *** ### PrototypeMixin ```ts static PrototypeMixin: any; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:647 *** ### superclass ```ts static superclass: any; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:648 ## Accessors ### \_debugContainerKey #### Get Signature ```ts get _debugContainerKey(): false | `${string}:${string}`; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/index.d.ts:34 ##### Returns `false` | `` `${string}:${string}` `` *** ### isDestroyed #### Get Signature ```ts get isDestroyed(): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:272 Destroyed object property flag. if this property is `true` the observers and bindings were already removed by the effect of calling the `destroy()` method. ##### Default ```ts false @public ``` ##### Returns `boolean` #### Set Signature ```ts set isDestroyed(_value): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:273 ##### Parameters ###### \_value `boolean` ##### Returns `void` *** ### isDestroying #### Get Signature ```ts get isDestroying(): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:284 Destruction scheduled flag. The `destroy()` method has been called. The object stays intact until the end of the run loop at which point the `isDestroyed` flag is set. ##### Default ```ts false @public ``` ##### Returns `boolean` #### Set Signature ```ts set isDestroying(_value): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:285 ##### Parameters ###### \_value `boolean` ##### Returns `void` ## Methods ### addObserver() #### Call Signature ```ts addObserver( key, target, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:333 Adds an observer on a property. This is the core method used to register an observer for a property. Once you call this method, any time the key's value is set, your observer will be notified. Note that the observers are triggered any time the value is set, regardless of whether it has actually changed. Your observer should be prepared to handle that. There are two common invocation patterns for `.addObserver()`: * Passing two arguments: * the name of the property to observe (as a string) * the function to invoke (an actual function) * Passing three arguments: * the name of the property to observe (as a string) * the target object (will be used to look up and invoke a function on) * the name of the function to invoke on the target object (as a string). ```app/components/my-component.js import Component from '@ember/component'; export default Component.extend({ init() { this._super(...arguments); // the following are equivalent: // using three arguments this.addObserver('foo', this, 'fooDidChange'); // using two arguments this.addObserver('foo', (...args) => { this.fooDidChange(...args); }); }, fooDidChange() { // your custom logic code } }); ``` ### Observer Methods Observer methods have the following signature: ```app/components/my-component.js import Component from '@ember/component'; export default Component.extend({ init() { this._super(...arguments); this.addObserver('foo', this, 'fooDidChange'); }, fooDidChange(sender, key, value, rev) { // your code } }); ``` The `sender` is the object that changed. The `key` is the property that changes. The `value` property is currently reserved and unused. The `rev` is the last property revision of the object when it changed, which you can use to detect if the key value has really changed or not. Usually you will not need the value or revision parameters at the end. In this case, it is common to write observer methods that take only a sender and key value as parameters or, if you aren't interested in any of these values, to write an observer that has no parameters at all. ##### Type Parameters ###### Target `Target` ##### Parameters ###### key keyof [`Serializer`](../../classes/Serializer.md) The key to observe ###### target `Target` The target object to invoke ###### method `ObserverMethod`<`Target`, [`Serializer`](../../classes/Serializer.md)> The method to invoke ##### Returns `this` ##### Method addObserver #### Call Signature ```ts addObserver(key, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:338 ##### Parameters ###### key keyof [`Serializer`](../../classes/Serializer.md) ###### method `ObserverMethod`<[`Serializer`](../../classes/Serializer.md), [`Serializer`](../../classes/Serializer.md)> ##### Returns `this` *** ### cacheFor() ```ts cacheFor(key): unknown; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:413 Returns the cached value of a computed property, if it exists. This allows you to inspect the value of a computed property without accidentally invoking it if it is intended to be generated lazily. #### Type Parameters ##### K `K` *extends* keyof [`Serializer`](../../classes/Serializer.md) #### Parameters ##### key `K` #### Returns `unknown` The cached value of the computed property, if any #### Method cacheFor *** ### decrementProperty() ```ts decrementProperty(keyName, decrement?): number; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:387 Set the value of a property to the current value minus some amount. ```javascript player.decrementProperty('lives'); orc.decrementProperty('health', 5); ``` #### Parameters ##### keyName keyof [`Serializer`](../../classes/Serializer.md) The name of the property to decrement ##### decrement? `number` The amount to decrement by. Defaults to 1 #### Returns `number` The new property value #### Method decrementProperty *** ### destroy() ```ts destroy(): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:300 Destroys an object by setting the `isDestroyed` flag and removing its metadata, which effectively destroys observers and bindings. If you try to set a property on a destroyed object, an exception will be raised. Note that destruction is scheduled for the end of the run loop and does not happen immediately. It will set an isDestroying flag immediately. #### Returns `this` receiver #### Method destroy *** ### get() #### Call Signature ```ts get(key): Serializer[K]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:121 Retrieves the value of a property from the object. This method is usually similar to using `object[keyName]` or `object.keyName`, however it supports both computed properties and the unknownProperty handler. Because `get` unifies the syntax for accessing all these kinds of properties, it can make many refactorings easier, such as replacing a simple property with a computed property, or vice versa. ### Computed Properties Computed properties are methods defined with the `property` modifier declared at the end, such as: ```javascript import { computed } from '@ember/object'; fullName: computed('firstName', 'lastName', function() { return this.get('firstName') + ' ' + this.get('lastName'); }) ``` When you call `get` on a computed property, the function will be called and the return value will be returned instead of the function itself. ### Unknown Properties Likewise, if you try to call `get` on a property whose value is `undefined`, the `unknownProperty()` method will be called on the object. If this method returns any value other than `undefined`, it will be returned instead. This allows you to implement "virtual" properties that are not defined upfront. ##### Type Parameters ###### K `K` *extends* keyof [`Serializer`](../../classes/Serializer.md) ##### Parameters ###### key `K` ##### Returns [`Serializer`](../../classes/Serializer.md)\[`K`] The property value or undefined. ##### Method get #### Call Signature ```ts get(key): unknown; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:122 ##### Parameters ###### key `string` ##### Returns `unknown` *** ### getProperties() #### Call Signature ```ts getProperties(list): { [Key in keyof Serializer]: Serializer[Key] }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:144 To get the values of multiple properties at once, call `getProperties` with a list of strings or an array: ```javascript record.getProperties('firstName', 'lastName', 'zipCode'); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } ``` is equivalent to: ```javascript record.getProperties(['firstName', 'lastName', 'zipCode']); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } ``` ##### Type Parameters ###### L `L` *extends* keyof [`Serializer`](../../classes/Serializer.md)\[] ##### Parameters ###### list `L` of keys to get ##### Returns `{ [Key in keyof Serializer]: Serializer[Key] }` ##### Method getProperties #### Call Signature ```ts getProperties(...list): { [Key in keyof Serializer]: Serializer[Key] }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:149 ##### Type Parameters ###### L `L` *extends* keyof [`Serializer`](../../classes/Serializer.md)\[] ##### Parameters ###### list ...`L` ##### Returns `{ [Key in keyof Serializer]: Serializer[Key] }` #### Call Signature ```ts getProperties(list): { [Key in string]: unknown }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:154 ##### Type Parameters ###### L `L` *extends* `string`\[] ##### Parameters ###### list `L` ##### Returns `{ [Key in string]: unknown }` #### Call Signature ```ts getProperties(...list): { [Key in string]: unknown }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:159 ##### Type Parameters ###### L `L` *extends* `string`\[] ##### Parameters ###### list ...`L` ##### Returns `{ [Key in string]: unknown }` *** ### incrementProperty() ```ts incrementProperty(keyName, increment?): number; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:372 Set the value of a property to the current value plus some amount. ```javascript person.incrementProperty('age'); team.incrementProperty('score', 2); ``` #### Parameters ##### keyName keyof [`Serializer`](../../classes/Serializer.md) The name of the property to increment ##### increment? `number` The amount to increment by. Defaults to 1 #### Returns `number` The new property value #### Method incrementProperty *** ### init() ```ts init(_properties): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:114 An overridable method called when objects are instantiated. By default, does nothing unless it is overridden during class definition. Example: ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ init() { alert(`Name is ${this.get('name')}`); } }); let steve = Person.create({ name: 'Steve' }); // alerts 'Name is Steve'. ``` NOTE: If you do override `init` for a framework class like `Component` from `@ember/component`, be sure to call `this._super(...arguments)` in your `init` declaration! If you don't, Ember may not have an opportunity to do important setup work, and you'll see strange behavior in your application. #### Parameters ##### \_properties `undefined` | `object` #### Returns `void` #### Method init *** ### normalize() ```ts normalize(_typeClass, hash): | EmptyResourceDocument | SingleResourceDocument; ``` Defined in: [warp-drive-packages/legacy/src/serializer.ts:266](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer.ts#L266) The `normalize` method is used to convert a payload received from your external data source into the normalized form `store.push()` expects. You should override this method, munge the hash and return the normalized payload. Example: ```js Serializer.extend({ normalize(modelClass, resourceHash) { let data = { id: resourceHash.id, type: modelClass.modelName, attributes: resourceHash }; return { data: data }; } }) ``` #### Parameters ##### \_typeClass [`ModelSchema`](../../../../core-types/index/interfaces/ModelSchema.md) ##### hash `Record`<`string`, `unknown`> #### Returns | [`EmptyResourceDocument`](../../../../core-types/spec/json-api-raw/type-aliases/EmptyResourceDocument.md) | [`SingleResourceDocument`](../../../../core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md) *** ### notifyPropertyChange() ```ts notifyPropertyChange(keyName): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:249 Convenience method to call `propertyWillChange` and `propertyDidChange` in succession. Notify the observer system that a property has just changed. Sometimes you need to change a value directly or indirectly without actually calling `get()` or `set()` on it. In this case, you can use this method instead. Calling this method will notify all observers that the property has potentially changed value. #### Parameters ##### keyName `string` The property key to be notified about. #### Returns `this` #### Method notifyPropertyChange *** ### removeObserver() #### Call Signature ```ts removeObserver( key, target, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:352 Remove an observer you have previously registered on this object. Pass the same key, target, and method you passed to `addObserver()` and your target will no longer receive notifications. ##### Type Parameters ###### Target `Target` ##### Parameters ###### key keyof [`Serializer`](../../classes/Serializer.md) The key to observe ###### target `Target` The target object to invoke ###### method `ObserverMethod`<`Target`, [`Serializer`](../../classes/Serializer.md)> The method to invoke ##### Returns `this` ##### Method removeObserver #### Call Signature ```ts removeObserver(key, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:357 ##### Parameters ###### key keyof [`Serializer`](../../classes/Serializer.md) ###### method `ObserverMethod`<[`Serializer`](../../classes/Serializer.md), [`Serializer`](../../classes/Serializer.md)> ##### Returns `this` *** ### reopen() ```ts reopen(...args): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:81 #### Parameters ##### args ...(`Record`<`string`, `unknown`> | `Mixin`)\[] #### Returns `this` *** ### set() #### Call Signature ```ts set(key, value): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:208 Sets the provided key or path to the value. ```javascript record.set("key", value); ``` This method is generally very similar to calling `object["key"] = value` or `object.key = value`, except that it provides support for computed properties, the `setUnknownProperty()` method and property observers. ### Computed Properties If you try to set a value on a key that has a computed property handler defined (see the `get()` method for an example), then `set()` will call that method, passing both the value and key instead of simply changing the value itself. This is useful for those times when you need to implement a property that is composed of one or more member properties. ### Unknown Properties If you try to set a value on a key that is undefined in the target object, then the `setUnknownProperty()` handler will be called instead. This gives you an opportunity to implement complex "virtual" properties that are not predefined on the object. If `setUnknownProperty()` returns undefined, then `set()` will simply set the value on the object. ### Property Observers In addition to changing the property, `set()` will also register a property change with the object. Unless you have placed this call inside of a `beginPropertyChanges()` and `endPropertyChanges(),` any "local" observers (i.e. observer methods declared on the same object), will be called immediately. Any "remote" observers (i.e. observer methods declared on another object) will be placed in a queue and called at a later time in a coalesced manner. ##### Type Parameters ###### K `K` *extends* keyof [`Serializer`](../../classes/Serializer.md) ###### T `T` *extends* | `undefined` | `string` | `boolean` | `unknown`\[] | [`default`](../../../../../@ember-data/store/index/classes/default.md) | `string`\[] | `Owner` | () => `string` | { } | () => `void` | (`_typeClass`, `hash`) => | [`EmptyResourceDocument`](../../../../core-types/spec/json-api-raw/type-aliases/EmptyResourceDocument.md) | [`SingleResourceDocument`](../../../../core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md) | (...`args`) => `this` | (`_properties`) => `void` | () => `this` | { <`K`> (`key`): [`Serializer`](../../classes/Serializer.md)\[`K`]; (`key`): `unknown`; } | { <`L`> (`list`): `{ [Key in keyof Serializer]: Serializer[Key] }`; <`L`> (...`list`): `{ [Key in keyof Serializer]: Serializer[Key] }`; <`L`> (`list`): `{ [Key in string]: unknown }`; <`L`> (...`list`): `{ [Key in string]: unknown }`; } | { <`K`, `T`> (`key`, `value`): `T`; <`T`> (`key`, `value`): `T`; } | { <`K`, `P`> (`hash`): `P`; <`T`> (`hash`): `T`; } | (`keyName`) => `this` | { <`Target`> (`key`, `target`, `method`): `this`; (`key`, `method`): `this`; } | { <`Target`> (`key`, `target`, `method`): `this`; (`key`, `method`): `this`; } | (`keyName`, `increment?`) => `number` | (`keyName`, `decrement?`) => `number` | (`keyName`) => `boolean` | <`K`>(`key`) => `unknown` ##### Parameters ###### key `K` ###### value `T` The value to set or `null`. ##### Returns `T` The passed value ##### Method set #### Call Signature ```ts set(key, value): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:209 ##### Type Parameters ###### T `T` ##### Parameters ###### key `string` ###### value `T` ##### Returns `T` *** ### setProperties() #### Call Signature ```ts setProperties(hash): P; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:224 Sets a list of properties at once. These properties are set inside a single `beginPropertyChanges` and `endPropertyChanges` batch, so observers will be buffered. ```javascript record.setProperties({ firstName: 'Charles', lastName: 'Jolley' }); ``` ##### Type Parameters ###### K `K` *extends* keyof [`Serializer`](../../classes/Serializer.md) ###### P `P` *extends* `{ [Key in keyof Serializer]: Serializer[Key] }` ##### Parameters ###### hash `P` the hash of keys and values to set ##### Returns `P` The passed in hash ##### Method setProperties #### Call Signature ```ts setProperties(hash): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:232 ##### Type Parameters ###### T `T` *extends* `Record`<`string`, `unknown`> ##### Parameters ###### hash `T` ##### Returns `T` *** ### toggleProperty() ```ts toggleProperty(keyName): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:401 Set the value of a boolean property to the opposite of its current value. ```javascript starship.toggleProperty('warpDriveEngaged'); ``` #### Parameters ##### keyName keyof [`Serializer`](../../classes/Serializer.md) The name of the property to toggle #### Returns `boolean` The new property value #### Method toggleProperty *** ### toString() ```ts toString(): string; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:347 Returns a string representation which attempts to provide more information than Javascript's `toString` typically does, in a generic way for all Ember objects. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend(); person = Person.create(); person.toString(); //=> "" ``` If the object's class is not defined on an Ember namespace, it will indicate it is a subclass of the registered superclass: ```javascript const Student = Person.extend(); let student = Student.create(); student.toString(); //=> "<(subclass of Person):ember1025>" ``` If the method `toStringExtension` is defined, its return value will be included in the output. ```javascript const Teacher = Person.extend({ toStringExtension() { return this.get('fullName'); } }); teacher = Teacher.create(); teacher.toString(); //=> "" ``` #### Returns `string` string representation #### Method toString *** ### willDestroy() ```ts willDestroy(): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:307 Override to implement teardown. #### Returns `void` #### Method willDestroy *** ### create() #### Call Signature ```ts readonly static create(this): InstanceType; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:487 Creates an instance of a class. Accepts either no arguments, or an object containing values to initialize the newly instantiated object with. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ helloWorld() { alert(`Hi, my name is ${this.get('name')}`); } }); let tom = Person.create({ name: 'Tom Dale' }); tom.helloWorld(); // alerts "Hi, my name is Tom Dale". ``` `create` will call the `init` function if defined during `AnyObject.extend` If no arguments are passed to `create`, it will not set values to the new instance during initialization: ```javascript let noName = Person.create(); noName.helloWorld(); // alerts undefined ``` NOTE: For performance reasons, you cannot declare methods or computed properties during `create`. You should instead declare methods and computed properties when using `extend`. ##### Type Parameters ###### C `C` *extends* *typeof* `CoreObject` ##### Parameters ###### this `C` ##### Returns `InstanceType`<`C`> ##### Method create ##### For @ember/object ##### Static #### Call Signature ```ts readonly static create(this, ...args): InstanceType & MergeArray; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:488 Creates an instance of a class. Accepts either no arguments, or an object containing values to initialize the newly instantiated object with. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ helloWorld() { alert(`Hi, my name is ${this.get('name')}`); } }); let tom = Person.create({ name: 'Tom Dale' }); tom.helloWorld(); // alerts "Hi, my name is Tom Dale". ``` `create` will call the `init` function if defined during `AnyObject.extend` If no arguments are passed to `create`, it will not set values to the new instance during initialization: ```javascript let noName = Person.create(); noName.helloWorld(); // alerts undefined ``` NOTE: For performance reasons, you cannot declare methods or computed properties during `create`. You should instead declare methods and computed properties when using `extend`. ##### Type Parameters ###### C `C` *extends* *typeof* `CoreObject` ###### I `I` *extends* `CoreObject` ###### K `K` *extends* `string` | `number` | `symbol` ###### Args `Args` *extends* `Partial`<{ \[Key in string | number | symbol]: I\[Key] }>\[] ##### Parameters ###### this `C` ###### args ...`Args` ##### Returns `InstanceType`<`C`> & `MergeArray`<`Args`> ##### Method create ##### For @ember/object ##### Static *** ### detectInstance() ```ts readonly static detectInstance(obj): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:600 #### Parameters ##### obj `unknown` #### Returns `boolean` *** ### extend() ```ts readonly static extend(this, ...mixins?): Readonly & EmberClassConstructor & MergeArray; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:442 Creates a new subclass. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ say(thing) { alert(thing); } }); ``` This defines a new subclass of EmberObject: `Person`. It contains one method: `say()`. You can also create a subclass from any existing class by calling its `extend()` method. For example, you might want to create a subclass of Ember's built-in `Component` class: ```javascript import Component from '@ember/component'; const PersonComponent = Component.extend({ tagName: 'li', classNameBindings: ['isAdministrator'] }); ``` When defining a subclass, you can override methods but still access the implementation of your parent class by calling the special `_super()` method: ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ say(thing) { let name = this.get('name'); alert(`${name} says: ${thing}`); } }); const Soldier = Person.extend({ say(thing) { this._super(`${thing}, sir!`); }, march(numberOfHours) { alert(`${this.get('name')} marches for ${numberOfHours} hours.`); } }); let yehuda = Soldier.create({ name: 'Yehuda Katz' }); yehuda.say('Yes'); // alerts "Yehuda Katz says: Yes, sir!" ``` The `create()` on line #17 creates an *instance* of the `Soldier` class. The `extend()` on line #8 creates a *subclass* of `Person`. Any instance of the `Person` class will *not* have the `march()` method. You can also pass `Mixin` classes to add additional properties to the subclass. ```javascript import EmberObject from '@ember/object'; import Mixin from '@ember/object/mixin'; const Person = EmberObject.extend({ say(thing) { alert(`${this.get('name')} says: ${thing}`); } }); const SingingMixin = Mixin.create({ sing(thing) { alert(`${this.get('name')} sings: la la la ${thing}`); } }); const BroadwayStar = Person.extend(SingingMixin, { dance() { alert(`${this.get('name')} dances: tap tap tap tap `); } }); ``` The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. #### Type Parameters ##### Statics `Statics` ##### Instance `Instance` ##### M `M` *extends* `unknown`\[] #### Parameters ##### this `Statics` & `EmberClassConstructor`<`Instance`> ##### mixins? ...`M` One or more Mixin classes #### Returns `Readonly`<`Statics`> & `EmberClassConstructor`<`Instance`> & `MergeArray`<`M`> #### Method extend #### Static #### For @ember/object *** ### extractAttributes() ```ts static extractAttributes(modelClass, resourceHash): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:632](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L632) Returns the resource's attributes formatted as a JSON-API "attributes object". http://jsonapi.org/format/#document-resource-object-attributes #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `any` *** ### extractErrors() ```ts static extractErrors( store, typeClass, payload, id): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1436](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1436) `extractErrors` is used to extract model errors when a call to `Model#save` fails with an `InvalidError`. By default Ember Data expects error information to be located on the `errors` property of the payload object. This serializer expects this `errors` object to be an Array similar to the following, compliant with the https://jsonapi.org/format/#errors specification: ```js { "errors": [ { "detail": "This username is already taken!", "source": { "pointer": "data/attributes/username" } }, { "detail": "Doesn't look like a valid email.", "source": { "pointer": "data/attributes/email" } } ] } ``` The key `detail` provides a textual description of the problem. Alternatively, the key `title` can be used for the same purpose. The nested keys `source.pointer` detail which specific element of the request data was invalid. Note that JSON-API also allows for object-level errors to be placed in an object with pointer `data`, signifying that the problem cannot be traced to a specific attribute: ```javascript { "errors": [ { "detail": "Some generic non property error message", "source": { "pointer": "data" } } ] } ``` When turn into a `Errors` object, you can read these errors through the property `base`: ```handlebars {{#each @model.errors.base as |error|}}
{{error.message}}
{{/each}} ``` Example of alternative implementation, overriding the default behavior to deal with a different format of errors: ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { extractErrors(store, typeClass, payload, id) { if (payload && typeof payload === 'object' && payload._problems) { payload = payload._problems; this.normalizeErrors(typeClass, payload); } return payload; } } ``` #### Parameters ##### store `Store` ##### typeClass `Model` ##### payload `any` ##### id `string` | `number` #### Returns `any` json The deserialized errors *** ### extractId() ```ts static extractId(modelClass, resourceHash): string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:616](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L616) Returns the resource's ID. #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `string` *** ### extractMeta() ```ts static extractMeta( store, modelClass, payload): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1343](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1343) `extractMeta` is used to deserialize any meta information in the adapter payload. By default Ember Data expects meta information to be located on the `meta` property of the payload object. Example ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { extractMeta(store, typeClass, payload) { if (payload && payload.hasOwnProperty('_pagination')) { let meta = payload._pagination; delete payload._pagination; return meta; } } } ``` #### Parameters ##### store `Store` ##### modelClass `Model` ##### payload `any` #### Returns `any` *** ### extractPolymorphicRelationship() ```ts static extractPolymorphicRelationship( relationshipModelName, relationshipHash, relationshipOptions): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:699](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L699) Returns a polymorphic relationship formatted as a JSON-API "relationship object". http://jsonapi.org/format/#document-resource-object-relationships `relationshipOptions` is a hash which contains more information about the polymorphic relationship which should be extracted: * `resourceHash` complete hash of the resource the relationship should be extracted from * `relationshipKey` key under which the value for the relationship is extracted from the resourceHash * `relationshipMeta` meta information about the relationship #### Parameters ##### relationshipModelName `any` ##### relationshipHash `any` ##### relationshipOptions `any` #### Returns `any` *** ### extractRelationship() ```ts static extractRelationship(relationshipModelName, relationshipHash): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:656](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L656) Returns a relationship formatted as a JSON-API "relationship object". http://jsonapi.org/format/#document-resource-object-relationships #### Parameters ##### relationshipModelName `any` ##### relationshipHash `any` #### Returns `any` *** ### extractRelationships() ```ts static extractRelationships(modelClass, resourceHash): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:713](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L713) Returns the resource's relationships formatted as a JSON-API "relationships object". http://jsonapi.org/format/#document-resource-object-relationships #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `any` *** ### keyForAttribute() ```ts static keyForAttribute(key, method): string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1507](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1507) `keyForAttribute` can be used to define rules for how to convert an attribute name in your model to a key in your JSON. Example ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; import { underscore } from '/utils/string-utils'; export default class ApplicationSerializer extends JSONSerializer { keyForAttribute(attr, method) { return underscore(attr).toUpperCase(); } } ``` #### Parameters ##### key `string` ##### method `string` #### Returns `string` normalized key *** ### keyForLink() ```ts static keyForLink(key, kind): string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1548](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1548) `keyForLink` can be used to define a custom key when deserializing link properties. #### Parameters ##### key `string` ##### kind `string` `belongsTo` or `hasMany` #### Returns `string` normalized key *** ### keyForRelationship() ```ts static keyForRelationship( key, typeClass, method): string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1535](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1535) `keyForRelationship` can be used to define a custom key when serializing and deserializing relationship properties. By default `JSONSerializer` does not provide an implementation of this method. Example ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; import { underscore } from '/utils/string-utils'; export default class PostSerializer extends JSONSerializer { keyForRelationship(key, relationship, method) { return `rel_${underscore(key)}`; } } ``` #### Parameters ##### key `string` ##### typeClass `string` ##### method `string` #### Returns `string` normalized key *** ### modelNameFromPayloadKey() ```ts static modelNameFromPayloadKey(key): string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:781](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L781) Dasherizes the model name in the payload #### Parameters ##### key `string` #### Returns `string` the model's modelName *** ### normalize() ```ts static normalize(modelClass, resourceHash): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:582](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L582) Normalizes a part of the JSON payload returned by the server. You should override this method, munge the hash and call super if you have generic normalization to do. It takes the type of the record that is being normalized (as a Model class), the property where the hash was originally found, and the hash to normalize. You can use this method, for example, to normalize underscored keys to camelized or other general-purpose normalizations. Example ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; import { underscore } from '/utils/string-utils'; import { get } from '@ember/object'; export default class ApplicationSerializer extends JSONSerializer { normalize(typeClass, hash) { let fields = typeClass.fields; fields.forEach(function(type, field) { let payloadField = underscore(field); if (field === payloadField) { return; } hash[field] = hash[payloadField]; delete hash[payloadField]; }); return super.normalize(...arguments); } } ``` #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `any` *** ### normalizeArrayResponse() ```ts static normalizeArrayResponse( store, primaryModelClass, payload, id, requestType): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:489](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L489) normalizeQueryResponse, normalizeFindManyResponse, and normalizeFindHasManyResponse delegate to this method by default. #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeCreateRecordResponse() ```ts static normalizeCreateRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:404](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L404) Called by the default normalizeResponse implementation when the type of request is `createRecord` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeDeleteRecordResponse() ```ts static normalizeDeleteRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:421](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L421) Called by the default normalizeResponse implementation when the type of request is `deleteRecord` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindAllResponse() ```ts static normalizeFindAllResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:319](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L319) Called by the default normalizeResponse implementation when the type of request is `findAll` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindBelongsToResponse() ```ts static normalizeFindBelongsToResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:336](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L336) Called by the default normalizeResponse implementation when the type of request is `findBelongsTo` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindHasManyResponse() ```ts static normalizeFindHasManyResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:353](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L353) Called by the default normalizeResponse implementation when the type of request is `findHasMany` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindManyResponse() ```ts static normalizeFindManyResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:370](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L370) Called by the default normalizeResponse implementation when the type of request is `findMany` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindRecordResponse() ```ts static normalizeFindRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:285](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L285) Called by the default normalizeResponse implementation when the type of request is `findRecord` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeQueryRecordResponse() ```ts static normalizeQueryRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:302](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L302) Called by the default normalizeResponse implementation when the type of request is `queryRecord` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeQueryResponse() ```ts static normalizeQueryResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:387](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L387) Called by the default normalizeResponse implementation when the type of request is `query` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeResponse() ```ts static normalizeResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:247](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L247) The `normalizeResponse` method is used to normalize a payload from the server to a JSON-API Document. http://jsonapi.org/format/#document-structure This method delegates to a more specific normalize method based on the `requestType`. To override this method with a custom one, make sure to call `return super.normalizeResponse(store, primaryModelClass, payload, id, requestType)` with your pre-processed data. Here's an example of using `normalizeResponse` manually: ```javascript socket.on('message', function(message) { let data = message.data; let modelClass = store.modelFor(data.modelName); let serializer = store.serializerFor(data.modelName); let normalized = serializer.normalizeSingleResponse(store, modelClass, data, data.id); store.push(normalized); }); ``` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeSaveResponse() ```ts static normalizeSaveResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:455](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L455) normalizeUpdateRecordResponse, normalizeCreateRecordResponse and normalizeDeleteRecordResponse delegate to this method by default. #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeSingleResponse() ```ts static normalizeSingleResponse( store, primaryModelClass, payload, id, requestType): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:472](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L472) normalizeQueryResponse and normalizeFindRecordResponse delegate to this method by default. #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeUpdateRecordResponse() ```ts static normalizeUpdateRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:438](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L438) Called by the default normalizeResponse implementation when the type of request is `updateRecord` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### proto() ```ts readonly static proto(): CoreObject; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:649 #### Returns `CoreObject` *** ### reopenClass() ```ts readonly static reopenClass(this, ...mixins): C; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:595 Augments a constructor's own properties and functions: ```javascript import EmberObject from '@ember/object'; const MyObject = EmberObject.extend({ name: 'an object' }); MyObject.reopenClass({ canBuild: false }); MyObject.canBuild; // false o = MyObject.create(); ``` In other words, this creates static properties and functions for the class. These are only available on the class and not on any instance of that class. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ name: '', sayHello() { alert(`Hello. My name is ${this.get('name')}`); } }); Person.reopenClass({ species: 'Homo sapiens', createPerson(name) { return Person.create({ name }); } }); let tom = Person.create({ name: 'Tom Dale' }); let yehuda = Person.createPerson('Yehuda Katz'); tom.sayHello(); // "Hello. My name is Tom Dale" yehuda.sayHello(); // "Hello. My name is Yehuda Katz" alert(Person.species); // "Homo sapiens" ``` Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` variables. They are only valid on `Person`. To add functions and properties to instances of a constructor by extending the constructor's prototype see `reopen` #### Type Parameters ##### C `C` *extends* *typeof* `CoreObject` #### Parameters ##### this `C` ##### mixins ...(`Record`<`string`, `unknown`> | `Mixin`)\[] #### Returns `C` #### Method reopenClass #### For @ember/object #### Static *** ### serialize() ```ts static serialize(snapshot, options): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1080](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1080) Called when a record is saved in order to convert the record into JSON. By default, it creates a JSON object with a key for each attribute and belongsTo relationship. For example, consider this model: ```js [app/models/comment.js] import Model, { attr, belongsTo } from '@ember-data/model'; export default class CommentModel extends Model { @attr title; @attr body; @belongsTo('user') author; } ``` The default serialization would create a JSON object like: ```javascript { "title": "Rails is unagi", "body": "Rails? Omakase? O_O", "author": 12 } ``` By default, attributes are passed through as-is, unless you specified an attribute type (`attr('date')`). If you specify a transform, the JavaScript value will be serialized when inserted into the JSON hash. By default, belongs-to relationships are converted into IDs when inserted into the JSON hash. ## IDs `serialize` takes an options hash with a single option: `includeId`. If this option is `true`, `serialize` will, by default include the ID in the JSON object it builds. The adapter passes in `includeId: true` when serializing a record for `createRecord`, but not for `updateRecord`. ## Customization Your server may expect a different JSON format than the built-in serialization format. In that case, you can implement `serialize` yourself and return a JSON hash of your choosing. ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { serialize(snapshot, options) { let json = { POST_TTL: snapshot.attr('title'), POST_BDY: snapshot.attr('body'), POST_CMS: snapshot.hasMany('comments', { ids: true }) }; if (options.includeId) { json.POST_ID_ = snapshot.id; } return json; } } ``` ## Customizing an App-Wide Serializer If you want to define a serializer for your entire application, you'll probably want to use `eachAttribute` and `eachRelationship` on the record. ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; import { singularize } from '/utils/string-utils'; export default class ApplicationSerializer extends JSONSerializer { serialize(snapshot, options) { let json = {}; snapshot.eachAttribute((name) => { json[serverAttributeName(name)] = snapshot.attr(name); }); snapshot.eachRelationship((name, relationship) => { if (relationship.kind === 'hasMany') { json[serverHasManyName(name)] = snapshot.hasMany(name, { ids: true }); } }); if (options.includeId) { json.ID_ = snapshot.id; } return json; } } function serverAttributeName(attribute) { return attribute.underscore().toUpperCase(); } function serverHasManyName(name) { return serverAttributeName(singularize(name)) + "_IDS"; } ``` This serializer will generate JSON that looks like this: ```javascript { "TITLE": "Rails is omakase", "BODY": "Yep. Omakase.", "COMMENT_IDS": [ "1", "2", "3" ] } ``` ## Tweaking the Default JSON If you just want to do some small tweaks on the default JSON, you can call `super.serialize` first and make the tweaks on the returned JSON. ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { serialize(snapshot, options) { let json = super.serialize(...arguments); json.subject = json.title; delete json.title; return json; } } ``` #### Parameters ##### snapshot `Snapshot` ##### options `any` #### Returns `any` json *** ### serializeAttribute() ```ts static serializeAttribute( snapshot, json, key, attribute): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1162](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1162) `serializeAttribute` can be used to customize how `attr` properties are serialized For example if you wanted to ensure all your attributes were always serialized as properties on an `attributes` object you could write: ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class ApplicationSerializer extends JSONSerializer { serializeAttribute(snapshot, json, key, attributes) { json.attributes = json.attributes || {}; super.serializeAttribute(snapshot, json.attributes, key, attributes); } } ``` #### Parameters ##### snapshot `Snapshot` ##### json `any` ##### key `string` ##### attribute `any` #### Returns `void` *** ### serializeBelongsTo() ```ts static serializeBelongsTo( snapshot, json, relationship): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1210](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1210) `serializeBelongsTo` can be used to customize how `belongsTo` properties are serialized. Example ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { serializeBelongsTo(snapshot, json, relationship) { let key = relationship.name; let belongsTo = snapshot.belongsTo(key); key = this.keyForRelationship ? this.keyForRelationship(key, "belongsTo", "serialize") : key; json[key] = !belongsTo ? null : belongsTo.record.toJSON(); } } ``` #### Parameters ##### snapshot `Snapshot` ##### json `any` ##### relationship `any` #### Returns `void` *** ### serializeHasMany() ```ts static serializeHasMany( snapshot, json, relationship): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1263](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1263) `serializeHasMany` can be used to customize how `hasMany` properties are serialized. Example ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { serializeHasMany(snapshot, json, relationship) { let key = relationship.name; if (key === 'comments') { return; } else { super.serializeHasMany(...arguments); } } } ``` #### Parameters ##### snapshot `Snapshot` ##### json `any` ##### relationship `any` #### Returns `void` *** ### serializeIntoHash() ```ts static serializeIntoHash( hash, typeClass, snapshot, options): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1133](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1133) You can use this method to customize how a serialized record is added to the complete JSON hash to be sent to the server. By default the JSON Serializer does not namespace the payload and just sends the raw serialized JSON object. If your server expects namespaced keys, you should consider using the RESTSerializer. Otherwise you can override this method to customize how the record is added to the hash. The hash property should be modified by reference. For example, your server may expect underscored root objects. ```js [app/serializers/application.js] import RESTSerializer from '@ember-data/serializer/rest'; import { underscoren} from '/utils/string-utils'; export default class ApplicationSerializer extends RESTSerializer { serializeIntoHash(data, type, snapshot, options) { let root = underscore(type.modelName); data[root] = this.serialize(snapshot, options); } } ``` #### Parameters ##### hash `any` ##### typeClass `Model` ##### snapshot `Snapshot` ##### options `any` #### Returns `void` *** ### serializePolymorphicType() ```ts static serializePolymorphicType(): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1315](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1315) You can use this method to customize how polymorphic objects are serialized. Objects are considered to be polymorphic if `{ polymorphic: true }` is pass as the second argument to the `belongsTo` function. Example ```js [app/serializers/comment.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class CommentSerializer extends JSONSerializer { serializePolymorphicType(snapshot, json, relationship) { let key = relationship.name; let belongsTo = snapshot.belongsTo(key); key = this.keyForAttribute ? this.keyForAttribute(key, 'serialize') : key; if (!belongsTo) { json[key + '_type'] = null; } else { json[key + '_type'] = belongsTo.modelName; } } } ``` #### Returns `void` *** ### shouldSerializeHasMany() ```ts static shouldSerializeHasMany( snapshot, key, relationship): boolean; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:918](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L918) Check if the given hasMany relationship should be serialized By default only many-to-many and many-to-none relationships are serialized. This could be configured per relationship by Serializer's `attrs` object. #### Parameters ##### snapshot `Snapshot` ##### key `string` ##### relationship `RelationshipSchema` #### Returns `boolean` true if the hasMany relationship should be serialized *** ### toString() ```ts readonly static toString(): string; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:650 #### Returns `string` *** ### willReopen() ```ts readonly static willReopen(): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:533 #### Returns `void` --- --- url: /api/@warp-drive/legacy/serializer/rest/classes/EmbeddedRecordsMixin.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [serializer/rest](../index.md) / EmbeddedRecordsMixin Defined in: [warp-drive-packages/legacy/src/serializer/-private/embedded-records-mixin.js:100](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/embedded-records-mixin.js#L100) ## Using Embedded Records `EmbeddedRecordsMixin` supports serializing embedded records. To set up embedded records, include the mixin when extending a serializer, then define and configure embedded (model) relationships. Note that embedded records will serialize with the serializer for their model instead of the serializer in which they are defined. Note also that this mixin does not work with JSONAPISerializer because the JSON:API specification does not describe how to format embedded resources. Below is an example of a per-type serializer (`post` type). ```js [app/serializers/post.js] import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest'; export default class PostSerializer extends RESTSerializer.extend(EmbeddedRecordsMixin) { attrs = { author: { embedded: 'always' }, comments: { serialize: 'ids' } } } ``` Note that this use of `{ embedded: 'always' }` is unrelated to the `{ embedded: 'always' }` that is defined as an option on `attr` as part of defining a model while working with the `ActiveModelSerializer`. Nevertheless, using `{ embedded: 'always' }` as an option to `attr` is not a valid way to set up embedded records. The `attrs` option for a resource `{ embedded: 'always' }` is shorthand for: ```js { serialize: 'records', deserialize: 'records' } ``` ### Configuring Attrs A resource's `attrs` option may be set to use `ids`, `records` or false for the `serialize` and `deserialize` settings. The `attrs` property can be set on the `ApplicationSerializer` or a per-type serializer. In the case where embedded JSON is expected while extracting a payload (reading) the setting is `deserialize: 'records'`, there is no need to use `ids` when extracting as that is the default behaviour without this mixin if you are using the vanilla `EmbeddedRecordsMixin`. Likewise, to embed JSON in the payload while serializing `serialize: 'records'` is the setting to use. There is an option of not embedding JSON in the serialized payload by using `serialize: 'ids'`. If you do not want the relationship sent at all, you can use `serialize: false`. ### EmbeddedRecordsMixin defaults If you do not overwrite `attrs` for a specific relationship, the `EmbeddedRecordsMixin` will behave in the following way: BelongsTo: `{ serialize: 'id', deserialize: 'id' }` HasMany: `{ serialize: false, deserialize: 'ids' }` ### Model Relationships Embedded records must have a model defined to be extracted and serialized. Note that when defining any relationships on your model such as `belongsTo` and `hasMany`, you should not both specify `async: true` and also indicate through the serializer's `attrs` attribute that the related model should be embedded for deserialization. If a model is declared embedded for deserialization (`embedded: 'always'` or `deserialize: 'records'`), then do not use `async: true`. To successfully extract and serialize embedded records the model relationships must be set up correctly. See the [defining relationships](https://guides.emberjs.com/current/models/relationships) section of the **Defining Models** guide page. Records without an `id` property are not considered embedded records, model instances must have an `id` property to be used with Ember Data. ### Example JSON payloads, Models and Serializers **When customizing a serializer it is important to grok what the customizations are. Please read the docs for the methods this mixin provides, in case you need to modify it to fit your specific needs.** For example, review the docs for each method of this mixin: * [normalize](/ember-data/release/classes/EmbeddedRecordsMixin/methods/normalize?anchor=normalize) * [serializeBelongsTo](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeBelongsTo?anchor=serializeBelongsTo) * [serializeHasMany](/ember-data/release/classes/EmbeddedRecordsMixin/methods/serializeHasMany?anchor=serializeHasMany) EmbeddedRecordsMixin ## Properties ### \[INIT\_FACTORY]? ```ts static optional [INIT_FACTORY]: null; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/mixin.d.ts:116 --- --- url: /api/@warp-drive/legacy/serializer/rest/classes/RESTSerializer.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [serializer/rest](../index.md) / RESTSerializer Defined in: [warp-drive-packages/legacy/src/serializer/rest.js:64](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/rest.js#L64) Normally, applications will use the `RESTSerializer` by implementing the `normalize` method. This allows you to do whatever kind of munging you need and is especially useful if your server is inconsistent and you need to do munging differently for many different kinds of responses. See the `normalize` documentation for more information. ## Across the Board Normalization There are also a number of hooks that you might find useful to define across-the-board rules for your payload. These rules will be useful if your server is consistent, or if you're building an adapter for an infrastructure service, like Firebase, and want to encode service conventions. For example, if all of your keys are underscored and all-caps, but otherwise consistent with the names you use in your models, you can implement across-the-board rules for how to convert an attribute name in your model to a key in your JSON. ```js [app/serializers/application.js] import { RESTSerializer } from '@warp-drive/legacy/serializer/rest'; import { underscore } from '/utils/string-utils'; export default class ApplicationSerializer extends RESTSerializer { keyForAttribute(attr, method) { return underscore(attr).toUpperCase(); } } ``` You can also implement `keyForRelationship`, which takes the name of the relationship as the first parameter, the kind of relationship (`hasMany` or `belongsTo`) as the second parameter, and the method (`serialize` or `deserialize`) as the third parameter. RESTSerializer ## Constructors ### Constructor ```ts new RESTSerializer(owner?): RESTSerializer; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:8 #### Parameters ##### owner? `Owner` #### Returns `RESTSerializer` ## Properties ### concatenatedProperties? ```ts optional concatenatedProperties: string | string[]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:655 *** ### mergedProperties? ```ts optional mergedProperties: unknown[]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:656 *** ### store ```ts store: default; ``` Defined in: [warp-drive-packages/legacy/src/serializer.ts:141](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer.ts#L141) *** ### \_lazyInjections()? ```ts readonly static optional _lazyInjections: () => void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:654 #### Returns `void` *** ### \_onLookup()? ```ts readonly static optional _onLookup: (debugContainerKey) => void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:653 #### Parameters ##### debugContainerKey `string` #### Returns `void` *** ### \[INIT\_FACTORY]? ```ts readonly static optional [INIT_FACTORY]: null; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/mixin.d.ts:116 *** ### isClass ```ts readonly static isClass: boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:651 *** ### isMethod ```ts readonly static isMethod: boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:652 *** ### mergedProperties ```ts readonly static mergedProperties: any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:182](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L182) The `attrs` object can be used to declare a simple mapping between property names on `Model` records and payload keys in the serialized JSON object representing the record. An object with the property `key` can also be used to designate the attribute's key on the response payload. Example ```js [app/models/person.js] import Model, { attr } from '@ember-data/model'; export default class PersonModel extends Model { @attr('string') firstName; @attr('string') lastName; @attr('string') occupation; @attr('boolean') admin; } ``` ```js [app/serializers/person.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PersonSerializer extends JSONSerializer { attrs = { admin: 'is_admin', occupation: { key: 'career' } } } ``` You can also remove attributes and relationships by setting the `serialize` key to `false` in your mapping object. Example ```js [app/serializers/person.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { attrs = { admin: { serialize: false }, occupation: { key: 'career' } } } ``` When serialized: ```javascript { "firstName": "Harry", "lastName": "Houdini", "career": "magician" } ``` Note that the `admin` is now not included in the payload. Setting `serialize` to `true` enforces serialization for hasMany relationships even if it's neither a many-to-many nor many-to-none relationship. *** ### primaryKey ```ts readonly static primaryKey: string = 'id'; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:113](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L113) The `primaryKey` is used when serializing and deserializing data. Ember Data always uses the `id` property to store the id of the record. The external source may not always follow this convention. In these cases it is useful to override the `primaryKey` property to match the `primaryKey` of your external store. Example ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class ApplicationSerializer extends JSONSerializer { primaryKey = '_id' } ``` #### Default ```ts 'id' ``` *** ### PrototypeMixin ```ts static PrototypeMixin: any; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:647 *** ### superclass ```ts static superclass: any; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:648 ## Accessors ### \_debugContainerKey #### Get Signature ```ts get _debugContainerKey(): false | `${string}:${string}`; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/index.d.ts:34 ##### Returns `false` | `` `${string}:${string}` `` *** ### isDestroyed #### Get Signature ```ts get isDestroyed(): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:272 Destroyed object property flag. if this property is `true` the observers and bindings were already removed by the effect of calling the `destroy()` method. ##### Default ```ts false @public ``` ##### Returns `boolean` #### Set Signature ```ts set isDestroyed(_value): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:273 ##### Parameters ###### \_value `boolean` ##### Returns `void` *** ### isDestroying #### Get Signature ```ts get isDestroying(): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:284 Destruction scheduled flag. The `destroy()` method has been called. The object stays intact until the end of the run loop at which point the `isDestroyed` flag is set. ##### Default ```ts false @public ``` ##### Returns `boolean` #### Set Signature ```ts set isDestroying(_value): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:285 ##### Parameters ###### \_value `boolean` ##### Returns `void` ## Methods ### addObserver() #### Call Signature ```ts addObserver( key, target, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:333 Adds an observer on a property. This is the core method used to register an observer for a property. Once you call this method, any time the key's value is set, your observer will be notified. Note that the observers are triggered any time the value is set, regardless of whether it has actually changed. Your observer should be prepared to handle that. There are two common invocation patterns for `.addObserver()`: * Passing two arguments: * the name of the property to observe (as a string) * the function to invoke (an actual function) * Passing three arguments: * the name of the property to observe (as a string) * the target object (will be used to look up and invoke a function on) * the name of the function to invoke on the target object (as a string). ```app/components/my-component.js import Component from '@ember/component'; export default Component.extend({ init() { this._super(...arguments); // the following are equivalent: // using three arguments this.addObserver('foo', this, 'fooDidChange'); // using two arguments this.addObserver('foo', (...args) => { this.fooDidChange(...args); }); }, fooDidChange() { // your custom logic code } }); ``` ### Observer Methods Observer methods have the following signature: ```app/components/my-component.js import Component from '@ember/component'; export default Component.extend({ init() { this._super(...arguments); this.addObserver('foo', this, 'fooDidChange'); }, fooDidChange(sender, key, value, rev) { // your code } }); ``` The `sender` is the object that changed. The `key` is the property that changes. The `value` property is currently reserved and unused. The `rev` is the last property revision of the object when it changed, which you can use to detect if the key value has really changed or not. Usually you will not need the value or revision parameters at the end. In this case, it is common to write observer methods that take only a sender and key value as parameters or, if you aren't interested in any of these values, to write an observer that has no parameters at all. ##### Type Parameters ###### Target `Target` ##### Parameters ###### key keyof [`Serializer`](../../classes/Serializer.md) The key to observe ###### target `Target` The target object to invoke ###### method `ObserverMethod`<`Target`, [`Serializer`](../../classes/Serializer.md)> The method to invoke ##### Returns `this` ##### Method addObserver #### Call Signature ```ts addObserver(key, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:338 ##### Parameters ###### key keyof [`Serializer`](../../classes/Serializer.md) ###### method `ObserverMethod`<[`Serializer`](../../classes/Serializer.md), [`Serializer`](../../classes/Serializer.md)> ##### Returns `this` *** ### cacheFor() ```ts cacheFor(key): unknown; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:413 Returns the cached value of a computed property, if it exists. This allows you to inspect the value of a computed property without accidentally invoking it if it is intended to be generated lazily. #### Type Parameters ##### K `K` *extends* keyof [`Serializer`](../../classes/Serializer.md) #### Parameters ##### key `K` #### Returns `unknown` The cached value of the computed property, if any #### Method cacheFor *** ### decrementProperty() ```ts decrementProperty(keyName, decrement?): number; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:387 Set the value of a property to the current value minus some amount. ```javascript player.decrementProperty('lives'); orc.decrementProperty('health', 5); ``` #### Parameters ##### keyName keyof [`Serializer`](../../classes/Serializer.md) The name of the property to decrement ##### decrement? `number` The amount to decrement by. Defaults to 1 #### Returns `number` The new property value #### Method decrementProperty *** ### destroy() ```ts destroy(): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:300 Destroys an object by setting the `isDestroyed` flag and removing its metadata, which effectively destroys observers and bindings. If you try to set a property on a destroyed object, an exception will be raised. Note that destruction is scheduled for the end of the run loop and does not happen immediately. It will set an isDestroying flag immediately. #### Returns `this` receiver #### Method destroy *** ### get() #### Call Signature ```ts get(key): Serializer[K]; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:121 Retrieves the value of a property from the object. This method is usually similar to using `object[keyName]` or `object.keyName`, however it supports both computed properties and the unknownProperty handler. Because `get` unifies the syntax for accessing all these kinds of properties, it can make many refactorings easier, such as replacing a simple property with a computed property, or vice versa. ### Computed Properties Computed properties are methods defined with the `property` modifier declared at the end, such as: ```javascript import { computed } from '@ember/object'; fullName: computed('firstName', 'lastName', function() { return this.get('firstName') + ' ' + this.get('lastName'); }) ``` When you call `get` on a computed property, the function will be called and the return value will be returned instead of the function itself. ### Unknown Properties Likewise, if you try to call `get` on a property whose value is `undefined`, the `unknownProperty()` method will be called on the object. If this method returns any value other than `undefined`, it will be returned instead. This allows you to implement "virtual" properties that are not defined upfront. ##### Type Parameters ###### K `K` *extends* keyof [`Serializer`](../../classes/Serializer.md) ##### Parameters ###### key `K` ##### Returns [`Serializer`](../../classes/Serializer.md)\[`K`] The property value or undefined. ##### Method get #### Call Signature ```ts get(key): unknown; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:122 ##### Parameters ###### key `string` ##### Returns `unknown` *** ### getProperties() #### Call Signature ```ts getProperties(list): { [Key in keyof Serializer]: Serializer[Key] }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:144 To get the values of multiple properties at once, call `getProperties` with a list of strings or an array: ```javascript record.getProperties('firstName', 'lastName', 'zipCode'); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } ``` is equivalent to: ```javascript record.getProperties(['firstName', 'lastName', 'zipCode']); // { firstName: 'John', lastName: 'Doe', zipCode: '10011' } ``` ##### Type Parameters ###### L `L` *extends* keyof [`Serializer`](../../classes/Serializer.md)\[] ##### Parameters ###### list `L` of keys to get ##### Returns `{ [Key in keyof Serializer]: Serializer[Key] }` ##### Method getProperties #### Call Signature ```ts getProperties(...list): { [Key in keyof Serializer]: Serializer[Key] }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:149 ##### Type Parameters ###### L `L` *extends* keyof [`Serializer`](../../classes/Serializer.md)\[] ##### Parameters ###### list ...`L` ##### Returns `{ [Key in keyof Serializer]: Serializer[Key] }` #### Call Signature ```ts getProperties(list): { [Key in string]: unknown }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:154 ##### Type Parameters ###### L `L` *extends* `string`\[] ##### Parameters ###### list `L` ##### Returns `{ [Key in string]: unknown }` #### Call Signature ```ts getProperties(...list): { [Key in string]: unknown }; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:159 ##### Type Parameters ###### L `L` *extends* `string`\[] ##### Parameters ###### list ...`L` ##### Returns `{ [Key in string]: unknown }` *** ### incrementProperty() ```ts incrementProperty(keyName, increment?): number; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:372 Set the value of a property to the current value plus some amount. ```javascript person.incrementProperty('age'); team.incrementProperty('score', 2); ``` #### Parameters ##### keyName keyof [`Serializer`](../../classes/Serializer.md) The name of the property to increment ##### increment? `number` The amount to increment by. Defaults to 1 #### Returns `number` The new property value #### Method incrementProperty *** ### init() ```ts init(_properties): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:114 An overridable method called when objects are instantiated. By default, does nothing unless it is overridden during class definition. Example: ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ init() { alert(`Name is ${this.get('name')}`); } }); let steve = Person.create({ name: 'Steve' }); // alerts 'Name is Steve'. ``` NOTE: If you do override `init` for a framework class like `Component` from `@ember/component`, be sure to call `this._super(...arguments)` in your `init` declaration! If you don't, Ember may not have an opportunity to do important setup work, and you'll see strange behavior in your application. #### Parameters ##### \_properties `undefined` | `object` #### Returns `void` #### Method init *** ### normalize() ```ts normalize(_typeClass, hash): | EmptyResourceDocument | SingleResourceDocument; ``` Defined in: [warp-drive-packages/legacy/src/serializer.ts:266](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer.ts#L266) The `normalize` method is used to convert a payload received from your external data source into the normalized form `store.push()` expects. You should override this method, munge the hash and return the normalized payload. Example: ```js Serializer.extend({ normalize(modelClass, resourceHash) { let data = { id: resourceHash.id, type: modelClass.modelName, attributes: resourceHash }; return { data: data }; } }) ``` #### Parameters ##### \_typeClass [`ModelSchema`](../../../../core-types/index/interfaces/ModelSchema.md) ##### hash `Record`<`string`, `unknown`> #### Returns | [`EmptyResourceDocument`](../../../../core-types/spec/json-api-raw/type-aliases/EmptyResourceDocument.md) | [`SingleResourceDocument`](../../../../core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md) *** ### notifyPropertyChange() ```ts notifyPropertyChange(keyName): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:249 Convenience method to call `propertyWillChange` and `propertyDidChange` in succession. Notify the observer system that a property has just changed. Sometimes you need to change a value directly or indirectly without actually calling `get()` or `set()` on it. In this case, you can use this method instead. Calling this method will notify all observers that the property has potentially changed value. #### Parameters ##### keyName `string` The property key to be notified about. #### Returns `this` #### Method notifyPropertyChange *** ### removeObserver() #### Call Signature ```ts removeObserver( key, target, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:352 Remove an observer you have previously registered on this object. Pass the same key, target, and method you passed to `addObserver()` and your target will no longer receive notifications. ##### Type Parameters ###### Target `Target` ##### Parameters ###### key keyof [`Serializer`](../../classes/Serializer.md) The key to observe ###### target `Target` The target object to invoke ###### method `ObserverMethod`<`Target`, [`Serializer`](../../classes/Serializer.md)> The method to invoke ##### Returns `this` ##### Method removeObserver #### Call Signature ```ts removeObserver(key, method): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:357 ##### Parameters ###### key keyof [`Serializer`](../../classes/Serializer.md) ###### method `ObserverMethod`<[`Serializer`](../../classes/Serializer.md), [`Serializer`](../../classes/Serializer.md)> ##### Returns `this` *** ### reopen() ```ts reopen(...args): this; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:81 #### Parameters ##### args ...(`Record`<`string`, `unknown`> | `Mixin`)\[] #### Returns `this` *** ### set() #### Call Signature ```ts set(key, value): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:208 Sets the provided key or path to the value. ```javascript record.set("key", value); ``` This method is generally very similar to calling `object["key"] = value` or `object.key = value`, except that it provides support for computed properties, the `setUnknownProperty()` method and property observers. ### Computed Properties If you try to set a value on a key that has a computed property handler defined (see the `get()` method for an example), then `set()` will call that method, passing both the value and key instead of simply changing the value itself. This is useful for those times when you need to implement a property that is composed of one or more member properties. ### Unknown Properties If you try to set a value on a key that is undefined in the target object, then the `setUnknownProperty()` handler will be called instead. This gives you an opportunity to implement complex "virtual" properties that are not predefined on the object. If `setUnknownProperty()` returns undefined, then `set()` will simply set the value on the object. ### Property Observers In addition to changing the property, `set()` will also register a property change with the object. Unless you have placed this call inside of a `beginPropertyChanges()` and `endPropertyChanges(),` any "local" observers (i.e. observer methods declared on the same object), will be called immediately. Any "remote" observers (i.e. observer methods declared on another object) will be placed in a queue and called at a later time in a coalesced manner. ##### Type Parameters ###### K `K` *extends* keyof [`Serializer`](../../classes/Serializer.md) ###### T `T` *extends* | `undefined` | `string` | `boolean` | `unknown`\[] | [`default`](../../../../../@ember-data/store/index/classes/default.md) | `string`\[] | `Owner` | () => `string` | { } | () => `void` | (`_typeClass`, `hash`) => | [`EmptyResourceDocument`](../../../../core-types/spec/json-api-raw/type-aliases/EmptyResourceDocument.md) | [`SingleResourceDocument`](../../../../core-types/spec/json-api-raw/type-aliases/SingleResourceDocument.md) | (...`args`) => `this` | (`_properties`) => `void` | () => `this` | { <`K`> (`key`): [`Serializer`](../../classes/Serializer.md)\[`K`]; (`key`): `unknown`; } | { <`L`> (`list`): `{ [Key in keyof Serializer]: Serializer[Key] }`; <`L`> (...`list`): `{ [Key in keyof Serializer]: Serializer[Key] }`; <`L`> (`list`): `{ [Key in string]: unknown }`; <`L`> (...`list`): `{ [Key in string]: unknown }`; } | { <`K`, `T`> (`key`, `value`): `T`; <`T`> (`key`, `value`): `T`; } | { <`K`, `P`> (`hash`): `P`; <`T`> (`hash`): `T`; } | (`keyName`) => `this` | { <`Target`> (`key`, `target`, `method`): `this`; (`key`, `method`): `this`; } | { <`Target`> (`key`, `target`, `method`): `this`; (`key`, `method`): `this`; } | (`keyName`, `increment?`) => `number` | (`keyName`, `decrement?`) => `number` | (`keyName`) => `boolean` | <`K`>(`key`) => `unknown` ##### Parameters ###### key `K` ###### value `T` The value to set or `null`. ##### Returns `T` The passed value ##### Method set #### Call Signature ```ts set(key, value): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:209 ##### Type Parameters ###### T `T` ##### Parameters ###### key `string` ###### value `T` ##### Returns `T` *** ### setProperties() #### Call Signature ```ts setProperties(hash): P; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:224 Sets a list of properties at once. These properties are set inside a single `beginPropertyChanges` and `endPropertyChanges` batch, so observers will be buffered. ```javascript record.setProperties({ firstName: 'Charles', lastName: 'Jolley' }); ``` ##### Type Parameters ###### K `K` *extends* keyof [`Serializer`](../../classes/Serializer.md) ###### P `P` *extends* `{ [Key in keyof Serializer]: Serializer[Key] }` ##### Parameters ###### hash `P` the hash of keys and values to set ##### Returns `P` The passed in hash ##### Method setProperties #### Call Signature ```ts setProperties(hash): T; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:232 ##### Type Parameters ###### T `T` *extends* `Record`<`string`, `unknown`> ##### Parameters ###### hash `T` ##### Returns `T` *** ### toggleProperty() ```ts toggleProperty(keyName): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/observable.d.ts:401 Set the value of a boolean property to the opposite of its current value. ```javascript starship.toggleProperty('warpDriveEngaged'); ``` #### Parameters ##### keyName keyof [`Serializer`](../../classes/Serializer.md) The name of the property to toggle #### Returns `boolean` The new property value #### Method toggleProperty *** ### toString() ```ts toString(): string; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:347 Returns a string representation which attempts to provide more information than Javascript's `toString` typically does, in a generic way for all Ember objects. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend(); person = Person.create(); person.toString(); //=> "" ``` If the object's class is not defined on an Ember namespace, it will indicate it is a subclass of the registered superclass: ```javascript const Student = Person.extend(); let student = Student.create(); student.toString(); //=> "<(subclass of Person):ember1025>" ``` If the method `toStringExtension` is defined, its return value will be included in the output. ```javascript const Teacher = Person.extend({ toStringExtension() { return this.get('fullName'); } }); teacher = Teacher.create(); teacher.toString(); //=> "" ``` #### Returns `string` string representation #### Method toString *** ### willDestroy() ```ts willDestroy(): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:307 Override to implement teardown. #### Returns `void` #### Method willDestroy *** ### \_normalizePolymorphicRecord() ```ts static _normalizePolymorphicRecord( store, hash, prop, primaryModelClass, primarySerializer): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/rest.js:194](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/rest.js#L194) #### Parameters ##### store `any` ##### hash `any` ##### prop `any` ##### primaryModelClass `any` ##### primarySerializer `any` #### Returns `any` *** ### create() #### Call Signature ```ts readonly static create(this): InstanceType; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:487 Creates an instance of a class. Accepts either no arguments, or an object containing values to initialize the newly instantiated object with. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ helloWorld() { alert(`Hi, my name is ${this.get('name')}`); } }); let tom = Person.create({ name: 'Tom Dale' }); tom.helloWorld(); // alerts "Hi, my name is Tom Dale". ``` `create` will call the `init` function if defined during `AnyObject.extend` If no arguments are passed to `create`, it will not set values to the new instance during initialization: ```javascript let noName = Person.create(); noName.helloWorld(); // alerts undefined ``` NOTE: For performance reasons, you cannot declare methods or computed properties during `create`. You should instead declare methods and computed properties when using `extend`. ##### Type Parameters ###### C `C` *extends* *typeof* `CoreObject` ##### Parameters ###### this `C` ##### Returns `InstanceType`<`C`> ##### Method create ##### For @ember/object ##### Static #### Call Signature ```ts readonly static create(this, ...args): InstanceType & MergeArray; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:488 Creates an instance of a class. Accepts either no arguments, or an object containing values to initialize the newly instantiated object with. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ helloWorld() { alert(`Hi, my name is ${this.get('name')}`); } }); let tom = Person.create({ name: 'Tom Dale' }); tom.helloWorld(); // alerts "Hi, my name is Tom Dale". ``` `create` will call the `init` function if defined during `AnyObject.extend` If no arguments are passed to `create`, it will not set values to the new instance during initialization: ```javascript let noName = Person.create(); noName.helloWorld(); // alerts undefined ``` NOTE: For performance reasons, you cannot declare methods or computed properties during `create`. You should instead declare methods and computed properties when using `extend`. ##### Type Parameters ###### C `C` *extends* *typeof* `CoreObject` ###### I `I` *extends* `CoreObject` ###### K `K` *extends* `string` | `number` | `symbol` ###### Args `Args` *extends* `Partial`<{ \[Key in string | number | symbol]: I\[Key] }>\[] ##### Parameters ###### this `C` ###### args ...`Args` ##### Returns `InstanceType`<`C`> & `MergeArray`<`Args`> ##### Method create ##### For @ember/object ##### Static *** ### detectInstance() ```ts readonly static detectInstance(obj): boolean; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:600 #### Parameters ##### obj `unknown` #### Returns `boolean` *** ### extend() ```ts readonly static extend(this, ...mixins?): Readonly & EmberClassConstructor & MergeArray; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:442 Creates a new subclass. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ say(thing) { alert(thing); } }); ``` This defines a new subclass of EmberObject: `Person`. It contains one method: `say()`. You can also create a subclass from any existing class by calling its `extend()` method. For example, you might want to create a subclass of Ember's built-in `Component` class: ```javascript import Component from '@ember/component'; const PersonComponent = Component.extend({ tagName: 'li', classNameBindings: ['isAdministrator'] }); ``` When defining a subclass, you can override methods but still access the implementation of your parent class by calling the special `_super()` method: ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ say(thing) { let name = this.get('name'); alert(`${name} says: ${thing}`); } }); const Soldier = Person.extend({ say(thing) { this._super(`${thing}, sir!`); }, march(numberOfHours) { alert(`${this.get('name')} marches for ${numberOfHours} hours.`); } }); let yehuda = Soldier.create({ name: 'Yehuda Katz' }); yehuda.say('Yes'); // alerts "Yehuda Katz says: Yes, sir!" ``` The `create()` on line #17 creates an *instance* of the `Soldier` class. The `extend()` on line #8 creates a *subclass* of `Person`. Any instance of the `Person` class will *not* have the `march()` method. You can also pass `Mixin` classes to add additional properties to the subclass. ```javascript import EmberObject from '@ember/object'; import Mixin from '@ember/object/mixin'; const Person = EmberObject.extend({ say(thing) { alert(`${this.get('name')} says: ${thing}`); } }); const SingingMixin = Mixin.create({ sing(thing) { alert(`${this.get('name')} sings: la la la ${thing}`); } }); const BroadwayStar = Person.extend(SingingMixin, { dance() { alert(`${this.get('name')} dances: tap tap tap tap `); } }); ``` The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`. #### Type Parameters ##### Statics `Statics` ##### Instance `Instance` ##### M `M` *extends* `unknown`\[] #### Parameters ##### this `Statics` & `EmberClassConstructor`<`Instance`> ##### mixins? ...`M` One or more Mixin classes #### Returns `Readonly`<`Statics`> & `EmberClassConstructor`<`Instance`> & `MergeArray`<`M`> #### Method extend #### Static #### For @ember/object *** ### extractAttributes() ```ts readonly static extractAttributes(modelClass, resourceHash): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:632](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L632) Returns the resource's attributes formatted as a JSON-API "attributes object". http://jsonapi.org/format/#document-resource-object-attributes #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `any` *** ### extractErrors() ```ts readonly static extractErrors( store, typeClass, payload, id): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1436](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1436) `extractErrors` is used to extract model errors when a call to `Model#save` fails with an `InvalidError`. By default Ember Data expects error information to be located on the `errors` property of the payload object. This serializer expects this `errors` object to be an Array similar to the following, compliant with the https://jsonapi.org/format/#errors specification: ```js { "errors": [ { "detail": "This username is already taken!", "source": { "pointer": "data/attributes/username" } }, { "detail": "Doesn't look like a valid email.", "source": { "pointer": "data/attributes/email" } } ] } ``` The key `detail` provides a textual description of the problem. Alternatively, the key `title` can be used for the same purpose. The nested keys `source.pointer` detail which specific element of the request data was invalid. Note that JSON-API also allows for object-level errors to be placed in an object with pointer `data`, signifying that the problem cannot be traced to a specific attribute: ```javascript { "errors": [ { "detail": "Some generic non property error message", "source": { "pointer": "data" } } ] } ``` When turn into a `Errors` object, you can read these errors through the property `base`: ```handlebars {{#each @model.errors.base as |error|}}
{{error.message}}
{{/each}} ``` Example of alternative implementation, overriding the default behavior to deal with a different format of errors: ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { extractErrors(store, typeClass, payload, id) { if (payload && typeof payload === 'object' && payload._problems) { payload = payload._problems; this.normalizeErrors(typeClass, payload); } return payload; } } ``` #### Parameters ##### store `Store` ##### typeClass `Model` ##### payload `any` ##### id `string` | `number` #### Returns `any` json The deserialized errors *** ### extractId() ```ts readonly static extractId(modelClass, resourceHash): string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:616](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L616) Returns the resource's ID. #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `string` *** ### extractMeta() ```ts readonly static extractMeta( store, modelClass, payload): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1343](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1343) `extractMeta` is used to deserialize any meta information in the adapter payload. By default Ember Data expects meta information to be located on the `meta` property of the payload object. Example ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { extractMeta(store, typeClass, payload) { if (payload && payload.hasOwnProperty('_pagination')) { let meta = payload._pagination; delete payload._pagination; return meta; } } } ``` #### Parameters ##### store `Store` ##### modelClass `Model` ##### payload `any` #### Returns `any` *** ### extractPolymorphicRelationship() Returns a polymorphic relationship formatted as a JSON-API "relationship object". http://jsonapi.org/format/#document-resource-object-relationships `relationshipOptions` is a hash which contains more information about the polymorphic relationship which should be extracted: * `resourceHash` complete hash of the resource the relationship should be extracted from * `relationshipKey` key under which the value for the relationship is extracted from the resourceHash * `relationshipMeta` meta information about the relationship #### Param #### Param #### Param #### Call Signature ```ts static extractPolymorphicRelationship( relationshipModelName, relationshipHash, relationshipOptions): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:699](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L699) ##### Parameters ###### relationshipModelName `any` ###### relationshipHash `any` ###### relationshipOptions `any` ##### Returns `any` #### Call Signature ```ts static extractPolymorphicRelationship( relationshipType, relationshipHash, relationshipOptions, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/rest.js:750](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/rest.js#L750) You can use this method to customize how a polymorphic relationship should be extracted. ##### Parameters ###### relationshipType `any` ###### relationshipHash `any` ###### relationshipOptions `any` ###### args ...`any` ##### Returns `any` ##### Param ##### Param ##### Param *** ### extractRelationship() ```ts readonly static extractRelationship(relationshipModelName, relationshipHash): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:656](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L656) Returns a relationship formatted as a JSON-API "relationship object". http://jsonapi.org/format/#document-resource-object-relationships #### Parameters ##### relationshipModelName `any` ##### relationshipHash `any` #### Returns `any` *** ### extractRelationships() ```ts readonly static extractRelationships(modelClass, resourceHash): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:713](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L713) Returns the resource's relationships formatted as a JSON-API "relationships object". http://jsonapi.org/format/#document-resource-object-relationships #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `any` *** ### isPrimaryType() ```ts static isPrimaryType( store, modelName, primaryModelClass): boolean; ``` Defined in: [warp-drive-packages/legacy/src/serializer/rest.js:352](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/rest.js#L352) #### Parameters ##### store `any` ##### modelName `any` ##### primaryModelClass `any` #### Returns `boolean` *** ### keyForAttribute() ```ts readonly static keyForAttribute(key, method): string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1507](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1507) `keyForAttribute` can be used to define rules for how to convert an attribute name in your model to a key in your JSON. Example ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; import { underscore } from '/utils/string-utils'; export default class ApplicationSerializer extends JSONSerializer { keyForAttribute(attr, method) { return underscore(attr).toUpperCase(); } } ``` #### Parameters ##### key `string` ##### method `string` #### Returns `string` normalized key *** ### keyForLink() ```ts readonly static keyForLink(key, kind): string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1548](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1548) `keyForLink` can be used to define a custom key when deserializing link properties. #### Parameters ##### key `string` ##### kind `string` `belongsTo` or `hasMany` #### Returns `string` normalized key *** ### keyForPolymorphicType() ```ts static keyForPolymorphicType( key, typeClass, method): string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/rest.js:90](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/rest.js#L90) `keyForPolymorphicType` can be used to define a custom key when serializing and deserializing a polymorphic type. By default, the returned key is `${key}Type`. Example ```js [app/serializers/post.js] import { RESTSerializer } from '@warp-drive/legacy/serializer/rest'; export default class ApplicationSerializer extends RESTSerializer { keyForPolymorphicType(key, relationship) { let relationshipKey = this.keyForRelationship(key); return 'type-' + relationshipKey; } } ``` #### Parameters ##### key `string` ##### typeClass `string` ##### method `string` #### Returns `string` normalized key *** ### keyForRelationship() ```ts readonly static keyForRelationship( key, typeClass, method): string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1535](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1535) `keyForRelationship` can be used to define a custom key when serializing and deserializing relationship properties. By default `JSONSerializer` does not provide an implementation of this method. Example ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; import { underscore } from '/utils/string-utils'; export default class PostSerializer extends JSONSerializer { keyForRelationship(key, relationship, method) { return `rel_${underscore(key)}`; } } ``` #### Parameters ##### key `string` ##### typeClass `string` ##### method `string` #### Returns `string` normalized key *** ### modelNameFromPayloadKey() ```ts static modelNameFromPayloadKey(key): string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:781](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L781) Dasherizes the model name in the payload #### Parameters ##### key `string` #### Returns `string` the model's modelName *** ### normalize() ```ts readonly static normalize(modelClass, resourceHash): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:582](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L582) Normalizes a part of the JSON payload returned by the server. You should override this method, munge the hash and call super if you have generic normalization to do. It takes the type of the record that is being normalized (as a Model class), the property where the hash was originally found, and the hash to normalize. You can use this method, for example, to normalize underscored keys to camelized or other general-purpose normalizations. Example ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; import { underscore } from '/utils/string-utils'; import { get } from '@ember/object'; export default class ApplicationSerializer extends JSONSerializer { normalize(typeClass, hash) { let fields = typeClass.fields; fields.forEach(function(type, field) { let payloadField = underscore(field); if (field === payloadField) { return; } hash[field] = hash[payloadField]; delete hash[payloadField]; }); return super.normalize(...arguments); } } ``` #### Parameters ##### modelClass `any` ##### resourceHash `any` #### Returns `any` *** ### normalizeArrayResponse() ```ts readonly static normalizeArrayResponse( store, primaryModelClass, payload, id, requestType): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:489](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L489) normalizeQueryResponse, normalizeFindManyResponse, and normalizeFindHasManyResponse delegate to this method by default. #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeCreateRecordResponse() ```ts readonly static normalizeCreateRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:404](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L404) Called by the default normalizeResponse implementation when the type of request is `createRecord` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeDeleteRecordResponse() ```ts readonly static normalizeDeleteRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:421](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L421) Called by the default normalizeResponse implementation when the type of request is `deleteRecord` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindAllResponse() ```ts readonly static normalizeFindAllResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:319](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L319) Called by the default normalizeResponse implementation when the type of request is `findAll` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindBelongsToResponse() ```ts readonly static normalizeFindBelongsToResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:336](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L336) Called by the default normalizeResponse implementation when the type of request is `findBelongsTo` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindHasManyResponse() ```ts readonly static normalizeFindHasManyResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:353](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L353) Called by the default normalizeResponse implementation when the type of request is `findHasMany` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindManyResponse() ```ts readonly static normalizeFindManyResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:370](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L370) Called by the default normalizeResponse implementation when the type of request is `findMany` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeFindRecordResponse() ```ts readonly static normalizeFindRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:285](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L285) Called by the default normalizeResponse implementation when the type of request is `findRecord` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeQueryRecordResponse() ```ts readonly static normalizeQueryRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:302](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L302) Called by the default normalizeResponse implementation when the type of request is `queryRecord` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeQueryResponse() ```ts readonly static normalizeQueryResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:387](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L387) Called by the default normalizeResponse implementation when the type of request is `query` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeResponse() ```ts readonly static normalizeResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:247](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L247) The `normalizeResponse` method is used to normalize a payload from the server to a JSON-API Document. http://jsonapi.org/format/#document-structure This method delegates to a more specific normalize method based on the `requestType`. To override this method with a custom one, make sure to call `return super.normalizeResponse(store, primaryModelClass, payload, id, requestType)` with your pre-processed data. Here's an example of using `normalizeResponse` manually: ```javascript socket.on('message', function(message) { let data = message.data; let modelClass = store.modelFor(data.modelName); let serializer = store.serializerFor(data.modelName); let normalized = serializer.normalizeSingleResponse(store, modelClass, data, data.id); store.push(normalized); }); ``` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeSaveResponse() ```ts readonly static normalizeSaveResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:455](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L455) normalizeUpdateRecordResponse, normalizeCreateRecordResponse and normalizeDeleteRecordResponse delegate to this method by default. #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeSingleResponse() ```ts readonly static normalizeSingleResponse( store, primaryModelClass, payload, id, requestType): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:472](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L472) normalizeQueryResponse and normalizeFindRecordResponse delegate to this method by default. #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### normalizeUpdateRecordResponse() ```ts readonly static normalizeUpdateRecordResponse( store, primaryModelClass, payload, id, requestType, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:438](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L438) Called by the default normalizeResponse implementation when the type of request is `updateRecord` #### Parameters ##### store `Store` ##### primaryModelClass `Model` ##### payload `any` ##### id `string` | `number` ##### requestType `string` ##### args ...`any` #### Returns `any` JSON-API Document #### Since 1.13.0 *** ### payloadKeyFromModelName() ```ts static payloadKeyFromModelName(modelName): string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/rest.js:714](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/rest.js#L714) You can use `payloadKeyFromModelName` to override the root key for an outgoing request. By default, the RESTSerializer returns a camelized version of the model's name. For a model called TacoParty, its `modelName` would be the string `taco-party`. The RESTSerializer will send it to the server with `tacoParty` as the root key in the JSON payload: ```js { "tacoParty": { "id": "1", "location": "Matthew Beale's House" } } ``` For example, your server may expect dasherized root objects: ```js [app/serializers/application.js] import { RESTSerializer } from '@warp-drive/legacy/serializer/rest'; import { dasherize } from '/utils/string-utils'; export default class ApplicationSerializer extends RESTSerializer { payloadKeyFromModelName(modelName) { return dasherize(modelName); } } ``` Given a `TacoParty` model, calling `save` on it would produce an outgoing request like: ```js { "taco-party": { "id": "1", "location": "Matthew Beale's House" } } ``` #### Parameters ##### modelName `string` #### Returns `string` *** ### proto() ```ts readonly static proto(): CoreObject; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:649 #### Returns `CoreObject` *** ### pushPayload() ```ts static pushPayload(store, payload): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/rest.js:387](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/rest.js#L387) This method allows you to push a payload containing top-level collections of records organized per type. ```js { "posts": [{ "id": "1", "title": "Rails is omakase", "author", "1", "comments": [ "1" ] }], "comments": [{ "id": "1", "body": "FIRST" }], "users": [{ "id": "1", "name": "@d2h" }] } ``` It will first normalize the payload, so you can use this to push in data streaming in from your server structured the same way that fetches and saves are structured. #### Parameters ##### store `Store` ##### payload `any` #### Returns `void` *** ### reopenClass() ```ts readonly static reopenClass(this, ...mixins): C; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:595 Augments a constructor's own properties and functions: ```javascript import EmberObject from '@ember/object'; const MyObject = EmberObject.extend({ name: 'an object' }); MyObject.reopenClass({ canBuild: false }); MyObject.canBuild; // false o = MyObject.create(); ``` In other words, this creates static properties and functions for the class. These are only available on the class and not on any instance of that class. ```javascript import EmberObject from '@ember/object'; const Person = EmberObject.extend({ name: '', sayHello() { alert(`Hello. My name is ${this.get('name')}`); } }); Person.reopenClass({ species: 'Homo sapiens', createPerson(name) { return Person.create({ name }); } }); let tom = Person.create({ name: 'Tom Dale' }); let yehuda = Person.createPerson('Yehuda Katz'); tom.sayHello(); // "Hello. My name is Tom Dale" yehuda.sayHello(); // "Hello. My name is Yehuda Katz" alert(Person.species); // "Homo sapiens" ``` Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda` variables. They are only valid on `Person`. To add functions and properties to instances of a constructor by extending the constructor's prototype see `reopen` #### Type Parameters ##### C `C` *extends* *typeof* `CoreObject` #### Parameters ##### this `C` ##### mixins ...(`Record`<`string`, `unknown`> | `Mixin`)\[] #### Returns `C` #### Method reopenClass #### For @ember/object #### Static *** ### serialize() Called when a record is saved in order to convert the record into JSON. By default, it creates a JSON object with a key for each attribute and belongsTo relationship. For example, consider this model: ```js [app/models/comment.js] import Model, { attr, belongsTo } from '@ember-data/model'; export default class CommentModel extends Model { @attr title; @attr body; @belongsTo('user') author; } ``` The default serialization would create a JSON object like: ```javascript { "title": "Rails is unagi", "body": "Rails? Omakase? O_O", "author": 12 } ``` By default, attributes are passed through as-is, unless you specified an attribute type (`attr('date')`). If you specify a transform, the JavaScript value will be serialized when inserted into the JSON hash. By default, belongs-to relationships are converted into IDs when inserted into the JSON hash. ## IDs `serialize` takes an options hash with a single option: `includeId`. If this option is `true`, `serialize` will, by default include the ID in the JSON object it builds. The adapter passes in `includeId: true` when serializing a record for `createRecord`, but not for `updateRecord`. ## Customization Your server may expect a different JSON format than the built-in serialization format. In that case, you can implement `serialize` yourself and return a JSON hash of your choosing. ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { serialize(snapshot, options) { let json = { POST_TTL: snapshot.attr('title'), POST_BDY: snapshot.attr('body'), POST_CMS: snapshot.hasMany('comments', { ids: true }) }; if (options.includeId) { json.POST_ID_ = snapshot.id; } return json; } } ``` ## Customizing an App-Wide Serializer If you want to define a serializer for your entire application, you'll probably want to use `eachAttribute` and `eachRelationship` on the record. ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; import { singularize } from '/utils/string-utils'; export default class ApplicationSerializer extends JSONSerializer { serialize(snapshot, options) { let json = {}; snapshot.eachAttribute((name) => { json[serverAttributeName(name)] = snapshot.attr(name); }); snapshot.eachRelationship((name, relationship) => { if (relationship.kind === 'hasMany') { json[serverHasManyName(name)] = snapshot.hasMany(name, { ids: true }); } }); if (options.includeId) { json.ID_ = snapshot.id; } return json; } } function serverAttributeName(attribute) { return attribute.underscore().toUpperCase(); } function serverHasManyName(name) { return serverAttributeName(singularize(name)) + "_IDS"; } ``` This serializer will generate JSON that looks like this: ```javascript { "TITLE": "Rails is omakase", "BODY": "Yep. Omakase.", "COMMENT_IDS": [ "1", "2", "3" ] } ``` ## Tweaking the Default JSON If you just want to do some small tweaks on the default JSON, you can call `super.serialize` first and make the tweaks on the returned JSON. ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { serialize(snapshot, options) { let json = super.serialize(...arguments); json.subject = json.title; delete json.title; return json; } } ``` #### Param #### Param #### Call Signature ```ts static serialize(snapshot, options): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1080](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1080) ##### Parameters ###### snapshot `Snapshot` ###### options `any` ##### Returns `any` #### Call Signature ```ts static serialize( snapshot, options, ... args): any; ``` Defined in: [warp-drive-packages/legacy/src/serializer/rest.js:633](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/rest.js#L633) Called when a record is saved in order to convert the record into JSON. By default, it creates a JSON object with a key for each attribute and belongsTo relationship. For example, consider this model: ```js [app/models/comment.js] import Model, { attr, belongsTo } from '@ember-data/model'; export default class Comment extends Model { @attr title @attr body @belongsTo('user') author } ``` The default serialization would create a JSON object like: ```js { "title": "Rails is unagi", "body": "Rails? Omakase? O_O", "author": 12 } ``` By default, attributes are passed through as-is, unless you specified an attribute type (`attr('date')`). If you specify a transform, the JavaScript value will be serialized when inserted into the JSON hash. By default, belongs-to relationships are converted into IDs when inserted into the JSON hash. ## IDs `serialize` takes an options hash with a single option: `includeId`. If this option is `true`, `serialize` will, by default include the ID in the JSON object it builds. The adapter passes in `includeId: true` when serializing a record for `createRecord`, but not for `updateRecord`. ## Customization Your server may expect a different JSON format than the built-in serialization format. In that case, you can implement `serialize` yourself and return a JSON hash of your choosing. ```js [app/serializers/post.js] import { RESTSerializer } from '@warp-drive/legacy/serializer/rest'; export default class ApplicationSerializer extends RESTSerializer { serialize(snapshot, options) { let json = { POST_TTL: snapshot.attr('title'), POST_BDY: snapshot.attr('body'), POST_CMS: snapshot.hasMany('comments', { ids: true }) }; if (options.includeId) { json.POST_ID_ = snapshot.id; } return json; } } ``` ## Customizing an App-Wide Serializer If you want to define a serializer for your entire application, you'll probably want to use `eachAttribute` and `eachRelationship` on the record. ```js [app/serializers/application.js] import { RESTSerializer } from '@warp-drive/legacy/serializer/rest'; import { pluralize } from '/utils/string-utils'; export default class ApplicationSerializer extends RESTSerializer { serialize(snapshot, options) { let json = {}; snapshot.eachAttribute(function(name) { json[serverAttributeName(name)] = snapshot.attr(name); }); snapshot.eachRelationship(function(name, relationship) { if (relationship.kind === 'hasMany') { json[serverHasManyName(name)] = snapshot.hasMany(name, { ids: true }); } }); if (options.includeId) { json.ID_ = snapshot.id; } return json; } } function serverAttributeName(attribute) { return attribute.underscore().toUpperCase(); } function serverHasManyName(name) { return serverAttributeName(singularize(name)) + "_IDS"; } ``` This serializer will generate JSON that looks like this: ```js { "TITLE": "Rails is omakase", "BODY": "Yep. Omakase.", "COMMENT_IDS": [ 1, 2, 3 ] } ``` ## Tweaking the Default JSON If you just want to do some small tweaks on the default JSON, you can call super first and make the tweaks on the returned JSON. ```js [app/serializers/post.js] import { RESTSerializer } from '@warp-drive/legacy/serializer/rest'; export default class ApplicationSerializer extends RESTSerializer { serialize(snapshot, options) { let json = super.serialize(snapshot, options); json.subject = json.title; delete json.title; return json; } } ``` ##### Parameters ###### snapshot `Snapshot` ###### options `any` ###### args ...`any` ##### Returns `any` json ##### Param ##### Param *** ### serializeAttribute() ```ts readonly static serializeAttribute( snapshot, json, key, attribute): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1162](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1162) `serializeAttribute` can be used to customize how `attr` properties are serialized For example if you wanted to ensure all your attributes were always serialized as properties on an `attributes` object you could write: ```js [app/serializers/application.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class ApplicationSerializer extends JSONSerializer { serializeAttribute(snapshot, json, key, attributes) { json.attributes = json.attributes || {}; super.serializeAttribute(snapshot, json.attributes, key, attributes); } } ``` #### Parameters ##### snapshot `Snapshot` ##### json `any` ##### key `string` ##### attribute `any` #### Returns `void` *** ### serializeBelongsTo() ```ts readonly static serializeBelongsTo( snapshot, json, relationship): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1210](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1210) `serializeBelongsTo` can be used to customize how `belongsTo` properties are serialized. Example ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { serializeBelongsTo(snapshot, json, relationship) { let key = relationship.name; let belongsTo = snapshot.belongsTo(key); key = this.keyForRelationship ? this.keyForRelationship(key, "belongsTo", "serialize") : key; json[key] = !belongsTo ? null : belongsTo.record.toJSON(); } } ``` #### Parameters ##### snapshot `Snapshot` ##### json `any` ##### relationship `any` #### Returns `void` *** ### serializeHasMany() ```ts readonly static serializeHasMany( snapshot, json, relationship): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1263](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1263) `serializeHasMany` can be used to customize how `hasMany` properties are serialized. Example ```js [app/serializers/post.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class PostSerializer extends JSONSerializer { serializeHasMany(snapshot, json, relationship) { let key = relationship.name; if (key === 'comments') { return; } else { super.serializeHasMany(...arguments); } } } ``` #### Parameters ##### snapshot `Snapshot` ##### json `any` ##### relationship `any` #### Returns `void` *** ### serializeIntoHash() ```ts static serializeIntoHash( hash, typeClass, snapshot, options): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1133](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1133) You can use this method to customize how a serialized record is added to the complete JSON hash to be sent to the server. By default the JSON Serializer does not namespace the payload and just sends the raw serialized JSON object. If your server expects namespaced keys, you should consider using the RESTSerializer. Otherwise you can override this method to customize how the record is added to the hash. The hash property should be modified by reference. For example, your server may expect underscored root objects. ```js [app/serializers/application.js] import RESTSerializer from '@ember-data/serializer/rest'; import { underscoren} from '/utils/string-utils'; export default class ApplicationSerializer extends RESTSerializer { serializeIntoHash(data, type, snapshot, options) { let root = underscore(type.modelName); data[root] = this.serialize(snapshot, options); } } ``` #### Parameters ##### hash `any` ##### typeClass `Model` ##### snapshot `Snapshot` ##### options `any` #### Returns `void` *** ### serializePolymorphicType() You can use this method to customize how polymorphic objects are serialized. Objects are considered to be polymorphic if `{ polymorphic: true }` is pass as the second argument to the `belongsTo` function. Example ```js [app/serializers/comment.js] import { JSONSerializer } from '@warp-drive/legacy/serializer/json'; export default class CommentSerializer extends JSONSerializer { serializePolymorphicType(snapshot, json, relationship) { let key = relationship.name; let belongsTo = snapshot.belongsTo(key); key = this.keyForAttribute ? this.keyForAttribute(key, 'serialize') : key; if (!belongsTo) { json[key + '_type'] = null; } else { json[key + '_type'] = belongsTo.modelName; } } } ``` #### Param #### Param #### Param #### Call Signature ```ts static serializePolymorphicType(): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:1315](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L1315) ##### Returns `void` #### Call Signature ```ts static serializePolymorphicType( snapshot, json, relationship): void; ``` Defined in: [warp-drive-packages/legacy/src/serializer/rest.js:728](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/rest.js#L728) You can use this method to customize how polymorphic objects are serialized. By default the REST Serializer creates the key by appending `Type` to the attribute and value from the model's camelcased model name. ##### Parameters ###### snapshot `Snapshot` ###### json `any` ###### relationship `any` ##### Returns `void` ##### Param ##### Param ##### Param *** ### shouldSerializeHasMany() ```ts readonly static shouldSerializeHasMany( snapshot, key, relationship): boolean; ``` Defined in: [warp-drive-packages/legacy/src/serializer/json.js:918](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/json.js#L918) Check if the given hasMany relationship should be serialized By default only many-to-many and many-to-none relationships are serialized. This could be configured per relationship by Serializer's `attrs` object. #### Parameters ##### snapshot `Snapshot` ##### key `string` ##### relationship `RelationshipSchema` #### Returns `boolean` true if the hasMany relationship should be serialized *** ### toString() ```ts readonly static toString(): string; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:650 #### Returns `string` *** ### willReopen() ```ts readonly static willReopen(): void; ``` Defined in: node\_modules/.pnpm/ember-source@6.3.0/node\_modules/ember-source/types/stable/@ember/object/core.d.ts:533 #### Returns `void` --- --- url: /api/@warp-drive/legacy/serializer/rest.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / serializer/rest ## Classes * [EmbeddedRecordsMixin](classes/EmbeddedRecordsMixin.md) * [RESTSerializer](classes/RESTSerializer.md) --- --- url: /api/@warp-drive/legacy/serializer/transform/classes/BooleanTransform.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [serializer/transform](../index.md) / BooleanTransform Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/boolean.ts:38](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/boolean.ts#L38) The `BooleanTransform` class is used to serialize and deserialize boolean attributes on Ember Data record objects. This transform is used when `boolean` is passed as the type parameter to the [attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function. Usage ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('boolean') isAdmin; @attr('string') name; @attr('string') email; } ``` By default, the boolean transform only allows for values of `true` or `false`. You can opt into allowing `null` values for boolean attributes via `attr('boolean', { allowNull: true })` ```js [app/models/user.js] import { Model, attr } from '@warp-drive/legacy/model'; export default class UserModel extends Model { @attr('string') email; @attr('string') username; @attr('boolean', { allowNull: true }) wantsWeeklyEmail; } ``` BooleanTransform ## Constructors ### Constructor ```ts new BooleanTransform(): BooleanTransform; ``` #### Returns `BooleanTransform` ## Properties ### \_\_\_(unique) Symbol($type) ```ts ___(unique) Symbol($type): "boolean"; ``` Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/boolean.ts:63](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/boolean.ts#L63) ## Methods ### deserialize() ```ts deserialize(serialized, options?): null | boolean; ``` Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/boolean.ts:39](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/boolean.ts#L39) #### Parameters ##### serialized `null` | `string` | `number` | `boolean` ##### options? ###### allowNull? `boolean` #### Returns `null` | `boolean` *** ### serialize() ```ts serialize(deserialized, options?): null | boolean; ``` Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/boolean.ts:55](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/boolean.ts#L55) #### Parameters ##### deserialized `null` | `boolean` ##### options? ###### allowNull? `boolean` #### Returns `null` | `boolean` *** ### create() ```ts static create(): BooleanTransform; ``` Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/boolean.ts:65](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/boolean.ts#L65) #### Returns `BooleanTransform` --- --- url: /api/@warp-drive/legacy/serializer/transform/classes/NumberTransform.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [serializer/transform](../index.md) / NumberTransform Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/number.ts:28](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/number.ts#L28) The `NumberTransform` class is used to serialize and deserialize numeric attributes on Ember Data record objects. This transform is used when `number` is passed as the type parameter to the [attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function. Usage ```js [app/models/score.js] import Model, { attr, belongsTo } from '@ember-data/model'; export default class ScoreModel extends Model { @attr('number') value; @belongsTo('player') player; @attr('date') date; } ``` NumberTransform ## Constructors ### Constructor ```ts new NumberTransform(): NumberTransform; ``` #### Returns `NumberTransform` ## Properties ### \_\_\_(unique) Symbol($type) ```ts ___(unique) Symbol($type): "number"; ``` Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/number.ts:49](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/number.ts#L49) ## Methods ### deserialize() ```ts deserialize(serialized, _options?): null | number; ``` Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/number.ts:29](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/number.ts#L29) #### Parameters ##### serialized `undefined` | `null` | `string` | `number` ##### \_options? `Record`<`string`, `unknown`> #### Returns `null` | `number` *** ### serialize() ```ts serialize(deserialized, _options?): null | number; ``` Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/number.ts:39](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/number.ts#L39) #### Parameters ##### deserialized `undefined` | `null` | `string` | `number` ##### \_options? `Record`<`string`, `unknown`> #### Returns `null` | `number` *** ### create() ```ts static create(): NumberTransform; ``` Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/number.ts:51](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/number.ts#L51) #### Returns `NumberTransform` --- --- url: /api/@warp-drive/legacy/serializer/transform/classes/DateTransform.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [serializer/transform](../index.md) / DateTransform Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/date.ts:24](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/date.ts#L24) The `DateTransform` class is used to serialize and deserialize date attributes on Ember Data record objects. This transform is used when `date` is passed as the type parameter to the [attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function. It uses the [`ISO 8601`](https://en.wikipedia.org/wiki/ISO_8601) standard. ```js [app/models/score.js] import Model, { attr, belongsTo } from '@ember-data/model'; export default class ScoreModel extends Model { @attr('number') value; @belongsTo('player') player; @attr('date') date; } ``` DateTransform ## Constructors ### Constructor ```ts new DateTransform(): DateTransform; ``` #### Returns `DateTransform` ## Properties ### \_\_\_(unique) Symbol($type) ```ts ___(unique) Symbol($type): "date"; ``` Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/date.ts:54](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/date.ts#L54) ## Methods ### deserialize() ```ts deserialize(serialized, _options?): null | Date; ``` Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/date.ts:25](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/date.ts#L25) #### Parameters ##### serialized `null` | `string` | `number` ##### \_options? `Record`<`string`, `unknown`> #### Returns `null` | `Date` *** ### serialize() ```ts serialize(date, _options?): null | string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/date.ts:45](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/date.ts#L45) #### Parameters ##### date `Date` ##### \_options? `Record`<`string`, `unknown`> #### Returns `null` | `string` *** ### create() ```ts static create(): DateTransform; ``` Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/date.ts:56](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/date.ts#L56) #### Returns `DateTransform` --- --- url: /api/@warp-drive/legacy/serializer/transform/classes/StringTransform.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [serializer/transform](../index.md) / StringTransform Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/string.ts:24](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/string.ts#L24) The `StringTransform` class is used to serialize and deserialize string attributes on Ember Data record objects. This transform is used when `string` is passed as the type parameter to the [attr](/ember-data/release/functions/@ember-data%2Fmodel/attr) function. Usage ```js [app/models/user.js] import Model, { attr, belongsTo } from '@ember-data/model'; export default class UserModel extends Model { @attr('boolean') isAdmin; @attr('string') name; @attr('string') email; } ``` StringTransform ## Constructors ### Constructor ```ts new StringTransform(): StringTransform; ``` #### Returns `StringTransform` ## Properties ### \_\_\_(unique) Symbol($type) ```ts ___(unique) Symbol($type): "string"; ``` Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/string.ts:32](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/string.ts#L32) ## Methods ### deserialize() ```ts deserialize(serialized, _options?): null | string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/string.ts:25](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/string.ts#L25) #### Parameters ##### serialized `unknown` ##### \_options? `Record`<`string`, `unknown`> #### Returns `null` | `string` *** ### serialize() ```ts serialize(deserialized, _options?): null | string; ``` Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/string.ts:28](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/string.ts#L28) #### Parameters ##### deserialized `unknown` ##### \_options? `Record`<`string`, `unknown`> #### Returns `null` | `string` *** ### create() ```ts static create(): StringTransform; ``` Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/string.ts:34](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/string.ts#L34) #### Returns `StringTransform` --- --- url: /api/@warp-drive/legacy/serializer/transform.md --- [Documentation](../../../../index.md) / [@warp-drive/legacy](../../index.md) / serializer/transform ## Classes * [BooleanTransform](classes/BooleanTransform.md) * [DateTransform](classes/DateTransform.md) * [NumberTransform](classes/NumberTransform.md) * [StringTransform](classes/StringTransform.md) ## Interfaces * [Transform](interfaces/Transform.md) ## Variables * [Transform](variables/Transform.md) --- --- url: /api/@warp-drive/legacy/serializer/transform/interfaces/Transform.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [serializer/transform](../index.md) / Transform Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/transform.ts:116](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/transform.ts#L116) When given a serialized value from a JSON object this method must return the deserialized value for the record attribute. Example ```javascript deserialize(serialized, options) { return empty(serialized) ? null : Number(serialized); } ``` ## Param The serialized value ## Param hash of options passed to `attr` ## Methods ### deserialize() ```ts deserialize(value, options): unknown; ``` Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/transform.ts:118](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/transform.ts#L118) #### Parameters ##### value `unknown` ##### options `undefined` | [`ObjectValue`](../../../../core-types/json/raw/interfaces/ObjectValue.md) #### Returns `unknown` *** ### serialize() ```ts serialize(value, options): unknown; ``` Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/transform.ts:117](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/transform.ts#L117) #### Parameters ##### value `unknown` ##### options `undefined` | [`ObjectValue`](../../../../core-types/json/raw/interfaces/ObjectValue.md) #### Returns `unknown` --- --- url: /api/@warp-drive/legacy/serializer/transform/variables/Transform.md --- [Documentation](../../../../../index.md) / [@warp-drive/legacy](../../../index.md) / [serializer/transform](../index.md) / Transform ```ts Transform: typeof EmberObject; ``` Defined in: [warp-drive-packages/legacy/src/serializer/-private/transforms/transform.ts:116](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/legacy/src/serializer/-private/transforms/transform.ts#L116) --- --- url: /api/@warp-drive/schema-record/classes/SchemaRecord.md --- [Documentation](../../../index.md) / [@warp-drive/schema-record](../index.md) / SchemaRecord Defined in: record.d.ts:18 A class that uses a the ResourceSchema for a ResourceType and a ResouceKey to transform data from the cache into a rich, reactive object. This class is not directly instantiable. To use it, you should configure the store's `instantiateRecord` and `teardownRecord` hooks with the matching hooks provided by this package. ## Properties ### \[toStringTag] ```ts [toStringTag]: `SchemaRecord<${string}>`; ``` Defined in: record.d.ts:33 ## Methods ### \_\_\_(unique) Symbol(Checkout)() ```ts ___(unique) Symbol(Checkout)(): Promise; ``` Defined in: record.d.ts:59 Create an editable copy of the record SchemaRecord instances are not editable by default. This method creates an editable copy of the record. To use, import the `Checkout` symbol from `@warp-drive/schema-record` and call it on the record. ```ts import { Checkout } from '@warp-drive/schema-record'; const record = store.peekRecord('user', '1'); const editableRecord = await record[Checkout](); ``` #### Returns `Promise`<`SchemaRecord`> a promise that resolves to the editable record #### Throws if the record is already editable or if the record is embedded --- --- url: /api/@warp-drive/schema-record/classes/SchemaService.md --- [Documentation](../../../index.md) / [@warp-drive/schema-record](../index.md) / SchemaService Defined in: schema.d.ts:97 A SchemaService designed to work with dynamically registered schemas. SchemaService ## Implements * [`SchemaService`](../../core-types/index/interfaces/SchemaService.md) ## Constructors ### Constructor ```ts new SchemaService(): SchemaService; ``` Defined in: schema.d.ts:125 #### Returns `SchemaService` ## Methods ### ~~attributesDefinitionFor()~~ ```ts attributesDefinitionFor(identifier): Record; ``` Defined in: schema.d.ts:99 DEPRECATED - use `fields` instead Returns definitions for all properties of the specified resource that are considered "attributes". Generally these are properties that are not related to book-keeping state on the client and do not represent a linkage to another resource. The return value should be a dictionary of key:value pairs where the `key` is the attribute or property's name and `value` is an object with at least the property `name` which should also match `key`. Optionally, this object may also specify `type`, which should be a string reference to a `transform`, and `options` which should be dictionary in which any key:value pairs are permissable. For instance, when using `@ember-data/model`, the following attribute definition: ```ts class extends Model { @attr('string', { defaultValue: 'hello' }) greeting; @attr('date') birthday; @attr firstName; } ``` Would be returned as: ```js { greeting: { name: 'greeting', type: 'string', options: { defaultValue: 'hello' } }, birthday: { name: 'birthday', type: 'date' }, firstName: { name: 'firstName' } } ``` #### Parameters ##### identifier ###### type `string` #### Returns `Record`<`string`, [`LegacyAttributeField`](../../core-types/schema/fields/interfaces/LegacyAttributeField.md)> #### Deprecated *** ### derivation() ```ts derivation(field): Derivation; ``` Defined in: schema.d.ts:134 Returns the derivation registered with the name provided by `field.type`. Validates that the field is a valid DerivedField. #### Parameters ##### field [`DerivedField`](../../core-types/schema/fields/interfaces/DerivedField.md) | { `type`: `string`; } #### Returns [`Derivation`](../../core-types/schema/concepts/type-aliases/Derivation.md) *** ### ~~doesTypeExist()~~ ```ts doesTypeExist(type): boolean; ``` Defined in: schema.d.ts:98 DEPRECATED - use `hasResource` instead Queries whether the SchemaService recognizes `type` as a resource type #### Parameters ##### type `string` #### Returns `boolean` #### Deprecated *** ### fields() ```ts fields(resource): Map; ``` Defined in: schema.d.ts:172 Queries for the fields of a given resource type or resource identity. Should error if the resource type is not recognized. #### Parameters ##### resource ###### type `string` #### Returns `Map`<`string`, [`FieldSchema`](../../core-types/schema/fields/type-aliases/FieldSchema.md)> *** ### hashFn() ```ts hashFn(field): HashFn; ``` Defined in: schema.d.ts:137 Returns the hash function registered with the name provided by `field.type`. Validates that the field is a valid HashField. #### Parameters ##### field [`HashField`](../../core-types/schema/fields/interfaces/HashField.md) | { `type`: `string`; } #### Returns [`HashFn`](../../core-types/schema/concepts/type-aliases/HashFn.md) *** ### hasResource() ```ts hasResource(resource): boolean; ``` Defined in: schema.d.ts:175 Queries whether the SchemaService recognizes `type` as a resource type #### Parameters ##### resource ###### type `string` #### Returns `boolean` *** ### hasTrait() ```ts hasTrait(type): boolean; ``` Defined in: schema.d.ts:127 Queries whether the SchemaService recognizes `type` as a resource trait #### Parameters ##### type `string` #### Returns `boolean` *** ### registerDerivation() ```ts registerDerivation(derivation): void; ``` Defined in: schema.d.ts:146 Enables registration of a derivation. The derivation can later be retrieved by the name attached to it's `[Type]` property. #### Type Parameters ##### R `R` ##### T `T` ##### FM `FM` *extends* | `null` | [`ObjectValue`](../../core-types/json/raw/interfaces/ObjectValue.md) #### Parameters ##### derivation [`Derivation`](../../core-types/schema/concepts/type-aliases/Derivation.md)<`R`, `T`, `FM`> #### Returns `void` *** ### registerHashFn() ```ts registerHashFn(hashFn): void; ``` Defined in: schema.d.ts:171 Enables registration of a hashing function The hashing function can later be retrieved by the name attached to it's `[Type]` property. #### Type Parameters ##### T `T` *extends* `object` #### Parameters ##### hashFn [`HashFn`](../../core-types/schema/concepts/type-aliases/HashFn.md)<`T`> #### Returns `void` *** ### registerResource() ```ts registerResource(schema): void; ``` Defined in: schema.d.ts:144 Enables registration of a single Schema representing either a resource in PolarisMode or LegacyMode or an ObjectSchema representing an embedded structure in other schemas. This can be useful for either pre-loading schema information or for registering schema information delivered by API calls or other sources just-in-time. #### Parameters ##### schema [`ResourceSchema`](../../core-types/schema/fields/type-aliases/ResourceSchema.md) | [`ObjectSchema`](../../core-types/schema/fields/interfaces/ObjectSchema.md) #### Returns `void` *** ### registerResources() ```ts registerResources(schemas): void; ``` Defined in: schema.d.ts:143 Enables registration of multiple Schemas at once. This can be useful for either pre-loading schema information or for registering schema information delivered by API calls or other sources just-in-time. #### Parameters ##### schemas ( | [`ResourceSchema`](../../core-types/schema/fields/type-aliases/ResourceSchema.md) | [`ObjectSchema`](../../core-types/schema/fields/interfaces/ObjectSchema.md))\[] #### Returns `void` *** ### registerTransformation() ```ts registerTransformation(transformation): void; ``` Defined in: schema.d.ts:145 Enables registration of a transformation. The transformation can later be retrieved by the name attached to it's `[Type]` property. #### Type Parameters ##### T `T` *extends* [`Value`](../../core-types/json/raw/type-aliases/Value.md) = `string` ##### PT `PT` = `unknown` #### Parameters ##### transformation [`Transformation`](../type-aliases/Transformation.md)<`T`, `PT`> #### Returns `void` *** ### ~~relationshipsDefinitionFor()~~ ```ts relationshipsDefinitionFor(identifier): Record; ``` Defined in: schema.d.ts:102 DEPRECATED - use `fields` instead Returns definitions for all properties of the specified resource that are considered "relationships". Generally these are properties that represent a linkage to another resource. The return value should be a dictionary of key:value pairs where the `key` is the relationship or property's name and `value` is an object with at least the following properties: * `name` which should also match the `key` used in the dictionary. * `kind` which should be either `belongsTo` or `hasMany` * `type` which should be the related resource's string "type" * `options` which should be a dictionary allowing any key but with at least the below keys present. * `options.async` a boolean representing whether data for this relationship is typically loaded on-demand. * `options.inverse` a string or null representing the field name / key of the corresponding relationship on the inverse resource. Additionally the following options properties are optional. See [Polymorphic Relationships](https://rfcs.emberjs.com/id/0793-polymporphic-relations-without-inheritance) * `options.polymorphic` a boolean representing whether multiple resource types can be used to satisfy this relationship. * `options.as` a string representing the abstract type that the concrete side of a relationship must specify when fulfilling a polymorphic inverse. For example, the following Model using @ember-data/model would generate this relationships definition by default: ```js class User extends Model { @belongsTo('user', { async: false, inverse: null }) bestFriend; @hasMany('user', { async: true, inverse: 'friends' }) friends; @hasMany('pet', { async: false, polymorphic: true, inverse: 'owner' }) pets; } ``` Which would be returned as ```js { bestFriend: { name: 'bestFriend', kind: 'belongsTo', type: 'user', options: { async: false, inverse: null } }, friends: { name: 'friends', kind: 'hasMany', type: 'user', options: { async: true, inverse: 'friends' } }, pets: { name: 'pets', kind: 'hasMany', type: 'pet', options: { async: false, polymorphic: true, inverse: 'owner' } }, } ``` #### Parameters ##### identifier ###### type `string` #### Returns `Record`<`string`, [`LegacyRelationshipField`](../../core-types/schema/fields/type-aliases/LegacyRelationshipField.md)> #### Deprecated *** ### resource() ```ts resource(resource): | ResourceSchema | ObjectSchema; ``` Defined in: schema.d.ts:140 Returns the schema for the provided resource type. #### Parameters ##### resource [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) | { `type`: `string`; } #### Returns | [`ResourceSchema`](../../core-types/schema/fields/type-aliases/ResourceSchema.md) | [`ObjectSchema`](../../core-types/schema/fields/interfaces/ObjectSchema.md) *** ### resourceHasTrait() ```ts resourceHasTrait(resource, trait): boolean; ``` Defined in: schema.d.ts:128 Queries whether the given resource has the given trait #### Parameters ##### resource [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) | { `type`: `string`; } ##### trait `string` #### Returns `boolean` *** ### resourceTypes() ```ts resourceTypes(): readonly string[]; ``` Defined in: schema.d.ts:126 Returns all known resource types #### Returns readonly `string`\[] *** ### transformation() ```ts transformation(field): Transformation; ``` Defined in: schema.d.ts:131 Returns the transformation registered with the name provided by `field.type`. Validates that the field is a valid transformable. #### Parameters ##### field [`GenericField`](../../core-types/schema/fields/interfaces/GenericField.md) | [`ObjectField`](../../core-types/schema/fields/interfaces/ObjectField.md) | [`ArrayField`](../../core-types/schema/fields/interfaces/ArrayField.md) | { `type`: `string`; } #### Returns [`Transformation`](../type-aliases/Transformation.md) --- --- url: /api/@warp-drive/schema-record/functions/instantiateRecord.md --- [Documentation](../../../index.md) / [@warp-drive/schema-record](../index.md) / instantiateRecord ```ts function instantiateRecord( store, identifier, createArgs?): SchemaRecord; ``` Defined in: hooks.d.ts:4 ## Parameters ### store [`default`](../../../@ember-data/store/index/classes/default.md) ### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) ### createArgs? `Record`<`string`, `unknown`> ## Returns [`SchemaRecord`](../classes/SchemaRecord.md) --- --- url: /api/@warp-drive/schema-record/functions/fromIdentity.md --- [Documentation](../../../index.md) / [@warp-drive/schema-record](../index.md) / fromIdentity ## Call Signature ```ts function fromIdentity( record, options, key): string; ``` Defined in: schema.d.ts:48 A derivation that computes its value from the record's identity. It can be used via a derived field definition like: ```ts { kind: 'derived', name: 'id', type: '@identity', options: { key: 'id' } } ``` Valid keys are `'id'`, `'lid'`, `'type'`, and `'^'`. `^` returns the entire identifier object. ### Parameters #### record [`SchemaRecord`](../classes/SchemaRecord.md) #### options { `key`: `"lid"`; } | { `key`: `"type"`; } #### key `string` ### Returns `string` ## Call Signature ```ts function fromIdentity( record, options, key): null | string; ``` Defined in: schema.d.ts:53 A derivation that computes its value from the record's identity. It can be used via a derived field definition like: ```ts { kind: 'derived', name: 'id', type: '@identity', options: { key: 'id' } } ``` Valid keys are `'id'`, `'lid'`, `'type'`, and `'^'`. `^` returns the entire identifier object. ### Parameters #### record [`SchemaRecord`](../classes/SchemaRecord.md) #### options ##### key `"id"` #### key `string` ### Returns `null` | `string` ## Call Signature ```ts function fromIdentity( record, options, key): StableRecordIdentifier; ``` Defined in: schema.d.ts:56 A derivation that computes its value from the record's identity. It can be used via a derived field definition like: ```ts { kind: 'derived', name: 'id', type: '@identity', options: { key: 'id' } } ``` Valid keys are `'id'`, `'lid'`, `'type'`, and `'^'`. `^` returns the entire identifier object. ### Parameters #### record [`SchemaRecord`](../classes/SchemaRecord.md) #### options ##### key `"^"` #### key `string` ### Returns [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) ## Call Signature ```ts function fromIdentity( record, options, key): asserts options; ``` Defined in: schema.d.ts:59 A derivation that computes its value from the record's identity. It can be used via a derived field definition like: ```ts { kind: 'derived', name: 'id', type: '@identity', options: { key: 'id' } } ``` Valid keys are `'id'`, `'lid'`, `'type'`, and `'^'`. `^` returns the entire identifier object. ### Parameters #### record [`SchemaRecord`](../classes/SchemaRecord.md) #### options `null` #### key `string` ### Returns `asserts options` --- --- url: /api/@warp-drive/schema-record/functions/registerDerivations.md --- [Documentation](../../../index.md) / [@warp-drive/schema-record](../index.md) / registerDerivations ```ts function registerDerivations(schema): void; ``` Defined in: schema.d.ts:72 Registers the default derivations for records that want to use the PolarisMode defaults provided by ```ts import { withDefaults } from '@warp-drive/schema-record'; ``` ## Parameters ### schema [`SchemaService`](../../core-types/index/interfaces/SchemaService.md) ## Returns `void` --- --- url: /api/@warp-drive/schema-record/functions/teardownRecord.md --- [Documentation](../../../index.md) / [@warp-drive/schema-record](../index.md) / teardownRecord ```ts function teardownRecord(record): void; ``` Defined in: hooks.d.ts:5 ## Parameters ### record `unknown` ## Returns `void` --- --- url: /api/@warp-drive/schema-record/functions/withDefaults.md --- [Documentation](../../../index.md) / [@warp-drive/schema-record](../index.md) / withDefaults ```ts function withDefaults(schema): ResourceSchema; ``` Defined in: schema.d.ts:26 Utility for constructing a ResourceSchema with the recommended fields for the PolarisMode experience. Using this requires registering the PolarisMode derivations ```ts import { registerDerivations } from '@warp-drive/schema-record'; registerDerivations(schema); ``` ## Parameters ### schema [`WithPartial`](../../core-types/utils/type-aliases/WithPartial.md)<[`PolarisResourceSchema`](../../core-types/schema/fields/interfaces/PolarisResourceSchema.md), `"identity"`> ## Returns [`ResourceSchema`](../../core-types/schema/fields/type-aliases/ResourceSchema.md) --- --- url: /api/@warp-drive/schema-record.md --- [Documentation](../../index.md) / @warp-drive/schema-record SchemaRecord is a reactive object that transforms raw data from an Cache | associated cache into reactive data backed by Signals. The shape of the object and the transformation of raw cache data into its reactive form is controlled by a resource schema. Resource schemas are simple JSON, allowing them to be defined and delivered from anywhere. The capabilities that SchemaRecord brings to [*Warp***Drive**](https://github.com/emberjs/data/) will simplify even the most complex parts of your app's state management. ## Installation Install using your javascript package manager of choice. For instance with [pnpm](https://pnpm.io/) ```cli pnpm add @warp-drive/schema-record ``` *** ## Getting Started If this package is how you are first learning about WarpDrive/EmberData, we recommend starting with learning about [Requests](../modules/@ember-data%2Frequest) and the [Store](../modules/@ember-data%2Fstore). *** ## 🚀 Setup SchemaRecord integrates with WarpDrive via the Store's resource lifecycle hooks. When WarpDrive needs to create a new record instance to give reactive access to a resource in the cache, it calls `instantiateRecord`. When it no longer needs that instance, it will call `teardownRecord`. ```diff import Store from '@ember-data/store'; +import { instantiateRecord, teardownRecord, registerDerivations, SchemaService } from '@warp-drive/schema-record'; class AppStore extends Store { + createSchemaService() { + const schema = new SchemaService(); + registerDerivations(schema); + return schema; + } + instantiateRecord(identifier, createArgs) { + return instantiateRecord(this, identifier, createArgs); + } + teardownRecord(record) { + return teardownRecord(record); + } } ``` Any Store API that returns a record instance will use the `instantiateRecord` hook configured above to instantiate a SchemaRecord once this is in place. After that, its up to you what SchemaRecord can do. *** ## Start Using ### Modes SchemaRecord has two modes: `legacy` and `polaris`. **LegacyMode** can be used to emulate the behaviors and capabilities of EmberData's `Model` class, and because there is little distinction between Model and SchemaRecord in LegacyMode we refer to both of these approaches as LegacyMode. This mode is the default experience in V5. In LegacyMode: * records are mutable * local changes immediately reflect app wide * records have all the APIs of Model (references, state props, currentState, methods etc) * the continued use of `@ember-data/model` and `@ember-data/legacy-compat` packages is required (though most imports from them can be removed) * `async: true` relationships are supported (but not recommended outside of [LinksMode](https://github.com/emberjs/data/blob/main/guides/relationships/features/links-mode.md)) *** **PolarisMode** is an upcoming suite of features that will become the default experience in V6. In PolarisMode: * records are immutable, unless creating a new resource or explicitly checking out a record for editing * local changes are isolated until committed, displaying only via the editable version of the record * records have a more limited API, focused on only what is in their schema. * some common operations may have more friction to perform because intended utilities are not yet available * `async: true` relationships are not supported (see [LinksMode](https://github.com/emberjs/data/blob/main/guides/relationships/features/links-mode.md)) * `@ember-data/model` and `@ember-data/legacy-compat` packages are not required These modes are interopable. The reactive object (record) for a resource in PolarisMode can relate to a record in LegacyMode and vice-versa. This interopability is true whether the record in LegacyMode is a SchemaRecord or a Model. *** ### About SchemaRecord is a reactive object that transforms raw data from an associated cache into reactive data backed by Signals. The shape of the object and the transformation of raw cache data into its reactive form is controlled by a resource schema. For instance, lets say your API is a [{JSON:API}](https://jsonapi.org) and your store is using the Cache provided by [@ember-data/json-api](../modules/@ember-data%2Fjson-api), and a request returns the following raw data: ```ts { data: { type: 'user', id: '1', attributes: { firstName: 'Chris', lastName: 'Thoburn' }, relationships: { pets: { data: [{ type: 'dog', id: '1' }] }} }, included: [ { type: 'dog', id: '1', attributes: { name: 'Rey' }, relationships: { owner: { data: { type: 'user', id: '1' }}} } ] } ``` We could describe the `'user'` and `'dog'` resources in the above payload with the following schemas: ```ts store.schema.registerResources([ { type: 'user', identity: { type: '@id', name: 'id' }, fields: [ { type: '@identity', name: '$type', kind: 'derived', options: { key: 'type' }, }, { kind: 'field', name: 'firstName' }, { kind: 'field', name: 'lastName' }, { kind: 'derived', name: 'name', type: 'concat', options: { fields: ['firstName', 'lastName'], separator: ' ' } }, { kind: 'hasMany', name: 'pets', type: 'pet', options: { async: false, inverse: 'owner', polymorphic: true, linksMode: true, } } ] }, { type: 'dog', identity: { type: '@id', name: 'id' }, fields: [ { type: '@identity', name: '$type', kind: 'derived', options: { key: 'type' }, }, { kind: 'field', name: 'name' }, { kind: 'belongsTo', name: 'owner', type: 'user', options: { async: false, inverse: 'pets', as: 'pet', linksMode: true, } } ] } ]); ``` With these schemas in place, the reactive objects that the store would provide us whenever we encountered a `'user'` or a `'dog'` would be: ```ts interface Pet { readonly id: string; readonly owner: User; } interface Dog extends Pet { readonly $type: 'dog'; readonly name: string; } interface EditableUser { readonly $type: 'user'; readonly id: string; firstName: string; lastName: string; readonly name: string; pets: Array; } interface User { readonly $type: 'user'; readonly id: string; readonly firstName: string; readonly lastName: string; readonly name: string; readonly pets: Readonly>; [Checkout]: Promise }> ``` Note how based on the schema the reactive object we receive is able to produce `name` on user (despite no name field being in the cache), provide `$type` pulled from the identity of the resource, and flatten the individual attributes and relationships onto the record for easier use. Notice also how we typed this object with `readonly`. This is because while SchemaRecord instances are ***deeply reactive***, they are also ***immutable***. We can mutate a SchemaRecord only be explicitly asking permission to do so, and in the process gaining access to an editable copy. The immutable version will not show any in-process edits made to this editable copy. ```ts import { Checkout } from '@warp-drive/schema-record'; const editable = await user[Checkout](); ``` *** ### Utilities SchemaRecord provides a schema builder that simplifies setting up a couple of conventional fields like identity and `$type`. We can rewrite the schema definition above using this utility like so: ```ts import { withDefaults } from '@warp-drive/schema-record'; store.schema.registerResources([ withDefaults({ type: 'user', fields: [ { kind: 'field', name: 'firstName' }, { kind: 'field', name: 'lastName' }, { kind: 'derived', name: 'name', type: 'concat', options: { fields: ['firstName', 'lastName'], separator: ' ' } }, { kind: 'hasMany', name: 'pets', type: 'pet', options: { async: false, inverse: 'owner', polymorphic: true, linksMode: true, resetOnRemoteUpdate: false, } } ] }), withDefaults({ type: 'dog', fields: [ { kind: 'field', name: 'name' }, { kind: 'belongsTo', name: 'owner', type: 'user', options: { async: false, inverse: 'pets', as: 'pet', linksMode: true, resetOnRemoteUpdate: false, } } ] }) ]); ``` Additionally, `@warp-drive/core-types` provides several utilities for type-checking and narrowing schemas. * PolarisResourceSchema * LegacyResourceSchema * ObjectSchema * resourceSchema * objectSchema * isResourceSchema * isLegacyResourceSchema *** ### Field Schemas LegacyMode * LegacyModeFieldSchema PolarisMode * PolarisModeFieldSchema ## Namespaces * [fromIdentity](namespaces/fromIdentity/index.md) ## Classes * [SchemaRecord](classes/SchemaRecord.md) * [SchemaService](classes/SchemaService.md) ## Type Aliases * [Transformation](type-aliases/Transformation.md) ## Variables * [Checkout](variables/Checkout.md) ## Functions * [fromIdentity](functions/fromIdentity.md) * [instantiateRecord](functions/instantiateRecord.md) * [registerDerivations](functions/registerDerivations.md) * [teardownRecord](functions/teardownRecord.md) * [withDefaults](functions/withDefaults.md) --- --- url: /api/@warp-drive/schema-record/namespaces/fromIdentity.md --- [Documentation](../../../../index.md) / [@warp-drive/schema-record](../../index.md) / fromIdentity --- --- url: /api/@warp-drive/schema-record/type-aliases/Transformation.md --- [Documentation](../../../index.md) / [@warp-drive/schema-record](../index.md) / Transformation ```ts type Transformation = object; ``` Defined in: schema.d.ts:80 ## Type Parameters ### T `T` *extends* [`Value`](../../core-types/json/raw/type-aliases/Value.md) = [`Value`](../../core-types/json/raw/type-aliases/Value.md) ### PT `PT` = `unknown` ## Properties ### \_\_\_(unique) Symbol($type) ```ts ___(unique) Symbol($type): string; ``` Defined in: schema.d.ts:84 ## Methods ### defaultValue()? ```ts optional defaultValue(options, identifier): T; ``` Defined in: schema.d.ts:83 #### Parameters ##### options `null` | `Record`<`string`, `unknown`> ##### identifier [`StableRecordIdentifier`](../../core-types/identifier/type-aliases/StableRecordIdentifier.md) #### Returns `T` *** ### hydrate() ```ts hydrate( value, options, record): PT; ``` Defined in: schema.d.ts:82 #### Parameters ##### value `undefined` | `T` ##### options `null` | `Record`<`string`, `unknown`> ##### record [`SchemaRecord`](../classes/SchemaRecord.md) #### Returns `PT` *** ### serialize() ```ts serialize( value, options, record): T; ``` Defined in: schema.d.ts:81 #### Parameters ##### value `PT` ##### options `null` | `Record`<`string`, `unknown`> ##### record [`SchemaRecord`](../classes/SchemaRecord.md) #### Returns `T` --- --- url: /api/@warp-drive/schema-record/variables/Checkout.md --- [Documentation](../../../index.md) / [@warp-drive/schema-record](../index.md) / Checkout ```ts const Checkout: "___(unique) Symbol(Checkout)"; ``` Defined in: symbols.d.ts:7 --- --- url: /api/@warp-drive/utilities/*/functions/createRecord.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [\*](../index.md) / createRecord ## Call Signature ```ts function createRecord(record, options?): CreateRequestOptions; ``` Defined in: [utilities/src/-private/rest/save-record.ts:145](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/rest/save-record.ts#L145) Builds request options to create new record for resources, configured for the url, method and header expectations of most REST APIs. **Basic Usage** ```ts import { createRecord } from '@warp-drive/utilities/rest'; const person = store.createRecord('person', { name: 'Ted' }); const data = await store.request(createRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { createRecord } from '@warp-drive/utilities/rest'; const person = store.createRecord('person', { name: 'Ted' }); const options = createRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### record `T` #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`CreateRequestOptions`](../../../core-types/request/type-aliases/CreateRequestOptions.md)<`T`> ## Call Signature ```ts function createRecord(record, options?): CreateRequestOptions; ``` Defined in: [utilities/src/-private/rest/save-record.ts:146](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/rest/save-record.ts#L146) Builds request options to create new record for resources, configured for the url, method and header expectations of most REST APIs. **Basic Usage** ```ts import { createRecord } from '@warp-drive/utilities/rest'; const person = store.createRecord('person', { name: 'Ted' }); const data = await store.request(createRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { createRecord } from '@warp-drive/utilities/rest'; const person = store.createRecord('person', { name: 'Ted' }); const options = createRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Parameters #### record `unknown` #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`CreateRequestOptions`](../../../core-types/request/type-aliases/CreateRequestOptions.md) --- --- url: /api/@warp-drive/utilities/*/functions/deleteRecord.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [\*](../index.md) / deleteRecord ## Call Signature ```ts function deleteRecord(record, options?): DeleteRequestOptions; ``` Defined in: [utilities/src/-private/rest/save-record.ts:75](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/rest/save-record.ts#L75) Builds request options to delete record for resources, configured for the url, method and header expectations of REST APIs. **Basic Usage** ```ts import { deleteRecord } from '@warp-drive/utilities/rest'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const data = await store.request(deleteRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { deleteRecord } from '@warp-drive/utilities/rest'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const options = deleteRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### record `T` #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`DeleteRequestOptions`](../../../core-types/request/type-aliases/DeleteRequestOptions.md)<`T`> ## Call Signature ```ts function deleteRecord(record, options?): DeleteRequestOptions; ``` Defined in: [utilities/src/-private/rest/save-record.ts:76](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/rest/save-record.ts#L76) Builds request options to delete record for resources, configured for the url, method and header expectations of REST APIs. **Basic Usage** ```ts import { deleteRecord } from '@warp-drive/utilities/rest'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const data = await store.request(deleteRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { deleteRecord } from '@warp-drive/utilities/rest'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const options = deleteRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Parameters #### record `unknown` #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`DeleteRequestOptions`](../../../core-types/request/type-aliases/DeleteRequestOptions.md) --- --- url: /api/@warp-drive/utilities/*/functions/findRecord.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [\*](../index.md) / findRecord ## Call Signature ```ts function findRecord(identifier, options?): FindRecordRequestOptions, T>; ``` Defined in: [utilities/src/-private/rest/find-record.ts:70](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/rest/find-record.ts#L70) ### Type Parameters #### T `T` ### Parameters #### identifier [`RemotelyAccessibleIdentifier`](../../../core-types/request/type-aliases/RemotelyAccessibleIdentifier.md)<[`TypeFromInstance`](../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`>> #### options? [`FindRecordOptions`](../../../core-types/request/type-aliases/FindRecordOptions.md)<`T`> ### Returns [`FindRecordRequestOptions`](../../../core-types/request/type-aliases/FindRecordRequestOptions.md)<`FindRecordResultDocument`<`T`>, `T`> ## Call Signature ```ts function findRecord(identifier, options?): FindRecordRequestOptions; ``` Defined in: [utilities/src/-private/rest/find-record.ts:74](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/rest/find-record.ts#L74) ### Parameters #### identifier [`RemotelyAccessibleIdentifier`](../../../core-types/request/type-aliases/RemotelyAccessibleIdentifier.md) #### options? [`FindRecordOptions`](../../../core-types/request/type-aliases/FindRecordOptions.md) ### Returns [`FindRecordRequestOptions`](../../../core-types/request/type-aliases/FindRecordRequestOptions.md) ## Call Signature ```ts function findRecord( type, id, options?): FindRecordRequestOptions, T>; ``` Defined in: [utilities/src/-private/rest/find-record.ts:78](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/rest/find-record.ts#L78) ### Type Parameters #### T `T` ### Parameters #### type [`TypeFromInstance`](../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`> #### id `string` #### options? [`FindRecordOptions`](../../../core-types/request/type-aliases/FindRecordOptions.md)<`T`> ### Returns [`FindRecordRequestOptions`](../../../core-types/request/type-aliases/FindRecordRequestOptions.md)<`FindRecordResultDocument`<`T`>, `T`> ## Call Signature ```ts function findRecord( type, id, options?): FindRecordRequestOptions; ``` Defined in: [utilities/src/-private/rest/find-record.ts:83](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/rest/find-record.ts#L83) ### Parameters #### type `string` #### id `string` #### options? [`FindRecordOptions`](../../../core-types/request/type-aliases/FindRecordOptions.md) ### Returns [`FindRecordRequestOptions`](../../../core-types/request/type-aliases/FindRecordRequestOptions.md) --- --- url: /api/@warp-drive/utilities/*/functions/updateRecord.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [\*](../index.md) / updateRecord ## Call Signature ```ts function updateRecord(record, options?): UpdateRequestOptions>, T>; ``` Defined in: [utilities/src/-private/rest/save-record.ts:217](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/rest/save-record.ts#L217) Builds request options to update existing record for resources, configured for the url, method and header expectations of most REST APIs. **Basic Usage** ```ts import { updateRecord } from '@warp-drive/utilities/rest'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const data = await store.request(updateRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`. * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { updateRecord } from '@warp-drive/utilities/rest'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const options = updateRecord(person, { patch: true }); const data = await store.request(options); ``` ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../../../core-types/record/interfaces/TypedRecordInstance.md) #### RT `RT` *extends* [`TypedRecordInstance`](../../../core-types/record/interfaces/TypedRecordInstance.md) = `T` ### Parameters #### record `T` #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) & `object` ### Returns [`UpdateRequestOptions`](../../../core-types/request/type-aliases/UpdateRequestOptions.md)<[`SingleResourceDataDocument`](../../../core-types/spec/document/interfaces/SingleResourceDataDocument.md)<`RT`, `StableExistingRecordIdentifier`<`string`>>, `T`> ## Call Signature ```ts function updateRecord(record, options?): UpdateRequestOptions; ``` Defined in: [utilities/src/-private/rest/save-record.ts:221](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/rest/save-record.ts#L221) Builds request options to update existing record for resources, configured for the url, method and header expectations of most REST APIs. **Basic Usage** ```ts import { updateRecord } from '@warp-drive/utilities/rest'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const data = await store.request(updateRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`. * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { updateRecord } from '@warp-drive/utilities/rest'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const options = updateRecord(person, { patch: true }); const data = await store.request(options); ``` ### Parameters #### record `unknown` #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) & `object` ### Returns [`UpdateRequestOptions`](../../../core-types/request/type-aliases/UpdateRequestOptions.md) --- --- url: /api/@warp-drive/utilities/*/functions/query.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [\*](../index.md) / query ## Call Signature ```ts function query( type, query?, options?): QueryRequestOptions, T>; ``` Defined in: [utilities/src/-private/rest/query.ts:57](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/rest/query.ts#L57) Builds request options to query for resources, usually by a primary type, configured for the url and header expectations of most REST APIs. **Basic Usage** ```ts import { query } from '@warp-drive/utilities/rest'; const data = await store.request(query('person')); ``` **With Query Params** ```ts import { query } from '@warp-drive/utilities/rest'; const options = query('person', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing and camelCasing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSettings` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { query } from '@warp-drive/utilities/rest'; const options = query('person', { include: ['pets', 'friends'] }, { reload: true }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### type [`TypeFromInstance`](../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`> #### query? [`QueryParamsSource`](../../../core-types/params/type-aliases/QueryParamsSource.md) #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`QueryRequestOptions`](../../../core-types/request/type-aliases/QueryRequestOptions.md)<[`CollectionResourceDataDocument`](../../../core-types/spec/document/interfaces/CollectionResourceDataDocument.md)<`T`>, `T`> ## Call Signature ```ts function query( type, query?, options?): QueryRequestOptions; ``` Defined in: [utilities/src/-private/rest/query.ts:62](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/rest/query.ts#L62) Builds request options to query for resources, usually by a primary type, configured for the url and header expectations of most REST APIs. **Basic Usage** ```ts import { query } from '@warp-drive/utilities/rest'; const data = await store.request(query('person')); ``` **With Query Params** ```ts import { query } from '@warp-drive/utilities/rest'; const options = query('person', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing and camelCasing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSettings` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { query } from '@warp-drive/utilities/rest'; const options = query('person', { include: ['pets', 'friends'] }, { reload: true }); const data = await store.request(options); ``` ### Parameters #### type `string` #### query? [`QueryParamsSource`](../../../core-types/params/type-aliases/QueryParamsSource.md) #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`QueryRequestOptions`](../../../core-types/request/type-aliases/QueryRequestOptions.md) --- --- url: /api/@warp-drive/utilities/*.md --- [Documentation](../../../index.md) / [@warp-drive/utilities](../index.md) / \* This package provides utilities for working with **REST**ful APIs with [*Ember***Data**](https://github.com/emberjs/data/). ## Installation Install using your javascript package manager of choice. For instance with [pnpm](https://pnpm.io/) ```no-highlight pnpm add @ember-data/json-api ``` ## Usage Request builders are functions that produce [Fetch Options](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). They take a few contextual inputs about the request you want to make, abstracting away the gnarlier details. For instance, to fetch a resource from your API ```ts import { findRecord } from '@ember-data/rest/request'; const options = findRecord('ember-developer', '1', { include: ['pets', 'friends'] }); /* => { url: 'https://api.example.com/v1/emberDevelopers/1?include=friends,pets', method: 'GET', headers: , // 'Content-Type': 'application/json;charset=utf-8' op: 'findRecord'; records: [{ type: 'ember-developer', id: '1' }] } * / ``` Request builder output is ready to go for use with [store.request](https://api.emberjs.com/ember-data/release/classes/Store/methods/request?anchor=request), [manager.request](https://api.emberjs.com/ember-data/release/classes/RequestManager/methods/request?anchor=request) and most conventional REST APIs. Resource types are pluralized and camelized for the url. URLs are stable. The same query will produce the same URL every time, even if the order of keys in the query or values in an array changes. URLs follow the most common REST format (camelCase pluralized resource types). * ## Functions * [createRecord](functions/createRecord.md) * [deleteRecord](functions/deleteRecord.md) * [findRecord](functions/findRecord.md) * [query](functions/query.md) * [updateRecord](functions/updateRecord.md) --- --- url: /api/@warp-drive/utilities/active-record/functions/createRecord.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [active-record](../index.md) / createRecord ## Call Signature ```ts function createRecord(record, options?): CreateRequestOptions; ``` Defined in: [utilities/src/-private/active-record/save-record.ts:145](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/active-record/save-record.ts#L145) Builds request options to create new record for resources, configured for the url, method and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { createRecord } from '@warp-drive/utilities/active-record'; const person = store.createRecord('person', { name: 'Ted' }); const data = await store.request(createRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { createRecord } from '@warp-drive/utilities/active-record'; const person = store.createRecord('person', { name: 'Ted' }); const options = createRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### record `T` #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`CreateRequestOptions`](../../../core-types/request/type-aliases/CreateRequestOptions.md)<`T`> ## Call Signature ```ts function createRecord(record, options?): CreateRequestOptions; ``` Defined in: [utilities/src/-private/active-record/save-record.ts:146](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/active-record/save-record.ts#L146) Builds request options to create new record for resources, configured for the url, method and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { createRecord } from '@warp-drive/utilities/active-record'; const person = store.createRecord('person', { name: 'Ted' }); const data = await store.request(createRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { createRecord } from '@warp-drive/utilities/active-record'; const person = store.createRecord('person', { name: 'Ted' }); const options = createRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Parameters #### record `unknown` #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`CreateRequestOptions`](../../../core-types/request/type-aliases/CreateRequestOptions.md) --- --- url: /api/@warp-drive/utilities/active-record/functions/deleteRecord.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [active-record](../index.md) / deleteRecord ## Call Signature ```ts function deleteRecord(record, options?): DeleteRequestOptions; ``` Defined in: [utilities/src/-private/active-record/save-record.ts:75](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/active-record/save-record.ts#L75) Builds request options to delete record for resources, configured for the url, method and header expectations of ActiveRecord APIs. **Basic Usage** ```ts import { deleteRecord } from '@warp-drive/utilities/active-record'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const data = await store.request(deleteRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { deleteRecord } from '@warp-drive/utilities/active-record'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const options = deleteRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### record `T` #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`DeleteRequestOptions`](../../../core-types/request/type-aliases/DeleteRequestOptions.md)<`T`> ## Call Signature ```ts function deleteRecord(record, options?): DeleteRequestOptions; ``` Defined in: [utilities/src/-private/active-record/save-record.ts:76](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/active-record/save-record.ts#L76) Builds request options to delete record for resources, configured for the url, method and header expectations of ActiveRecord APIs. **Basic Usage** ```ts import { deleteRecord } from '@warp-drive/utilities/active-record'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const data = await store.request(deleteRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { deleteRecord } from '@warp-drive/utilities/active-record'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const options = deleteRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Parameters #### record `unknown` #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`DeleteRequestOptions`](../../../core-types/request/type-aliases/DeleteRequestOptions.md) --- --- url: /api/@warp-drive/utilities/active-record/functions/findRecord.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [active-record](../index.md) / findRecord ## Call Signature ```ts function findRecord(identifier, options?): FindRecordRequestOptions, T>; ``` Defined in: [utilities/src/-private/active-record/find-record.ts:70](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/active-record/find-record.ts#L70) Builds request options to fetch a single resource by a known id or identifier configured for the url and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const data = await store.request(findRecord('person', '1')); ``` **With Options** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord('person', '1', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **With an Identifier** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### identifier [`RemotelyAccessibleIdentifier`](../../../core-types/request/type-aliases/RemotelyAccessibleIdentifier.md)<[`TypeFromInstance`](../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`>> #### options? [`FindRecordOptions`](../../../core-types/request/type-aliases/FindRecordOptions.md)<`T`> ### Returns [`FindRecordRequestOptions`](../../../core-types/request/type-aliases/FindRecordRequestOptions.md)<`FindRecordResultDocument`<`T`>, `T`> ## Call Signature ```ts function findRecord(identifier, options?): FindRecordRequestOptions; ``` Defined in: [utilities/src/-private/active-record/find-record.ts:74](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/active-record/find-record.ts#L74) Builds request options to fetch a single resource by a known id or identifier configured for the url and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const data = await store.request(findRecord('person', '1')); ``` **With Options** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord('person', '1', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **With an Identifier** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' }); const data = await store.request(options); ``` ### Parameters #### identifier [`RemotelyAccessibleIdentifier`](../../../core-types/request/type-aliases/RemotelyAccessibleIdentifier.md) #### options? [`FindRecordOptions`](../../../core-types/request/type-aliases/FindRecordOptions.md) ### Returns [`FindRecordRequestOptions`](../../../core-types/request/type-aliases/FindRecordRequestOptions.md) ## Call Signature ```ts function findRecord( type, id, options?): FindRecordRequestOptions, T>; ``` Defined in: [utilities/src/-private/active-record/find-record.ts:78](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/active-record/find-record.ts#L78) Builds request options to fetch a single resource by a known id or identifier configured for the url and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const data = await store.request(findRecord('person', '1')); ``` **With Options** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord('person', '1', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **With an Identifier** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### type [`TypeFromInstance`](../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`> #### id `string` #### options? [`FindRecordOptions`](../../../core-types/request/type-aliases/FindRecordOptions.md)<`T`> ### Returns [`FindRecordRequestOptions`](../../../core-types/request/type-aliases/FindRecordRequestOptions.md)<`FindRecordResultDocument`<`T`>, `T`> ## Call Signature ```ts function findRecord( type, id, options?): FindRecordRequestOptions; ``` Defined in: [utilities/src/-private/active-record/find-record.ts:83](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/active-record/find-record.ts#L83) Builds request options to fetch a single resource by a known id or identifier configured for the url and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const data = await store.request(findRecord('person', '1')); ``` **With Options** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord('person', '1', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **With an Identifier** ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { findRecord } from '@warp-drive/utilities/active-record'; const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' }); const data = await store.request(options); ``` ### Parameters #### type `string` #### id `string` #### options? [`FindRecordOptions`](../../../core-types/request/type-aliases/FindRecordOptions.md) ### Returns [`FindRecordRequestOptions`](../../../core-types/request/type-aliases/FindRecordRequestOptions.md) --- --- url: /api/@warp-drive/utilities/active-record/functions/query.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [active-record](../index.md) / query ## Call Signature ```ts function query( type, query?, options?): QueryRequestOptions, T>; ``` Defined in: [utilities/src/-private/active-record/query.ts:57](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/active-record/query.ts#L57) Builds request options to query for resources, usually by a primary type, configured for the url and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { query } from '@warp-drive/utilities/active-record'; const data = await store.request(query('person')); ``` **With Query Params** ```ts import { query } from '@warp-drive/utilities/active-record'; const options = query('person', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { query } from '@warp-drive/utilities/active-record'; const options = query('person', { include: ['pets', 'friends'] }, { reload: true }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### type [`TypeFromInstance`](../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`> #### query? [`QueryParamsSource`](../../../core-types/params/type-aliases/QueryParamsSource.md) #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`QueryRequestOptions`](../../../core-types/request/type-aliases/QueryRequestOptions.md)<[`CollectionResourceDataDocument`](../../../core-types/spec/document/interfaces/CollectionResourceDataDocument.md)<`T`>, `T`> ## Call Signature ```ts function query( type, query?, options?): QueryRequestOptions; ``` Defined in: [utilities/src/-private/active-record/query.ts:62](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/active-record/query.ts#L62) Builds request options to query for resources, usually by a primary type, configured for the url and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { query } from '@warp-drive/utilities/active-record'; const data = await store.request(query('person')); ``` **With Query Params** ```ts import { query } from '@warp-drive/utilities/active-record'; const options = query('person', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { query } from '@warp-drive/utilities/active-record'; const options = query('person', { include: ['pets', 'friends'] }, { reload: true }); const data = await store.request(options); ``` ### Parameters #### type `string` #### query? [`QueryParamsSource`](../../../core-types/params/type-aliases/QueryParamsSource.md) #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`QueryRequestOptions`](../../../core-types/request/type-aliases/QueryRequestOptions.md) --- --- url: /api/@warp-drive/utilities/active-record.md --- [Documentation](../../../index.md) / [@warp-drive/utilities](../index.md) / active-record This package provides utilities for working with [ActiveRecord](https://guides.rubyonrails.org/active_record_basics.html#convention-over-configuration-in-active-record) APIs. ## Installation Install using your javascript package manager of choice. For instance with [pnpm](https://pnpm.io/) ::: code-group ```sh [pnpm] pnpm add -E @ember-data/active-record ``` ```sh [npm] npm add -E @ember-data/active-record ``` ```sh [yarn] yarn add -E @ember-data/active-record ``` ```sh [bun] bun add --exact @ember-data/active-record ``` ::: ## Usage Request builders are functions that produce [Fetch Options](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). They take a few contextual inputs about the request you want to make, abstracting away the gnarlier details. For instance, to construct a request that would fetch a resource from your API: ```ts import { findRecord } from '@ember-data/active-record/request'; const options = findRecord('ember-developer', '1', { include: ['pets', 'friends'] }); ``` This would produce the following request object: ```js { url: 'https://api.example.com/v1/ember_developers/1?include=friends,pets', method: 'GET', headers: , // 'Accept': 'application/json;charset=utf-8' op: 'findRecord'; records: [{ type: 'ember-developer', id: '1' }] } ``` Request builder output may be used with either `requestManager.request` or `store.request`. ```ts const data = await store.request(options); ``` URLs are stable. The same query will produce the same URL every time, even if the order of keys in the query or values in an array changes. URLs follow the most common ActiveRecord format (underscored pluralized resource types). ## Functions * [createRecord](functions/createRecord.md) * [deleteRecord](functions/deleteRecord.md) * [findRecord](functions/findRecord.md) * [query](functions/query.md) * [updateRecord](functions/updateRecord.md) --- --- url: /api/@warp-drive/utilities/active-record/functions/updateRecord.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [active-record](../index.md) / updateRecord ## Call Signature ```ts function updateRecord(record, options?): UpdateRequestOptions>, T>; ``` Defined in: [utilities/src/-private/active-record/save-record.ts:217](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/active-record/save-record.ts#L217) Builds request options to update existing record for resources, configured for the url, method and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { updateRecord } from '@warp-drive/utilities/active-record'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const data = await store.request(updateRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`. * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { updateRecord } from '@warp-drive/utilities/active-record'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const options = updateRecord(person, { patch: true }); const data = await store.request(options); ``` ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../../../core-types/record/interfaces/TypedRecordInstance.md) #### RT `RT` *extends* [`TypedRecordInstance`](../../../core-types/record/interfaces/TypedRecordInstance.md) = `T` ### Parameters #### record `T` #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) & `object` ### Returns [`UpdateRequestOptions`](../../../core-types/request/type-aliases/UpdateRequestOptions.md)<[`SingleResourceDataDocument`](../../../core-types/spec/document/interfaces/SingleResourceDataDocument.md)<`RT`, `StableExistingRecordIdentifier`<`string`>>, `T`> ## Call Signature ```ts function updateRecord(record, options?): UpdateRequestOptions; ``` Defined in: [utilities/src/-private/active-record/save-record.ts:221](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/active-record/save-record.ts#L221) Builds request options to update existing record for resources, configured for the url, method and header expectations of most ActiveRecord APIs. **Basic Usage** ```ts import { updateRecord } from '@warp-drive/utilities/active-record'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const data = await store.request(updateRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`. * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { updateRecord } from '@warp-drive/utilities/active-record'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const options = updateRecord(person, { patch: true }); const data = await store.request(options); ``` ### Parameters #### record `unknown` #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) & `object` ### Returns [`UpdateRequestOptions`](../../../core-types/request/type-aliases/UpdateRequestOptions.md) --- --- url: /api/@warp-drive/utilities/handlers/classes/AutoCompress.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [handlers](../index.md) / AutoCompress Defined in: [utilities/src/-private/handlers/auto-compress.ts:179](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/handlers/auto-compress.ts#L179) A request handler that automatically compresses the request body if the request body is a string, array buffer, blob, or form data. This uses the [CompressionStream API](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream) The compression format as well as the kinds of data to compress can be configured using the `format` and `constraints` options. ```diff +import { AutoCompress } from '@ember-data/request-utils/handlers'; import Fetch from '@ember-data/request/fetch'; import RequestManager from '@ember-data/request'; import Store from '@ember-data/store'; class AppStore extends Store { requestManager = new RequestManager() .use([ + new AutoCompress(), Fetch ]); } ``` AutoCompress ## Since 5.5.0 ## Implements * [`Handler`](../../../../@ember-data/request/index/interfaces/Handler.md) ## Constructors ### Constructor ```ts new AutoCompress(options): AutoCompress; ``` Defined in: [utilities/src/-private/handlers/auto-compress.ts:182](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/handlers/auto-compress.ts#L182) #### Parameters ##### options `CompressionOptions` = `{}` #### Returns `AutoCompress` ## Properties ### options ```ts options: Required & object; ``` Defined in: [utilities/src/-private/handlers/auto-compress.ts:180](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/handlers/auto-compress.ts#L180) #### Type declaration ##### constraints ```ts constraints: Required; ``` ## Methods ### request() ```ts request(context, next): | Promise | Future; ``` Defined in: [utilities/src/-private/handlers/auto-compress.ts:192](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/handlers/auto-compress.ts#L192) Method to implement to handle requests. Receives the request context and a nextFn to call to pass-along the request to other handlers. #### Type Parameters ##### T `T` #### Parameters ##### context [`RequestContext`](../../../core-types/request/interfaces/RequestContext.md) ##### next [`NextFn`](../../../../@ember-data/request/index/type-aliases/NextFn.md)<`T`> #### Returns | `Promise`<`T`> | [`Future`](../../../../@ember-data/request/index/interfaces/Future.md)<`T`> #### Implementation of [`Handler`](../../../../@ember-data/request/index/interfaces/Handler.md).[`request`](../../../../@ember-data/request/index/interfaces/Handler.md#request) --- --- url: /api/@warp-drive/utilities/handlers.md --- [Documentation](../../../index.md) / [@warp-drive/utilities](../index.md) / handlers A selection of pre-built request handlers for handling common request scenarios. ## Classes * [AutoCompress](classes/AutoCompress.md) ## Variables * [SupportsRequestStreams](variables/SupportsRequestStreams.md) --- --- url: /api/@warp-drive/utilities/handlers/variables/SupportsRequestStreams.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [handlers](../index.md) / SupportsRequestStreams ```ts const SupportsRequestStreams: boolean; ``` Defined in: [utilities/src/-private/handlers/auto-compress.ts:8](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/handlers/auto-compress.ts#L8) --- --- url: /api/@warp-drive/utilities.md --- [Documentation](../../index.md) / @warp-drive/utilities ## Modules * [\*](*/index.md) * [active-record](active-record/index.md) * [handlers](handlers/index.md) * [index](index/index.md) * [json-api](json-api/index.md) * [string](string/index.md) --- --- url: /api/@warp-drive/utilities/index/functions/buildBaseURL.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [index](../index.md) / buildBaseURL ```ts function buildBaseURL(urlOptions): string; ``` Defined in: [utilities/src/index.ts:270](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L270) Builds a URL for a request based on the provided options. Does not include support for building query params (see `buildQueryParams`) so that it may be composed cleanly with other query-params strategies. Usage: ```ts import { buildBaseURL } from '@ember-data/request-utils'; const url = buildBaseURL({ host: 'https://api.example.com', namespace: 'api/v1', resourcePath: 'emberDevelopers', op: 'query', identifier: { type: 'ember-developer' } }); // => 'https://api.example.com/api/v1/emberDevelopers' ``` On the surface this may seem like a lot of work to do something simple, but it is designed to be composable with other utilities and interfaces that the average product engineer will never need to see or use. A few notes: * `resourcePath` is optional, but if it is not provided, `identifier.type` will be used. * `host` and `namespace` are optional, but if they are not provided, the values globally configured via `setBuildURLConfig` will be used. * `op` is required and must be one of the following: * 'findRecord' 'query' 'findMany' 'findRelatedCollection' 'findRelatedRecord'\` 'createRecord' 'updateRecord' 'deleteRecord' * Depending on the value of `op`, `identifier` or `identifiers` will be required. ## Parameters ### urlOptions [`UrlOptions`](../type-aliases/UrlOptions.md) ## Returns `string` --- --- url: /api/@warp-drive/utilities/index/functions/buildQueryParams.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [index](../index.md) / buildQueryParams ```ts function buildQueryParams(params, options?): string; ``` Defined in: [utilities/src/index.ts:505](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L505) Sorts query params by both key and value, returning a query params string Treats `included` specially, splicing it into an array if it is a string and sorting the array. Options: * arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma' 'bracket': appends \[] to the key for every value e.g. `ids[]=1&ids[]=2` 'indices': appends \[i] to the key for every value e.g. `ids[0]=1&ids[1]=2` 'repeat': appends the key for every value e.g. `ids=1&ids=2` 'comma' (default): appends the key once with a comma separated list of values e.g. `ids=1,2` ## Parameters ### params [`QueryParamsSource`](../../../core-types/params/type-aliases/QueryParamsSource.md) ### options? [`QueryParamsSerializationOptions`](../../../core-types/params/type-aliases/QueryParamsSerializationOptions.md) ## Returns `string` A sorted query params string without the leading `?` --- --- url: /api/@warp-drive/utilities/index/functions/filterEmpty.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [index](../index.md) / filterEmpty ```ts function filterEmpty(source): Record; ``` Defined in: [utilities/src/index.ts:394](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L394) filter out keys of an object that have falsy values or point to empty arrays returning a new object with only those keys that have truthy values / non-empty arrays ## Parameters ### source `Record`<`string`, [`Serializable`](../../../core-types/params/type-aliases/Serializable.md)> object to filter keys with empty values from ## Returns `Record`<`string`, [`Serializable`](../../../core-types/params/type-aliases/Serializable.md)> A new object with the keys that contained empty values removed --- --- url: /api/@warp-drive/utilities/index/functions/setBuildURLConfig.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [index](../index.md) / setBuildURLConfig ```ts function setBuildURLConfig(config): void; ``` Defined in: [utilities/src/index.ts:95](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L95) Sets the global configuration for `buildBaseURL` for host and namespace values for the application. These values may still be overridden by passing them to buildBaseURL directly. This method may be called as many times as needed. host values of `''` or `'/'` are equivalent. Except for the value of `/` as host, host should not end with `/`. namespace should not start or end with a `/`. ```ts type BuildURLConfig = { host: string; namespace: string' } ``` Example: ```ts import { setBuildURLConfig } from '@ember-data/request-utils'; setBuildURLConfig({ host: 'https://api.example.com', namespace: 'api/v1' }); ``` ## Parameters ### config [`BuildURLConfig`](../interfaces/BuildURLConfig.md) ## Returns `void` --- --- url: /api/@warp-drive/utilities/index/functions/sortQueryParams.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [index](../index.md) / sortQueryParams ```ts function sortQueryParams(params, options?): URLSearchParams; ``` Defined in: [utilities/src/index.ts:427](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L427) Sorts query params by both key and value returning a new URLSearchParams object with the keys inserted in sorted order. Treats `included` specially, splicing it into an array if it is a string and sorting the array. Options: * arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma' 'bracket': appends \[] to the key for every value e.g. `&ids[]=1&ids[]=2` 'indices': appends \[i] to the key for every value e.g. `&ids[0]=1&ids[1]=2` 'repeat': appends the key for every value e.g. `&ids=1&ids=2` 'comma' (default): appends the key once with a comma separated list of values e.g. `&ids=1,2` ## Parameters ### params [`QueryParamsSource`](../../../core-types/params/type-aliases/QueryParamsSource.md) ### options? [`QueryParamsSerializationOptions`](../../../core-types/params/type-aliases/QueryParamsSerializationOptions.md) ## Returns `URLSearchParams` A URLSearchParams with keys inserted in sorted order --- --- url: /api/@warp-drive/utilities/index.md --- [Documentation](../../../index.md) / [@warp-drive/utilities](../index.md) / index ## Interfaces * [BuildURLConfig](interfaces/BuildURLConfig.md) * [CreateRecordUrlOptions](interfaces/CreateRecordUrlOptions.md) * [DeleteRecordUrlOptions](interfaces/DeleteRecordUrlOptions.md) * [FindManyUrlOptions](interfaces/FindManyUrlOptions.md) * [FindRecordUrlOptions](interfaces/FindRecordUrlOptions.md) * [FindRelatedCollectionUrlOptions](interfaces/FindRelatedCollectionUrlOptions.md) * [FindRelatedResourceUrlOptions](interfaces/FindRelatedResourceUrlOptions.md) * [GenericUrlOptions](interfaces/GenericUrlOptions.md) * [QueryUrlOptions](interfaces/QueryUrlOptions.md) * [UpdateRecordUrlOptions](interfaces/UpdateRecordUrlOptions.md) ## Type Aliases * [UrlOptions](type-aliases/UrlOptions.md) ## Functions * [buildBaseURL](functions/buildBaseURL.md) * [buildQueryParams](functions/buildQueryParams.md) * [filterEmpty](functions/filterEmpty.md) * [setBuildURLConfig](functions/setBuildURLConfig.md) * [sortQueryParams](functions/sortQueryParams.md) --- --- url: /api/@warp-drive/utilities/index/interfaces/BuildURLConfig.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [index](../index.md) / BuildURLConfig Defined in: [utilities/src/index.ts:48](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L48) ## Properties ### host ```ts host: null | string; ``` Defined in: [utilities/src/index.ts:49](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L49) *** ### namespace ```ts namespace: null | string; ``` Defined in: [utilities/src/index.ts:50](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L50) --- --- url: /api/@warp-drive/utilities/index/interfaces/CreateRecordUrlOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [index](../index.md) / CreateRecordUrlOptions Defined in: [utilities/src/index.ts:160](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L160) ## Properties ### host? ```ts optional host: string; ``` Defined in: [utilities/src/index.ts:164](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L164) *** ### identifier ```ts identifier: object; ``` Defined in: [utilities/src/index.ts:162](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L162) #### type ```ts type: string; ``` *** ### namespace? ```ts optional namespace: string; ``` Defined in: [utilities/src/index.ts:165](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L165) *** ### op ```ts op: "createRecord"; ``` Defined in: [utilities/src/index.ts:161](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L161) *** ### resourcePath? ```ts optional resourcePath: string; ``` Defined in: [utilities/src/index.ts:163](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L163) --- --- url: /api/@warp-drive/utilities/index/interfaces/DeleteRecordUrlOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [index](../index.md) / DeleteRecordUrlOptions Defined in: [utilities/src/index.ts:176](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L176) ## Properties ### host? ```ts optional host: string; ``` Defined in: [utilities/src/index.ts:180](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L180) *** ### identifier ```ts identifier: object; ``` Defined in: [utilities/src/index.ts:178](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L178) #### id ```ts id: string; ``` #### type ```ts type: string; ``` *** ### namespace? ```ts optional namespace: string; ``` Defined in: [utilities/src/index.ts:181](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L181) *** ### op ```ts op: "deleteRecord"; ``` Defined in: [utilities/src/index.ts:177](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L177) *** ### resourcePath? ```ts optional resourcePath: string; ``` Defined in: [utilities/src/index.ts:179](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L179) --- --- url: /api/@warp-drive/utilities/index/interfaces/FindManyUrlOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [index](../index.md) / FindManyUrlOptions Defined in: [utilities/src/index.ts:135](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L135) ## Properties ### host? ```ts optional host: string; ``` Defined in: [utilities/src/index.ts:139](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L139) *** ### identifiers ```ts identifiers: object[]; ``` Defined in: [utilities/src/index.ts:137](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L137) #### id ```ts id: string; ``` #### type ```ts type: string; ``` *** ### namespace? ```ts optional namespace: string; ``` Defined in: [utilities/src/index.ts:140](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L140) *** ### op ```ts op: "findMany"; ``` Defined in: [utilities/src/index.ts:136](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L136) *** ### resourcePath? ```ts optional resourcePath: string; ``` Defined in: [utilities/src/index.ts:138](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L138) --- --- url: /api/@warp-drive/utilities/index/interfaces/FindRelatedCollectionUrlOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [index](../index.md) / FindRelatedCollectionUrlOptions Defined in: [utilities/src/index.ts:142](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L142) ## Properties ### fieldPath ```ts fieldPath: string; ``` Defined in: [utilities/src/index.ts:145](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L145) *** ### host? ```ts optional host: string; ``` Defined in: [utilities/src/index.ts:147](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L147) *** ### identifier ```ts identifier: object; ``` Defined in: [utilities/src/index.ts:144](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L144) #### id ```ts id: string; ``` #### type ```ts type: string; ``` *** ### namespace? ```ts optional namespace: string; ``` Defined in: [utilities/src/index.ts:148](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L148) *** ### op ```ts op: "findRelatedCollection"; ``` Defined in: [utilities/src/index.ts:143](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L143) *** ### resourcePath? ```ts optional resourcePath: string; ``` Defined in: [utilities/src/index.ts:146](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L146) --- --- url: /api/@warp-drive/utilities/index/interfaces/FindRecordUrlOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [index](../index.md) / FindRecordUrlOptions Defined in: [utilities/src/index.ts:119](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L119) ## Properties ### host? ```ts optional host: string; ``` Defined in: [utilities/src/index.ts:123](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L123) *** ### identifier ```ts identifier: object; ``` Defined in: [utilities/src/index.ts:121](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L121) #### id ```ts id: string; ``` #### type ```ts type: string; ``` *** ### namespace? ```ts optional namespace: string; ``` Defined in: [utilities/src/index.ts:124](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L124) *** ### op ```ts op: "findRecord"; ``` Defined in: [utilities/src/index.ts:120](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L120) *** ### resourcePath? ```ts optional resourcePath: string; ``` Defined in: [utilities/src/index.ts:122](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L122) --- --- url: /api/@warp-drive/utilities/index/interfaces/FindRelatedResourceUrlOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [index](../index.md) / FindRelatedResourceUrlOptions Defined in: [utilities/src/index.ts:151](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L151) ## Properties ### fieldPath ```ts fieldPath: string; ``` Defined in: [utilities/src/index.ts:154](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L154) *** ### host? ```ts optional host: string; ``` Defined in: [utilities/src/index.ts:156](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L156) *** ### identifier ```ts identifier: object; ``` Defined in: [utilities/src/index.ts:153](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L153) #### id ```ts id: string; ``` #### type ```ts type: string; ``` *** ### namespace? ```ts optional namespace: string; ``` Defined in: [utilities/src/index.ts:157](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L157) *** ### op ```ts op: "findRelatedRecord"; ``` Defined in: [utilities/src/index.ts:152](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L152) *** ### resourcePath? ```ts optional resourcePath: string; ``` Defined in: [utilities/src/index.ts:155](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L155) --- --- url: /api/@warp-drive/utilities/index/interfaces/GenericUrlOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [index](../index.md) / GenericUrlOptions Defined in: [utilities/src/index.ts:184](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L184) ## Properties ### host? ```ts optional host: string; ``` Defined in: [utilities/src/index.ts:186](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L186) *** ### namespace? ```ts optional namespace: string; ``` Defined in: [utilities/src/index.ts:187](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L187) *** ### resourcePath ```ts resourcePath: string; ``` Defined in: [utilities/src/index.ts:185](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L185) --- --- url: /api/@warp-drive/utilities/index/interfaces/QueryUrlOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [index](../index.md) / QueryUrlOptions Defined in: [utilities/src/index.ts:127](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L127) ## Properties ### host? ```ts optional host: string; ``` Defined in: [utilities/src/index.ts:131](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L131) *** ### identifier ```ts identifier: object; ``` Defined in: [utilities/src/index.ts:129](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L129) #### type ```ts type: string; ``` *** ### namespace? ```ts optional namespace: string; ``` Defined in: [utilities/src/index.ts:132](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L132) *** ### op ```ts op: "query"; ``` Defined in: [utilities/src/index.ts:128](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L128) *** ### resourcePath? ```ts optional resourcePath: string; ``` Defined in: [utilities/src/index.ts:130](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L130) --- --- url: /api/@warp-drive/utilities/index/interfaces/UpdateRecordUrlOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [index](../index.md) / UpdateRecordUrlOptions Defined in: [utilities/src/index.ts:168](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L168) ## Properties ### host? ```ts optional host: string; ``` Defined in: [utilities/src/index.ts:172](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L172) *** ### identifier ```ts identifier: object; ``` Defined in: [utilities/src/index.ts:170](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L170) #### id ```ts id: string; ``` #### type ```ts type: string; ``` *** ### namespace? ```ts optional namespace: string; ``` Defined in: [utilities/src/index.ts:173](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L173) *** ### op ```ts op: "updateRecord"; ``` Defined in: [utilities/src/index.ts:169](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L169) *** ### resourcePath? ```ts optional resourcePath: string; ``` Defined in: [utilities/src/index.ts:171](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L171) --- --- url: /api/@warp-drive/utilities/index/type-aliases/UrlOptions.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [index](../index.md) / UrlOptions ```ts type UrlOptions = | FindRecordUrlOptions | QueryUrlOptions | FindManyUrlOptions | FindRelatedCollectionUrlOptions | FindRelatedResourceUrlOptions | CreateRecordUrlOptions | UpdateRecordUrlOptions | DeleteRecordUrlOptions | GenericUrlOptions; ``` Defined in: [utilities/src/index.ts:190](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/index.ts#L190) --- --- url: /api/@warp-drive/utilities/json-api/functions/createRecord.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [json-api](../index.md) / createRecord ## Call Signature ```ts function createRecord(record, options?): CreateRequestOptions; ``` Defined in: [utilities/src/-private/json-api/save-record.ts:146](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/json-api/save-record.ts#L146) Builds request options to create new record for resources, configured for the url, method and header expectations of most JSON:API APIs. **Basic Usage** ```ts import { createRecord } from '@warp-drive/utilities/json-api'; const person = store.createRecord('person', { name: 'Ted' }); const data = await store.request(createRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { createRecord } from '@warp-drive/utilities/json-api'; const person = store.createRecord('person', { name: 'Ted' }); const options = createRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### record `T` #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`CreateRequestOptions`](../../../core-types/request/type-aliases/CreateRequestOptions.md)<`T`> ## Call Signature ```ts function createRecord(record, options?): CreateRequestOptions; ``` Defined in: [utilities/src/-private/json-api/save-record.ts:147](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/json-api/save-record.ts#L147) Builds request options to create new record for resources, configured for the url, method and header expectations of most JSON:API APIs. **Basic Usage** ```ts import { createRecord } from '@warp-drive/utilities/json-api'; const person = store.createRecord('person', { name: 'Ted' }); const data = await store.request(createRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { createRecord } from '@warp-drive/utilities/json-api'; const person = store.createRecord('person', { name: 'Ted' }); const options = createRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Parameters #### record `unknown` #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`CreateRequestOptions`](../../../core-types/request/type-aliases/CreateRequestOptions.md) --- --- url: /api/@warp-drive/utilities/json-api/functions/deleteRecord.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [json-api](../index.md) / deleteRecord ## Call Signature ```ts function deleteRecord(record, options?): DeleteRequestOptions; ``` Defined in: [utilities/src/-private/json-api/save-record.ts:76](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/json-api/save-record.ts#L76) Builds request options to delete record for resources, configured for the url, method and header expectations of most JSON:API APIs. **Basic Usage** ```ts import { deleteRecord } from '@warp-drive/utilities/json-api'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const data = await store.request(deleteRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { deleteRecord } from '@warp-drive/utilities/json-api'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const options = deleteRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### record `T` #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`DeleteRequestOptions`](../../../core-types/request/type-aliases/DeleteRequestOptions.md)<`T`> ## Call Signature ```ts function deleteRecord(record, options?): DeleteRequestOptions; ``` Defined in: [utilities/src/-private/json-api/save-record.ts:77](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/json-api/save-record.ts#L77) Builds request options to delete record for resources, configured for the url, method and header expectations of most JSON:API APIs. **Basic Usage** ```ts import { deleteRecord } from '@warp-drive/utilities/json-api'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const data = await store.request(deleteRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { deleteRecord } from '@warp-drive/utilities/json-api'; const person = store.peekRecord('person', '1'); // mark record as deleted store.deleteRecord(person); // persist deletion const options = deleteRecord(person, { namespace: 'api/v1' }); const data = await store.request(options); ``` ### Parameters #### record `unknown` #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`DeleteRequestOptions`](../../../core-types/request/type-aliases/DeleteRequestOptions.md) --- --- url: /api/@warp-drive/utilities/json-api/functions/findRecord.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [json-api](../index.md) / findRecord ## Call Signature ```ts function findRecord(identifier, options?): FindRecordRequestOptions, T>; ``` Defined in: [utilities/src/-private/json-api/find-record.ts:72](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/json-api/find-record.ts#L72) ### Type Parameters #### T `T` ### Parameters #### identifier [`RemotelyAccessibleIdentifier`](../../../core-types/request/type-aliases/RemotelyAccessibleIdentifier.md)<[`TypeFromInstance`](../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`>> #### options? [`FindRecordOptions`](../../../core-types/request/type-aliases/FindRecordOptions.md)<`T`> ### Returns [`FindRecordRequestOptions`](../../../core-types/request/type-aliases/FindRecordRequestOptions.md)<`FindRecordResultDocument`<`T`>, `T`> ## Call Signature ```ts function findRecord(identifier, options?): FindRecordRequestOptions; ``` Defined in: [utilities/src/-private/json-api/find-record.ts:76](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/json-api/find-record.ts#L76) ### Parameters #### identifier [`RemotelyAccessibleIdentifier`](../../../core-types/request/type-aliases/RemotelyAccessibleIdentifier.md) #### options? [`FindRecordOptions`](../../../core-types/request/type-aliases/FindRecordOptions.md) ### Returns [`FindRecordRequestOptions`](../../../core-types/request/type-aliases/FindRecordRequestOptions.md) ## Call Signature ```ts function findRecord( type, id, options?): FindRecordRequestOptions, T>; ``` Defined in: [utilities/src/-private/json-api/find-record.ts:80](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/json-api/find-record.ts#L80) ### Type Parameters #### T `T` ### Parameters #### type [`TypeFromInstance`](../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`> #### id `string` #### options? [`FindRecordOptions`](../../../core-types/request/type-aliases/FindRecordOptions.md)<`T`> ### Returns [`FindRecordRequestOptions`](../../../core-types/request/type-aliases/FindRecordRequestOptions.md)<`FindRecordResultDocument`<`T`>, `T`> ## Call Signature ```ts function findRecord( type, id, options?): FindRecordRequestOptions; ``` Defined in: [utilities/src/-private/json-api/find-record.ts:85](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/json-api/find-record.ts#L85) ### Parameters #### type `string` #### id `string` #### options? [`FindRecordOptions`](../../../core-types/request/type-aliases/FindRecordOptions.md) ### Returns [`FindRecordRequestOptions`](../../../core-types/request/type-aliases/FindRecordRequestOptions.md) --- --- url: /api/@warp-drive/utilities/json-api/functions/postQuery.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [json-api](../index.md) / postQuery ## Call Signature ```ts function postQuery( type, query?, options?): PostQueryRequestOptions, T>; ``` Defined in: [utilities/src/-private/json-api/query.ts:149](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/json-api/query.ts#L149) Builds request options to query for resources, usually by a primary type, configured for the url and header expectations of most JSON:API APIs. The key difference between this and `query` is that this method will send the query as the JSON body of a "POST" request instead of as query params in the url of a "GET" request. A CacheKey is generated from the url and query params, and used to cache the response in the store. ```ts import { postQuery } from '@warp-drive/utilities/json-api'; const options = postQuery('person', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { postQuery } from '@warp-drive/utilities/json-api'; const options = postQuery('person', { include: ['pets', 'friends'] }, { reload: true }); const data = await store.request(options); ``` ### Type Parameters #### T `T` ### Parameters #### type [`TypeFromInstance`](../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`> #### query? [`QueryParamsSource`](../../../core-types/params/type-aliases/QueryParamsSource.md) #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`PostQueryRequestOptions`](../../../core-types/request/type-aliases/PostQueryRequestOptions.md)<[`CollectionResourceDataDocument`](../../../core-types/spec/document/interfaces/CollectionResourceDataDocument.md)<`T`>, `T`> ## Call Signature ```ts function postQuery( type, query?, options?): PostQueryRequestOptions; ``` Defined in: [utilities/src/-private/json-api/query.ts:154](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/json-api/query.ts#L154) Builds request options to query for resources, usually by a primary type, configured for the url and header expectations of most JSON:API APIs. The key difference between this and `query` is that this method will send the query as the JSON body of a "POST" request instead of as query params in the url of a "GET" request. A CacheKey is generated from the url and query params, and used to cache the response in the store. ```ts import { postQuery } from '@warp-drive/utilities/json-api'; const options = postQuery('person', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { postQuery } from '@warp-drive/utilities/json-api'; const options = postQuery('person', { include: ['pets', 'friends'] }, { reload: true }); const data = await store.request(options); ``` ### Parameters #### type `string` #### query? [`QueryParamsSource`](../../../core-types/params/type-aliases/QueryParamsSource.md) #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`PostQueryRequestOptions`](../../../core-types/request/type-aliases/PostQueryRequestOptions.md) --- --- url: /api/@warp-drive/utilities/json-api/functions/query.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [json-api](../index.md) / query ## Call Signature ```ts function query( type, query?, options?): QueryRequestOptions, T>; ``` Defined in: [utilities/src/-private/json-api/query.ts:66](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/json-api/query.ts#L66) Builds request options to query for resources, usually by a primary type, configured for the url and header expectations of most JSON:API APIs. The key difference between this and `postQuery` is that this method will send the query as query params in the url of a "GET" request instead of as the JSON body of a "POST" request. **Basic Usage** ```ts import { query } from '@warp-drive/utilities/json-api'; const data = await store.request(query('person')); ``` **With Query Params** ```ts import { query } from '@warp-drive/utilities/json-api'; const options = query('person', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { query } from '@warp-drive/utilities/json-api'; const options = query('person', { include: ['pets', 'friends'] }, { reload: true }); const data = await store.request(options); ``` ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../../../core-types/record/interfaces/TypedRecordInstance.md) ### Parameters #### type [`TypeFromInstance`](../../../core-types/record/type-aliases/TypeFromInstance.md)<`T`> #### query? [`QueryParamsSource`](../../../core-types/params/type-aliases/QueryParamsSource.md)<`T`> #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`QueryRequestOptions`](../../../core-types/request/type-aliases/QueryRequestOptions.md)<[`CollectionResourceDataDocument`](../../../core-types/spec/document/interfaces/CollectionResourceDataDocument.md)<`T`>, `T`> ## Call Signature ```ts function query( type, query?, options?): QueryRequestOptions; ``` Defined in: [utilities/src/-private/json-api/query.ts:71](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/json-api/query.ts#L71) Builds request options to query for resources, usually by a primary type, configured for the url and header expectations of most JSON:API APIs. The key difference between this and `postQuery` is that this method will send the query as query params in the url of a "GET" request instead of as the JSON body of a "POST" request. **Basic Usage** ```ts import { query } from '@warp-drive/utilities/json-api'; const data = await store.request(query('person')); ``` **With Query Params** ```ts import { query } from '@warp-drive/utilities/json-api'; const options = query('person', { include: ['pets', 'friends'] }); const data = await store.request(options); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { query } from '@warp-drive/utilities/json-api'; const options = query('person', { include: ['pets', 'friends'] }, { reload: true }); const data = await store.request(options); ``` ### Parameters #### type `string` #### query? [`QueryParamsSource`](../../../core-types/params/type-aliases/QueryParamsSource.md) #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) ### Returns [`QueryRequestOptions`](../../../core-types/request/type-aliases/QueryRequestOptions.md) --- --- url: /api/@warp-drive/utilities/json-api/functions/serializePatch.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [json-api](../index.md) / serializePatch ```ts function serializePatch(cache, identifier): object; ``` Defined in: [utilities/src/-private/json-api/serialize.ts:126](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/json-api/serialize.ts#L126) Serializes changes to a resource for use with PATCH requests. Only attributes which are changed are serialized. Only relationships which are changed are serialized. Collection relationships serialize the collection as a whole. If you would like to serialize updates to a collection more granularly (for instance, as operations) request the diff from the store and serialize as desired: ```ts const relationshipDiffMap = cache.changedRelationships(identifier); ``` ## Parameters ### cache [`Cache`](../../../core-types/cache/interfaces/Cache.md) ### identifier [`StableRecordIdentifier`](../../../core-types/identifier/type-aliases/StableRecordIdentifier.md) ## Returns `object` An object with a `data` property containing the serialized resource patch ### data ```ts data: JsonApiResourcePatch; ``` --- --- url: /api/@warp-drive/utilities/json-api/functions/setBuildURLConfig.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [json-api](../index.md) / setBuildURLConfig ```ts function setBuildURLConfig(config): void; ``` Defined in: [utilities/src/-private/json-api/-utils.ts:61](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/json-api/-utils.ts#L61) Allows setting extensions and profiles to be used in the `Accept` header. Extensions and profiles are keyed by their namespace with the value being their URI. Example: ```ts setBuildURLConfig({ extensions: { atomic: 'https://jsonapi.org/ext/atomic' }, profiles: { pagination: 'https://jsonapi.org/profiles/ethanresnick/cursor-pagination' } }); ``` This also sets the global configuration for `buildBaseURL` for host and namespace values for the global coniguration done via `import { setBuildURLConfig } from '@warp-drive/utilities';` These values may still be overridden by passing them to buildBaseURL directly. This method may be called as many times as needed ```ts type BuildURLConfig = { host: string; namespace: string' } ``` ## Parameters ### config `JSONAPIConfig` ## Returns `void` --- --- url: /api/@warp-drive/utilities/json-api/functions/serializeResources.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [json-api](../index.md) / serializeResources ## Call Signature ```ts function serializeResources(cache, identifiers): object; ``` Defined in: [utilities/src/-private/json-api/serialize.ts:33](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/json-api/serialize.ts#L33) Serializes the current state of a resource or array of resources for use with POST or PUT requests. ### Parameters #### cache [`Cache`](../../../core-types/cache/interfaces/Cache.md) #### identifiers [`StableRecordIdentifier`](../../../core-types/identifier/type-aliases/StableRecordIdentifier.md) ### Returns `object` An object with a `data` property containing the serialized resource patch #### data ```ts data: ResourceObject; ``` ## Call Signature ```ts function serializeResources(cache, identifiers): object; ``` Defined in: [utilities/src/-private/json-api/serialize.ts:34](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/json-api/serialize.ts#L34) Serializes the current state of a resource or array of resources for use with POST or PUT requests. ### Parameters #### cache [`Cache`](../../../core-types/cache/interfaces/Cache.md) #### identifiers [`StableRecordIdentifier`](../../../core-types/identifier/type-aliases/StableRecordIdentifier.md)\[] ### Returns `object` An object with a `data` property containing the serialized resource patch #### data ```ts data: ResourceObject[]; ``` --- --- url: /api/@warp-drive/utilities/json-api/functions/updateRecord.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [json-api](../index.md) / updateRecord ## Call Signature ```ts function updateRecord(record, options?): UpdateRequestOptions>, T>; ``` Defined in: [utilities/src/-private/json-api/save-record.ts:218](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/json-api/save-record.ts#L218) Builds request options to update existing record for resources, configured for the url, method and header expectations of most JSON:API APIs. **Basic Usage** ```ts import { updateRecord } from '@warp-drive/utilities/json-api'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const data = await store.request(updateRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`. * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { updateRecord } from '@warp-drive/utilities/json-api'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const options = updateRecord(person, { patch: true }); const data = await store.request(options); ``` ### Type Parameters #### T `T` *extends* [`TypedRecordInstance`](../../../core-types/record/interfaces/TypedRecordInstance.md) #### RT `RT` *extends* [`TypedRecordInstance`](../../../core-types/record/interfaces/TypedRecordInstance.md) = `T` ### Parameters #### record `T` #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) & `object` ### Returns [`UpdateRequestOptions`](../../../core-types/request/type-aliases/UpdateRequestOptions.md)<[`SingleResourceDataDocument`](../../../core-types/spec/document/interfaces/SingleResourceDataDocument.md)<`RT`, `StableExistingRecordIdentifier`<`string`>>, `T`> ## Call Signature ```ts function updateRecord(record, options?): UpdateRequestOptions; ``` Defined in: [utilities/src/-private/json-api/save-record.ts:222](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/json-api/save-record.ts#L222) Builds request options to update existing record for resources, configured for the url, method and header expectations of most JSON:API APIs. **Basic Usage** ```ts import { updateRecord } from '@warp-drive/utilities/json-api'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const data = await store.request(updateRecord(person)); ``` **Supplying Options to Modify the Request Behavior** The following options are supported: * `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`. * `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`. * `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`. * `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type * `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting to `false` if none is configured. * `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`) ```ts import { updateRecord } from '@warp-drive/utilities/json-api'; const person = store.peekRecord('person', '1'); person.name = 'Chris'; const options = updateRecord(person, { patch: true }); const data = await store.request(options); ``` ### Parameters #### record `unknown` #### options? [`ConstrainedRequestOptions`](../../../core-types/request/type-aliases/ConstrainedRequestOptions.md) & `object` ### Returns [`UpdateRequestOptions`](../../../core-types/request/type-aliases/UpdateRequestOptions.md) --- --- url: /api/@warp-drive/utilities/json-api.md --- [Documentation](../../../index.md) / [@warp-drive/utilities](../index.md) / json-api This package provides utilities for working with [JSON:API](https://json-api.org) APIs with [*Ember***Data**](https://github.com/emberjs/data/). ## Installation Install using your javascript package manager of choice. For instance with [pnpm](https://pnpm.io/) ```no-highlight pnpm add @ember-data/json-api ``` ## Usage Request builders are functions that produce [Fetch Options](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). They take a few contextual inputs about the request you want to make, abstracting away the gnarlier details. For instance, to fetch a resource from your API ```ts import { findRecord } from '@ember-data/json-api/request'; const options = findRecord('ember-developer', '1', { include: ['pets', 'friends'] }); /* { url: 'https://api.example.com/v1/ember-developers/1?include=friends,pets', method: 'GET', headers: , // => 'Accept': 'application/vnd.api+json' // => 'Content-Type': 'application/vnd.api+json' op: 'findRecord'; records: [{ type: 'ember-developer', id: '1' }] } *\ ``` Request builder output may be used with either `requestManager.request` or `store.request`. URLs are stable. The same query will produce the same URL every time, even if the order of keys in the query or values in an array changes. URLs follow the most common JSON:API format (dasherized pluralized resource types). \* \* ## Functions * [createRecord](functions/createRecord.md) * [deleteRecord](functions/deleteRecord.md) * [findRecord](functions/findRecord.md) * [postQuery](functions/postQuery.md) * [query](functions/query.md) * [serializePatch](functions/serializePatch.md) * [serializeResources](functions/serializeResources.md) * [setBuildURLConfig](functions/setBuildURLConfig.md) * [updateRecord](functions/updateRecord.md) --- --- url: /api/@warp-drive/utilities/string/functions/capitalize.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [string](../index.md) / capitalize ```ts function capitalize(str): string; ``` Defined in: [utilities/src/-private/string/transform.ts:107](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/string/transform.ts#L107) Returns the Capitalized form of a string ```js import { capitalize } from '@warp-drive/utilities/string'; capitalize('innerHTML') // 'InnerHTML' capitalize('action_name') // 'Action_name' capitalize('css-class-name') // 'Css-class-name' capitalize('my favorite items') // 'My favorite items' capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice' ``` ## Parameters ### str `string` ## Returns `string` ## Since 4.13.0 --- --- url: /api/@warp-drive/utilities/string/functions/clear.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [string](../index.md) / clear ```ts function clear(): void; ``` Defined in: [utilities/src/-private/string/inflect.ts:101](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/string/inflect.ts#L101) Clears the caches for singularize and pluralize. ## Returns `void` ## Since 4.13.0 --- --- url: /api/@warp-drive/utilities/string/functions/camelize.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [string](../index.md) / camelize ```ts function camelize(str): string; ``` Defined in: [utilities/src/-private/string/transform.ts:63](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/string/transform.ts#L63) Returns the lowerCamelCase form of a string. ```js import { camelize } from '@warp-drive/utilities/string'; camelize('innerHTML'); // 'innerHTML' camelize('action_name'); // 'actionName' camelize('css-class-name'); // 'cssClassName' camelize('my favorite items'); // 'myFavoriteItems' camelize('My Favorite Items'); // 'myFavoriteItems' camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice' ``` ## Parameters ### str `string` ## Returns `string` ## Since 4.13.0 --- --- url: /api/@warp-drive/utilities/string/functions/clearRules.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [string](../index.md) / clearRules ```ts function clearRules(): void; ``` Defined in: [utilities/src/-private/string/inflect.ts:129](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/string/inflect.ts#L129) Clears all inflection rules and resets the caches for singularize and pluralize. ## Returns `void` ## Since 4.13.0 --- --- url: /api/@warp-drive/utilities/string/functions/irregular.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [string](../index.md) / irregular ```ts function irregular(single, plur): void; ``` Defined in: [utilities/src/-private/string/inflect.ts:62](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/string/inflect.ts#L62) Marks a word as irregular. Irregular words have unique pluralization and singularization rules. ## Parameters ### single `string` ### plur `string` ## Returns `void` ## Since 4.13.0 --- --- url: /api/@warp-drive/utilities/string/functions/loadIrregular.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [string](../index.md) / loadIrregular ```ts function loadIrregular(irregularPairs): void; ``` Defined in: [utilities/src/-private/string/inflect.ts:81](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/string/inflect.ts#L81) Marks a list of word pairs as irregular. Irregular words have unique pluralization and singularization rules. ## Parameters ### irregularPairs \[`string`, `string`]\[] ## Returns `void` ## Since 4.13.0 --- --- url: /api/@warp-drive/utilities/string/functions/loadUncountable.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [string](../index.md) / loadUncountable ```ts function loadUncountable(uncountables): void; ``` Defined in: [utilities/src/-private/string/inflect.ts:46](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/string/inflect.ts#L46) Marks a list of words as uncountable. Uncountable words are not pluralized or singularized. ## Parameters ### uncountables `string`\[] ## Returns `void` ## Since 4.13.0 --- --- url: /api/@warp-drive/utilities/string/functions/plural.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [string](../index.md) / plural ```ts function plural(regex, string): void; ``` Defined in: [utilities/src/-private/string/inflect.ts:185](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/string/inflect.ts#L185) Adds a pluralization rule. ## Parameters ### regex `RegExp` ### string `string` ## Returns `void` ## Since 4.13.0 --- --- url: /api/@warp-drive/utilities/string/functions/pluralize.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [string](../index.md) / pluralize ```ts function pluralize(word): string; ``` Defined in: [utilities/src/-private/string/inflect.ts:161](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/string/inflect.ts#L161) Pluralizes a word. ## Parameters ### word `string` ## Returns `string` ## Since 4.13.0 --- --- url: /api/@warp-drive/utilities/string/functions/resetToDefaults.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [string](../index.md) / resetToDefaults ```ts function resetToDefaults(): void; ``` Defined in: [utilities/src/-private/string/inflect.ts:113](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/string/inflect.ts#L113) Resets the inflection rules to the defaults. ## Returns `void` ## Since 4.13.0 --- --- url: /api/@warp-drive/utilities/string/functions/singular.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [string](../index.md) / singular ```ts function singular(regex, string): void; ``` Defined in: [utilities/src/-private/string/inflect.ts:204](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/string/inflect.ts#L204) Adds a singularization rule. ## Parameters ### regex `RegExp` ### string `string` ## Returns `void` ## Since 4.13.0 --- --- url: /api/@warp-drive/utilities/string/functions/setMaxLRUCacheSize.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [string](../index.md) / setMaxLRUCacheSize ```ts function setMaxLRUCacheSize(size): void; ``` Defined in: [utilities/src/-private/string/transform.ts:120](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/string/transform.ts#L120) Sets the maximum size of the LRUCache for all string transformation functions. The default size is 10,000. ## Parameters ### size `number` ## Returns `void` ## Since 4.13.0 --- --- url: /api/@warp-drive/utilities/string/functions/singularize.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [string](../index.md) / singularize ```ts function singularize(word): string; ``` Defined in: [utilities/src/-private/string/inflect.ts:147](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/string/inflect.ts#L147) Singularizes a word. ## Parameters ### word `string` ## Returns `string` ## Since 4.13.0 --- --- url: /api/@warp-drive/utilities/string/functions/uncountable.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [string](../index.md) / uncountable ```ts function uncountable(word): void; ``` Defined in: [utilities/src/-private/string/inflect.ts:33](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/string/inflect.ts#L33) Marks a word as uncountable. Uncountable words are not pluralized or singularized. ## Parameters ### word `string` ## Returns `void` ## Since 4.13.0 --- --- url: /api/@warp-drive/utilities/string/functions/underscore.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [string](../index.md) / underscore ```ts function underscore(str): string; ``` Defined in: [utilities/src/-private/string/transform.ts:85](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/string/transform.ts#L85) Returns the lower\_case\_and\_underscored form of a string. ```js import { underscore } from '@warp-drive/utilities/string'; underscore('innerHTML'); // 'inner_html' underscore('action_name'); // 'action_name' underscore('css-class-name'); // 'css_class_name' underscore('my favorite items'); // 'my_favorite_items' underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice' ``` ## Parameters ### str `string` ## Returns `string` ## Since 4.13.0 --- --- url: /api/@warp-drive/utilities/string/variables/dasherize.md --- [Documentation](../../../../index.md) / [@warp-drive/utilities](../../index.md) / [string](../index.md) / dasherize ```ts const dasherize: object = internalDasherize; ``` Defined in: [utilities/src/-private/string/transform.ts:42](https://github.com/emberjs/data/blob/21d1449c749486791af79cbe8179f316a8b2457c/warp-drive-packages/utilities/src/-private/string/transform.ts#L42) Replaces underscores, spaces, or camelCase with dashes. ```js import { dasherize } from '@warp-drive/utilities/string'; dasherize('innerHTML'); // 'inner-html' dasherize('action_name'); // 'action-name' dasherize('css-class-name'); // 'css-class-name' dasherize('my favorite items'); // 'my-favorite-items' dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice' ``` ## Param ## Returns ## Since 4.13.0 --- --- url: /api/@warp-drive/utilities/string.md --- [Documentation](../../../index.md) / [@warp-drive/utilities](../index.md) / string String utilties for transforming and inflecting strings useful for when the format provided by the server is not the format you want to use in your application. Each transformation function stores its results in an LRUCache to avoid recomputing the same value multiple times. The cache size can be set using the `setMaxLRUCacheSize` function. The default size is 10,000. ## Variables * [dasherize](variables/dasherize.md) ## Functions * [camelize](functions/camelize.md) * [capitalize](functions/capitalize.md) * [clear](functions/clear.md) * [clearRules](functions/clearRules.md) * [irregular](functions/irregular.md) * [loadIrregular](functions/loadIrregular.md) * [loadUncountable](functions/loadUncountable.md) * [plural](functions/plural.md) * [pluralize](functions/pluralize.md) * [resetToDefaults](functions/resetToDefaults.md) * [setMaxLRUCacheSize](functions/setMaxLRUCacheSize.md) * [singular](functions/singular.md) * [singularize](functions/singularize.md) * [uncountable](functions/uncountable.md) * [underscore](functions/underscore.md) --- --- url: /api.md --- ## Packages * [@ember-data/active-record](@ember-data/active-record/index.md) * [@ember-data/adapter](@ember-data/adapter/index.md) * [@ember-data/graph](@ember-data/graph/index.md) * [@ember-data/json-api](@ember-data/json-api/index.md) * [@ember-data/legacy-compat](@ember-data/legacy-compat/index.md) * [@ember-data/model](@ember-data/model/index.md) * [@ember-data/request](@ember-data/request/index.md) * [@ember-data/request-utils](@ember-data/request-utils/index.md) * [@ember-data/rest](@ember-data/rest/index.md) * [@ember-data/serializer](@ember-data/serializer/index.md) * [@ember-data/store](@ember-data/store/index.md) * [@ember-data/tracking](@ember-data/tracking/index.md) * [@warp-drive/build-config](@warp-drive/build-config/index.md) * [@warp-drive/core](@warp-drive/core/index.md) * [@warp-drive/core-types](@warp-drive/core-types/index.md) * [@warp-drive/experiments](@warp-drive/experiments/index.md) * [@warp-drive/json-api](@warp-drive/json-api/index.md) * [@warp-drive/legacy](@warp-drive/legacy/index.md) * [@warp-drive/schema-record](@warp-drive/schema-record/index.md) * [@warp-drive/utilities](@warp-drive/utilities/index.md) --- --- url: /guide/1-configuration/3-linting.md --- Optionally, install the ESLint plugin `eslint-plugin-warp-drive` ::: code-group ```sh [pnpm] pnpm add -E eslint-plugin-warp-drive@latest ``` ```sh [npm] npm add -E eslint-plugin-warp-drive@latest ``` ```sh [yarn] yarn add -E eslint-plugin-warp-drive@latest ``` ```sh [bun] bun add --exact eslint-plugin-warp-drive@latest ``` ::: --- --- url: /guide/11-about.md --- [❖ Table of Contents](./0-index.md) [Overview →](./2-overview.md) ## Why WarpDrive? WarpDrive is the data framework for building ambitious applications. What do we mean by ambitious? WarpDrive is ideal for applications looking to be best-in-class: whether that's a small todo app, e-commerce, a social app, or an enterprise b2b software solution. That's because WarpDrive is designed to seamlessly handle the hardest parts of state management when building an app, helping you focus on creating the features and user experiences that drive value. At its most basic, it is "managed fetch". At its most advanced it is a powerful local-first or offline-first solution that dedupes and reactively updates requests across tabs. Our value goes beyond our feature set. WarpDrive embraces the platform, making it quick to pickup the basics. Our patterns are portable and scalable, meaning that as your app, team and data needs evolve we'll be right there with you. Usage across various rendering frameworks will be similar. In fact, this is an explicit goal: WarpDrive enables developers to quickly port and re-use data patterns. Because we are universal and also not tied to any API Format or backend architecture, there's no lock-in. The data patterns you learn and the code you write is portable between frontend frameworks and backend APIs and can help smooth the evolution of both. We're also not specific to a given frontend architecture. When serving on the same domain, you can dedupe and cache requests across multiple apps and tabs at once! This means we are as good for embedded content and MPAs as we are for SPAs. A single WarpDrive configuration can power multiple web-apps using differing frameworks all sharing a single domain: bridging the gap between MPA and SPA. We see this as one of the keys to scalability. Providing a stable framework for how data is requested, cached, mutated, and mocked allows developers to focus more time on the product requirements that matter. Our core philosophy is to deliver value that lasts decades and evolves with your app, helping you ship, iterate and deliver to your customers. ## A Very Brief History WarpDrive began in ~2006 as a suite of ORM-like data utilities in SproutCore that later evolved into EmberData. Beginning in ~2017 the team plotted a course towards a significant evolution of the library based on the lessons learned in the first eleven years. In ~2023 we lifted the veil on that work, shifting from a resource-centric library to a request-centric library and began accelerating towards our goal of becoming a universal library prepared for the demands of web applications over the coming decades. *** [Overview →](./2-overview.md) --- --- url: /guide/4-data.md --- | | | | -- | -- | | [← Making Requests](./2-requests.md)                        |                       [Caching →](./4-caching.md) | ## Data In every application data can take on many different representations: * the API format (what your backend understands) * the wire format (what your backend sends you) * the cache format (what your frontend deserializes the wire format into) * the presentation format (what your frontend transforms the cache format into for utility) As much as possible, WarpDrive encourages aligning *at-least* the first three of these four formats. Aligning formats reduces the mental complexity required to understand the flow of data through your application, making it easier to debug, and reduces the computation necessary at each layer, making your application faster. Misalignment tends to occur when API and Application developers don't work together to understand requirements, or when the format in use is "lossy" (unable to accurately convey the full scope of information being serialized). We encourage the use of [JSON:API](https://jsonapi.org/) as the wire and cache format because unlike most other formats in use today it encodes information about your data in a near-lossless and easily-cacheable manner. For the presentation format, we encourage applications to limit the amount of manual transformation done. Applications should wherever possible align the interfaces of the data components expect to the shape of the data available, rather than transforming data to fit into the component. This said, WarpDrive offers powerful schema-defined transformation and derivation capabilities built-in to the reactivity layer for presenting data from the cache. Handling transformation universally via schema enables apps to align to component interfaces where needed in a safer, more performant manner. We'll explore these capabilities later on in the manual in the sections on [Presentation](./5-presentation.md) and [Schemas](./6-schemas.md). But first, lets take some time to look at some key concepts surrounding the wire and cache format. ### StructuredDocuments ### ResourceDocuments ### Resources ### CacheKeys ### Membership ### Fields | | | | -- | -- | | [← Making Requests](./2-requests.md)                        |                       [Caching →](./4-caching.md) | --- --- url: /guide/8-schemas.md --- | | | | -- | -- | | [← Working with Data in your UI](./5-presentation.md)                        |                       [Request Builders →](./7-builders.md) | ## Field Schemas | | | | -- | -- | | [← Working with Data in your UI](./5-presentation.md)                        |                       [Request Builders →](./7-builders.md) | --- --- url: /guide/concepts/builders.md --- --- --- url: /guide/concepts/handlers.md --- --- --- url: /guide/concepts/mutations.md --- --- --- url: /guide/concepts/normalization.md --- --- --- url: /guide/concepts/operations.md --- --- --- url: /guide/concepts/reactive-control-flow.md --- --- --- url: /guide/concepts/requests.md --- ```ts const result = await store.request({ url: '/api/users?search=Chris' }) ``` ```glimmer-ts const UsersSearch = { url: '/api/users?search=Chris' }; export default ``` Every request three distinct parts * *the request* - the object we construct to describe what it is we want to do * *fulfillment* - how we go about making the request do the thing we need it to do * *the response* - the processed result once the request is complete ### Fetch Example > \[!TIP] > When we want to show integration with a framework, this tutorial > uses [EmberJS](https://emberjs.com), a powerful modern web framework with an established multi-decade legacy. *Run This Example* → [Request | Fetch Example](https://warpdrive.nullvoxpopuli.com/manual/requests/fetch) Data fetching is managed by a `RequestManager`, which executes handlers you provide. In order to make requests, first we create a `RequestManager` for our application, and we tell it to fulfill requests using a `Fetch` handler. ```ts import RequestManager from '@ember-data/request'; import { Fetch } from '@ember-data/request/fetch'; const manager = new RequestManager().use([Fetch]); ``` Now we can issue a request for a list of our users: ```ts const { content } = await manager.request({ url: '/users' }); for (const user of content.data) { greet(`${user.firstName} ${user.lastName}`); } ``` If we wanted to type the above request, we could supply a type for the content returned by the request: ```ts type User = { id: string; firstName: string; lastName: string; age: number; }; type UsersQuery = { data: User[]; } ``` And use it like this: ```ts const { content } = await manager.request({ url: '/users' }); ``` > \[!TIP] > Manually supplying the generic is NOT the preferred way > to type a request, look for the section on [builders](./7-builders.md) > later. ### The Chain of Responsibility When we created the request manager for our application above, you may have noticed that when we told it to fulfill requests using the `Fetch` handler we did so by passing in an array: ```ts new RequestManager().use([Fetch]); ``` The request manager follows the [chain-of-responsibility pattern](https://en.wikipedia.org/wiki/Chain-of-responsibility_pattern): each handler in our array may choose to fulfill the request, modify it, or pass it along unchanged to the next handler in the array, in array order. ```mermaid --- config: theme: neutral --- flowchart LR C(Handler 1) C <==> D(Handler 2) D <==> E(Handler 3) C <--> F@{ shape: lin-cyl, label: "Source A" } D <--> G@{ shape: lin-cyl, label: "Source B" } E <--> H@{ shape: lin-cyl, label: "Source C" } ``` A handler receives the request `context` as well as a `next` function with which to pass along a request if it so chooses. ```ts type NextFn = (req: RequestInfo) => Future; type Handler = { request(context: RequestContext, next: NextFn): Promise | Future; } ``` `next` returns a Future, which is a promise with a few additional capabilities. Futures resolve with the response from the next handler in the chain. This allows a handler to read or modify the response if it wants. > \[!Important] > requests are immutable, to modify one the handler must create a new request, copying over or > cloning the parts it wants to leave unchanged. ```ts type NextFn = (req: RequestInfo) => Future; type Handler = { request(context: RequestContext, next: NextFn): Promise | Future; } ``` A handler may be any object with a `request` method. This allows both stateful and non-stateful handlers to be utilized. > \[!TIP] > Handlers should take care of the most generalizable concerns. In general great handlers > > * apply to many-if-not-all requests > * have a clear heuristic by which they activate (a header, op-code, option, or url scheme) > * don't block response streaming (we'll talk about this later) --- --- url: /guide/concepts/schemas.md --- --- --- url: /guide/concepts/serialization.md --- --- --- url: /guide/concepts/transformation.md --- --- --- url: /guide/contributing/issues.md --- ### Reporting Bugs Report issues you've discovered via [GitHub issues](https://github.com/emberjs/data/issues). We have provided an [issue template](.github/bug.md) what will help guide you through the process. If you are unsure if something is a bug, the `#ember-data` channel on [Discord](https://discord.gg/zT3asNS) is a great place to ask for help! --- --- url: /guide/contributing/linking-to-applications.md --- #### Testing WarpDrive source directly in your Application You can use package linking to test checkouts of WarpDrive against your application locally. This applies to consuming WarpDrive directly within an ember application. It will not work in your application if you are consuming WarpDrive through an addon (transitive dependency problem). This approach also presumes consuming all of WarpDrive. 1. clone this repository or another fork 2. install dependencies: `pnpm install` 3. change into the `ember-data` package directory `cd packages/-ember-data` If using `pnpm` 1. run `link`. `pnpm link -g` 2. `cd` into your application 3. run `pnpm link ember-data` If you don't use pnpm in your application, using the appropriate `yarn link` and `npm link` commands within the respective directories for the project and your app may work. Once you have linked WarpDrive to your application, you can run `ember serve` as usual in your application. --- --- url: /guide/contributing/project-architecture.md --- ## Architectural Diagram --- --- url: /guide/contributing/rfc-process.md --- ### Requesting Features or Deprecations While WarpDrive is universal in nature, its development is managed by the EmberJS community. WarpDrive participates in the [RFC process (GitHub emberjs/rfcs)](https://github.com/emberjs/rfcs/). Most changes to the public API including new features, changes in behavior, or deprecations require community discussion and must go through this process. While there is no guarantee that an RFC will be accepted, successful RFCs typically follow a pattern of iteration while gathering requirements, addressing feedback, and consensus building. The best RFCs are narrowly scoped with clear understanding of alternatives, drawbacks, and their effect on the community. ``` Here are a few suggestions of **steps to take before drafting your RFC** to best make your RFC successful. Often this process will complete quickly, but when it does not, don't despair! Often the best ideas take the longest to bake. ``` 1. Bring up your idea in the `#dev-ember-data` channel on [Discord](https://discord.gg/zT3asNS) or with individual [team members](https://emberjs.com/team/) 2. Reflect on any concerns, alternatives, or questions that arise from these discussions. 3. Continue to discuss the idea, giving time for everyone to digest and think about it. 4. Attend the weekly team meeting to discuss your idea 5. Open an [RFC issue](https://github.com/emberjs/rfcs/issues?q=is%3Aissue+is%3Aopen+label%3AT-ember-data) to broaden and record the discussion if the idea needs more time for discussion and iteration. * label your issue with `T-ember-data` (or ask someone in `#dev-ember-data` to add the label if you lack the permission) * announce your issue in `#dev-ember-data` and anywhere else desired such as `#news-and-announcements` and `bluesky`. 6. [Draft an RFC](https://github.com/emberjs/rfcs#what-the-process-is) and share it with those you have been discussing the ideas with. 7. Publish your RFC by opening a PR to [emberjs/rfcs/](https://github.com/emberjs/rfcs/pulls?q=is%3Apr+is%3Aopen+label%3AT-ember-data) * label your PR with `T-ember-data` (or ask someone in `#dev-ember-data` to add the label if you lack the permission) * announce your PR in `#dev-ember-data` and anywhere else desired such as `#news-and-announcements` and `bluesky`. 8. Attend weekly team meetings to discuss the RFC, continue iterating on the RFC, and help shepherd it to completion. 9. Build a proof-of-concept. Sometimes this is best if it occurs alongside drafting the RFC, as it often informs the RFC design, known drawbacks, and alternatives. Often it will become incorporated in the final implementation. 10. If you are able, help land the work in a release! It is not required that you implement your own RFC but often this is the best way to ensure that accepted RFCs are implemented in a timely manner. --- --- url: /guide/misc/8-community-resources.md --- ## Conference Talks * EmberConf 2023 | [EmberData: Data Management That Scales With You by Chris Thoburn](https://www.youtube.com/watch?v=KpakmlxvT0s) * EmberFest 2023 | [The New Era of Backend Integration – Kirill Shaplyko](https://www.youtube.com/watch?v=PKekDnJxUQY) * EmberConf 2024 | [An Important EmberData Project Update with Chris Thoburn and Krystan HuffMenne](https://www.youtube.com/watch?v=HQiKFaTAahM) * EmberConf 2024 | [The EmberData Upgrade Path with Kirill Shaplyko](https://www.youtube.com/watch?v=3_kTmfLG6b0) * EmberFest 2024 | [The Architecture of WarpDrive | Beyond Universal – Chris Thoburn](https://www.youtube.com/watch?v=BCv8OgcG5vM) ## Blog Posts * [Not Your Parent's EmberData](https://runspired.com/2024/01/31/modern-ember-data.html) | *2024-01-31* by [Chris Thoburn](https://github.com/runspired) * [Adventures in WarpDrive | Cascade On Delete](https://runspired.com/2024/11/29/cascade-on-delete.html) | *2024-11-29* by [Chris Thoburn](https://github.com/runspired) * [Exploring Transformed and Derived Values in @warp-drive/schema-record](https://runspired.com/2025/02/06/exploring-transformed-and-derivied-values-in-schema-record.html) | *2025-02-06* by [Chris Thoburn](https://github.com/runspired) --- --- url: /index.md --- --- --- url: /llm-docs.md --- ## LLM Optimized Documentation * [llms.txt](/llms.txt) * [llms-full.txt](/llms-full.txt) --- --- url: /guide/2-requests/5-using-"Just-Fetch".md --- # Using "Just Fetch" Throughout this guide we've shown usage of the `RequestManager` in context of a `Store`. ::: code-group ```ts [Setup] import Store, { CacheHandler} from '@ember-data/store'; import RequestManager from '@ember-data/request'; import Fetch from '@ember-data/request/fetch'; export default class AppStore extends Store { requestManager = new RequestManager() .use([Fetch]) .useCache(CacheHandler); } ``` ```ts [Usage] store.request({ url: '/users' }) ``` ::: This is because most applications will want access to features only available when using the store such as reactive-data, advanced caching, and relational mapping. Out of the box, the entire ***Warp*Drive** experience is optimized to be small and fast. However, if all your application needs is a pipeline to help you manage requests in a conventional way (or that plus reactive promise states / reactive control flow) then its possible to use an even more minimal ***Warp*Drive** setup. This guide covers how to do so. --- --- url: /guide/misc/0-index.md --- # WarpDrive Read [The Manual](./manual/0-index.md) ## Other Topics * [Relationships](./relationships/index.md) * [Requests](./requests/index.md) * [Reactivity](./reactive-data/index.md) * [Typescript](./typescript/index.md) * [Terminology](./terminology.md) * [Cookbook](./cookbook/index.md) * [The Two Store Migration Approach](./migrating/two-store-migration.md) ## Community Resources * [Conference Talks](./community-resources.md#conference-talks) * [Blog Posts](./community-resources.md#blog-posts) --- --- url: /guide/contributing/writing-api-docs.md --- # Writing Documentation There are two sources of documentation in this repository: * [Guides](../guides/) - markdown files that are compiled into the manual for the website * inline code comments and types - from which the API Docs are compiled Both are previewable by following the instructions in the [Docs Viewer](../docs-viewer/README.md) Great documentation requires both guides and docs. We encourage updating any associated guides affected by code changes as you make them, and writing new guides when appropriate. ## API Documentation Infra Overview API Documentation is generated from [TSDoc](https://tsdoc.org/) comments in the source code compiled with [TypeDoc](https://typedoc.org/) and transformed for [Vitepress](https://vitepress.dev/) using [typedoc-plugin-markdown](https://www.typedoc-plugin-markdown.org/plugins/vitepress) TSDoc syntax is similar to YUIDoc and JSDoc but there are occassional nuances where it becomes best to know the underlying grammar is TSDoc and parser is TypeDoc. TypeDoc is configured to follow our public package entrypoints to auto-discover documentation. It documents everything reachable, public or private including properties and methods that have no associated code docs. It uses typescript to understand the source-code and builds documentation from the combination of Type signatures and TSDoc comments. This is great, but it means that its very easy to leak private APIs into the docs, use `/** @internal */` on things that should not be put into the public docs. While API Documentation lives with the source-code, the code itself plays no-part in the documentation that is generated: everything is compiled from comments alone. The below guide will walk through best practices for writing doc comments, important nuances and syntaxes to know, as well as how to test and preview the doc comments. *** ## Documentation Syntax ### What are Doc Comments Only `**` comments are compiled as potential documentation, e.g. ```ts /** * This is a potential documentation block */ ``` Where as single star comment blocks are not considered documentation ```ts /* * This is not a potential documentation block */ ``` ### Where to put Doc Comments Documentation comments should be placed directly above the symbol they are documenting. ```ts /** * Documents the class */ class Foo { /** * Documents the method */ bar() {} /** * Documents the property */ bar = '1'; } /** * Documents the interface */ interface Foo { /** * Documents the member */ bar: string; } /** * Documents the type */ type Foo = { /** * Documents the member */ bar: string; } /** * Documents the variable */ const Foo = '1'; /** * Documents the function */ function foo() {} ``` ### Ignored Doc Comments When compiling the API documentation, comments using the `@internal` tag will be ignored: For example, the below doc comment would be ignored. This is useful for documenting code for fellow developers that shouldn't be exposed to end consumers. ```ts /** * This is a private utility for updating the state * of a relationship. * * @internal */ function somethingInside() {} ``` ### Auto Association TSDoc and TypeDoc will automatically place the documentation for a method inside the class it is on, the class inside the package it is in and at the export path it is exported from. Because it knows our entrypoints and our types, we don't need to tell it much! It already knows when something is an interface vs a class, when it extends something else, or that it implements a specific signature. This means you no longer need to add redundant tags like `@module` `@class` `@method` `@static` and `@property`. ### Doc Comments can be Markdown Doc comments can contain most any valid markdown syntax, most markdown-valid html, and can utilize code-highlighting via language prefix on a code block comment. For instance ````ts /** * ## Overview * * Some details * * ### An Example * * ```ts * new Store(); * ``` * * @public */ ```` Additionally, the markdown parser in use by our docs understands documentation groups, and [many other features](https://vitepress.dev/guide/markdown). This means we can do code examples that toggle between files or formats. ````ts /** * ::: code-group * * ```ts [example.ts] * export function numberFromStrong(str: string): number {} * ``` * * ```js [example.js] * export function numberFromStrong(str) {} * ``` * * ::: */ ```` Highlighting, focus management and code groups are three features that combine to enable crafting powerful examples in the documentation. ### Doc Comments should start every line with a `*` While technically doc comments only need to start with `/**`, providing a `*` for every line with matching indentation ensures correct parsing of all tags and documentation. Without this, some decorators in code examples may be incorrectly parsed as documentation tags, and some documentation may be unexpectedly truncated. **Good** ````ts /** * ## Overview * * Some details * * ### An Example * * ```ts * class User extends Model { * @attr name; * } * ``` * * @public */ ```` **Bad** ````ts /** ## Overview Some details ### An Example \```ts class User extends Model { @attr name; } \``` @public */ ```` ### Documenting Packages and Subpackages To create an overview for a module path e.g. `@warp-drive/core-types` or `@warp-drive/core-types/symbol` all that is needed is a doc comment at the top of the file with the tag \`@module. For instance, to write documentation giving an overview of `@warp-drive/core-types` we would do the following in `packages/core-types/src/index.ts` ```ts /** * This package provides essential types and symbols used * by all the other WarpDrive/EmberData packages. * * @module */ ``` ### Always specify `@since` on non-type public APIs ```ts /** * @since 1.13.0 * @public */ ``` ### Use `@hideconstructor` for classes that aren't directly instantiated by users [@hideconstructor](https://typedoc.org/documents/Tags._hideconstructor.html#hideconstructor) ```ts /** * @hideconstructor */ class SchemaRecord {} ``` Methods are documented with `@method` and attatch to the most recent class the parser has seen. ### Don't document types in @param and @return Because types are parsed from the typescript, @param and @return should be used to give a meaningful description only. ```ts /** * Adds two numbers * * @param a - the first number to add * @param b - the second number to add * @return the sum of the two numbers */ function add(a: number, b: number): number {} ``` *** ## Documentation Hygeine ### Documentation Tests > \[!Caution] > Ignore this section. Doc tests are deactivated while we > migrate to tsdoc and typedoc. Run `pnpm test:docs` This will lint discovered doc comments for common sources of error, as well as validate that no published documentation has been added or removed unexpectedly. If documentation has been added, an entry for it should be added to `tests/docs/fixtures/expected.js`. If documentation has been removed, similarly any entry for it should be removed from `tests/docs/fixtures/expected.js`. If documentation you've added is not being discovered by the test, it is likely that either * it may have been excluded due to using an [ignored doc comment](#ignored-doc-comments) * it may have been excluded due to not using the right [comment syntax](#what-are-doc-comments) * it may have been included in the list of paths to search for source code documentation in [yuidoc.json](../docs-generator/yuidoc.json) ### Previewing Documentation #### For `docs.warp-drive.io` From inside the `docs-viewer` directory * start sync for guides with `bun ./src/start-guides-sync.ts` * build/rebuild the API docs with `pnpm typedoc` (rerun as needed) * start the server with `pnpm dev`, visit the site url #### For `api.emberjs.com` > \[!Caution] > Ignore this section. Ember api docs are incompatible while we > migrate to tsdoc and typedoc. Once the migration is nearing > completion we will create a transform to restore these docs. Run `bun preview-api-docs` from the project root or the `docs-viewer` directory. This will build and run the (external) api-docs app with the current state of the api docs in the repo. Changes need to be manually rebuilt with `bun rebuild-api-docs`. See the [Docs Viewer README](../docs-viewer/README.md) for more info.