@ember-data-mirror/rest 5.6.0-alpha.2 → 5.6.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/request.js CHANGED
@@ -24,10 +24,6 @@ function extractCacheOptions(options) {
24
24
  return cacheOptions;
25
25
  }
26
26
 
27
- /**
28
- * @module @ember-data-mirror/rest/request
29
- */
30
-
31
27
  /**
32
28
  * Builds request options to fetch a single resource by a known id or identifier
33
29
  * configured for the url and header expectations of most REST APIs.
@@ -79,10 +75,7 @@ function extractCacheOptions(options) {
79
75
  * const data = await store.request(options);
80
76
  * ```
81
77
  *
82
- * @method findRecord
83
78
  * @public
84
- * @static
85
- * @for @ember-data-mirror/rest/request
86
79
  * @param identifier
87
80
  * @param options
88
81
  */
@@ -115,10 +108,6 @@ function findRecord(arg1, arg2, arg3) {
115
108
  };
116
109
  }
117
110
 
118
- /**
119
- * @module @ember-data-mirror/rest/request
120
- */
121
-
122
111
  /**
123
112
  * Builds request options to query for resources, usually by a primary
124
113
  * type, configured for the url and header expectations of most REST APIs.
@@ -161,10 +150,7 @@ function findRecord(arg1, arg2, arg3) {
161
150
  * const data = await store.request(options);
162
151
  * ```
163
152
  *
164
- * @method query
165
153
  * @public
166
- * @static
167
- * @for @ember-data-mirror/rest/request
168
154
  * @param identifier
169
155
  * @param query
170
156
  * @param options
@@ -243,10 +229,7 @@ function isExisting(identifier) {
243
229
  * const data = await store.request(options);
244
230
  * ```
245
231
  *
246
- * @method deleteRecord
247
232
  * @public
248
- * @static
249
- * @for @ember-data-mirror/rest/request
250
233
  * @param record
251
234
  * @param options
252
235
  */
