@ember-data/legacy-compat 5.3.11 → 5.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"builders.js","sources":["../src/builders/utils.ts","../src/builders/find-all.ts","../src/builders/find-record.ts","../src/builders/query.ts","../src/builders/save-record.ts"],"sourcesContent":["import { deprecate } from '@ember/debug';\n\nimport { dasherize } from '@ember-data/request-utils/string';\nimport { DEPRECATE_NON_STRICT_TYPES } from '@warp-drive/build-config/deprecations';\nimport type { ResourceIdentifierObject } from '@warp-drive/core-types/spec/json-api-raw';\n\nexport function isMaybeIdentifier(\n maybeIdentifier: string | ResourceIdentifierObject\n): maybeIdentifier is ResourceIdentifierObject {\n return Boolean(\n maybeIdentifier !== null &&\n typeof maybeIdentifier === 'object' &&\n (('id' in maybeIdentifier && 'type' in maybeIdentifier && maybeIdentifier.id && maybeIdentifier.type) ||\n maybeIdentifier.lid)\n );\n}\n\nexport function normalizeModelName(type: string): string {\n if (DEPRECATE_NON_STRICT_TYPES) {\n const result = dasherize(type);\n\n deprecate(\n `The resource type '${type}' is not normalized. Update your application code to use '${result}' instead of '${type}'.`,\n result === type,\n {\n id: 'ember-data:deprecate-non-strict-types',\n until: '6.0',\n for: 'ember-data',\n since: {\n available: '4.13',\n enabled: '5.3',\n },\n }\n );\n\n return result;\n }\n\n return type;\n}\n","/**\n * @module @ember-data/legacy-compat/builders\n */\nimport type { StoreRequestInput } from '@ember-data/store';\nimport type { FindAllOptions } from '@ember-data/store/types';\nimport { assert } from '@warp-drive/build-config/macros';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core-types/record';\nimport { SkipCache } from '@warp-drive/core-types/request';\nimport type { RequestSignature } from '@warp-drive/core-types/symbols';\n\nimport { normalizeModelName } from './utils';\n\ntype FindAllRequestInput<T extends string = string, RT = unknown[]> = StoreRequestInput & {\n op: 'findAll';\n data: {\n type: T;\n options: FindAllBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\ntype FindAllBuilderOptions<T = unknown> = FindAllOptions<T>;\n\n/**\n This function builds a request config to perform a `findAll` request for the given type.\n When passed to `store.request`, this config will result in the same behavior as a `store.findAll` request.\n Additionally, it takes the same options as `store.findAll`.\n\n 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.\n 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.\n To that end, these builders are deprecated and will be removed in a future version of Ember Data.\n\n @method findAll\n @deprecated\n @public\n @static\n @for @ember-data/legacy-compat/builders\n @param {string} type the name of the resource\n @param {object} query a query to be used by the adapter\n @param {FindAllBuilderOptions} [options] optional, may include `adapterOptions` hash which will be passed to adapter.findAll\n @return {FindAllRequestInput} request config\n*/\nexport function findAllBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n options?: FindAllBuilderOptions<T>\n): FindAllRequestInput<TypeFromInstance<T>, T[]>;\nexport function findAllBuilder(type: string, options?: FindAllBuilderOptions): FindAllRequestInput;\nexport function findAllBuilder(type: string, options: FindAllBuilderOptions = {}): FindAllRequestInput {\n assert(`You need to pass a model name to the findAll builder`, type);\n assert(\n `Model name passed to the findAll builder must be a dasherized string instead of ${type}`,\n typeof type === 'string'\n );\n\n return {\n op: 'findAll',\n data: {\n type: normalizeModelName(type),\n options: options || {},\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n","/**\n * @module @ember-data/legacy-compat/builders\n */\nimport type { StoreRequestInput } from '@ember-data/store';\nimport { constructResource, ensureStringId } from '@ember-data/store/-private';\nimport type { BaseFinderOptions, FindRecordOptions } from '@ember-data/store/types';\nimport { assert } from '@warp-drive/build-config/macros';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core-types/record';\nimport { SkipCache } from '@warp-drive/core-types/request';\nimport type { ResourceIdentifierObject } from '@warp-drive/core-types/spec/json-api-raw';\nimport type { RequestSignature } from '@warp-drive/core-types/symbols';\n\nimport { isMaybeIdentifier, normalizeModelName } from './utils';\n\ntype FindRecordRequestInput<T extends string = string, RT = unknown> = StoreRequestInput & {\n op: 'findRecord';\n data: {\n record: ResourceIdentifierObject<T>;\n options: FindRecordBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\ntype FindRecordBuilderOptions = Omit<FindRecordOptions, 'preload'>;\n\n/**\n This function builds a request config to find the record for a given identifier or type and id combination.\n When passed to `store.request`, this config will result in the same behavior as a `store.findRecord` request.\n Additionally, it takes the same options as `store.findRecord`, with the exception of `preload` (which is unsupported).\n\n **Example 1**\n\n ```ts\n import { findRecord } from '@ember-data/legacy-compat/builders';\n const { content: post } = await store.request<Post>(findRecord<Post>('post', '1'));\n ```\n\n **Example 2**\n\n `findRecord` can be called with a single identifier argument instead of the combination\n of `type` (modelName) and `id` as separate arguments. You may recognize this combo as\n the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification)\n\n ```ts\n import { findRecord } from '@ember-data/legacy-compat/builders';\n const { content: post } = await store.request<Post>(findRecord<Post>({ type: 'post', id }));\n ```\n\n 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.\n 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.\n To that end, these builders are deprecated and will be removed in a future version of Ember Data.\n\n @method findRecord\n @deprecated\n @public\n @static\n @for @ember-data/legacy-compat/builders\n @param {string|object} resource - 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\n @param {string|number|object} 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\n @param {FindRecordBuilderOptions} [options] - if the first param is a string this will be the optional options for the request. See examples for available options.\n @return {FindRecordRequestInput} request config\n*/\nexport function findRecordBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n id: string,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput<TypeFromInstance<T>, T>;\nexport function findRecordBuilder(type: string, id: string, options?: FindRecordBuilderOptions): FindRecordRequestInput;\nexport function findRecordBuilder<T extends TypedRecordInstance>(\n resource: ResourceIdentifierObject<TypeFromInstance<T>>,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput<TypeFromInstance<T>, T>;\nexport function findRecordBuilder(\n resource: ResourceIdentifierObject,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput;\nexport function findRecordBuilder(\n resource: string | ResourceIdentifierObject,\n idOrOptions?: string | FindRecordBuilderOptions,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput {\n assert(\n `You need to pass a modelName or resource identifier as the first argument to the findRecord builder`,\n resource\n );\n if (isMaybeIdentifier(resource)) {\n options = idOrOptions as BaseFinderOptions | undefined;\n } else {\n assert(\n `You need to pass a modelName or resource identifier as the first argument to the findRecord builder (passed ${resource})`,\n typeof resource === 'string'\n );\n const type = normalizeModelName(resource);\n const normalizedId = ensureStringId(idOrOptions as string | number);\n resource = constructResource(type, normalizedId);\n }\n\n options = options || {};\n\n assert('findRecord builder does not support options.preload', !(options as FindRecordOptions).preload);\n\n return {\n op: 'findRecord' as const,\n data: {\n record: resource,\n options,\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n","/**\n * @module @ember-data/legacy-compat/builders\n */\nimport type { StoreRequestInput } from '@ember-data/store';\nimport type { LegacyResourceQuery, QueryOptions } from '@ember-data/store/types';\nimport { assert } from '@warp-drive/build-config/macros';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core-types/record';\nimport { SkipCache } from '@warp-drive/core-types/request';\nimport type { RequestSignature } from '@warp-drive/core-types/symbols';\n\nimport { normalizeModelName } from './utils';\n\ntype QueryRequestInput<T extends string = string, RT = unknown[]> = StoreRequestInput & {\n op: 'query';\n data: {\n type: T;\n query: LegacyResourceQuery;\n options: QueryBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\ntype QueryBuilderOptions = QueryOptions;\n\n/**\n This function builds a request config for a given type and query object.\n When passed to `store.request`, this config will result in the same behavior as a `store.query` request.\n Additionally, it takes the same options as `store.query`.\n\n 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.\n 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.\n To that end, these builders are deprecated and will be removed in a future version of Ember Data.\n\n @method query\n @deprecated\n @public\n @static\n @for @ember-data/legacy-compat/builders\n @param {string} type the name of the resource\n @param {object} query a query to be used by the adapter\n @param {QueryBuilderOptions} [options] optional, may include `adapterOptions` hash which will be passed to adapter.query\n @return {QueryRequestInput} request config\n*/\nexport function queryBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n query: LegacyResourceQuery<T>,\n options?: QueryBuilderOptions\n): QueryRequestInput<TypeFromInstance<T>, T[]>;\nexport function queryBuilder(\n type: string,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRequestInput;\nexport function queryBuilder(\n type: string,\n query: LegacyResourceQuery,\n options: QueryBuilderOptions = {}\n): QueryRequestInput {\n assert(`You need to pass a model name to the query builder`, type);\n assert(`You need to pass a query hash to the query builder`, query);\n assert(\n `Model name passed to the query builder must be a dasherized string instead of ${type}`,\n typeof type === 'string'\n );\n\n return {\n op: 'query' as const,\n data: {\n type: normalizeModelName(type),\n query,\n options: options,\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n\ntype QueryRecordRequestInput<T extends string = string, RT = unknown> = StoreRequestInput & {\n op: 'queryRecord';\n data: {\n type: T;\n query: LegacyResourceQuery;\n options: QueryBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\n/**\n This function builds a request config for a given type and query object.\n When passed to `store.request`, this config will result in the same behavior as a `store.queryRecord` request.\n Additionally, it takes the same options as `store.queryRecord`.\n\n 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.\n 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.\n To that end, these builders are deprecated and will be removed in a future version of Ember Data.\n\n @method queryRecord\n @deprecated\n @public\n @static\n @for @ember-data/legacy-compat/builders\n @param {string} type the name of the resource\n @param {object} query a query to be used by the adapter\n @param {QueryBuilderOptions} [options] optional, may include `adapterOptions` hash which will be passed to adapter.query\n @return {QueryRecordRequestInput} request config\n*/\nexport function queryRecordBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n query: LegacyResourceQuery<T>,\n options?: QueryBuilderOptions\n): QueryRecordRequestInput<TypeFromInstance<T>, T | null>;\nexport function queryRecordBuilder(\n type: string,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRecordRequestInput;\nexport function queryRecordBuilder(\n type: string,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRecordRequestInput {\n assert(`You need to pass a model name to the queryRecord builder`, type);\n assert(`You need to pass a query hash to the queryRecord builder`, query);\n assert(\n `Model name passed to the queryRecord builder must be a dasherized string instead of ${type}`,\n typeof type === 'string'\n );\n\n return {\n op: 'queryRecord',\n data: {\n type: normalizeModelName(type),\n query,\n options: options || {},\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n","/**\n * @module @ember-data/legacy-compat/builders\n */\nimport { recordIdentifierFor, storeFor, type StoreRequestInput } from '@ember-data/store';\nimport type { InstanceCache } from '@ember-data/store/-private';\nimport { assert } from '@warp-drive/build-config/macros';\nimport type { StableRecordIdentifier } from '@warp-drive/core-types';\nimport type { Cache } from '@warp-drive/core-types/cache';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core-types/record';\nimport { SkipCache } from '@warp-drive/core-types/request';\nimport type { RequestSignature } from '@warp-drive/core-types/symbols';\n\ntype SaveRecordRequestInput<T extends string = string, RT = unknown> = StoreRequestInput & {\n op: 'createRecord' | 'deleteRecord' | 'updateRecord';\n data: {\n record: StableRecordIdentifier<T>;\n options: SaveRecordBuilderOptions;\n };\n records: [StableRecordIdentifier<T>];\n [RequestSignature]?: RT;\n};\n\ntype SaveRecordBuilderOptions = Record<string, unknown>;\n\nfunction _resourceIsFullDeleted(identifier: StableRecordIdentifier, cache: Cache): boolean {\n return cache.isDeletionCommitted(identifier) || (cache.isNew(identifier) && cache.isDeleted(identifier));\n}\n\nfunction resourceIsFullyDeleted(instanceCache: InstanceCache, identifier: StableRecordIdentifier): boolean {\n const cache = instanceCache.cache;\n return !cache || _resourceIsFullDeleted(identifier, cache);\n}\n\n/**\n This function builds a request config for saving the given record (e.g. creating, updating, or deleting the record).\n When passed to `store.request`, this config will result in the same behavior as a legacy `store.saveRecord` request.\n Additionally, it takes the same options as `store.saveRecord`.\n\n 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.\n 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.\n To that end, these builders are deprecated and will be removed in a future version of Ember Data.\n\n @method saveRecord\n @deprecated\n @public\n @static\n @for @ember-data/legacy-compat/builders\n @param {object} record a record to save\n @param {SaveRecordBuilderOptions} options optional, may include `adapterOptions` hash which will be passed to adapter.saveRecord\n @return {SaveRecordRequestInput} request config\n*/\nexport function saveRecordBuilder<T extends TypedRecordInstance>(\n record: T,\n options: Record<string, unknown> = {}\n): SaveRecordRequestInput<TypeFromInstance<T>, T> {\n const store = storeFor(record);\n assert(`Unable to initiate save for a record in a disconnected state`, store);\n const identifier = recordIdentifierFor<T>(record);\n\n if (!identifier) {\n // this commonly means we're disconnected\n // but just in case we throw here to prevent bad things.\n throw new Error(`Record Is Disconnected`);\n }\n assert(\n `Cannot initiate a save request for an unloaded record: ${identifier.lid}`,\n store._instanceCache.recordIsLoaded(identifier)\n );\n if (resourceIsFullyDeleted(store._instanceCache, identifier)) {\n throw new Error('cannot build saveRecord request for deleted record');\n }\n\n if (!options) {\n options = {};\n }\n let operation: 'createRecord' | 'deleteRecord' | 'updateRecord' = 'updateRecord';\n\n const cache = store.cache;\n if (cache.isNew(identifier)) {\n operation = 'createRecord';\n } else if (cache.isDeleted(identifier)) {\n operation = 'deleteRecord';\n }\n\n return {\n op: operation,\n data: {\n options,\n record: identifier,\n },\n records: [identifier],\n cacheOptions: { [SkipCache]: true },\n };\n}\n"],"names":["isMaybeIdentifier","maybeIdentifier","Boolean","id","type","lid","normalizeModelName","macroCondition","getGlobalConfig","WarpDrive","deprecations","DEPRECATE_NON_STRICT_TYPES","result","dasherize","deprecate","until","for","since","available","enabled","findAllBuilder","options","env","DEBUG","test","Error","op","data","cacheOptions","SkipCache","findRecordBuilder","resource","idOrOptions","normalizedId","ensureStringId","constructResource","preload","record","queryBuilder","query","queryRecordBuilder","_resourceIsFullDeleted","identifier","cache","isDeletionCommitted","isNew","isDeleted","resourceIsFullyDeleted","instanceCache","saveRecordBuilder","store","storeFor","recordIdentifierFor","_instanceCache","recordIsLoaded","operation","records"],"mappings":";;;;;;;AAMO,SAASA,iBAAiBA,CAC/BC,eAAkD,EACL;AAC7C,EAAA,OAAOC,OAAO,CACZD,eAAe,KAAK,IAAI,IACtB,OAAOA,eAAe,KAAK,QAAQ,KACjC,IAAI,IAAIA,eAAe,IAAI,MAAM,IAAIA,eAAe,IAAIA,eAAe,CAACE,EAAE,IAAIF,eAAe,CAACG,IAAI,IAClGH,eAAe,CAACI,GAAG,CACzB,CAAC,CAAA;AACH,CAAA;AAEO,SAASC,kBAAkBA,CAACF,IAAY,EAAU;EACvD,IAAAG,cAAA,CAAAC,eAAA,EAAA,CAAAC,SAAA,CAAAC,YAAA,CAAAC,0BAAA,CAAgC,EAAA;AAC9B,IAAA,MAAMC,MAAM,GAAGC,SAAS,CAACT,IAAI,CAAC,CAAA;AAE9BU,IAAAA,SAAS,CACP,CAAA,mBAAA,EAAsBV,IAAI,CAAA,0DAAA,EAA6DQ,MAAM,CAAA,cAAA,EAAiBR,IAAI,CAAA,EAAA,CAAI,EACtHQ,MAAM,KAAKR,IAAI,EACf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,cAAc,CAAA;AAEhF,EAAA,MAAMZ,KAAK,GAAGO,KAAK,CAACP,KAAK,CAAA;AACzB,EAAA,IAAIA,KAAK,CAACE,KAAK,CAACH,UAAU,CAAC,EAAE;AAC3Ba,IAAAA,SAAS,GAAG,cAAc,CAAA;GAC3B,MAAM,IAAIZ,KAAK,CAACG,SAAS,CAACJ,UAAU,CAAC,EAAE;AACtCa,IAAAA,SAAS,GAAG,cAAc,CAAA;AAC5B,GAAA;EAEA,OAAO;AACL7B,IAAAA,EAAE,EAAE6B,SAAS;AACb5B,IAAAA,IAAI,EAAE;MACJN,OAAO;AACPgB,MAAAA,MAAM,EAAEK,UAAAA;KACT;IACDc,OAAO,EAAE,CAACd,UAAU,CAAC;AACrBd,IAAAA,YAAY,EAAE;AAAE,MAAA,CAACC,SAAS,GAAG,IAAA;AAAK,KAAA;GACnC,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"builders.js","sources":["../src/builders/utils.ts","../src/builders/find-all.ts","../src/builders/find-record.ts","../src/builders/query.ts","../src/builders/save-record.ts"],"sourcesContent":["import { deprecate } from '@ember/debug';\n\nimport { dasherize } from '@ember-data/request-utils/string';\nimport { DEPRECATE_NON_STRICT_TYPES } from '@warp-drive/build-config/deprecations';\nimport type { ResourceIdentifierObject } from '@warp-drive/core-types/spec/json-api-raw';\n\nexport function isMaybeIdentifier(\n maybeIdentifier: string | ResourceIdentifierObject\n): maybeIdentifier is ResourceIdentifierObject {\n return Boolean(\n maybeIdentifier !== null &&\n typeof maybeIdentifier === 'object' &&\n (('id' in maybeIdentifier && 'type' in maybeIdentifier && maybeIdentifier.id && maybeIdentifier.type) ||\n maybeIdentifier.lid)\n );\n}\n\nexport function normalizeModelName(type: string): string {\n if (DEPRECATE_NON_STRICT_TYPES) {\n const result = dasherize(type);\n\n deprecate(\n `The resource type '${type}' is not normalized. Update your application code to use '${result}' instead of '${type}'.`,\n result === type,\n {\n id: 'ember-data:deprecate-non-strict-types',\n until: '6.0',\n for: 'ember-data',\n since: {\n available: '4.13',\n enabled: '5.3',\n },\n }\n );\n\n return result;\n }\n\n return type;\n}\n","/**\n * @module @ember-data/legacy-compat/builders\n */\nimport type { StoreRequestInput } from '@ember-data/store';\nimport type { FindAllOptions } from '@ember-data/store/types';\nimport { assert } from '@warp-drive/build-config/macros';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core-types/record';\nimport { SkipCache } from '@warp-drive/core-types/request';\nimport type { RequestSignature } from '@warp-drive/core-types/symbols';\n\nimport { normalizeModelName } from './utils';\n\ntype FindAllRequestInput<T extends string = string, RT = unknown[]> = StoreRequestInput & {\n op: 'findAll';\n data: {\n type: T;\n options: FindAllBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\ntype FindAllBuilderOptions<T = unknown> = FindAllOptions<T>;\n\n/**\n This function builds a request config to perform a `findAll` request for the given type.\n When passed to `store.request`, this config will result in the same behavior as a `store.findAll` request.\n Additionally, it takes the same options as `store.findAll`.\n\n 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.\n 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.\n To that end, these builders are deprecated and will be removed in a future version of Ember Data.\n\n @method findAll\n @deprecated\n @public\n @static\n @for @ember-data/legacy-compat/builders\n @param {string} type the name of the resource\n @param {object} query a query to be used by the adapter\n @param {FindAllBuilderOptions} [options] optional, may include `adapterOptions` hash which will be passed to adapter.findAll\n @return {FindAllRequestInput} request config\n*/\nexport function findAllBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n options?: FindAllBuilderOptions<T>\n): FindAllRequestInput<TypeFromInstance<T>, T[]>;\nexport function findAllBuilder(type: string, options?: FindAllBuilderOptions): FindAllRequestInput;\nexport function findAllBuilder(type: string, options: FindAllBuilderOptions = {}): FindAllRequestInput {\n assert(`You need to pass a model name to the findAll builder`, type);\n assert(\n `Model name passed to the findAll builder must be a dasherized string instead of ${type}`,\n typeof type === 'string'\n );\n\n return {\n op: 'findAll',\n data: {\n type: normalizeModelName(type),\n options: options || {},\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n","/**\n * @module @ember-data/legacy-compat/builders\n */\nimport type { StoreRequestInput } from '@ember-data/store';\nimport { constructResource, ensureStringId } from '@ember-data/store/-private';\nimport type { BaseFinderOptions, FindRecordOptions } from '@ember-data/store/types';\nimport { assert } from '@warp-drive/build-config/macros';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core-types/record';\nimport { SkipCache } from '@warp-drive/core-types/request';\nimport type { ResourceIdentifierObject } from '@warp-drive/core-types/spec/json-api-raw';\nimport type { RequestSignature } from '@warp-drive/core-types/symbols';\n\nimport { isMaybeIdentifier, normalizeModelName } from './utils';\n\ntype FindRecordRequestInput<T extends string = string, RT = unknown> = StoreRequestInput & {\n op: 'findRecord';\n data: {\n record: ResourceIdentifierObject<T>;\n options: FindRecordBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\ntype FindRecordBuilderOptions = Omit<FindRecordOptions, 'preload'>;\n\n/**\n This function builds a request config to find the record for a given identifier or type and id combination.\n When passed to `store.request`, this config will result in the same behavior as a `store.findRecord` request.\n Additionally, it takes the same options as `store.findRecord`, with the exception of `preload` (which is unsupported).\n\n **Example 1**\n\n ```ts\n import { findRecord } from '@ember-data/legacy-compat/builders';\n const { content: post } = await store.request<Post>(findRecord<Post>('post', '1'));\n ```\n\n **Example 2**\n\n `findRecord` can be called with a single identifier argument instead of the combination\n of `type` (modelName) and `id` as separate arguments. You may recognize this combo as\n the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification)\n\n ```ts\n import { findRecord } from '@ember-data/legacy-compat/builders';\n const { content: post } = await store.request<Post>(findRecord<Post>({ type: 'post', id }));\n ```\n\n 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.\n 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.\n To that end, these builders are deprecated and will be removed in a future version of Ember Data.\n\n @method findRecord\n @deprecated\n @public\n @static\n @for @ember-data/legacy-compat/builders\n @param {string|object} resource - 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\n @param {string|number|object} 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\n @param {FindRecordBuilderOptions} [options] - if the first param is a string this will be the optional options for the request. See examples for available options.\n @return {FindRecordRequestInput} request config\n*/\nexport function findRecordBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n id: string,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput<TypeFromInstance<T>, T>;\nexport function findRecordBuilder(type: string, id: string, options?: FindRecordBuilderOptions): FindRecordRequestInput;\nexport function findRecordBuilder<T extends TypedRecordInstance>(\n resource: ResourceIdentifierObject<TypeFromInstance<T>>,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput<TypeFromInstance<T>, T>;\nexport function findRecordBuilder(\n resource: ResourceIdentifierObject,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput;\nexport function findRecordBuilder(\n resource: string | ResourceIdentifierObject,\n idOrOptions?: string | FindRecordBuilderOptions,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput {\n assert(\n `You need to pass a modelName or resource identifier as the first argument to the findRecord builder`,\n resource\n );\n if (isMaybeIdentifier(resource)) {\n options = idOrOptions as BaseFinderOptions | undefined;\n } else {\n assert(\n `You need to pass a modelName or resource identifier as the first argument to the findRecord builder (passed ${resource})`,\n typeof resource === 'string'\n );\n const type = normalizeModelName(resource);\n const normalizedId = ensureStringId(idOrOptions as string | number);\n resource = constructResource(type, normalizedId);\n }\n\n options = options || {};\n\n assert('findRecord builder does not support options.preload', !(options as FindRecordOptions).preload);\n\n return {\n op: 'findRecord' as const,\n data: {\n record: resource,\n options,\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n","/**\n * @module @ember-data/legacy-compat/builders\n */\nimport type { StoreRequestInput } from '@ember-data/store';\nimport type { LegacyResourceQuery, QueryOptions } from '@ember-data/store/types';\nimport { assert } from '@warp-drive/build-config/macros';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core-types/record';\nimport { SkipCache } from '@warp-drive/core-types/request';\nimport type { RequestSignature } from '@warp-drive/core-types/symbols';\n\nimport { normalizeModelName } from './utils';\n\ntype QueryRequestInput<T extends string = string, RT = unknown[]> = StoreRequestInput & {\n op: 'query';\n data: {\n type: T;\n query: LegacyResourceQuery;\n options: QueryBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\ntype QueryBuilderOptions = QueryOptions;\n\n/**\n This function builds a request config for a given type and query object.\n When passed to `store.request`, this config will result in the same behavior as a `store.query` request.\n Additionally, it takes the same options as `store.query`.\n\n 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.\n 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.\n To that end, these builders are deprecated and will be removed in a future version of Ember Data.\n\n @method query\n @deprecated\n @public\n @static\n @for @ember-data/legacy-compat/builders\n @param {string} type the name of the resource\n @param {object} query a query to be used by the adapter\n @param {QueryBuilderOptions} [options] optional, may include `adapterOptions` hash which will be passed to adapter.query\n @return {QueryRequestInput} request config\n*/\nexport function queryBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n query: LegacyResourceQuery<T>,\n options?: QueryBuilderOptions\n): QueryRequestInput<TypeFromInstance<T>, T[]>;\nexport function queryBuilder(\n type: string,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRequestInput;\nexport function queryBuilder(\n type: string,\n query: LegacyResourceQuery,\n options: QueryBuilderOptions = {}\n): QueryRequestInput {\n assert(`You need to pass a model name to the query builder`, type);\n assert(`You need to pass a query hash to the query builder`, query);\n assert(\n `Model name passed to the query builder must be a dasherized string instead of ${type}`,\n typeof type === 'string'\n );\n\n return {\n op: 'query' as const,\n data: {\n type: normalizeModelName(type),\n query,\n options: options,\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n\ntype QueryRecordRequestInput<T extends string = string, RT = unknown> = StoreRequestInput & {\n op: 'queryRecord';\n data: {\n type: T;\n query: LegacyResourceQuery;\n options: QueryBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\n/**\n This function builds a request config for a given type and query object.\n When passed to `store.request`, this config will result in the same behavior as a `store.queryRecord` request.\n Additionally, it takes the same options as `store.queryRecord`.\n\n 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.\n 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.\n To that end, these builders are deprecated and will be removed in a future version of Ember Data.\n\n @method queryRecord\n @deprecated\n @public\n @static\n @for @ember-data/legacy-compat/builders\n @param {string} type the name of the resource\n @param {object} query a query to be used by the adapter\n @param {QueryBuilderOptions} [options] optional, may include `adapterOptions` hash which will be passed to adapter.query\n @return {QueryRecordRequestInput} request config\n*/\nexport function queryRecordBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n query: LegacyResourceQuery<T>,\n options?: QueryBuilderOptions\n): QueryRecordRequestInput<TypeFromInstance<T>, T | null>;\nexport function queryRecordBuilder(\n type: string,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRecordRequestInput;\nexport function queryRecordBuilder(\n type: string,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRecordRequestInput {\n assert(`You need to pass a model name to the queryRecord builder`, type);\n assert(`You need to pass a query hash to the queryRecord builder`, query);\n assert(\n `Model name passed to the queryRecord builder must be a dasherized string instead of ${type}`,\n typeof type === 'string'\n );\n\n return {\n op: 'queryRecord',\n data: {\n type: normalizeModelName(type),\n query,\n options: options || {},\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n","/**\n * @module @ember-data/legacy-compat/builders\n */\nimport { recordIdentifierFor, storeFor, type StoreRequestInput } from '@ember-data/store';\nimport type { InstanceCache } from '@ember-data/store/-private';\nimport { assert } from '@warp-drive/build-config/macros';\nimport type { StableRecordIdentifier } from '@warp-drive/core-types';\nimport type { Cache } from '@warp-drive/core-types/cache';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core-types/record';\nimport { SkipCache } from '@warp-drive/core-types/request';\nimport type { RequestSignature } from '@warp-drive/core-types/symbols';\n\ntype SaveRecordRequestInput<T extends string = string, RT = unknown> = StoreRequestInput & {\n op: 'createRecord' | 'deleteRecord' | 'updateRecord';\n data: {\n record: StableRecordIdentifier<T>;\n options: SaveRecordBuilderOptions;\n };\n records: [StableRecordIdentifier<T>];\n [RequestSignature]?: RT;\n};\n\ntype SaveRecordBuilderOptions = Record<string, unknown>;\n\nfunction _resourceIsFullDeleted(identifier: StableRecordIdentifier, cache: Cache): boolean {\n return cache.isDeletionCommitted(identifier) || (cache.isNew(identifier) && cache.isDeleted(identifier));\n}\n\nfunction resourceIsFullyDeleted(instanceCache: InstanceCache, identifier: StableRecordIdentifier): boolean {\n const cache = instanceCache.cache;\n return !cache || _resourceIsFullDeleted(identifier, cache);\n}\n\n/**\n This function builds a request config for saving the given record (e.g. creating, updating, or deleting the record).\n When passed to `store.request`, this config will result in the same behavior as a legacy `store.saveRecord` request.\n Additionally, it takes the same options as `store.saveRecord`.\n\n 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.\n 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.\n To that end, these builders are deprecated and will be removed in a future version of Ember Data.\n\n @method saveRecord\n @deprecated\n @public\n @static\n @for @ember-data/legacy-compat/builders\n @param {object} record a record to save\n @param {SaveRecordBuilderOptions} options optional, may include `adapterOptions` hash which will be passed to adapter.saveRecord\n @return {SaveRecordRequestInput} request config\n*/\nexport function saveRecordBuilder<T extends TypedRecordInstance>(\n record: T,\n options: Record<string, unknown> = {}\n): SaveRecordRequestInput<TypeFromInstance<T>, T> {\n const store = storeFor(record);\n assert(`Unable to initiate save for a record in a disconnected state`, store);\n const identifier = recordIdentifierFor<T>(record);\n\n if (!identifier) {\n // this commonly means we're disconnected\n // but just in case we throw here to prevent bad things.\n throw new Error(`Record Is Disconnected`);\n }\n assert(\n `Cannot initiate a save request for an unloaded record: ${identifier.lid}`,\n store._instanceCache.recordIsLoaded(identifier)\n );\n if (resourceIsFullyDeleted(store._instanceCache, identifier)) {\n throw new Error('cannot build saveRecord request for deleted record');\n }\n\n if (!options) {\n options = {};\n }\n let operation: 'createRecord' | 'deleteRecord' | 'updateRecord' = 'updateRecord';\n\n const cache = store.cache;\n if (cache.isNew(identifier)) {\n operation = 'createRecord';\n } else if (cache.isDeleted(identifier)) {\n operation = 'deleteRecord';\n }\n\n return {\n op: operation,\n data: {\n options,\n record: identifier,\n },\n records: [identifier],\n cacheOptions: { [SkipCache]: true },\n };\n}\n"],"names":["isMaybeIdentifier","maybeIdentifier","Boolean","id","type","lid","normalizeModelName","macroCondition","getGlobalConfig","WarpDrive","deprecations","DEPRECATE_NON_STRICT_TYPES","result","dasherize","deprecate","until","for","since","available","enabled","findAllBuilder","options","env","DEBUG","test","Error","op","data","cacheOptions","SkipCache","findRecordBuilder","resource","idOrOptions","normalizedId","ensureStringId","constructResource","preload","record","queryBuilder","query","queryRecordBuilder","_resourceIsFullDeleted","identifier","cache","isDeletionCommitted","isNew","isDeleted","resourceIsFullyDeleted","instanceCache","saveRecordBuilder","store","storeFor","recordIdentifierFor","_instanceCache","recordIsLoaded","operation","records"],"mappings":";;;;;;;AAMO,SAASA,iBAAiBA,CAC/BC,eAAkD,EACL;AAC7C,EAAA,OAAOC,OAAO,CACZD,eAAe,KAAK,IAAI,IACtB,OAAOA,eAAe,KAAK,QAAQ,KACjC,IAAI,IAAIA,eAAe,IAAI,MAAM,IAAIA,eAAe,IAAIA,eAAe,CAACE,EAAE,IAAIF,eAAe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AAC3Ba,IAAAA,SAAS,GAAG,cAAc;GAC3B,MAAM,IAAIZ,KAAK,CAACG,SAAS,CAACJ,UAAU,CAAC,EAAE;AACtCa,IAAAA,SAAS,GAAG,cAAc;AAC5B;EAEA,OAAO;AACL7B,IAAAA,EAAE,EAAE6B,SAAS;AACb5B,IAAAA,IAAI,EAAE;MACJN,OAAO;AACPgB,MAAAA,MAAM,EAAEK;KACT;IACDc,OAAO,EAAE,CAACd,UAAU,CAAC;AACrBd,IAAAA,YAAY,EAAE;AAAE,MAAA,CAACC,SAAS,GAAG;AAAK;GACnC;AACH;;;;"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { getOwner } from '@ember/application';
2
2
  import { recordIdentifierFor } from '@ember-data/store';
3
3
  import { _deprecatingNormalize } from '@ember-data/store/-private';
4
- import { p as payloadIsNotBlank, n as normalizeResponseHelper, i as iterateData, F as FetchManager, a as assertIdentifierHasId, S as SaveOp, b as SnapshotRecordArray } from "./-private-Dlia0pw1.js";
4
+ import { p as payloadIsNotBlank, n as normalizeResponseHelper, i as iterateData, F as FetchManager, S as SaveOp, a as assertIdentifierHasId, b as SnapshotRecordArray } from "./-private-Dlia0pw1.js";
5
5
  import { macroCondition, getGlobalConfig, importSync } from '@embroider/macros';
6
6
  function _findHasMany(adapter, store, identifier, link, relationship, options) {
7
7
  const promise = Promise.resolve().then(() => {
@@ -430,16 +430,6 @@ function saveRecord(context) {
430
430
  }, options);
431
431
  const fetchManagerPromise = store._fetchManager.scheduleSave(identifier, saveOptions);
432
432
  return fetchManagerPromise.then(payload => {
433
- if (macroCondition(getGlobalConfig().WarpDrive.debug.LOG_PAYLOADS)) {
434
- try {
435
- const payloadCopy = payload ? JSON.parse(JSON.stringify(payload)) : payload;
436
- // eslint-disable-next-line no-console
437
- console.log(`EmberData | Payload - ${operation}`, payloadCopy);
438
- } catch {
439
- // eslint-disable-next-line no-console
440
- console.log(`EmberData | Payload - ${operation}`, payload);
441
- }
442
- }
443
433
  let result;
444
434
  store._join(() => {
445
435
  // @ts-expect-error we don't have access to a response in legacy
@@ -637,9 +627,11 @@ function _findAll(adapter, store, type, snapshotArray, request, isAsyncFlush) {
637
627
  const payload = normalizeResponseHelper(serializer, store, schema, adapterPayload, null, 'findAll');
638
628
  store._push(payload, isAsyncFlush);
639
629
  snapshotArray._recordArray.isUpdating = false;
640
- if (macroCondition(getGlobalConfig().WarpDrive.debug.LOG_PAYLOADS)) {
641
- // eslint-disable-next-line no-console
642
- console.log(`request: findAll<${type}> background reload complete`);
630
+ if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_REQUESTS)) {
631
+ if (getGlobalConfig().WarpDrive.debug.LOG_REQUESTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REQUESTS) {
632
+ // eslint-disable-next-line no-console
633
+ console.log(`request: findAll<${type}> background reload complete`);
634
+ }
643
635
  }
644
636
  return snapshotArray._recordArray;
645
637
  });
@@ -677,7 +669,7 @@ function query(context) {
677
669
  throw new Error(`You tried to make a query but your adapter does not implement 'query'`);
678
670
  }
679
671
  })(typeof adapter.query === 'function') : {};
680
- const recordArray = options._recordArray || store.recordArrayManager.createArray({
672
+ const recordArray = options._recordArray || store.recordArrayManager.getCollection({
681
673
  type,
682
674
  query
683
675
  });