UNPKG

16 kBSource Map (JSON)View Raw
1{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["/**\n <p align=\"center\">\n <img\n class=\"project-logo\"\n src=\"https://raw.githubusercontent.com/emberjs/data/4612c9354e4c54d53327ec2cf21955075ce21294/ember-data-logo-light.svg#gh-light-mode-only\"\n alt=\"EmberData\"\n width=\"240px\"\n title=\"EmberData\"\n />\n</p>\n\n<p align=\"center\">The lightweight reactive data library for JavaScript applications</p>\n\n---\n\nWrangle your application's data management with scalable patterns for developer productivity.\n\n- ⚡️ Committed to Best-In-Class Performance\n- 🌲 Focused on being as svelte as possible\n- 🚀 SSR Ready\n- 🔜 Typescript Support\n- 🐹 Built with ♥️ by [Ember](https://emberjs.com)\n- ⚛️ Supports any API: `GraphQL` `JSON:API` `REST` `tRPC` ...bespoke or a mix\n\n### 📖 On This Page\n\n- [Overview](./#overview)\n - [Architecture](#🪜-architecture)\n - [Basic Installation](#basic-installation)\n - [Advanced Installation](#advanced-installation)\n- [Configuration](#configuration)\n - [Deprecation Stripping](#deprecation-stripping)\n - [randomUUID polyfill](#randomuuid-polyfill)\n - [Removing inspector support in production](#removing-inspector-support-in-production)\n - [Debugging](#debugging)\n\n\n# Overview\n\n*Ember*‍**Data** is a lightweight reactive data library for JavaScript applications that provides composable primitives for ordering query/mutation/peek flows, managing network and cache, and reducing data for presentation.\n\n## 🪜 Architecture\n\nThe core of *Ember*‍**Data** is the `Store`, which coordinates interaction between your application, the `Cache`, and sources of data (such as your `API` or a local persistence layer).\nOptionally, the Store can be configured to hydrate the response data into rich presentation classes.\n\n*Ember*‍**Data** is both resource centric and document centric in it's approach to caching, requesting and presenting data. Your application's configuration and usage drives which is important and when.\n\nThe `Store` is a **coordinator**. When using a `Store` you configure what cache to use, how cache data should be presented to the UI, and where it should look for requested data when it is not available in the cache.\n\nThis coordination is handled opaquely to the nature of the requests issued and the format of the data being handled. This approach gives applications broad flexibility to configure *Ember*‍**Data** to best suite their needs. This makes *Ember*‍**Data** a powerful solution for applications regardless of their size and complexity.\n\n*Ember*‍**Data** is designed to scale, with a religious focus on performance and asset-size to keep its footprint small but speedy while still being able to handle large complex APIs in huge data-driven applications with no additional code and no added application complexity. It's goal is to prevent applications from writing code to manage data that is difficult to maintain or reason about.\n\n*Ember*‍**Data**'s power comes not from specific features, data formats, or adherence to specific API specs such as `JSON:API` `trpc` or `GraphQL`, but from solid conventions around requesting and mutating data developed over decades of experience scaling developer productivity.\n\n## Basic Installation\n\nInstall using your javascript package manager of choice. For instance with [pnpm](https://pnpm.io/)\n\n```no-highlight\npnpm add ember-data\n```\n\n`ember-data` is installed by default for new applications generated with `ember-cli`. You can check what version is installed by looking in the `devDependencies` hash of your project's [package.json](https://docs.npmjs.com/cli/v8/configuring-npm/package-json) file.\n\nIf you have generated a new `Ember` application using `ember-cli` but do\nnot wish to use `ember-data`, remove `ember-data` from your project's `package.json` file and run your package manager's install command to update your lockfile.\n\n## Advanced Installation\n\n*Ember*‍**Data** is organized into primitives that compose together via public APIs.\n\n- [@ember-data/store](/ember-data/release/modules/@ember-data%2Fstore) is the core and handles coordination\n- [@ember-data/json-api](/ember-data/release/modules/@ember-data%2Fjson-api) provides a resource cache for JSON:API structured data. It integrates with the store via the hook `createCache`\n- [@ember-data/model](/ember-data/release/modules/@ember-data%2Fmodel) is a presentation layer, it integrates with the store via the hooks `instantiateRecord` and `teardownRecord`.\n- [@ember-data/adapter](/ember-data/release/modules/@ember-data%2Fadapter) provides various network API integrations for APIS built over specific REST or JSON:API conventions.\n- [@ember-data/serializer](/ember-data/release/modules/@ember-data%2Fserializer) pairs with `@ember-data/adapter` to normalize and serialize data to and from an API format into the `JSON:API` format understood by `@ember-data/json-api`.\n- [@ember-data/debug](/ember-data/release/modules/@ember-data%2Fdebug) provides debugging support for the `ember-inspector`.\n- **ember-data** is a \"meta\" package which bundles all of these together for convenience\n\nThe packages interop with each other through well defined public API boundaries. The core\nof the library is the store provided by `@ember-data/store`, while each of the other libraries plugs into the store when installed. Because these packages interop via fully\npublic APIs, other libraries or applications may provide their own implementations. For instance, [ember-m3](https://github.com/hjdivad/ember-m3) is a commonly used presentation and cache implementation suitable for complex resource objects and graphs.\n\n## Configuration\n\n### Deprecation Stripping\n\n*Ember*‍**Data** allows users to opt-in and remove code that exists to support deprecated behaviors.\n\nIf your app has resolved all deprecations present in a given version, you may specify that version as your \"compatibility\" version to remove the code that supported the deprecated behavior from your app.\n\n```ts\nlet app = new EmberApp(defaults, {\n emberData: {\n compatWith: '4.8',\n },\n});\n```\n\n- [Full Documentation](https://api.emberjs.com/ember-data/release/modules/@ember-data%2Fdeprecations)\n\n### randomUUID polyfill\n\n*Ember*‍**Data** uses `UUID V4` by default to generate identifiers for new data created on the client. Identifier generation is configurable, but we also for convenience will polyfill\nthe necessary feature if your browser support or deployment environment demands it. To\nactivate this polyfill:\n\n```ts\nlet app = new EmberApp(defaults, {\n '@embroider/macros': {\n setConfig: {\n '@ember-data/store': {\n polyfillUUID: true\n },\n },\n },\n});\n```\n\n### removing inspector support in production\n\nIf you do not with to ship inspector support in your production application, you can specify\nthat all support for it should be stripped from the build.\n\n```ts\nlet app = new EmberApp(defaults, {\n emberData: {\n includeDataAdapterInProduction: false\n }\n});\n```\n\n- [Full Documentation](https://api.emberjs.com/ember-data/release/modules/@ember-data%2Fdebug)\n\n### Debugging\n\nMany portions of the internals are helpfully instrumented with logging that can be activated\nat build time. This instrumentation is always removed from production builds or any builds\nthat has not explicitly activated it. To activate it set the appropriate flag to `true`.\n\n```ts\n let app = new EmberApp(defaults, {\n emberData: {\n debug: {\n LOG_PAYLOADS: false, // data store received to update cache with\n LOG_OPERATIONS: false, // updates to cache remote state\n LOG_MUTATIONS: false, // updates to cache local state\n LOG_NOTIFICATIONS: false,\n LOG_REQUESTS: false, // log Requests issued via the request manager\n LOG_REQUEST_STATUS: false,\n LOG_IDENTIFIERS: false,\n LOG_GRAPH: false,\n LOG_INSTANCE_CACHE: false,\n }\n }\n });\n ```\n\n @module ember-data-overview\n @main ember-data-overview\n*/\nimport { deprecate } from '@ember/debug';\n\nimport { dependencySatisfies, importSync, macroCondition } from '@embroider/macros';\n\nimport Adapter, { BuildURLMixin } from '@ember-data/adapter';\nimport AdapterError, {\n AbortError,\n ConflictError,\n ForbiddenError,\n InvalidError,\n NotFoundError,\n ServerError,\n TimeoutError,\n UnauthorizedError,\n} from '@ember-data/adapter/error';\nimport JSONAPIAdapter from '@ember-data/adapter/json-api';\nimport RESTAdapter from '@ember-data/adapter/rest';\nimport Model, { attr, belongsTo, hasMany } from '@ember-data/model';\nimport Serializer from '@ember-data/serializer';\nimport JSONSerializer from '@ember-data/serializer/json';\nimport JSONAPISerializer from '@ember-data/serializer/json-api';\nimport RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';\nimport Transform, {\n BooleanTransform,\n DateTransform,\n NumberTransform,\n StringTransform,\n} from '@ember-data/serializer/transform';\n\nimport {\n DS,\n Errors,\n ManyArray,\n PromiseArray,\n PromiseManyArray,\n PromiseObject,\n RecordArrayManager,\n Snapshot,\n Store,\n} from './-private/index';\nimport setupContainer from './setup-container';\n\ndeprecate(\n 'Importing from `ember-data` is deprecated. Please import from the appropriate `@ember-data/*` instead.',\n false,\n {\n id: 'ember-data:deprecate-legacy-imports',\n for: 'ember-data',\n until: '6.0',\n since: {\n enabled: '5.2',\n available: '5.2',\n },\n }\n);\n\ninterface DSLibrary extends DS {\n Store: typeof Store;\n PromiseArray: typeof PromiseArray;\n PromiseObject: typeof PromiseObject;\n PromiseManyArray: typeof PromiseManyArray;\n Model: typeof Model;\n attr: typeof attr;\n Errors: typeof Errors;\n Snapshot: typeof Snapshot;\n Adapter: typeof Adapter;\n AdapterError: typeof AdapterError;\n InvalidError: typeof InvalidError;\n TimeoutError: typeof TimeoutError;\n AbortError: typeof AbortError;\n UnauthorizedError: typeof UnauthorizedError;\n ForbiddenError: typeof ForbiddenError;\n NotFoundError: typeof NotFoundError;\n ConflictError: typeof ConflictError;\n ServerError: typeof ServerError;\n Serializer: typeof Serializer;\n DebugAdapter?: typeof import('@ember-data/debug').default;\n ManyArray: typeof ManyArray;\n RecordArrayManager: typeof RecordArrayManager;\n RESTAdapter: typeof RESTAdapter;\n BuildURLMixin: typeof BuildURLMixin;\n RESTSerializer: typeof RESTSerializer;\n JSONSerializer: typeof JSONSerializer;\n JSONAPIAdapter: typeof JSONAPIAdapter;\n JSONAPISerializer: typeof JSONAPISerializer;\n Transform: typeof Transform;\n DateTransform: typeof DateTransform;\n StringTransform: typeof StringTransform;\n NumberTransform: typeof NumberTransform;\n BooleanTransform: typeof BooleanTransform;\n EmbeddedRecordsMixin: typeof EmbeddedRecordsMixin;\n belongsTo: typeof belongsTo;\n hasMany: typeof hasMany;\n _setupContainer: typeof setupContainer;\n}\n\nfunction upgradeDS(obj: unknown): asserts obj is DSLibrary {}\n\nupgradeDS(DS);\n\nDS.Store = Store;\nDS.PromiseArray = PromiseArray;\nDS.PromiseObject = PromiseObject;\nDS.PromiseManyArray = PromiseManyArray;\nDS.Model = Model;\nDS.attr = attr;\nDS.Errors = Errors;\nDS.Snapshot = Snapshot;\nDS.Adapter = Adapter;\nDS.AdapterError = AdapterError;\nDS.InvalidError = InvalidError;\nDS.TimeoutError = TimeoutError;\nDS.AbortError = AbortError;\nDS.UnauthorizedError = UnauthorizedError;\nDS.ForbiddenError = ForbiddenError;\nDS.NotFoundError = NotFoundError;\nDS.ConflictError = ConflictError;\nDS.ServerError = ServerError;\nDS.Serializer = Serializer;\n\nif (macroCondition(dependencySatisfies('@ember-data/debug', '*'))) {\n DS.DebugAdapter = importSync('@ember-data/debug') as typeof import('@ember-data/debug').default;\n}\n\nDS.ManyArray = ManyArray;\nDS.RecordArrayManager = RecordArrayManager;\nDS.RESTAdapter = RESTAdapter;\nDS.BuildURLMixin = BuildURLMixin;\nDS.RESTSerializer = RESTSerializer;\nDS.JSONSerializer = JSONSerializer;\nDS.JSONAPIAdapter = JSONAPIAdapter;\nDS.JSONAPISerializer = JSONAPISerializer;\nDS.Transform = Transform;\nDS.DateTransform = DateTransform;\nDS.StringTransform = StringTransform;\nDS.NumberTransform = NumberTransform;\nDS.BooleanTransform = BooleanTransform;\nDS.EmbeddedRecordsMixin = EmbeddedRecordsMixin;\nDS.belongsTo = belongsTo;\nDS.hasMany = hasMany;\nDS._setupContainer = setupContainer;\n\nexport default DS;\n"],"names":["deprecate","id","for","until","since","enabled","available","DS","Store","PromiseArray","PromiseObject","PromiseManyArray","Model","attr","Errors","Snapshot","Adapter","AdapterError","InvalidError","TimeoutError","AbortError","UnauthorizedError","ForbiddenError","NotFoundError","ConflictError","ServerError","Serializer","macroCondition","dependencySatisfies","DebugAdapter","importSync","ManyArray","RecordArrayManager","RESTAdapter","BuildURLMixin","RESTSerializer","JSONSerializer","JSONAPIAdapter","JSONAPISerializer","Transform","DateTransform","StringTransform","NumberTransform","BooleanTransform","EmbeddedRecordsMixin","belongsTo","hasMany","_setupContainer","setupContainer"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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