@@ -319,10 +302,7 @@ function deleteRecord(record, options = {}) {
319
302
  * const data = await store.request(options);
320
303
  * ```
321
304
  *
322
- * @method createRecord
323
305
  * @public
324
- * @static
325
- * @for @ember-data-mirror/rest/request
326
306
  * @param record
327
307
  * @param options
328
308
  */
@@ -393,10 +373,7 @@ function createRecord(record, options = {}) {
393
373
  * const data = await store.request(options);
394
374
  * ```
395
375
  *
396
- * @method updateRecord
397
376
  * @public
398
- * @static
399
- * @for @ember-data-mirror/rest/request
400
377
  * @param record
401
378
  * @param options
402
379
  */
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","sources":["../src/-private/builders/-utils.ts","../src/-private/builders/find-record.ts","../src/-private/builders/query.ts","../src/-private/builders/save-record.ts"],"sourcesContent":["import type { UrlOptions } from '@ember-data-mirror/request-utils';\nimport type { CacheOptions, ConstrainedRequestOptions } from '@warp-drive-mirror/core-types/request';\n\nexport function copyForwardUrlOptions(urlOptions: UrlOptions, options: ConstrainedRequestOptions): void {\n if ('host' in options) {\n urlOptions.host = options.host;\n }\n if ('namespace' in options) {\n urlOptions.namespace = options.namespace;\n }\n if ('resourcePath' in options) {\n urlOptions.resourcePath = options.resourcePath;\n }\n}\n\nexport function extractCacheOptions(options: ConstrainedRequestOptions): CacheOptions {\n const cacheOptions: CacheOptions = {};\n if ('reload' in options) {\n cacheOptions.reload = options.reload;\n }\n if ('backgroundReload' in options) {\n cacheOptions.backgroundReload = options.backgroundReload;\n }\n return cacheOptions;\n}\n","/**\n * @module @ember-data-mirror/rest/request\n */\nimport { buildBaseURL, buildQueryParams, type FindRecordUrlOptions } from '@ember-data-mirror/request-utils';\nimport { camelize, pluralize } from '@ember-data-mirror/request-utils/string';\nimport type { TypeFromInstance } from '@warp-drive-mirror/core-types/record';\nimport type {\n FindRecordOptions,\n FindRecordRequestOptions,\n RemotelyAccessibleIdentifier,\n} from '@warp-drive-mirror/core-types/request';\nimport type { SingleResourceDataDocument } from '@warp-drive-mirror/core-types/spec/document';\n\nimport { copyForwardUrlOptions, extractCacheOptions } from './-utils';\n\n/**\n * Builds request options to fetch a single resource by a known id or identifier\n * configured for the url and header expectations of most REST APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { findRecord } from '@ember-data-mirror/rest/request';\n *\n * const data = await store.request(findRecord('person', '1'));\n * ```\n *\n * **With Options**\n *\n * ```ts\n * import { findRecord } from '@ember-data-mirror/rest/request';\n *\n * const options = findRecord('person', '1', { include: ['pets', 'friends'] });\n * const data = await store.request(options);\n * ```\n *\n * **With an Identifier**\n *\n * ```ts\n * import { findRecord } from '@ember-data-mirror/rest/request';\n *\n * const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] });\n * const data = await store.request(options);\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing and camelCasing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { findRecord } from '@ember-data-mirror/rest/request';\n *\n * const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' });\n * const data = await store.request(options);\n * ```\n *\n * @method findRecord\n * @public\n * @static\n * @for @ember-data-mirror/rest/request\n * @param identifier\n * @param options\n */\nexport type FindRecordResultDocument<T> = Omit<SingleResourceDataDocument<T>, 'data'> & { data: T };\n\nexport function findRecord<T>(\n identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>,\n options?: FindRecordOptions<T>\n): FindRecordRequestOptions<T, FindRecordResultDocument<T>>;\nexport function findRecord(\n identifier: RemotelyAccessibleIdentifier,\n options?: FindRecordOptions\n): FindRecordRequestOptions;\nexport function findRecord<T>(\n type: TypeFromInstance<T>,\n id: string,\n options?: FindRecordOptions<T>\n): FindRecordRequestOptions<T, FindRecordResultDocument<T>>;\nexport function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;\nexport function findRecord<T>(\n arg1: TypeFromInstance<T> | RemotelyAccessibleIdentifier<TypeFromInstance<T>>,\n arg2: string | FindRecordOptions | undefined,\n arg3?: FindRecordOptions\n): FindRecordRequestOptions<T, FindRecordResultDocument<T>> {\n const identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>> =\n typeof arg1 === 'string' ? { type: arg1, id: arg2 as string } : arg1;\n const options: FindRecordOptions = (typeof arg1 === 'string' ? arg3 : (arg2 as FindRecordOptions)) || {};\n const cacheOptions = extractCacheOptions(options);\n const urlOptions: FindRecordUrlOptions = {\n identifier,\n op: 'findRecord',\n resourcePath: pluralize(camelize(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url: options.include?.length\n ? `${url}?${buildQueryParams({ include: options.include }, options.urlParamsSettings)}`\n : url,\n method: 'GET',\n headers,\n cacheOptions,\n op: 'findRecord',\n records: [identifier],\n };\n}\n","/**\n * @module @ember-data-mirror/rest/request\n */\nimport { buildBaseURL, buildQueryParams, type QueryUrlOptions } from '@ember-data-mirror/request-utils';\nimport { camelize, pluralize } from '@ember-data-mirror/request-utils/string';\nimport type { QueryParamsSource } from '@warp-drive-mirror/core-types/params';\nimport type { TypeFromInstance } from '@warp-drive-mirror/core-types/record';\nimport type { ConstrainedRequestOptions, QueryRequestOptions } from '@warp-drive-mirror/core-types/request';\nimport type { CollectionResourceDataDocument } from '@warp-drive-mirror/core-types/spec/document';\n\nimport { copyForwardUrlOptions, extractCacheOptions } from './-utils';\n\n/**\n * Builds request options to query for resources, usually by a primary\n * type, configured for the url and header expectations of most REST APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { query } from '@ember-data-mirror/rest/request';\n *\n * const data = await store.request(query('person'));\n * ```\n *\n * **With Query Params**\n *\n * ```ts\n * import { query } from '@ember-data-mirror/rest/request';\n *\n * const options = query('person', { include: ['pets', 'friends'] });\n * const data = await store.request(options);\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing and camelCasing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSettings` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { query } from '@ember-data-mirror/rest/request';\n *\n * const options = query('person', { include: ['pets', 'friends'] }, { reload: true });\n * const data = await store.request(options);\n * ```\n *\n * @method query\n * @public\n * @static\n * @for @ember-data-mirror/rest/request\n * @param identifier\n * @param query\n * @param options\n */\nexport function query<T>(\n type: TypeFromInstance<T>,\n query?: QueryParamsSource,\n options?: ConstrainedRequestOptions\n): QueryRequestOptions<T, CollectionResourceDataDocument<T>>;\nexport function query(\n type: string,\n query?: QueryParamsSource,\n options?: ConstrainedRequestOptions\n): QueryRequestOptions;\nexport function query(\n type: string,\n // eslint-disable-next-line @typescript-eslint/no-shadow\n query: QueryParamsSource = {},\n options: ConstrainedRequestOptions = {}\n): QueryRequestOptions {\n const cacheOptions = extractCacheOptions(options);\n const urlOptions: QueryUrlOptions = {\n identifier: { type },\n op: 'query',\n resourcePath: pluralize(camelize(type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n const queryString = buildQueryParams(query, options.urlParamsSettings);\n\n return {\n url: queryString ? `${url}?${queryString}` : url,\n method: 'GET',\n headers,\n cacheOptions,\n op: 'query',\n };\n}\n","import {\n buildBaseURL,\n type CreateRecordUrlOptions,\n type DeleteRecordUrlOptions,\n type UpdateRecordUrlOptions,\n} from '@ember-data-mirror/request-utils';\nimport { camelize, pluralize } from '@ember-data-mirror/request-utils/string';\nimport { recordIdentifierFor } from '@ember-data-mirror/store';\nimport { assert } from '@warp-drive-mirror/build-config/macros';\nimport type { StableExistingRecordIdentifier, StableRecordIdentifier } from '@warp-drive-mirror/core-types/identifier';\nimport type {\n ConstrainedRequestOptions,\n CreateRequestOptions,\n DeleteRequestOptions,\n UpdateRequestOptions,\n} from '@warp-drive-mirror/core-types/request';\n\nimport { copyForwardUrlOptions } from './-utils';\n\nfunction isExisting(identifier: StableRecordIdentifier): identifier is StableExistingRecordIdentifier {\n return 'id' in identifier && identifier.id !== null && 'type' in identifier && identifier.type !== null;\n}\n\n/**\n * Builds request options to delete record for resources,\n * configured for the url, method and header expectations of REST APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { deleteRecord } from '@ember-data-mirror/rest/request';\n *\n * const person = store.peekRecord('person', '1');\n *\n * // mark record as deleted\n * store.deleteRecord(person);\n *\n * // persist deletion\n * const data = await store.request(deleteRecord(person));\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { deleteRecord } from '@ember-data-mirror/rest/request';\n *\n * const person = store.peekRecord('person', '1');\n *\n * // mark record as deleted\n * store.deleteRecord(person);\n *\n * // persist deletion\n * const options = deleteRecord(person, { namespace: 'api/v1' });\n * const data = await store.request(options);\n * ```\n *\n * @method deleteRecord\n * @public\n * @static\n * @for @ember-data-mirror/rest/request\n * @param record\n * @param options\n */\nexport function deleteRecord<T>(record: T, options?: ConstrainedRequestOptions): DeleteRequestOptions<T>;\nexport function deleteRecord(record: unknown, options?: ConstrainedRequestOptions): DeleteRequestOptions;\nexport function deleteRecord(record: unknown, options: ConstrainedRequestOptions = {}): DeleteRequestOptions {\n const identifier = recordIdentifierFor(record);\n assert(`Expected to be given a record instance`, identifier);\n assert(`Cannot delete a record that does not have an associated type and id.`, isExisting(identifier));\n\n const urlOptions: DeleteRecordUrlOptions = {\n identifier: identifier,\n op: 'deleteRecord',\n resourcePath: pluralize(camelize(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url,\n method: 'DELETE',\n headers,\n op: 'deleteRecord',\n data: {\n record: identifier,\n },\n records: [identifier],\n };\n}\n\n/**\n * Builds request options to create new record for resources,\n * configured for the url, method and header expectations of most REST APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { createRecord } from '@ember-data-mirror/rest/request';\n *\n * const person = store.createRecord('person', { name: 'Ted' });\n * const data = await store.request(createRecord(person));\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { createRecord } from '@ember-data-mirror/rest/request';\n *\n * const person = store.createRecord('person', { name: 'Ted' });\n * const options = createRecord(person, { namespace: 'api/v1' });\n * const data = await store.request(options);\n * ```\n *\n * @method createRecord\n * @public\n * @static\n * @for @ember-data-mirror/rest/request\n * @param record\n * @param options\n */\nexport function createRecord<T>(record: T, options?: ConstrainedRequestOptions): CreateRequestOptions<T>;\nexport function createRecord(record: unknown, options?: ConstrainedRequestOptions): CreateRequestOptions;\nexport function createRecord(record: unknown, options: ConstrainedRequestOptions = {}): CreateRequestOptions {\n const identifier = recordIdentifierFor(record);\n assert(`Expected to be given a record instance`, identifier);\n\n const urlOptions: CreateRecordUrlOptions = {\n identifier: identifier,\n op: 'createRecord',\n resourcePath: pluralize(camelize(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url,\n method: 'POST',\n headers,\n op: 'createRecord',\n data: {\n record: identifier,\n },\n records: [identifier],\n };\n}\n\n/**\n * Builds request options to update existing record for resources,\n * configured for the url, method and header expectations of most REST APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { updateRecord } from '@ember-data-mirror/rest/request';\n *\n * const person = store.peekRecord('person', '1');\n * person.name = 'Chris';\n * const data = await store.request(updateRecord(person));\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`.\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { updateRecord } from '@ember-data-mirror/rest/request';\n *\n * const person = store.peekRecord('person', '1');\n * person.name = 'Chris';\n * const options = updateRecord(person, { patch: true });\n * const data = await store.request(options);\n * ```\n *\n * @method updateRecord\n * @public\n * @static\n * @for @ember-data-mirror/rest/request\n * @param record\n * @param options\n */\nexport function updateRecord<T>(\n record: T,\n options?: ConstrainedRequestOptions & { patch?: boolean }\n): UpdateRequestOptions<T>;\nexport function updateRecord(\n record: unknown,\n options?: ConstrainedRequestOptions & { patch?: boolean }\n): UpdateRequestOptions;\nexport function updateRecord(\n record: unknown,\n options: ConstrainedRequestOptions & { patch?: boolean } = {}\n): UpdateRequestOptions {\n const identifier = recordIdentifierFor(record);\n assert(`Expected to be given a record instance`, identifier);\n assert(`Cannot update a record that does not have an associated type and id.`, isExisting(identifier));\n\n const urlOptions: UpdateRecordUrlOptions = {\n identifier: identifier,\n op: 'updateRecord',\n resourcePath: pluralize(camelize(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url,\n method: options.patch ? 'PATCH' : 'PUT',\n headers,\n op: 'updateRecord',\n data: {\n record: identifier,\n },\n records: [identifier],\n };\n}\n"],"names":["copyForwardUrlOptions","urlOptions","options","host","namespace","resourcePath","extractCacheOptions","cacheOptions","reload","backgroundReload","findRecord","arg1","arg2","arg3","identifier","type","id","op","pluralize","camelize","url","buildBaseURL","headers","Headers","append","include","length","buildQueryParams","urlParamsSettings","method","records","query","queryString","isExisting","deleteRecord","record","recordIdentifierFor","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","test","Error","data","createRecord","updateRecord","patch"],"mappings":";;;;;AAGO,SAASA,qBAAqBA,CAACC,UAAsB,EAAEC,OAAkC,EAAQ;EACtG,IAAI,MAAM,IAAIA,OAAO,EAAE;AACrBD,IAAAA,UAAU,CAACE,IAAI,GAAGD,OAAO,CAACC,IAAI;AAChC;EACA,IAAI,WAAW,IAAID,OAAO,EAAE;AAC1BD,IAAAA,UAAU,CAACG,SAAS,GAAGF,OAAO,CAACE,SAAS;AAC1C;EACA,IAAI,cAAc,IAAIF,OAAO,EAAE;AAC7BD,IAAAA,UAAU,CAACI,YAAY,GAAGH,OAAO,CAACG,YAAY;AAChD;AACF;AAEO,SAASC,mBAAmBA,CAACJ,OAAkC,EAAgB;EACpF,MAAMK,YAA0B,GAAG,EAAE;EACrC,IAAI,QAAQ,IAAIL,OAAO,EAAE;AACvBK,IAAAA,YAAY,CAACC,MAAM,GAAGN,OAAO,CAACM,MAAM;AACtC;EACA,IAAI,kBAAkB,IAAIN,OAAO,EAAE;AACjCK,IAAAA,YAAY,CAACE,gBAAgB,GAAGP,OAAO,CAACO,gBAAgB;AAC1D;AACA,EAAA,OAAOF,YAAY;AACrB;;ACxBA;AACA;AACA;;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;;AAiBO,SAASG,UAAUA,CACxBC,IAA6E,EAC7EC,IAA4C,EAC5CC,IAAwB,EACkC;AAC1D,EAAA,MAAMC,UAA6D,GACjE,OAAOH,IAAI,KAAK,QAAQ,GAAG;AAAEI,IAAAA,IAAI,EAAEJ,IAAI;AAAEK,IAAAA,EA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pC,EAAA,MAAMqB,OAAO,GAAG,IAAIC,OAAO,EAAE;AAC7BD,EAAAA,OAAO,CAACE,MAAM,CAAC,QAAQ,EAAE,gCAAgC,CAAC;EAE1D,OAAO;IACLJ,GAAG;AACHS,IAAAA,MAAM,EAAE3B,OAAO,CAAC6C,KAAK,GAAG,OAAO,GAAG,KAAK;IACvCzB,OAAO;AACPL,IAAAA,EAAE,EAAE,cAAc;AAClB2B,IAAAA,IAAI,EAAE;AACJT,MAAAA,MAAM,EAAErB;KACT;IACDgB,OAAO,EAAE,CAAChB,UAAU;GACrB;AACH;;;;"}
1
+ {"version":3,"file":"request.js","sources":["../src/-private/builders/-utils.ts","../src/-private/builders/find-record.ts","../src/-private/builders/query.ts","../src/-private/builders/save-record.ts"],"sourcesContent":["import type { UrlOptions } from '@ember-data-mirror/request-utils';\nimport type { CacheOptions, ConstrainedRequestOptions } from '@warp-drive-mirror/core-types/request';\n\nexport function copyForwardUrlOptions(urlOptions: UrlOptions, options: ConstrainedRequestOptions): void {\n if ('host' in options) {\n urlOptions.host = options.host;\n }\n if ('namespace' in options) {\n urlOptions.namespace = options.namespace;\n }\n if ('resourcePath' in options) {\n urlOptions.resourcePath = options.resourcePath;\n }\n}\n\nexport function extractCacheOptions(options: ConstrainedRequestOptions): CacheOptions {\n const cacheOptions: CacheOptions = {};\n if ('reload' in options) {\n cacheOptions.reload = options.reload;\n }\n if ('backgroundReload' in options) {\n cacheOptions.backgroundReload = options.backgroundReload;\n }\n return cacheOptions;\n}\n","import { buildBaseURL, buildQueryParams, type FindRecordUrlOptions } from '@ember-data-mirror/request-utils';\nimport { camelize, pluralize } from '@ember-data-mirror/request-utils/string';\nimport type { TypeFromInstance } from '@warp-drive-mirror/core-types/record';\nimport type {\n FindRecordOptions,\n FindRecordRequestOptions,\n RemotelyAccessibleIdentifier,\n} from '@warp-drive-mirror/core-types/request';\nimport type { SingleResourceDataDocument } from '@warp-drive-mirror/core-types/spec/document';\n\nimport { copyForwardUrlOptions, extractCacheOptions } from './-utils';\n\n/**\n * Builds request options to fetch a single resource by a known id or identifier\n * configured for the url and header expectations of most REST APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { findRecord } from '@ember-data-mirror/rest/request';\n *\n * const data = await store.request(findRecord('person', '1'));\n * ```\n *\n * **With Options**\n *\n * ```ts\n * import { findRecord } from '@ember-data-mirror/rest/request';\n *\n * const options = findRecord('person', '1', { include: ['pets', 'friends'] });\n * const data = await store.request(options);\n * ```\n *\n * **With an Identifier**\n *\n * ```ts\n * import { findRecord } from '@ember-data-mirror/rest/request';\n *\n * const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] });\n * const data = await store.request(options);\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing and camelCasing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { findRecord } from '@ember-data-mirror/rest/request';\n *\n * const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param identifier\n * @param options\n */\nexport type FindRecordResultDocument<T> = Omit<SingleResourceDataDocument<T>, 'data'> & { data: T };\n\nexport function findRecord<T>(\n identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>,\n options?: FindRecordOptions<T>\n): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;\nexport function findRecord(\n identifier: RemotelyAccessibleIdentifier,\n options?: FindRecordOptions\n): FindRecordRequestOptions;\nexport function findRecord<T>(\n type: TypeFromInstance<T>,\n id: string,\n options?: FindRecordOptions<T>\n): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;\nexport function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;\nexport function findRecord<T>(\n arg1: TypeFromInstance<T> | RemotelyAccessibleIdentifier<TypeFromInstance<T>>,\n arg2: string | FindRecordOptions | undefined,\n arg3?: FindRecordOptions\n): FindRecordRequestOptions<FindRecordResultDocument<T>, T> {\n const identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>> =\n typeof arg1 === 'string' ? { type: arg1, id: arg2 as string } : arg1;\n const options: FindRecordOptions = (typeof arg1 === 'string' ? arg3 : (arg2 as FindRecordOptions)) || {};\n const cacheOptions = extractCacheOptions(options);\n const urlOptions: FindRecordUrlOptions = {\n identifier,\n op: 'findRecord',\n resourcePath: pluralize(camelize(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url: options.include?.length\n ? `${url}?${buildQueryParams({ include: options.include }, options.urlParamsSettings)}`\n : url,\n method: 'GET',\n headers,\n cacheOptions,\n op: 'findRecord',\n records: [identifier],\n };\n}\n","import { buildBaseURL, buildQueryParams, type QueryUrlOptions } from '@ember-data-mirror/request-utils';\nimport { camelize, pluralize } from '@ember-data-mirror/request-utils/string';\nimport type { QueryParamsSource } from '@warp-drive-mirror/core-types/params';\nimport type { TypeFromInstance } from '@warp-drive-mirror/core-types/record';\nimport type { ConstrainedRequestOptions, QueryRequestOptions } from '@warp-drive-mirror/core-types/request';\nimport type { CollectionResourceDataDocument } from '@warp-drive-mirror/core-types/spec/document';\n\nimport { copyForwardUrlOptions, extractCacheOptions } from './-utils';\n\n/**\n * Builds request options to query for resources, usually by a primary\n * type, configured for the url and header expectations of most REST APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { query } from '@ember-data-mirror/rest/request';\n *\n * const data = await store.request(query('person'));\n * ```\n *\n * **With Query Params**\n *\n * ```ts\n * import { query } from '@ember-data-mirror/rest/request';\n *\n * const options = query('person', { include: ['pets', 'friends'] });\n * const data = await store.request(options);\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing and camelCasing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSettings` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { query } from '@ember-data-mirror/rest/request';\n *\n * const options = query('person', { include: ['pets', 'friends'] }, { reload: true });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param identifier\n * @param query\n * @param options\n */\nexport function query<T>(\n type: TypeFromInstance<T>,\n query?: QueryParamsSource,\n options?: ConstrainedRequestOptions\n): QueryRequestOptions<CollectionResourceDataDocument<T>, T>;\nexport function query(\n type: string,\n query?: QueryParamsSource,\n options?: ConstrainedRequestOptions\n): QueryRequestOptions;\nexport function query(\n type: string,\n // eslint-disable-next-line @typescript-eslint/no-shadow\n query: QueryParamsSource = {},\n options: ConstrainedRequestOptions = {}\n): QueryRequestOptions {\n const cacheOptions = extractCacheOptions(options);\n const urlOptions: QueryUrlOptions = {\n identifier: { type },\n op: 'query',\n resourcePath: pluralize(camelize(type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n const queryString = buildQueryParams(query, options.urlParamsSettings);\n\n return {\n url: queryString ? `${url}?${queryString}` : url,\n method: 'GET',\n headers,\n cacheOptions,\n op: 'query',\n };\n}\n","import {\n buildBaseURL,\n type CreateRecordUrlOptions,\n type DeleteRecordUrlOptions,\n type UpdateRecordUrlOptions,\n} from '@ember-data-mirror/request-utils';\nimport { camelize, pluralize } from '@ember-data-mirror/request-utils/string';\nimport { recordIdentifierFor } from '@ember-data-mirror/store';\nimport { assert } from '@warp-drive-mirror/build-config/macros';\nimport type { StableExistingRecordIdentifier, StableRecordIdentifier } from '@warp-drive-mirror/core-types/identifier';\nimport type { TypedRecordInstance } from '@warp-drive-mirror/core-types/record';\nimport type {\n ConstrainedRequestOptions,\n CreateRequestOptions,\n DeleteRequestOptions,\n UpdateRequestOptions,\n} from '@warp-drive-mirror/core-types/request';\nimport type { SingleResourceDataDocument } from '@warp-drive-mirror/core-types/spec/document';\n\nimport { copyForwardUrlOptions } from './-utils';\n\nfunction isExisting(identifier: StableRecordIdentifier): identifier is StableExistingRecordIdentifier {\n return 'id' in identifier && identifier.id !== null && 'type' in identifier && identifier.type !== null;\n}\n\n/**\n * Builds request options to delete record for resources,\n * configured for the url, method and header expectations of REST APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { deleteRecord } from '@ember-data-mirror/rest/request';\n *\n * const person = store.peekRecord('person', '1');\n *\n * // mark record as deleted\n * store.deleteRecord(person);\n *\n * // persist deletion\n * const data = await store.request(deleteRecord(person));\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { deleteRecord } from '@ember-data-mirror/rest/request';\n *\n * const person = store.peekRecord('person', '1');\n *\n * // mark record as deleted\n * store.deleteRecord(person);\n *\n * // persist deletion\n * const options = deleteRecord(person, { namespace: 'api/v1' });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param record\n * @param options\n */\nexport function deleteRecord<T>(record: T, options?: ConstrainedRequestOptions): DeleteRequestOptions<T>;\nexport function deleteRecord(record: unknown, options?: ConstrainedRequestOptions): DeleteRequestOptions;\nexport function deleteRecord(record: unknown, options: ConstrainedRequestOptions = {}): DeleteRequestOptions {\n const identifier = recordIdentifierFor(record);\n assert(`Expected to be given a record instance`, identifier);\n assert(`Cannot delete a record that does not have an associated type and id.`, isExisting(identifier));\n\n const urlOptions: DeleteRecordUrlOptions = {\n identifier: identifier,\n op: 'deleteRecord',\n resourcePath: pluralize(camelize(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url,\n method: 'DELETE',\n headers,\n op: 'deleteRecord',\n data: {\n record: identifier,\n },\n records: [identifier],\n };\n}\n\n/**\n * Builds request options to create new record for resources,\n * configured for the url, method and header expectations of most REST APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { createRecord } from '@ember-data-mirror/rest/request';\n *\n * const person = store.createRecord('person', { name: 'Ted' });\n * const data = await store.request(createRecord(person));\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { createRecord } from '@ember-data-mirror/rest/request';\n *\n * const person = store.createRecord('person', { name: 'Ted' });\n * const options = createRecord(person, { namespace: 'api/v1' });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param record\n * @param options\n */\nexport function createRecord<T>(record: T, options?: ConstrainedRequestOptions): CreateRequestOptions<T>;\nexport function createRecord(record: unknown, options?: ConstrainedRequestOptions): CreateRequestOptions;\nexport function createRecord(record: unknown, options: ConstrainedRequestOptions = {}): CreateRequestOptions {\n const identifier = recordIdentifierFor(record);\n assert(`Expected to be given a record instance`, identifier);\n\n const urlOptions: CreateRecordUrlOptions = {\n identifier: identifier,\n op: 'createRecord',\n resourcePath: pluralize(camelize(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url,\n method: 'POST',\n headers,\n op: 'createRecord',\n data: {\n record: identifier,\n },\n records: [identifier],\n };\n}\n\n/**\n * Builds request options to update existing record for resources,\n * configured for the url, method and header expectations of most REST APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { updateRecord } from '@ember-data-mirror/rest/request';\n *\n * const person = store.peekRecord('person', '1');\n * person.name = 'Chris';\n * const data = await store.request(updateRecord(person));\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`.\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { updateRecord } from '@ember-data-mirror/rest/request';\n *\n * const person = store.peekRecord('person', '1');\n * person.name = 'Chris';\n * const options = updateRecord(person, { patch: true });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param record\n * @param options\n */\nexport function updateRecord<T extends TypedRecordInstance, RT extends TypedRecordInstance = T>(\n record: T,\n options?: ConstrainedRequestOptions & { patch?: boolean }\n): UpdateRequestOptions<SingleResourceDataDocument<RT>, T>;\nexport function updateRecord(\n record: unknown,\n options?: ConstrainedRequestOptions & { patch?: boolean }\n): UpdateRequestOptions;\nexport function updateRecord(\n record: unknown,\n options: ConstrainedRequestOptions & { patch?: boolean } = {}\n): UpdateRequestOptions {\n const identifier = recordIdentifierFor(record);\n assert(`Expected to be given a record instance`, identifier);\n assert(`Cannot update a record that does not have an associated type and id.`, isExisting(identifier));\n\n const urlOptions: UpdateRecordUrlOptions = {\n identifier: identifier,\n op: 'updateRecord',\n resourcePath: pluralize(camelize(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url,\n method: options.patch ? 'PATCH' : 'PUT',\n headers,\n op: 'updateRecord',\n data: {\n record: identifier,\n },\n records: [identifier],\n };\n}\n"],"names":["copyForwardUrlOptions","urlOptions","options","host","namespace","resourcePath","extractCacheOptions","cacheOptions","reload","backgroundReload","findRecord","arg1","arg2","arg3","identifier","type","id","op","pluralize","camelize","url","buildBaseURL","headers","Headers","append","include","length","buildQueryParams","urlParamsSettings","method","records","query","queryString","isExisting","deleteRecord","record","recordIdentifierFor","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","test","Error","data","createRecord","updateRecord","patch"],"mappings":";;;;;AAGO,SAASA,qBAAqBA,CAACC,UAAsB,EAAEC,OAAkC,EAAQ;EACtG,IAAI,MAAM,IAAIA,OAAO,EAAE;AACrBD,IAAAA,UAAU,CAACE,IAAI,GAAGD,OAAO,CAACC,IAAI;AAChC;EACA,IAAI,WAAW,IAAID,OAAO,EAAE;AAC1BD,IAAAA,UAAU,CAACG,SAAS,GAAGF,OAAO,CAACE,SAAS;AAC1C;EACA,IAAI,cAAc,IAAIF,OAAO,EAAE;AAC7BD,IAAAA,UAAU,CAACI,YAAY,GAAGH,OAAO,CAACG,YAAY;AAChD;AACF;AAEO,SAASC,mBAAmBA,CAACJ,OAAkC,EAAgB;EACpF,MAAMK,YAA0B,GAAG,EAAE;EACrC,IAAI,QAAQ,IAAIL,OAAO,EAAE;AACvBK,IAAAA,YAAY,CAACC,MAAM,GAAGN,OAAO,CAACM,MAAM;AACtC;EACA,IAAI,kBAAkB,IAAIN,OAAO,EAAE;AACjCK,IAAAA,YAAY,CAACE,gBAAgB,GAAGP,OAAO,CAACO,gBAAgB;AAC1D;AACA,EAAA,OAAOF,YAAY;AACrB;;ACZA;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;;AAiBO,SAASG,UAAUA,CACxBC,IAA6E,EAC7EC,IAA4C,EAC5CC,IAAwB,EACkC;AAC1D,EAAA,MAAMC,UAA6D,GACjE,OAAOH,IAA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pC,EAAA,MAAMqB,OAAO,GAAG,IAAIC,OAAO,EAAE;AAC7BD,EAAAA,OAAO,CAACE,MAAM,CAAC,QAAQ,EAAE,gCAAgC,CAAC;EAE1D,OAAO;IACLJ,GAAG;AACHS,IAAAA,MAAM,EAAE3B,OAAO,CAAC6C,KAAK,GAAG,OAAO,GAAG,KAAK;IACvCzB,OAAO;AACPL,IAAAA,EAAE,EAAE,cAAc;AAClB2B,IAAAA,IAAI,EAAE;AACJT,MAAAA,MAAM,EAAErB;KACT;IACDgB,OAAO,EAAE,CAAChB,UAAU;GACrB;AACH;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ember-data-mirror/rest",
3
3
  "description": "REST Format Support for EmberData",
4
- "version": "5.6.0-alpha.2",
4
+ "version": "5.6.0-alpha.4",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "author": "Chris Thoburn <runspired@users.noreply.github.com>",
@@ -12,9 +12,6 @@
12
12
  },
13
13
  "homepage": "https://github.com/emberjs/data",
14
14
  "bugs": "https://github.com/emberjs/data/issues",
15
- "engines": {
16
- "node": ">= 18.20.8"
17
- },
18
15
  "keywords": [
19
16
  "ember-addon"
20
17
  ],
@@ -23,12 +20,12 @@
23
20
  },
24
21
  "dependencies": {
25
22
  "@embroider/macros": "^1.16.12",
26
- "@warp-drive-mirror/build-config": "5.6.0-alpha.2"
23
+ "@warp-drive-mirror/build-config": "5.6.0-alpha.4"
27
24
  },
28
25
  "peerDependencies": {
29
- "@ember-data-mirror/request-utils": "5.6.0-alpha.2",
26
+ "@ember-data-mirror/request-utils": "5.6.0-alpha.4",
30
27
  "@ember-data-mirror/store": "^4.12.0 || ^5.0.0",
31
- "@warp-drive-mirror/core-types": "5.6.0-alpha.2"
28
+ "@warp-drive-mirror/core-types": "5.6.0-alpha.4"
32
29
  },
33
30
  "files": [
34
31
  "unstable-preview-types",
@@ -56,12 +53,12 @@
56
53
  "@babel/plugin-transform-typescript": "^7.27.0",
57
54
  "@babel/preset-env": "^7.26.9",
58
55
  "@babel/preset-typescript": "^7.27.0",
59
- "@ember-data-mirror/request": "5.6.0-alpha.2",
60
- "@ember-data-mirror/request-utils": "5.6.0-alpha.2",
61
- "@ember-data-mirror/store": "5.6.0-alpha.2",
56
+ "@ember-data-mirror/request": "5.6.0-alpha.4",
57
+ "@ember-data-mirror/request-utils": "5.6.0-alpha.4",
58
+ "@ember-data-mirror/store": "5.6.0-alpha.4",
62
59
  "@glimmer/component": "^2.0.0",
63
- "@warp-drive-mirror/core-types": "5.6.0-alpha.2",
64
- "@warp-drive/internal-config": "5.6.0-alpha.2",
60
+ "@warp-drive-mirror/core-types": "5.6.0-alpha.4",
61
+ "@warp-drive/internal-config": "5.6.0-alpha.4",
65
62
  "ember-source": "~6.3.0",
66
63
  "vite": "^5.4.15"
67
64
  },
@@ -53,19 +53,16 @@ declare module '@ember-data-mirror/rest/-private/builders/find-record' {
53
53
  * const data = await store.request(options);
54
54
  * ```
55
55
  *
56
- * @method findRecord
57
56
  * @public
58
- * @static
59
- * @for @ember-data-mirror/rest/request
60
57
  * @param identifier
61
58
  * @param options
62
59
  */
63
60
  export type FindRecordResultDocument<T> = Omit<SingleResourceDataDocument<T>, 'data'> & {
64
61
  data: T;
65
62
  };
66
- export function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions<T>): FindRecordRequestOptions<T, FindRecordResultDocument<T>>;
63
+ export function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions<T>): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
67
64
  export function findRecord(identifier: RemotelyAccessibleIdentifier, options?: FindRecordOptions): FindRecordRequestOptions;
68
- export function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions<T>): FindRecordRequestOptions<T, FindRecordResultDocument<T>>;
65
+ export function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions<T>): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
69
66
  export function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;
70
67
  }
71
68
  //# sourceMappingURL=find-record.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"find-record.d.ts","sourceRoot":"","sources":["../../../src/-private/builders/find-record.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EACV,iBAAiB,EACjB,wBAAwB,EACxB,4BAA4B,EAC7B,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAIvF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,MAAM,MAAM,wBAAwB,CAAC,CAAC,IAAI,IAAI,CAAC,0BAA0B,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC;AAEpG,wBAAgB,UAAU,CAAC,CAAC,EAC1B,UAAU,EAAE,4BAA4B,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAC7D,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC7B,wBAAwB,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D,wBAAgB,UAAU,CACxB,UAAU,EAAE,4BAA4B,EACxC,OAAO,CAAC,EAAE,iBAAiB,GAC1B,wBAAwB,CAAC;AAC5B,wBAAgB,UAAU,CAAC,CAAC,EAC1B,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EACzB,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC7B,wBAAwB,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D,wBAAgB,UAAU,CAAC,I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E,OAAO,CAAC,EAAE,iBAAiB,GAAG,wBAAwB,CAAC"}
@@ -45,15 +45,12 @@ declare module '@ember-data-mirror/rest/-private/builders/query' {
45
45
  * const data = await store.request(options);
46
46
  * ```
47
47
  *
48
- * @method query
49
48
  * @public
50
- * @static
51
- * @for @ember-data-mirror/rest/request
52
49
  * @param identifier
53
50
  * @param query
54
51
  * @param options
55
52
  */
56
- export function query<T>(type: TypeFromInstance<T>, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions<T, CollectionResourceDataDocument<T>>;
53
+ export function query<T>(type: TypeFromInstance<T>, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions<CollectionResourceDataDocument<T>, T>;
57
54
  export function query(type: string, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions;
58
55
  }
59
56
  //# sourceMappingURL=query.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/-private/builders/query.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrG,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AAI3F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAgB,KAAK,CAAC,CAAC,EACrB,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EACzB,KAAK,CAAC,EAAE,iBAAiB,EACzB,OAAO,CAAC,EAAE,yBAAyB,GAClC,mBAAmB,CAAC,CAAC,EAAE,8BAA8B,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7D,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,iBAAiB,EACzB,OAAO,CAAC,EAAE,yBAAyB,GAClC,mBAAmB,CAAC"}
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/-private/builders/query.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrG,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AAI3F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,KAAK,CAAC,CAAC,EACrB,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EACzB,KAAK,CAAC,EAAE,iBAAiB,EACzB,OAAO,CAAC,EAAE,yBAAyB,GAClC,mBAAmB,CAAC,8BAA8B,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC7D,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,iBAAiB,EACzB,OAAO,CAAC,EAAE,yBAAyB,GAClC,mBAAmB,CAAC"}
@@ -1,5 +1,7 @@
1
1
  declare module '@ember-data-mirror/rest/-private/builders/save-record' {
2
+ import type { TypedRecordInstance } from '@warp-drive-mirror/core-types/record';
2
3
  import type { ConstrainedRequestOptions, CreateRequestOptions, DeleteRequestOptions, UpdateRequestOptions } from '@warp-drive-mirror/core-types/request';
4
+ import type { SingleResourceDataDocument } from '@warp-drive-mirror/core-types/spec/document';
3
5
  /**
4
6
  * Builds request options to delete record for resources,
5
7
  * configured for the url, method and header expectations of REST APIs.
@@ -45,10 +47,7 @@ declare module '@ember-data-mirror/rest/-private/builders/save-record' {
45
47
  * const data = await store.request(options);
46
48
  * ```
47
49
  *
48
- * @method deleteRecord
49
50
  * @public
50
- * @static
51
- * @for @ember-data-mirror/rest/request
52
51
  * @param record
53
52
  * @param options
54
53
  */
@@ -89,10 +88,7 @@ declare module '@ember-data-mirror/rest/-private/builders/save-record' {
89
88
  * const data = await store.request(options);
90
89
  * ```
91
90
  *
92
- * @method createRecord
93
91
  * @public
94
- * @static
95
- * @for @ember-data-mirror/rest/request
96
92
  * @param record
97
93
  * @param options
98
94
  */
@@ -136,16 +132,13 @@ declare module '@ember-data-mirror/rest/-private/builders/save-record' {
136
132
  * const data = await store.request(options);
137
133
  * ```
138
134
  *
139
- * @method updateRecord
140
135
  * @public
141
- * @static
142
- * @for @ember-data-mirror/rest/request
143
136
  * @param record
144
137
  * @param options
145
138
  */
146
- export function updateRecord<T>(record: T, options?: ConstrainedRequestOptions & {
139
+ export function updateRecord<T extends TypedRecordInstance, RT extends TypedRecordInstance = T>(record: T, options?: ConstrainedRequestOptions & {
147
140
  patch?: boolean;
148
- }): UpdateRequestOptions<T>;
141
+ }): UpdateRequestOptions<SingleResourceDataDocument<RT>, T>;
149
142
  export function updateRecord(record: unknown, options?: ConstrainedRequestOptions & {
150
143
  patch?: boolean;
151
144
  }): UpdateRequestOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"save-record.d.ts","sourceRoot":"","sources":["../../../src/-private/builders/save-record.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,gCAAgC,CAAC;AAQxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC;AACzG,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,oBAAoB,CAAC;AA8BzG;;;;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BAAyB,GAAG,oBAAoB,CAAC;AA8BzG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC;AACzG,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,oBAAoB,CAAC;AA6BzG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,mBAAmB,EAAE,EAAE,SAAS,mBAAmB,GAAG,CAAC,EAC5F,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,yBAAyB,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GACxD,oBAAoB,CAAC,0BAA0B,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC3D,wBAAgB,YAAY,CAC1B,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,yBAAyB,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GACxD,oBAAoB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /// <reference path="./request.d.ts" />
2
- /// <reference path="./-private/builders/query.d.ts" />
3
- /// <reference path="./-private/builders/save-record.d.ts" />
4
2
  /// <reference path="./-private/builders/-utils.d.ts" />
5
- /// <reference path="./-private/builders/find-record.d.ts" />
3
+ /// <reference path="./-private/builders/find-record.d.ts" />
4
+ /// <reference path="./-private/builders/save-record.d.ts" />
5
+ /// <reference path="./-private/builders/query.d.ts" />
@@ -61,8 +61,7 @@ declare module '@ember-data-mirror/rest/request' {
61
61
  - [query](https://api.emberjs.com/ember-data/release/functions/@ember-data%2Frest/query)
62
62
  - [updateRecord](https://api.emberjs.com/ember-data/release/functions/@ember-data%2Frest/updateRecord)
63
63
 
64
- * @module @ember-data-mirror/rest/request
65
- * @main @ember-data-mirror/rest/request
64
+ * @module
66
65
  * @public
67
66
  */
68
67
  export { findRecord } from '@ember-data-mirror/rest/-private/builders/find-record';
@@ -1 +1 @@
1
- {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC"}
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC"}