@ember-data/request-utils 5.4.0-alpha.6 → 5.4.0-alpha.8

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/addon/index.js CHANGED
@@ -47,8 +47,32 @@ let CONFIG = {
47
47
  host: '',
48
48
  namespace: ''
49
49
  };
50
- function setBuildURLConfig(values) {
51
- CONFIG = values;
50
+
51
+ /**
52
+ * Sets the global configuration for `buildBaseURL`
53
+ * for host and namespace values for the application.
54
+ *
55
+ * These values may still be overridden by passing
56
+ * them to buildBaseURL directly.
57
+ *
58
+ * This method may be called as many times as needed
59
+ *
60
+ * ```ts
61
+ type BuildURLConfig = {
62
+ host: string;
63
+ namespace: string'
64
+ }
65
+ ```
66
+ *
67
+ * @method setBuildURLConfig
68
+ * @static
69
+ * @public
70
+ * @for @ember-data/request-utils
71
+ * @param {BuildURLConfig} config
72
+ * @returns void
73
+ */
74
+ function setBuildURLConfig(config) {
75
+ CONFIG = config;
52
76
  }
53
77
  const OPERATIONS_WITH_PRIMARY_RECORDS = new Set(['findRecord', 'findRelatedRecord', 'findRelatedCollection', 'updateRecord', 'deleteRecord']);
54
78
  function isOperationWithPrimaryRecord(options) {
@@ -140,18 +164,53 @@ function handleInclude(include) {
140
164
  assert(`Expected include to be a string or array, got ${typeof include}`, typeof include === 'string' || Array.isArray(include));
141
165
  return typeof include === 'string' ? include.split(',') : include;
142
166
  }
143
- function filterEmpty(obj) {
167
+
168
+ /**
169
+ * filter out keys of an object that have falsey values or point to empty arrays
170
+ * returning a new object with only those keys that have truthy values / non-empty arrays
171
+ *
172
+ * @method filterEmpty
173
+ * @static
174
+ * @public
175
+ * @for @ember-data/request-utils
176
+ * @param {Record<string, Serializable>} source object to filter keys with empty values from
177
+ * @returns {Record<string, Serializable>} A new object with the keys that contained empty values removed
178
+ */
179
+ function filterEmpty(source) {
144
180
  const result = {};
145
- for (const key in obj) {
146
- const value = obj[key];
181
+ for (const key in source) {
182
+ const value = source[key];
147
183
  if (value) {
148
184
  if (!Array.isArray(value) || value.length > 0) {
149
- result[key] = obj[key];
185
+ result[key] = source[key];
150
186
  }
151
187
  }
152
188
  }
153
189
  return result;
154
190
  }
191
+
192
+ /**
193
+ * Sorts query params by both key and value returning a new URLSearchParams
194
+ * object with the keys inserted in sorted order.
195
+ *
196
+ * Treats `included` specially, splicing it into an array if it is a string and sorting the array.
197
+ *
198
+ * Options:
199
+ * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'
200
+ *
201
+ * 'bracket': appends [] to the key for every value e.g. `&ids[]=1&ids[]=2`
202
+ * 'indices': appends [i] to the key for every value e.g. `&ids[0]=1&ids[1]=2`
203
+ * 'repeat': appends the key for every value e.g. `&ids=1&ids=2`
204
+ * 'comma' (default): appends the key once with a comma separated list of values e.g. `&ids=1,2`
205
+ *
206
+ * @method sortQueryParams
207
+ * @static
208
+ * @public
209
+ * @for @ember-data/request-utils
210
+ * @param {URLSearchParams | object} params
211
+ * @param {object} options
212
+ * @returns {URLSearchParams} A URLSearchParams with keys inserted in sorted order
213
+ */
155
214
  function sortQueryParams(params, options) {
156
215
  options = Object.assign({}, DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS, options);
157
216
  const paramsIsObject = !(params instanceof URLSearchParams);
@@ -207,10 +266,62 @@ function sortQueryParams(params, options) {
207
266
  });
208
267
  return urlParams;
209
268
  }
269
+
270
+ /**
271
+ * Sorts query params by both key and value, returning a query params string
272
+ *
273
+ * Treats `included` specially, splicing it into an array if it is a string and sorting the array.
274
+ *
275
+ * Options:
276
+ * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'
277
+ *
278
+ * 'bracket': appends [] to the key for every value e.g. `ids[]=1&ids[]=2`
279
+ * 'indices': appends [i] to the key for every value e.g. `ids[0]=1&ids[1]=2`
280
+ * 'repeat': appends the key for every value e.g. `ids=1&ids=2`
281
+ * 'comma' (default): appends the key once with a comma separated list of values e.g. `ids=1,2`
282
+ *
283
+ * @method sortQueryParams
284
+ * @static
285
+ * @public
286
+ * @for @ember-data/request-utils
287
+ * @param {URLSearchParams | object} params
288
+ * @param {object} [options]
289
+ * @returns {string} A sorted query params string without the leading `?`
290
+ */
210
291
  function buildQueryParams(params, options) {
211
292
  return sortQueryParams(params, options).toString();
212
293
  }
213
294
  const NUMERIC_KEYS = new Set(['max-age', 's-maxage', 'stale-if-error', 'stale-while-revalidate']);
295
+
296
+ /**
297
+ * Parses a string Cache-Control header value into an object with the following structure:
298
+ *
299
+ ```ts
300
+ interface CacheControlValue {
301
+ immutable?: boolean;
302
+ 'max-age'?: number;
303
+ 'must-revalidate'?: boolean;
304
+ 'must-understand'?: boolean;
305
+ 'no-cache'?: boolean;
306
+ 'no-store'?: boolean;
307
+ 'no-transform'?: boolean;
308
+ 'only-if-cached'?: boolean;
309
+ private?: boolean;
310
+ 'proxy-revalidate'?: boolean;
311
+ public?: boolean;
312
+ 's-maxage'?: number;
313
+ 'stale-if-error'?: number;
314
+ 'stale-while-revalidate'?: number;
315
+ }
316
+ ```
317
+
318
+ * @method parseCacheControl
319
+ * @static
320
+ * @public
321
+ * @for @ember-data/request-utils
322
+ * @param {string} header
323
+ * @returns {CacheControlValue}
324
+ */
214
325
  function parseCacheControl(header) {
215
326
  let key = '';
216
327
  let value = '';
@@ -257,6 +368,40 @@ function isStale(headers, expirationTime) {
257
368
  const result = now > deadline;
258
369
  return result;
259
370
  }
371
+ /**
372
+ * A basic LifetimesService that can be added to the Store service.
373
+ *
374
+ * Determines staleness based on time since the request was last received from the API
375
+ * using the `date` header.
376
+ *
377
+ * This allows the Store's CacheHandler to determine if a request is expired and
378
+ * should be refetched upon next request.
379
+ *
380
+ * The `Fetch` handler provided by `@ember-data/request/fetch` will automatically
381
+ * add the `date` header to responses if it is not present.
382
+ *
383
+ * Usage:
384
+ *
385
+ * ```ts
386
+ * import { LifetimesService } from '@ember-data/request-utils';
387
+ * import DataStore from '@ember-data/store';
388
+ *
389
+ * // ...
390
+ *
391
+ * export class Store extends DataStore {
392
+ * constructor(args) {
393
+ * super(args);
394
+ * this.lifetimes = new LifetimesService(this, { apiCacheSoftExpires: 30_000, apiCacheHardExpires: 60_000 });
395
+ * }
396
+ * }
397
+ * ```
398
+ *
399
+ * @class LifetimesService
400
+ * @public
401
+ * @module @ember-data/request-utils
402
+ */
403
+ // TODO this doesn't get documented correctly on the website because it shares a class name
404
+ // with the interface expected by the Store service
260
405
  class LifetimesService {
261
406
  constructor(store, config) {
262
407
  this.store = store;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { assert } from '@ember/debug';\n\nimport type Store from '@ember-data/store';\nimport { StableDocumentIdentifier } from '@ember-data/types/cache/identifier';\n\n/**\n * Simple utility function to assist in url building,\n * query params, and other common request operations.\n *\n * These primitives may be used directly or composed\n * by request builders to provide a consistent interface\n * for building requests.\n *\n * For instance:\n *\n * ```ts\n * import { buildBaseURL, buildQueryParams } from '@ember-data/request-utils';\n *\n * const baseURL = buildBaseURL({\n * host: 'https://api.example.com',\n * namespace: 'api/v1',\n * resourcePath: 'emberDevelopers',\n * op: 'query',\n * identifier: { type: 'ember-developer' }\n * });\n * const url = `${baseURL}?${buildQueryParams({ name: 'Chris', include:['pets'] })}`;\n * // => 'https://api.example.com/api/v1/emberDevelopers?include=pets&name=Chris'\n * ```\n *\n * This is useful, but not as useful as the REST request builder for query which is sugar\n * over this (and more!):\n *\n * ```ts\n * import { query } from '@ember-data/rest/request';\n *\n * const options = query('ember-developer', { name: 'Chris', include:['pets'] });\n * // => { url: 'https://api.example.com/api/v1/emberDevelopers?include=pets&name=Chris' }\n * // Note: options will also include other request options like headers, method, etc.\n * ```\n *\n * @module @ember-data/request-utils\n * @main @ember-data/request-utils\n * @public\n */\n\n// prevents the final constructed object from needing to add\n// host and namespace which are provided by the final consuming\n// class to the prototype which can result in overwrite errors\n\ninterface BuildURLConfig {\n host: string | null;\n namespace: string | null;\n}\n\nlet CONFIG: BuildURLConfig = {\n host: '',\n namespace: '',\n};\n\nexport function setBuildURLConfig(values: BuildURLConfig) {\n CONFIG = values;\n}\n\nexport interface FindRecordUrlOptions {\n op: 'findRecord';\n identifier: { type: string; id: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface QueryUrlOptions {\n op: 'query';\n identifier: { type: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface FindManyUrlOptions {\n op: 'findMany';\n identifiers: { type: string; id: string }[];\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\nexport interface FindRelatedCollectionUrlOptions {\n op: 'findRelatedCollection';\n identifier: { type: string; id: string };\n fieldPath: string;\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface FindRelatedResourceUrlOptions {\n op: 'findRelatedRecord';\n identifier: { type: string; id: string };\n fieldPath: string;\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface CreateRecordUrlOptions {\n op: 'createRecord';\n identifier: { type: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface UpdateRecordUrlOptions {\n op: 'updateRecord';\n identifier: { type: string; id: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface DeleteRecordUrlOptions {\n op: 'deleteRecord';\n identifier: { type: string; id: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport type UrlOptions =\n | FindRecordUrlOptions\n | QueryUrlOptions\n | FindManyUrlOptions\n | FindRelatedCollectionUrlOptions\n | FindRelatedResourceUrlOptions\n | CreateRecordUrlOptions\n | UpdateRecordUrlOptions\n | DeleteRecordUrlOptions;\n\nconst OPERATIONS_WITH_PRIMARY_RECORDS = new Set([\n 'findRecord',\n 'findRelatedRecord',\n 'findRelatedCollection',\n 'updateRecord',\n 'deleteRecord',\n]);\n\nfunction isOperationWithPrimaryRecord(\n options: UrlOptions\n): options is\n | FindRecordUrlOptions\n | FindRelatedCollectionUrlOptions\n | FindRelatedResourceUrlOptions\n | UpdateRecordUrlOptions\n | DeleteRecordUrlOptions {\n return OPERATIONS_WITH_PRIMARY_RECORDS.has(options.op);\n}\n\nfunction resourcePathForType(options: UrlOptions): string {\n return options.op === 'findMany' ? options.identifiers[0].type : options.identifier.type;\n}\n\n/**\n * Builds a URL for a request based on the provided options.\n * Does not include support for building query params (see `buildQueryParams`)\n * so that it may be composed cleanly with other query-params strategies.\n *\n * Usage:\n *\n * ```ts\n * import { buildBaseURL } from '@ember-data/request-utils';\n *\n * const url = buildBaseURL({\n * host: 'https://api.example.com',\n * namespace: 'api/v1',\n * resourcePath: 'emberDevelopers',\n * op: 'query',\n * identifier: { type: 'ember-developer' }\n * });\n *\n * // => 'https://api.example.com/api/v1/emberDevelopers'\n * ```\n *\n * On the surface this may seem like a lot of work to do something simple, but\n * it is designed to be composable with other utilities and interfaces that the\n * average product engineer will never need to see or use.\n *\n * A few notes:\n *\n * - `resourcePath` is optional, but if it is not provided, `identifier.type` will be used.\n * - `host` and `namespace` are optional, but if they are not provided, the values globally\n * configured via `setBuildURLConfig` will be used.\n * - `op` is required and must be one of the following:\n * - 'findRecord' 'query' 'findMany' 'findRelatedCollection' 'findRelatedRecord'` 'createRecord' 'updateRecord' 'deleteRecord'\n * - Depending on the value of `op`, `identifier` or `identifiers` will be required.\n *\n * @method buildBaseURL\n * @static\n * @public\n * @for @ember-data/request-utils\n * @param urlOptions\n * @returns string\n */\nexport function buildBaseURL(urlOptions: UrlOptions): string {\n const options = Object.assign(\n {\n host: CONFIG.host,\n namespace: CONFIG.namespace,\n },\n urlOptions\n );\n assert(\n `buildBaseURL: You must pass \\`op\\` as part of options`,\n typeof options.op === 'string' && options.op.length > 0\n );\n assert(\n `buildBaseURL: You must pass \\`identifier\\` as part of options`,\n options.op === 'findMany' || (options.identifier && typeof options.identifier === 'object')\n );\n assert(\n `buildBaseURL: You must pass \\`identifiers\\` as part of options`,\n options.op !== 'findMany' ||\n (options.identifiers &&\n Array.isArray(options.identifiers) &&\n options.identifiers.length > 0 &&\n options.identifiers.every((i) => i && typeof i === 'object'))\n );\n assert(\n `buildBaseURL: You must pass valid \\`identifier\\` as part of options, expected 'id'`,\n !isOperationWithPrimaryRecord(options) ||\n (typeof options.identifier.id === 'string' && options.identifier.id.length > 0)\n );\n assert(\n `buildBaseURL: You must pass \\`identifiers\\` as part of options`,\n options.op !== 'findMany' || options.identifiers.every((i) => typeof i.id === 'string' && i.id.length > 0)\n );\n assert(\n `buildBaseURL: You must pass valid \\`identifier\\` as part of options, expected 'type'`,\n options.op === 'findMany' || (typeof options.identifier.type === 'string' && options.identifier.type.length > 0)\n );\n assert(\n `buildBaseURL: You must pass valid \\`identifiers\\` as part of options, expected 'type'`,\n options.op !== 'findMany' ||\n (typeof options.identifiers[0].type === 'string' && options.identifiers[0].type.length > 0)\n );\n\n // prettier-ignore\n const idPath: string =\n isOperationWithPrimaryRecord(options) ? encodeURIComponent(options.identifier.id)\n : '';\n const resourcePath = options.resourcePath || resourcePathForType(options);\n const { host, namespace } = options;\n const fieldPath = 'fieldPath' in options ? options.fieldPath : '';\n\n assert(\n `buildBaseURL: You tried to build a ${String(\n (options as { op: string }).op\n )} request to ${resourcePath} but op must be one of \"${[\n 'findRecord',\n 'findRelatedRecord',\n 'findRelatedCollection',\n 'updateRecord',\n 'deleteRecord',\n 'createRecord',\n 'query',\n 'findMany',\n ].join('\",\"')}\".`,\n [\n 'findRecord',\n 'query',\n 'findMany',\n 'findRelatedCollection',\n 'findRelatedRecord',\n 'createRecord',\n 'updateRecord',\n 'deleteRecord',\n ].includes(options.op)\n );\n\n assert(`buildBaseURL: host must NOT end with '/', received '${host}'`, host === '/' || !host.endsWith('/'));\n assert(`buildBaseURL: namespace must NOT start with '/', received '${namespace}'`, !namespace.startsWith('/'));\n assert(`buildBaseURL: namespace must NOT end with '/', received '${namespace}'`, !namespace.endsWith('/'));\n assert(\n `buildBaseURL: resourcePath must NOT start with '/', received '${resourcePath}'`,\n !resourcePath.startsWith('/')\n );\n assert(`buildBaseURL: resourcePath must NOT end with '/', received '${resourcePath}'`, !resourcePath.endsWith('/'));\n assert(`buildBaseURL: fieldPath must NOT start with '/', received '${fieldPath}'`, !fieldPath.startsWith('/'));\n assert(`buildBaseURL: fieldPath must NOT end with '/', received '${fieldPath}'`, !fieldPath.endsWith('/'));\n assert(`buildBaseURL: idPath must NOT start with '/', received '${idPath}'`, !idPath.startsWith('/'));\n assert(`buildBaseURL: idPath must NOT end with '/', received '${idPath}'`, !idPath.endsWith('/'));\n\n const url = [host === '/' ? '' : host, namespace, resourcePath, idPath, fieldPath].filter(Boolean).join('/');\n return host ? url : `/${url}`;\n}\n\ntype SerializablePrimitive = string | number | boolean | null;\ntype Serializable = SerializablePrimitive | SerializablePrimitive[];\nexport type QueryParamsSerializationOptions = {\n arrayFormat?: 'bracket' | 'indices' | 'repeat' | 'comma';\n};\nexport type QueryParamsSource = Record<string, Serializable> | URLSearchParams;\n\nconst DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS: QueryParamsSerializationOptions = {\n arrayFormat: 'comma',\n};\n\nfunction handleInclude(include: string | string[]): string[] {\n assert(\n `Expected include to be a string or array, got ${typeof include}`,\n typeof include === 'string' || Array.isArray(include)\n );\n return typeof include === 'string' ? include.split(',') : include;\n}\n\nexport function filterEmpty(obj: Record<string, Serializable>): Record<string, Serializable> {\n const result: Record<string, Serializable> = {};\n for (const key in obj) {\n const value = obj[key];\n if (value) {\n if (!Array.isArray(value) || value.length > 0) {\n result[key] = obj[key];\n }\n }\n }\n return result;\n}\n\nexport function sortQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): URLSearchParams {\n options = Object.assign({}, DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS, options);\n const paramsIsObject = !(params instanceof URLSearchParams);\n const urlParams = new URLSearchParams();\n const dictionaryParams: Record<string, Serializable> = paramsIsObject ? params : {};\n\n if (!paramsIsObject) {\n params.forEach((value, key) => {\n const hasExisting = key in dictionaryParams;\n if (!hasExisting) {\n dictionaryParams[key] = value;\n } else {\n const existingValue = dictionaryParams[key];\n if (Array.isArray(existingValue)) {\n existingValue.push(value);\n } else {\n dictionaryParams[key] = [existingValue, value];\n }\n }\n });\n }\n\n if ('include' in dictionaryParams) {\n dictionaryParams.include = handleInclude(dictionaryParams.include as string | string[]);\n }\n\n const sortedKeys = Object.keys(dictionaryParams).sort();\n sortedKeys.forEach((key) => {\n const value = dictionaryParams[key];\n if (Array.isArray(value)) {\n value.sort();\n switch (options!.arrayFormat) {\n case 'indices':\n value.forEach((v, i) => {\n urlParams.append(`${key}[${i}]`, String(v));\n });\n return;\n case 'bracket':\n value.forEach((v) => {\n urlParams.append(`${key}[]`, String(v));\n });\n return;\n case 'repeat':\n value.forEach((v) => {\n urlParams.append(key, String(v));\n });\n return;\n case 'comma':\n default:\n urlParams.append(key, value.join(','));\n return;\n }\n } else {\n urlParams.append(key, String(value));\n }\n });\n\n return urlParams;\n}\n\nexport function buildQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): string {\n return sortQueryParams(params, options).toString();\n}\nexport interface CacheControlValue {\n immutable?: boolean;\n 'max-age'?: number;\n 'must-revalidate'?: boolean;\n 'must-understand'?: boolean;\n 'no-cache'?: boolean;\n 'no-store'?: boolean;\n 'no-transform'?: boolean;\n 'only-if-cached'?: boolean;\n private?: boolean;\n 'proxy-revalidate'?: boolean;\n public?: boolean;\n 's-maxage'?: number;\n 'stale-if-error'?: number;\n 'stale-while-revalidate'?: number;\n}\n\nconst NUMERIC_KEYS = new Set(['max-age', 's-maxage', 'stale-if-error', 'stale-while-revalidate']);\n\nexport function parseCacheControl(header: string): CacheControlValue {\n let key = '';\n let value = '';\n let isParsingKey = true;\n let cacheControlValue: CacheControlValue = {};\n\n for (let i = 0; i < header.length; i++) {\n let char = header.charAt(i);\n if (char === ',') {\n assert(`Invalid Cache-Control value, expected a value`, !isParsingKey || !NUMERIC_KEYS.has(key));\n assert(\n `Invalid Cache-Control value, expected a value after \"=\" but got \",\"`,\n i === 0 || header.charAt(i - 1) !== '='\n );\n isParsingKey = true;\n cacheControlValue[key] = NUMERIC_KEYS.has(key) ? Number.parseInt(value) : true;\n key = '';\n value = '';\n continue;\n } else if (char === '=') {\n assert(`Invalid Cache-Control value, expected a value after \"=\"`, i + 1 !== header.length);\n isParsingKey = false;\n } else if (char === ' ' || char === `\\t` || char === `\\n`) {\n continue;\n } else if (isParsingKey) {\n key += char;\n } else {\n value += char;\n }\n\n if (i === header.length - 1) {\n cacheControlValue[key] = NUMERIC_KEYS.has(key) ? Number.parseInt(value) : true;\n }\n }\n\n return cacheControlValue;\n}\n\nfunction isStale(headers: Headers, expirationTime: number): boolean {\n // const age = headers.get('age');\n // const cacheControl = parseCacheControl(headers.get('cache-control') || '');\n // const expires = headers.get('expires');\n // const lastModified = headers.get('last-modified');\n const date = headers.get('date');\n\n if (!date) {\n return true;\n }\n\n const time = new Date(date).getTime();\n const now = Date.now();\n const deadline = time + expirationTime;\n\n const result = now > deadline;\n\n return result;\n}\n\nexport type LifetimesConfig = { apiCacheSoftExpires: number; apiCacheHardExpires: number };\n\nexport class LifetimesService {\n declare store: Store;\n declare config: LifetimesConfig;\n constructor(store: Store, config: LifetimesConfig) {\n this.store = store;\n this.config = config;\n }\n\n isHardExpired(identifier: StableDocumentIdentifier): boolean {\n const cached = this.store.cache.peekRequest(identifier);\n return !cached || !cached.response || isStale(cached.response.headers, this.config.apiCacheHardExpires);\n }\n isSoftExpired(identifier: StableDocumentIdentifier): boolean {\n const cached = this.store.cache.peekRequest(identifier);\n return !cached || !cached.response || isStale(cached.response.headers, this.config.apiCacheSoftExpires);\n }\n}\n"],"names":["CONFIG","host","namespace","setBuildURLConfig","values","OPERATIONS_WITH_PRIMARY_RECORDS","Set","isOperationWithPrimaryRecord","options","has","op","resourcePathForType","identifiers","type","identifier","buildBaseURL","urlOptions","Object","assign","assert","length","Array","isArray","every","i","id","idPath","encodeURIComponent","resourcePath","fieldPath","String","join","includes","endsWith","startsWith","url","filter","Boolean","DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS","arrayFormat","handleInclude","include","split","filterEmpty","obj","result","key","value","sortQueryParams","params","paramsIsObject","URLSearchParams","urlParams","dictionaryParams","forEach","hasExisting","existingValue","push","sortedKeys","keys","sort","v","append","buildQueryParams","toString","NUMERIC_KEYS","parseCacheControl","header","isParsingKey","cacheControlValue","char","charAt","Number","parseInt","isStale","headers","expirationTime","date","get","time","Date","getTime","now","deadline","LifetimesService","constructor","store","config","isHardExpired","cached","cache","peekRequest","response","apiCacheHardExpires","isSoftExpired","apiCacheSoftExpires"],"mappings":";;AAKA;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;;AAEA;AACA;AACA;AAOA,IAAIA,MAAsB,GAAG;AAC3BC,EAAAA,IAAI,EAAE,EAAE;AACRC,EAAAA,SAAS,EAAE,EAAA;AACb,CAAC,CAAA;AAEM,SAASC,iBAAiBA,CAACC,MAAsB,EAAE;AACxDJ,EAAAA,MAAM,GAAGI,MAAM,CAAA;AACjB,CAAA;AA6EA,MAAMC,+BAA+B,GAAG,IAAIC,GAAG,CAAC,CAC9C,YAAY,EACZ,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,cAAc,CACf,CAAC,CAAA;AAEF,SAASC,4BAA4BA,CACnCC,OAAmB,EAMM;AACzB,EAAA,OAAOH,+BAA+B,CAACI,GAAG,CAACD,OAAO,CAACE,EAAE,CAAC,CAAA;AACxD,CAAA;AAEA,SAASC,mBAAmBA,CAACH,OAAmB,EAAU;AACxD,EAAA,OAAOA,OAAO,CAACE,EAAE,KAAK,UAAU,GAAGF,OAAO,CAACI,WAAW,CAAC,CAAC,CAAC,CAACC,IAAI,GAAGL,OAAO,CAACM,UAAU,CAACD,IAAI,CAAA;AAC1F,CAAA;;A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}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { assert } from '@ember/debug';\n\nimport type Store from '@ember-data/store';\nimport { StableDocumentIdentifier } from '@ember-data/types/cache/identifier';\n\n/**\n * Simple utility function to assist in url building,\n * query params, and other common request operations.\n *\n * These primitives may be used directly or composed\n * by request builders to provide a consistent interface\n * for building requests.\n *\n * For instance:\n *\n * ```ts\n * import { buildBaseURL, buildQueryParams } from '@ember-data/request-utils';\n *\n * const baseURL = buildBaseURL({\n * host: 'https://api.example.com',\n * namespace: 'api/v1',\n * resourcePath: 'emberDevelopers',\n * op: 'query',\n * identifier: { type: 'ember-developer' }\n * });\n * const url = `${baseURL}?${buildQueryParams({ name: 'Chris', include:['pets'] })}`;\n * // => 'https://api.example.com/api/v1/emberDevelopers?include=pets&name=Chris'\n * ```\n *\n * This is useful, but not as useful as the REST request builder for query which is sugar\n * over this (and more!):\n *\n * ```ts\n * import { query } from '@ember-data/rest/request';\n *\n * const options = query('ember-developer', { name: 'Chris', include:['pets'] });\n * // => { url: 'https://api.example.com/api/v1/emberDevelopers?include=pets&name=Chris' }\n * // Note: options will also include other request options like headers, method, etc.\n * ```\n *\n * @module @ember-data/request-utils\n * @main @ember-data/request-utils\n * @public\n */\n\n// prevents the final constructed object from needing to add\n// host and namespace which are provided by the final consuming\n// class to the prototype which can result in overwrite errors\n\ninterface BuildURLConfig {\n host: string | null;\n namespace: string | null;\n}\n\nlet CONFIG: BuildURLConfig = {\n host: '',\n namespace: '',\n};\n\n/**\n * Sets the global configuration for `buildBaseURL`\n * for host and namespace values for the application.\n *\n * These values may still be overridden by passing\n * them to buildBaseURL directly.\n *\n * This method may be called as many times as needed\n *\n * ```ts\n type BuildURLConfig = {\n host: string;\n namespace: string'\n }\n ```\n *\n * @method setBuildURLConfig\n * @static\n * @public\n * @for @ember-data/request-utils\n * @param {BuildURLConfig} config\n * @returns void\n */\nexport function setBuildURLConfig(config: BuildURLConfig) {\n CONFIG = config;\n}\n\nexport interface FindRecordUrlOptions {\n op: 'findRecord';\n identifier: { type: string; id: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface QueryUrlOptions {\n op: 'query';\n identifier: { type: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface FindManyUrlOptions {\n op: 'findMany';\n identifiers: { type: string; id: string }[];\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\nexport interface FindRelatedCollectionUrlOptions {\n op: 'findRelatedCollection';\n identifier: { type: string; id: string };\n fieldPath: string;\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface FindRelatedResourceUrlOptions {\n op: 'findRelatedRecord';\n identifier: { type: string; id: string };\n fieldPath: string;\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface CreateRecordUrlOptions {\n op: 'createRecord';\n identifier: { type: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface UpdateRecordUrlOptions {\n op: 'updateRecord';\n identifier: { type: string; id: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface DeleteRecordUrlOptions {\n op: 'deleteRecord';\n identifier: { type: string; id: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport type UrlOptions =\n | FindRecordUrlOptions\n | QueryUrlOptions\n | FindManyUrlOptions\n | FindRelatedCollectionUrlOptions\n | FindRelatedResourceUrlOptions\n | CreateRecordUrlOptions\n | UpdateRecordUrlOptions\n | DeleteRecordUrlOptions;\n\nconst OPERATIONS_WITH_PRIMARY_RECORDS = new Set([\n 'findRecord',\n 'findRelatedRecord',\n 'findRelatedCollection',\n 'updateRecord',\n 'deleteRecord',\n]);\n\nfunction isOperationWithPrimaryRecord(\n options: UrlOptions\n): options is\n | FindRecordUrlOptions\n | FindRelatedCollectionUrlOptions\n | FindRelatedResourceUrlOptions\n | UpdateRecordUrlOptions\n | DeleteRecordUrlOptions {\n return OPERATIONS_WITH_PRIMARY_RECORDS.has(options.op);\n}\n\nfunction resourcePathForType(options: UrlOptions): string {\n return options.op === 'findMany' ? options.identifiers[0].type : options.identifier.type;\n}\n\n/**\n * Builds a URL for a request based on the provided options.\n * Does not include support for building query params (see `buildQueryParams`)\n * so that it may be composed cleanly with other query-params strategies.\n *\n * Usage:\n *\n * ```ts\n * import { buildBaseURL } from '@ember-data/request-utils';\n *\n * const url = buildBaseURL({\n * host: 'https://api.example.com',\n * namespace: 'api/v1',\n * resourcePath: 'emberDevelopers',\n * op: 'query',\n * identifier: { type: 'ember-developer' }\n * });\n *\n * // => 'https://api.example.com/api/v1/emberDevelopers'\n * ```\n *\n * On the surface this may seem like a lot of work to do something simple, but\n * it is designed to be composable with other utilities and interfaces that the\n * average product engineer will never need to see or use.\n *\n * A few notes:\n *\n * - `resourcePath` is optional, but if it is not provided, `identifier.type` will be used.\n * - `host` and `namespace` are optional, but if they are not provided, the values globally\n * configured via `setBuildURLConfig` will be used.\n * - `op` is required and must be one of the following:\n * - 'findRecord' 'query' 'findMany' 'findRelatedCollection' 'findRelatedRecord'` 'createRecord' 'updateRecord' 'deleteRecord'\n * - Depending on the value of `op`, `identifier` or `identifiers` will be required.\n *\n * @method buildBaseURL\n * @static\n * @public\n * @for @ember-data/request-utils\n * @param urlOptions\n * @returns string\n */\nexport function buildBaseURL(urlOptions: UrlOptions): string {\n const options = Object.assign(\n {\n host: CONFIG.host,\n namespace: CONFIG.namespace,\n },\n urlOptions\n );\n assert(\n `buildBaseURL: You must pass \\`op\\` as part of options`,\n typeof options.op === 'string' && options.op.length > 0\n );\n assert(\n `buildBaseURL: You must pass \\`identifier\\` as part of options`,\n options.op === 'findMany' || (options.identifier && typeof options.identifier === 'object')\n );\n assert(\n `buildBaseURL: You must pass \\`identifiers\\` as part of options`,\n options.op !== 'findMany' ||\n (options.identifiers &&\n Array.isArray(options.identifiers) &&\n options.identifiers.length > 0 &&\n options.identifiers.every((i) => i && typeof i === 'object'))\n );\n assert(\n `buildBaseURL: You must pass valid \\`identifier\\` as part of options, expected 'id'`,\n !isOperationWithPrimaryRecord(options) ||\n (typeof options.identifier.id === 'string' && options.identifier.id.length > 0)\n );\n assert(\n `buildBaseURL: You must pass \\`identifiers\\` as part of options`,\n options.op !== 'findMany' || options.identifiers.every((i) => typeof i.id === 'string' && i.id.length > 0)\n );\n assert(\n `buildBaseURL: You must pass valid \\`identifier\\` as part of options, expected 'type'`,\n options.op === 'findMany' || (typeof options.identifier.type === 'string' && options.identifier.type.length > 0)\n );\n assert(\n `buildBaseURL: You must pass valid \\`identifiers\\` as part of options, expected 'type'`,\n options.op !== 'findMany' ||\n (typeof options.identifiers[0].type === 'string' && options.identifiers[0].type.length > 0)\n );\n\n // prettier-ignore\n const idPath: string =\n isOperationWithPrimaryRecord(options) ? encodeURIComponent(options.identifier.id)\n : '';\n const resourcePath = options.resourcePath || resourcePathForType(options);\n const { host, namespace } = options;\n const fieldPath = 'fieldPath' in options ? options.fieldPath : '';\n\n assert(\n `buildBaseURL: You tried to build a ${String(\n (options as { op: string }).op\n )} request to ${resourcePath} but op must be one of \"${[\n 'findRecord',\n 'findRelatedRecord',\n 'findRelatedCollection',\n 'updateRecord',\n 'deleteRecord',\n 'createRecord',\n 'query',\n 'findMany',\n ].join('\",\"')}\".`,\n [\n 'findRecord',\n 'query',\n 'findMany',\n 'findRelatedCollection',\n 'findRelatedRecord',\n 'createRecord',\n 'updateRecord',\n 'deleteRecord',\n ].includes(options.op)\n );\n\n assert(`buildBaseURL: host must NOT end with '/', received '${host}'`, host === '/' || !host.endsWith('/'));\n assert(`buildBaseURL: namespace must NOT start with '/', received '${namespace}'`, !namespace.startsWith('/'));\n assert(`buildBaseURL: namespace must NOT end with '/', received '${namespace}'`, !namespace.endsWith('/'));\n assert(\n `buildBaseURL: resourcePath must NOT start with '/', received '${resourcePath}'`,\n !resourcePath.startsWith('/')\n );\n assert(`buildBaseURL: resourcePath must NOT end with '/', received '${resourcePath}'`, !resourcePath.endsWith('/'));\n assert(`buildBaseURL: fieldPath must NOT start with '/', received '${fieldPath}'`, !fieldPath.startsWith('/'));\n assert(`buildBaseURL: fieldPath must NOT end with '/', received '${fieldPath}'`, !fieldPath.endsWith('/'));\n assert(`buildBaseURL: idPath must NOT start with '/', received '${idPath}'`, !idPath.startsWith('/'));\n assert(`buildBaseURL: idPath must NOT end with '/', received '${idPath}'`, !idPath.endsWith('/'));\n\n const url = [host === '/' ? '' : host, namespace, resourcePath, idPath, fieldPath].filter(Boolean).join('/');\n return host ? url : `/${url}`;\n}\n\ntype SerializablePrimitive = string | number | boolean | null;\ntype Serializable = SerializablePrimitive | SerializablePrimitive[];\nexport type QueryParamsSerializationOptions = {\n arrayFormat?: 'bracket' | 'indices' | 'repeat' | 'comma';\n};\nexport type QueryParamsSource = Record<string, Serializable> | URLSearchParams;\n\nconst DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS: QueryParamsSerializationOptions = {\n arrayFormat: 'comma',\n};\n\nfunction handleInclude(include: string | string[]): string[] {\n assert(\n `Expected include to be a string or array, got ${typeof include}`,\n typeof include === 'string' || Array.isArray(include)\n );\n return typeof include === 'string' ? include.split(',') : include;\n}\n\n/**\n * filter out keys of an object that have falsey values or point to empty arrays\n * returning a new object with only those keys that have truthy values / non-empty arrays\n *\n * @method filterEmpty\n * @static\n * @public\n * @for @ember-data/request-utils\n * @param {Record<string, Serializable>} source object to filter keys with empty values from\n * @returns {Record<string, Serializable>} A new object with the keys that contained empty values removed\n */\nexport function filterEmpty(source: Record<string, Serializable>): Record<string, Serializable> {\n const result: Record<string, Serializable> = {};\n for (const key in source) {\n const value = source[key];\n if (value) {\n if (!Array.isArray(value) || value.length > 0) {\n result[key] = source[key];\n }\n }\n }\n return result;\n}\n\n/**\n * Sorts query params by both key and value returning a new URLSearchParams\n * object with the keys inserted in sorted order.\n *\n * Treats `included` specially, splicing it into an array if it is a string and sorting the array.\n *\n * Options:\n * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'\n *\n * 'bracket': appends [] to the key for every value e.g. `&ids[]=1&ids[]=2`\n * 'indices': appends [i] to the key for every value e.g. `&ids[0]=1&ids[1]=2`\n * 'repeat': appends the key for every value e.g. `&ids=1&ids=2`\n * 'comma' (default): appends the key once with a comma separated list of values e.g. `&ids=1,2`\n *\n * @method sortQueryParams\n * @static\n * @public\n * @for @ember-data/request-utils\n * @param {URLSearchParams | object} params\n * @param {object} options\n * @returns {URLSearchParams} A URLSearchParams with keys inserted in sorted order\n */\nexport function sortQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): URLSearchParams {\n options = Object.assign({}, DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS, options);\n const paramsIsObject = !(params instanceof URLSearchParams);\n const urlParams = new URLSearchParams();\n const dictionaryParams: Record<string, Serializable> = paramsIsObject ? params : {};\n\n if (!paramsIsObject) {\n params.forEach((value, key) => {\n const hasExisting = key in dictionaryParams;\n if (!hasExisting) {\n dictionaryParams[key] = value;\n } else {\n const existingValue = dictionaryParams[key];\n if (Array.isArray(existingValue)) {\n existingValue.push(value);\n } else {\n dictionaryParams[key] = [existingValue, value];\n }\n }\n });\n }\n\n if ('include' in dictionaryParams) {\n dictionaryParams.include = handleInclude(dictionaryParams.include as string | string[]);\n }\n\n const sortedKeys = Object.keys(dictionaryParams).sort();\n sortedKeys.forEach((key) => {\n const value = dictionaryParams[key];\n if (Array.isArray(value)) {\n value.sort();\n switch (options!.arrayFormat) {\n case 'indices':\n value.forEach((v, i) => {\n urlParams.append(`${key}[${i}]`, String(v));\n });\n return;\n case 'bracket':\n value.forEach((v) => {\n urlParams.append(`${key}[]`, String(v));\n });\n return;\n case 'repeat':\n value.forEach((v) => {\n urlParams.append(key, String(v));\n });\n return;\n case 'comma':\n default:\n urlParams.append(key, value.join(','));\n return;\n }\n } else {\n urlParams.append(key, String(value));\n }\n });\n\n return urlParams;\n}\n\n/**\n * Sorts query params by both key and value, returning a query params string\n *\n * Treats `included` specially, splicing it into an array if it is a string and sorting the array.\n *\n * Options:\n * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'\n *\n * 'bracket': appends [] to the key for every value e.g. `ids[]=1&ids[]=2`\n * 'indices': appends [i] to the key for every value e.g. `ids[0]=1&ids[1]=2`\n * 'repeat': appends the key for every value e.g. `ids=1&ids=2`\n * 'comma' (default): appends the key once with a comma separated list of values e.g. `ids=1,2`\n *\n * @method sortQueryParams\n * @static\n * @public\n * @for @ember-data/request-utils\n * @param {URLSearchParams | object} params\n * @param {object} [options]\n * @returns {string} A sorted query params string without the leading `?`\n */\nexport function buildQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): string {\n return sortQueryParams(params, options).toString();\n}\nexport interface CacheControlValue {\n immutable?: boolean;\n 'max-age'?: number;\n 'must-revalidate'?: boolean;\n 'must-understand'?: boolean;\n 'no-cache'?: boolean;\n 'no-store'?: boolean;\n 'no-transform'?: boolean;\n 'only-if-cached'?: boolean;\n private?: boolean;\n 'proxy-revalidate'?: boolean;\n public?: boolean;\n 's-maxage'?: number;\n 'stale-if-error'?: number;\n 'stale-while-revalidate'?: number;\n}\n\nconst NUMERIC_KEYS = new Set(['max-age', 's-maxage', 'stale-if-error', 'stale-while-revalidate']);\n\n/**\n * Parses a string Cache-Control header value into an object with the following structure:\n *\n ```ts\n interface CacheControlValue {\n immutable?: boolean;\n 'max-age'?: number;\n 'must-revalidate'?: boolean;\n 'must-understand'?: boolean;\n 'no-cache'?: boolean;\n 'no-store'?: boolean;\n 'no-transform'?: boolean;\n 'only-if-cached'?: boolean;\n private?: boolean;\n 'proxy-revalidate'?: boolean;\n public?: boolean;\n 's-maxage'?: number;\n 'stale-if-error'?: number;\n 'stale-while-revalidate'?: number;\n }\n ```\n\n * @method parseCacheControl\n * @static\n * @public\n * @for @ember-data/request-utils\n * @param {string} header\n * @returns {CacheControlValue}\n */\nexport function parseCacheControl(header: string): CacheControlValue {\n let key = '';\n let value = '';\n let isParsingKey = true;\n let cacheControlValue: CacheControlValue = {};\n\n for (let i = 0; i < header.length; i++) {\n let char = header.charAt(i);\n if (char === ',') {\n assert(`Invalid Cache-Control value, expected a value`, !isParsingKey || !NUMERIC_KEYS.has(key));\n assert(\n `Invalid Cache-Control value, expected a value after \"=\" but got \",\"`,\n i === 0 || header.charAt(i - 1) !== '='\n );\n isParsingKey = true;\n cacheControlValue[key] = NUMERIC_KEYS.has(key) ? Number.parseInt(value) : true;\n key = '';\n value = '';\n continue;\n } else if (char === '=') {\n assert(`Invalid Cache-Control value, expected a value after \"=\"`, i + 1 !== header.length);\n isParsingKey = false;\n } else if (char === ' ' || char === `\\t` || char === `\\n`) {\n continue;\n } else if (isParsingKey) {\n key += char;\n } else {\n value += char;\n }\n\n if (i === header.length - 1) {\n cacheControlValue[key] = NUMERIC_KEYS.has(key) ? Number.parseInt(value) : true;\n }\n }\n\n return cacheControlValue;\n}\n\nfunction isStale(headers: Headers, expirationTime: number): boolean {\n // const age = headers.get('age');\n // const cacheControl = parseCacheControl(headers.get('cache-control') || '');\n // const expires = headers.get('expires');\n // const lastModified = headers.get('last-modified');\n const date = headers.get('date');\n\n if (!date) {\n return true;\n }\n\n const time = new Date(date).getTime();\n const now = Date.now();\n const deadline = time + expirationTime;\n\n const result = now > deadline;\n\n return result;\n}\n\nexport type LifetimesConfig = { apiCacheSoftExpires: number; apiCacheHardExpires: number };\n\n/**\n * A basic LifetimesService that can be added to the Store service.\n *\n * Determines staleness based on time since the request was last received from the API\n * using the `date` header.\n *\n * This allows the Store's CacheHandler to determine if a request is expired and\n * should be refetched upon next request.\n *\n * The `Fetch` handler provided by `@ember-data/request/fetch` will automatically\n * add the `date` header to responses if it is not present.\n *\n * Usage:\n *\n * ```ts\n * import { LifetimesService } from '@ember-data/request-utils';\n * import DataStore from '@ember-data/store';\n *\n * // ...\n *\n * export class Store extends DataStore {\n * constructor(args) {\n * super(args);\n * this.lifetimes = new LifetimesService(this, { apiCacheSoftExpires: 30_000, apiCacheHardExpires: 60_000 });\n * }\n * }\n * ```\n *\n * @class LifetimesService\n * @public\n * @module @ember-data/request-utils\n */\n// TODO this doesn't get documented correctly on the website because it shares a class name\n// with the interface expected by the Store service\nexport class LifetimesService {\n declare store: Store;\n declare config: LifetimesConfig;\n constructor(store: Store, config: LifetimesConfig) {\n this.store = store;\n this.config = config;\n }\n\n isHardExpired(identifier: StableDocumentIdentifier): boolean {\n const cached = this.store.cache.peekRequest(identifier);\n return !cached || !cached.response || isStale(cached.response.headers, this.config.apiCacheHardExpires);\n }\n isSoftExpired(identifier: StableDocumentIdentifier): boolean {\n const cached = this.store.cache.peekRequest(identifier);\n return !cached || !cached.response || isStale(cached.response.headers, this.config.apiCacheSoftExpires);\n }\n}\n"],"names":["CONFIG","host","namespace","setBuildURLConfig","config","OPERATIONS_WITH_PRIMARY_RECORDS","Set","isOperationWithPrimaryRecord","options","has","op","resourcePathForType","identifiers","type","identifier","buildBaseURL","urlOptions","Object","assign","assert","length","Array","isArray","every","i","id","idPath","encodeURIComponent","resourcePath","fieldPath","String","join","includes","endsWith","startsWith","url","filter","Boolean","DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS","arrayFormat","handleInclude","include","split","filterEmpty","source","result","key","value","sortQueryParams","params","paramsIsObject","URLSearchParams","urlParams","dictionaryParams","forEach","hasExisting","existingValue","push","sortedKeys","keys","sort","v","append","buildQueryParams","toString","NUMERIC_KEYS","parseCacheControl","header","isParsingKey","cacheControlValue","char","charAt","Number","parseInt","isStale","headers","expirationTime","date","get","time","Date","getTime","now","deadline","LifetimesService","constructor","store","isHardExpired","cached","cache","peekRequest","response","apiCacheHardExpires","isSoftExpired","apiCacheSoftExpires"],"mappings":";;AAKA;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;;AAEA;AACA;AACA;AAOA,IAAIA,MAAsB,GAAG;AAC3BC,EAAAA,IAAI,EAAE,EAAE;AACRC,EAAAA,SAAS,EAAE,EAAA;AACb,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,iBAAiBA,CAACC,MAAsB,EAAE;AACxDJ,EAAAA,MAAM,GAAGI,MAAM,CAAA;AACjB,CAAA;AA6EA,MAAMC,+BAA+B,GAAG,IAAIC,GAAG,CAAC,CAC9C,YAAY,EACZ,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,cAAc,CACf,CAAC,CAAA;AAEF,SAASC,4BAA4BA,CACnCC,OAAmB,EAMM;AACzB,EAAA,OAAOH,+BAA+B,CAACI,GAAG,CAACD,OAAO,CAACE,EAAE,CAAC,CAAA;AACxD,CAAA;AAEA,SAASC,mBAAmBA,CAACH,OAAmB,EAAU;AACxD,EAAA,OAAOA,OAAO,CAACE,EAAE,KAAK,UAAU,GAAGF,OAAO,CAACI,WAAW,CAAC,CAAC,CAAC,CAACC,IAAI,GAAGL,OAAO,CAACM,UAAU,CAACD,IAAI,CAAA;AAC1F,CAAA;;AAEA;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;AACO,SAASE,YAAYA,CAACC,UAAsB,EAAU;AAC3D,EAAA,MAAMR,OAAO,GAAGS,MAAM,CAACC,MAAM,CAC3B;IACEjB,IAAI,EAAED,MAAM,CAACC,IAAI;IACjBC,SAAS,EAAEF,MAAM,CAACE,SAAAA;GACnB,EACDc,UACF,CAAC,CAAA;AACDG,EAAAA,MAAM,CACH,CAAsD,qDAAA,CAAA,EACvD,OAAOX,OAAO,CAACE,EAAE,KAAK,QAAQ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,CAAChB,OAAO,EAAE,IAAI,CAACvE,MAAM,CAAC0F,mBAAmB,CAAC,CAAA;AACzG,GAAA;AACF;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ember-data/request-utils",
3
3
  "description": "Request Building Utilities for use with EmberData",
4
- "version": "5.4.0-alpha.6",
4
+ "version": "5.4.0-alpha.8",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "author": "Chris Thoburn <runspired@users.noreply.github.com>",