@ember-data/request-utils 5.4.0-beta.4 → 5.4.0-beta.6

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/README.md CHANGED
@@ -28,6 +28,16 @@ Install using your javascript package manager of choice. For instance with [pnpm
28
28
  ```no-highlight
29
29
  pnpm add @ember-data/request-utils
30
30
  ```
31
+
32
+ **Tagged Releases**
33
+
34
+ - ![NPM Canary Version](https://img.shields.io/npm/v/%40ember-data/request-utils/canary?label=%40canary&color=FFBF00)
35
+ - ![NPM Beta Version](https://img.shields.io/npm/v/%40ember-data/request-utils/beta?label=%40beta&color=ff00ff)
36
+ - ![NPM Stable Version](https://img.shields.io/npm/v/%40ember-data/request-utils/latest?label=%40latest&color=90EE90)
37
+ - ![NPM LTS Version](https://img.shields.io/npm/v/%40ember-data/request-utils/lts?label=%40lts&color=0096FF)
38
+ - ![NPM LTS 4.12 Version](https://img.shields.io/npm/v/%40ember-data/request-utils/lts-4-12?label=%40lts-4-12&color=bbbbbb)
39
+
40
+
31
41
  ## Utils
32
42
 
33
43
  - [buildBaseUrl]()
package/addon-main.cjs ADDED
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const { addonShim } = require('@warp-drive/build-config/addon-shim.cjs');
4
+
5
+ module.exports = addonShim(__dirname);
@@ -1,4 +1,5 @@
1
- import { assert, deprecate } from '@ember/debug';
1
+ import { deprecate } from '@ember/debug';
2
+ import { macroCondition, getGlobalConfig } from '@embroider/macros';
2
3
 
3
4
  /**
4
5
  * Simple utility function to assist in url building,
@@ -39,11 +40,9 @@ import { assert, deprecate } from '@ember/debug';
39
40
  * @main @ember-data/request-utils
40
41
  * @public
41
42
  */
42
-
43
43
  // prevents the final constructed object from needing to add
44
44
  // host and namespace which are provided by the final consuming
45
45
  // class to the prototype which can result in overwrite errors
46
-
47
46
  const CONFIG = {
48
47
  host: '',
49
48
  namespace: ''
@@ -90,13 +89,33 @@ const CONFIG = {
90
89
  * @return void
91
90
  */
92
91
  function setBuildURLConfig(config) {
93
- assert(`setBuildURLConfig: You must pass a config object`, config);
94
- assert(`setBuildURLConfig: You must pass a config object with a 'host' or 'namespace' property`, 'host' in config || 'namespace' in config);
92
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
93
+ if (!test) {
94
+ throw new Error(`setBuildURLConfig: You must pass a config object`);
95
+ }
96
+ })(config) : {};
97
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
98
+ if (!test) {
99
+ throw new Error(`setBuildURLConfig: You must pass a config object with a 'host' or 'namespace' property`);
100
+ }
101
+ })('host' in config || 'namespace' in config) : {};
95
102
  CONFIG.host = config.host || '';
96
103
  CONFIG.namespace = config.namespace || '';
97
- assert(`buildBaseURL: host must NOT end with '/', received '${CONFIG.host}'`, CONFIG.host === '/' || !CONFIG.host.endsWith('/'));
98
- assert(`buildBaseURL: namespace must NOT start with '/', received '${CONFIG.namespace}'`, !CONFIG.namespace.startsWith('/'));
99
- assert(`buildBaseURL: namespace must NOT end with '/', received '${CONFIG.namespace}'`, !CONFIG.namespace.endsWith('/'));
104
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
105
+ if (!test) {
106
+ throw new Error(`buildBaseURL: host must NOT end with '/', received '${CONFIG.host}'`);
107
+ }
108
+ })(CONFIG.host === '/' || !CONFIG.host.endsWith('/')) : {};
109
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
110
+ if (!test) {
111
+ throw new Error(`buildBaseURL: namespace must NOT start with '/', received '${CONFIG.namespace}'`);
112
+ }
113
+ })(!CONFIG.namespace.startsWith('/')) : {};
114
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
115
+ if (!test) {
116
+ throw new Error(`buildBaseURL: namespace must NOT end with '/', received '${CONFIG.namespace}'`);
117
+ }
118
+ })(!CONFIG.namespace.endsWith('/')) : {};
100
119
  }
101
120
  const OPERATIONS_WITH_PRIMARY_RECORDS = new Set(['findRecord', 'findRelatedRecord', 'findRelatedCollection', 'updateRecord', 'deleteRecord']);
102
121
  function isOperationWithPrimaryRecord(options) {
@@ -106,7 +125,11 @@ function hasResourcePath(options) {
106
125
  return 'resourcePath' in options && typeof options.resourcePath === 'string' && options.resourcePath.length > 0;
107
126
  }
108
127
  function resourcePathForType(options) {
109
- assert(`resourcePathForType: You must pass a valid op as part of options`, 'op' in options && typeof options.op === 'string');
128
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
129
+ if (!test) {
130
+ throw new Error(`resourcePathForType: You must pass a valid op as part of options`);
131
+ }
132
+ })('op' in options && typeof options.op === 'string') : {};
110
133
  return options.op === 'findMany' ? options.identifiers[0].type : options.identifier.type;
111
134
  }
112
135
 
@@ -156,13 +179,41 @@ function buildBaseURL(urlOptions) {
156
179
  host: CONFIG.host,
157
180
  namespace: CONFIG.namespace
158
181
  }, urlOptions);
159
- assert(`buildBaseURL: You must pass \`op\` as part of options`, hasResourcePath(options) || typeof options.op === 'string' && options.op.length > 0);
160
- assert(`buildBaseURL: You must pass \`identifier\` as part of options`, hasResourcePath(options) || options.op === 'findMany' || options.identifier && typeof options.identifier === 'object');
161
- assert(`buildBaseURL: You must pass \`identifiers\` as part of options`, hasResourcePath(options) || options.op !== 'findMany' || options.identifiers && Array.isArray(options.identifiers) && options.identifiers.length > 0 && options.identifiers.every(i => i && typeof i === 'object'));
162
- assert(`buildBaseURL: You must pass valid \`identifier\` as part of options, expected 'id'`, hasResourcePath(options) || !isOperationWithPrimaryRecord(options) || typeof options.identifier.id === 'string' && options.identifier.id.length > 0);
163
- assert(`buildBaseURL: You must pass \`identifiers\` as part of options`, hasResourcePath(options) || options.op !== 'findMany' || options.identifiers.every(i => typeof i.id === 'string' && i.id.length > 0));
164
- assert(`buildBaseURL: You must pass valid \`identifier\` as part of options, expected 'type'`, hasResourcePath(options) || options.op === 'findMany' || typeof options.identifier.type === 'string' && options.identifier.type.length > 0);
165
- assert(`buildBaseURL: You must pass valid \`identifiers\` as part of options, expected 'type'`, hasResourcePath(options) || options.op !== 'findMany' || typeof options.identifiers[0].type === 'string' && options.identifiers[0].type.length > 0);
182
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
183
+ if (!test) {
184
+ throw new Error(`buildBaseURL: You must pass \`op\` as part of options`);
185
+ }
186
+ })(hasResourcePath(options) || typeof options.op === 'string' && options.op.length > 0) : {};
187
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
188
+ if (!test) {
189
+ throw new Error(`buildBaseURL: You must pass \`identifier\` as part of options`);
190
+ }
191
+ })(hasResourcePath(options) || options.op === 'findMany' || options.identifier && typeof options.identifier === 'object') : {};
192
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
193
+ if (!test) {
194
+ throw new Error(`buildBaseURL: You must pass \`identifiers\` as part of options`);
195
+ }
196
+ })(hasResourcePath(options) || options.op !== 'findMany' || options.identifiers && Array.isArray(options.identifiers) && options.identifiers.length > 0 && options.identifiers.every(i => i && typeof i === 'object')) : {};
197
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
198
+ if (!test) {
199
+ throw new Error(`buildBaseURL: You must pass valid \`identifier\` as part of options, expected 'id'`);
200
+ }
201
+ })(hasResourcePath(options) || !isOperationWithPrimaryRecord(options) || typeof options.identifier.id === 'string' && options.identifier.id.length > 0) : {};
202
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
203
+ if (!test) {
204
+ throw new Error(`buildBaseURL: You must pass \`identifiers\` as part of options`);
205
+ }
206
+ })(hasResourcePath(options) || options.op !== 'findMany' || options.identifiers.every(i => typeof i.id === 'string' && i.id.length > 0)) : {};
207
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
208
+ if (!test) {
209
+ throw new Error(`buildBaseURL: You must pass valid \`identifier\` as part of options, expected 'type'`);
210
+ }
211
+ })(hasResourcePath(options) || options.op === 'findMany' || typeof options.identifier.type === 'string' && options.identifier.type.length > 0) : {};
212
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
213
+ if (!test) {
214
+ throw new Error(`buildBaseURL: You must pass valid \`identifiers\` as part of options, expected 'type'`);
215
+ }
216
+ })(hasResourcePath(options) || options.op !== 'findMany' || typeof options.identifiers[0].type === 'string' && options.identifiers[0].type.length > 0) : {};
166
217
 
167
218
  // prettier-ignore
168
219
  const idPath = isOperationWithPrimaryRecord(options) ? encodeURIComponent(options.identifier.id) : '';
@@ -172,16 +223,56 @@ function buildBaseURL(urlOptions) {
172
223
  namespace
173
224
  } = options;
174
225
  const fieldPath = 'fieldPath' in options ? options.fieldPath : '';
175
- assert(`buildBaseURL: You tried to build a url for a ${String('op' in options ? options.op + ' ' : '')}request to ${resourcePath} but resourcePath must be set or op must be one of "${['findRecord', 'findRelatedRecord', 'findRelatedCollection', 'updateRecord', 'deleteRecord', 'createRecord', 'query', 'findMany'].join('","')}".`, hasResourcePath(options) || ['findRecord', 'query', 'findMany', 'findRelatedCollection', 'findRelatedRecord', 'createRecord', 'updateRecord', 'deleteRecord'].includes(options.op));
176
- assert(`buildBaseURL: host must NOT end with '/', received '${host}'`, host === '/' || !host.endsWith('/'));
177
- assert(`buildBaseURL: namespace must NOT start with '/', received '${namespace}'`, !namespace.startsWith('/'));
178
- assert(`buildBaseURL: namespace must NOT end with '/', received '${namespace}'`, !namespace.endsWith('/'));
179
- assert(`buildBaseURL: resourcePath must NOT start with '/', received '${resourcePath}'`, !resourcePath.startsWith('/'));
180
- assert(`buildBaseURL: resourcePath must NOT end with '/', received '${resourcePath}'`, !resourcePath.endsWith('/'));
181
- assert(`buildBaseURL: fieldPath must NOT start with '/', received '${fieldPath}'`, !fieldPath.startsWith('/'));
182
- assert(`buildBaseURL: fieldPath must NOT end with '/', received '${fieldPath}'`, !fieldPath.endsWith('/'));
183
- assert(`buildBaseURL: idPath must NOT start with '/', received '${idPath}'`, !idPath.startsWith('/'));
184
- assert(`buildBaseURL: idPath must NOT end with '/', received '${idPath}'`, !idPath.endsWith('/'));
226
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
227
+ if (!test) {
228
+ throw new Error(`buildBaseURL: You tried to build a url for a ${String('op' in options ? options.op + ' ' : '')}request to ${resourcePath} but resourcePath must be set or op must be one of "${['findRecord', 'findRelatedRecord', 'findRelatedCollection', 'updateRecord', 'deleteRecord', 'createRecord', 'query', 'findMany'].join('","')}".`);
229
+ }
230
+ })(hasResourcePath(options) || ['findRecord', 'query', 'findMany', 'findRelatedCollection', 'findRelatedRecord', 'createRecord', 'updateRecord', 'deleteRecord'].includes(options.op)) : {};
231
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
232
+ if (!test) {
233
+ throw new Error(`buildBaseURL: host must NOT end with '/', received '${host}'`);
234
+ }
235
+ })(host === '/' || !host.endsWith('/')) : {};
236
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
237
+ if (!test) {
238
+ throw new Error(`buildBaseURL: namespace must NOT start with '/', received '${namespace}'`);
239
+ }
240
+ })(!namespace.startsWith('/')) : {};
241
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
242
+ if (!test) {
243
+ throw new Error(`buildBaseURL: namespace must NOT end with '/', received '${namespace}'`);
244
+ }
245
+ })(!namespace.endsWith('/')) : {};
246
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
247
+ if (!test) {
248
+ throw new Error(`buildBaseURL: resourcePath must NOT start with '/', received '${resourcePath}'`);
249
+ }
250
+ })(!resourcePath.startsWith('/')) : {};
251
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
252
+ if (!test) {
253
+ throw new Error(`buildBaseURL: resourcePath must NOT end with '/', received '${resourcePath}'`);
254
+ }
255
+ })(!resourcePath.endsWith('/')) : {};
256
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
257
+ if (!test) {
258
+ throw new Error(`buildBaseURL: fieldPath must NOT start with '/', received '${fieldPath}'`);
259
+ }
260
+ })(!fieldPath.startsWith('/')) : {};
261
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
262
+ if (!test) {
263
+ throw new Error(`buildBaseURL: fieldPath must NOT end with '/', received '${fieldPath}'`);
264
+ }
265
+ })(!fieldPath.endsWith('/')) : {};
266
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
267
+ if (!test) {
268
+ throw new Error(`buildBaseURL: idPath must NOT start with '/', received '${idPath}'`);
269
+ }
270
+ })(!idPath.startsWith('/')) : {};
271
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
272
+ if (!test) {
273
+ throw new Error(`buildBaseURL: idPath must NOT end with '/', received '${idPath}'`);
274
+ }
275
+ })(!idPath.endsWith('/')) : {};
185
276
  const hasHost = host !== '' && host !== '/';
186
277
  const url = [hasHost ? host : '', namespace, resourcePath, idPath, fieldPath].filter(Boolean).join('/');
187
278
  return hasHost ? url : `/${url}`;
@@ -190,7 +281,11 @@ const DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS = {
190
281
  arrayFormat: 'comma'
191
282
  };
192
283
  function handleInclude(include) {
193
- assert(`Expected include to be a string or array, got ${typeof include}`, typeof include === 'string' || Array.isArray(include));
284
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
285
+ if (!test) {
286
+ throw new Error(`Expected include to be a string or array, got ${typeof include}`);
287
+ }
288
+ })(typeof include === 'string' || Array.isArray(include)) : {};
194
289
  return typeof include === 'string' ? include.split(',') : include;
195
290
  }
196
291
 
@@ -358,14 +453,26 @@ function parseCacheControl(header) {
358
453
  const cacheControlValue = {};
359
454
  function parseCacheControlValue(stringToParse) {
360
455
  const parsedValue = Number.parseInt(stringToParse);
361
- assert(`Invalid Cache-Control value, expected a number but got - ${stringToParse}`, !Number.isNaN(parsedValue));
456
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
457
+ if (!test) {
458
+ throw new Error(`Invalid Cache-Control value, expected a number but got - ${stringToParse}`);
459
+ }
460
+ })(!Number.isNaN(parsedValue)) : {};
362
461
  return parsedValue;
363
462
  }
364
463
  for (let i = 0; i < header.length; i++) {
365
464
  const char = header.charAt(i);
366
465
  if (char === ',') {
367
- assert(`Invalid Cache-Control value, expected a value`, !isParsingKey || !NUMERIC_KEYS.has(key));
368
- assert(`Invalid Cache-Control value, expected a value after "=" but got ","`, i === 0 || header.charAt(i - 1) !== '=');
466
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
467
+ if (!test) {
468
+ throw new Error(`Invalid Cache-Control value, expected a value`);
469
+ }
470
+ })(!isParsingKey || !NUMERIC_KEYS.has(key)) : {};
471
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
472
+ if (!test) {
473
+ throw new Error(`Invalid Cache-Control value, expected a value after "=" but got ","`);
474
+ }
475
+ })(i === 0 || header.charAt(i - 1) !== '=') : {};
369
476
  isParsingKey = true;
370
477
  // @ts-expect-error TS incorrectly thinks that optional keys must have a type that includes undefined
371
478
  cacheControlValue[key] = NUMERIC_KEYS.has(key) ? parseCacheControlValue(value) : true;
@@ -373,7 +480,11 @@ function parseCacheControl(header) {
373
480
  value = '';
374
481
  continue;
375
482
  } else if (char === '=') {
376
- assert(`Invalid Cache-Control value, expected a value after "="`, i + 1 !== header.length);
483
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
484
+ if (!test) {
485
+ throw new Error(`Invalid Cache-Control value, expected a value after "="`);
486
+ }
487
+ })(i + 1 !== header.length) : {};
377
488
  isParsingKey = false;
378
489
  } else if (char === ' ' || char === `\t` || char === `\n`) {
379
490
  continue;
@@ -405,7 +516,7 @@ function isStale(headers, expirationTime) {
405
516
  return result;
406
517
  }
407
518
  /**
408
- * A basic LifetimesService that can be added to the Store service.
519
+ * A basic CachePolicy that can be added to the Store service.
409
520
  *
410
521
  * Determines staleness based on time since the request was last received from the API
411
522
  * using the `date` header.
@@ -413,19 +524,30 @@ function isStale(headers, expirationTime) {
413
524
  * Invalidates any request for which `cacheOptions.types` was provided when a createRecord
414
525
  * request for that type is successful.
415
526
  *
527
+ * For this to work, the `createRecord` request must include the `cacheOptions.types` array
528
+ * with the types that should be invalidated, or its request should specify the identifiers
529
+ * of the records that are being created via `records`. Providing both is valid.
530
+ *
531
+ * > [!NOTE]
532
+ * > only requests that had specified `cacheOptions.types` and occurred prior to the
533
+ * > createRecord request will be invalidated. This means that a given request should always
534
+ * > specify the types that would invalidate it to opt into this behavior. Abstracting this
535
+ * > behavior via builders is recommended to ensure consistency.
536
+ *
416
537
  * This allows the Store's CacheHandler to determine if a request is expired and
417
538
  * should be refetched upon next request.
418
539
  *
419
540
  * The `Fetch` handler provided by `@ember-data/request/fetch` will automatically
420
541
  * add the `date` header to responses if it is not present.
421
542
  *
422
- * Note: Date headers do not have millisecond precision, so expiration times should
423
- * generally be larger than 1000ms.
543
+ * > [!NOTE]
544
+ * > Date headers do not have millisecond precision, so expiration times should
545
+ * > generally be larger than 1000ms.
424
546
  *
425
547
  * Usage:
426
548
  *
427
549
  * ```ts
428
- * import { LifetimesService } from '@ember-data/request-utils';
550
+ * import { CachePolicy } from '@ember-data/request-utils';
429
551
  * import DataStore from '@ember-data/store';
430
552
  *
431
553
  * // ...
@@ -433,16 +555,16 @@ function isStale(headers, expirationTime) {
433
555
  * export class Store extends DataStore {
434
556
  * constructor(args) {
435
557
  * super(args);
436
- * this.lifetimes = new LifetimesService({ apiCacheSoftExpires: 30_000, apiCacheHardExpires: 60_000 });
558
+ * this.lifetimes = new CachePolicy({ apiCacheSoftExpires: 30_000, apiCacheHardExpires: 60_000 });
437
559
  * }
438
560
  * }
439
561
  * ```
440
562
  *
441
- * @class LifetimesService
563
+ * @class CachePolicy
442
564
  * @public
443
565
  * @module @ember-data/request-utils
444
566
  */
445
- class LifetimesService {
567
+ class CachePolicy {
446
568
  _getStore(store) {
447
569
  let set = this._stores.get(store);
448
570
  if (!set) {
@@ -457,7 +579,7 @@ class LifetimesService {
457
579
  constructor(config) {
458
580
  this._stores = new WeakMap();
459
581
  const _config = arguments.length === 1 ? config : arguments[1];
460
- deprecate(`Passing a Store to the LifetimesService is deprecated, please pass only a config instead.`, arguments.length === 1, {
582
+ deprecate(`Passing a Store to the CachePolicy is deprecated, please pass only a config instead.`, arguments.length === 1, {
461
583
  id: 'ember-data:request-utils:lifetimes-service-store-arg',
462
584
  since: {
463
585
  enabled: '5.4',
@@ -466,16 +588,28 @@ class LifetimesService {
466
588
  for: '@ember-data/request-utils',
467
589
  until: '6.0'
468
590
  });
469
- assert(`You must pass a config to the LifetimesService`, _config);
470
- assert(`You must pass a apiCacheSoftExpires to the LifetimesService`, typeof _config.apiCacheSoftExpires === 'number');
471
- assert(`You must pass a apiCacheHardExpires to the LifetimesService`, typeof _config.apiCacheHardExpires === 'number');
591
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
592
+ if (!test) {
593
+ throw new Error(`You must pass a config to the CachePolicy`);
594
+ }
595
+ })(_config) : {};
596
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
597
+ if (!test) {
598
+ throw new Error(`You must pass a apiCacheSoftExpires to the CachePolicy`);
599
+ }
600
+ })(typeof _config.apiCacheSoftExpires === 'number') : {};
601
+ macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
602
+ if (!test) {
603
+ throw new Error(`You must pass a apiCacheHardExpires to the CachePolicy`);
604
+ }
605
+ })(typeof _config.apiCacheHardExpires === 'number') : {};
472
606
  this.config = _config;
473
607
  }
474
608
 
475
609
  /**
476
610
  * Invalidate a request by its identifier for a given store instance.
477
611
  *
478
- * While the store argument may seem redundant, the lifetimes service
612
+ * While the store argument may seem redundant, the CachePolicy
479
613
  * is designed to be shared across multiple stores / forks
480
614
  * of the store.
481
615
  *
@@ -496,7 +630,7 @@ class LifetimesService {
496
630
  * Invalidate all requests associated to a specific type
497
631
  * for a given store instance.
498
632
  *
499
- * While the store argument may seem redundant, the lifetimes service
633
+ * While the store argument may seem redundant, the CachePolicy
500
634
  * is designed to be shared across multiple stores / forks
501
635
  * of the store.
502
636
  *
@@ -546,6 +680,10 @@ class LifetimesService {
546
680
  const statusNumber = response?.status ?? 0;
547
681
  if (statusNumber >= 200 && statusNumber < 400) {
548
682
  const types = new Set(request.records?.map(r => r.type));
683
+ const additionalTypes = request.cacheOptions?.types;
684
+ additionalTypes?.forEach(type => {
685
+ types.add(type);
686
+ });
549
687
  types.forEach(type => {
550
688
  this.invalidateRequestsForType(type, store);
551
689
  });
@@ -617,4 +755,18 @@ class LifetimesService {
617
755
  return !cached || !cached.response || isStale(cached.response.headers, this.config.apiCacheSoftExpires);
618
756
  }
619
757
  }
620
- export { LifetimesService, buildBaseURL, buildQueryParams, filterEmpty, parseCacheControl, setBuildURLConfig, sortQueryParams };
758
+ class LifetimesService extends CachePolicy {
759
+ constructor(config) {
760
+ deprecate(`\`import { LifetimesService } from '@ember-data/request-utils';\` is deprecated, please use \`import { CachePolicy } from '@ember-data/request-utils';\` instead.`, false, {
761
+ id: 'ember-data:deprecate-lifetimes-service-import',
762
+ since: {
763
+ enabled: '5.4',
764
+ available: '5.4'
765
+ },
766
+ for: 'ember-data',
767
+ until: '6.0'
768
+ });
769
+ super(config);
770
+ }
771
+ }
772
+ export { CachePolicy, LifetimesService, buildBaseURL, buildQueryParams, filterEmpty, parseCacheControl, setBuildURLConfig, sortQueryParams };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { deprecate } from '@ember/debug';\n\nimport { assert } from '@warp-drive/build-config/macros';\nimport type { Cache } from '@warp-drive/core-types/cache';\nimport type { StableDocumentIdentifier } from '@warp-drive/core-types/identifier';\nimport type { QueryParamsSerializationOptions, QueryParamsSource, Serializable } from '@warp-drive/core-types/params';\nimport type { ImmutableRequestInfo, ResponseInfo } from '@warp-drive/core-types/request';\n\ntype Store = {\n cache: Cache;\n};\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\nexport interface BuildURLConfig {\n host: string | null;\n namespace: string | null;\n}\n\nconst 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 * host values of `''` or `'/'` are equivalent.\n *\n * Except for the value of `/` as host, host should not\n * end with `/`.\n *\n * namespace should not start or end with a `/`.\n *\n * ```ts\n * type BuildURLConfig = {\n * host: string;\n * namespace: string'\n * }\n * ```\n *\n * Example:\n *\n * ```ts\n * import { setBuildURLConfig } from '@ember-data/request-utils';\n *\n * setBuildURLConfig({\n * host: 'https://api.example.com',\n * namespace: 'api/v1'\n * });\n * ```\n *\n * @method setBuildURLConfig\n * @static\n * @public\n * @for @ember-data/request-utils\n * @param {BuildURLConfig} config\n * @return void\n */\nexport function setBuildURLConfig(config: BuildURLConfig) {\n assert(`setBuildURLConfig: You must pass a config object`, config);\n assert(\n `setBuildURLConfig: You must pass a config object with a 'host' or 'namespace' property`,\n 'host' in config || 'namespace' in config\n );\n\n CONFIG.host = config.host || '';\n CONFIG.namespace = config.namespace || '';\n\n assert(\n `buildBaseURL: host must NOT end with '/', received '${CONFIG.host}'`,\n CONFIG.host === '/' || !CONFIG.host.endsWith('/')\n );\n assert(\n `buildBaseURL: namespace must NOT start with '/', received '${CONFIG.namespace}'`,\n !CONFIG.namespace.startsWith('/')\n );\n assert(\n `buildBaseURL: namespace must NOT end with '/', received '${CONFIG.namespace}'`,\n !CONFIG.namespace.endsWith('/')\n );\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 interface GenericUrlOptions {\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 | GenericUrlOptions;\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 'op' in options && OPERATIONS_WITH_PRIMARY_RECORDS.has(options.op);\n}\n\nfunction hasResourcePath(options: UrlOptions): options is GenericUrlOptions {\n return 'resourcePath' in options && typeof options.resourcePath === 'string' && options.resourcePath.length > 0;\n}\n\nfunction resourcePathForType(options: UrlOptions): string {\n assert(\n `resourcePathForType: You must pass a valid op as part of options`,\n 'op' in options && typeof options.op === 'string'\n );\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 * @return 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 hasResourcePath(options) || (typeof options.op === 'string' && options.op.length > 0)\n );\n assert(\n `buildBaseURL: You must pass \\`identifier\\` as part of options`,\n hasResourcePath(options) ||\n options.op === 'findMany' ||\n (options.identifier && typeof options.identifier === 'object')\n );\n assert(\n `buildBaseURL: You must pass \\`identifiers\\` as part of options`,\n hasResourcePath(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 hasResourcePath(options) ||\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 hasResourcePath(options) ||\n options.op !== 'findMany' ||\n 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 hasResourcePath(options) ||\n options.op === 'findMany' ||\n (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 hasResourcePath(options) ||\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 url for a ${String(\n 'op' in options ? options.op + ' ' : ''\n )}request to ${resourcePath} but resourcePath must be set or op must be one of \"${[\n 'findRecord',\n 'findRelatedRecord',\n 'findRelatedCollection',\n 'updateRecord',\n 'deleteRecord',\n 'createRecord',\n 'query',\n 'findMany',\n ].join('\",\"')}\".`,\n hasResourcePath(options) ||\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 hasHost = host !== '' && host !== '/';\n const url = [hasHost ? host : '', namespace, resourcePath, idPath, fieldPath].filter(Boolean).join('/');\n return hasHost ? url : `/${url}`;\n}\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 falsy 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 * @return {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 // Allow `0` and `false` but filter falsy values that indicate \"empty\"\n if (value !== undefined && value !== null && 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 * @return {URLSearchParams} A URLSearchParams with keys inserted in sorted order\n */\nexport function sortQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): URLSearchParams {\n const opts = 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 (opts.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 buildQueryParams\n * @static\n * @public\n * @for @ember-data/request-utils\n * @param {URLSearchParams | object} params\n * @param {object} [options]\n * @return {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\ntype CacheControlKey = keyof CacheControlValue;\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 * @method parseCacheControl\n * @static\n * @public\n * @for @ember-data/request-utils\n * @param {string} header\n * @return {CacheControlValue}\n */\nexport function parseCacheControl(header: string): CacheControlValue {\n let key: CacheControlKey = '' as CacheControlKey;\n let value = '';\n let isParsingKey = true;\n const cacheControlValue: CacheControlValue = {};\n\n function parseCacheControlValue(stringToParse: string): number {\n const parsedValue = Number.parseInt(stringToParse);\n assert(`Invalid Cache-Control value, expected a number but got - ${stringToParse}`, !Number.isNaN(parsedValue));\n return parsedValue;\n }\n\n for (let i = 0; i < header.length; i++) {\n const 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 // @ts-expect-error TS incorrectly thinks that optional keys must have a type that includes undefined\n cacheControlValue[key] = NUMERIC_KEYS.has(key) ? parseCacheControlValue(value) : true;\n key = '' as CacheControlKey;\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 // @ts-expect-error TS incorrectly thinks that optional keys must have a type that includes undefined\n cacheControlValue[key] = NUMERIC_KEYS.has(key) ? parseCacheControlValue(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 PolicyConfig = { apiCacheSoftExpires: number; apiCacheHardExpires: number };\n\n/**\n * A basic CachePolicy 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 * Invalidates any request for which `cacheOptions.types` was provided when a createRecord\n * request for that type is successful.\n *\n * For this to work, the `createRecord` request must include the `cacheOptions.types` array\n * with the types that should be invalidated, or its request should specify the identifiers\n * of the records that are being created via `records`. Providing both is valid.\n *\n * > [!NOTE]\n * > only requests that had specified `cacheOptions.types` and occurred prior to the\n * > createRecord request will be invalidated. This means that a given request should always\n * > specify the types that would invalidate it to opt into this behavior. Abstracting this\n * > behavior via builders is recommended to ensure consistency.\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 * > [!NOTE]\n * > Date headers do not have millisecond precision, so expiration times should\n * > generally be larger than 1000ms.\n *\n * Usage:\n *\n * ```ts\n * import { CachePolicy } 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 CachePolicy({ apiCacheSoftExpires: 30_000, apiCacheHardExpires: 60_000 });\n * }\n * }\n * ```\n *\n * @class CachePolicy\n * @public\n * @module @ember-data/request-utils\n */\nexport class CachePolicy {\n declare config: PolicyConfig;\n declare _stores: WeakMap<Store, { invalidated: Set<string>; types: Map<string, Set<string>> }>;\n\n _getStore(store: Store): { invalidated: Set<string>; types: Map<string, Set<string>> } {\n let set = this._stores.get(store);\n if (!set) {\n set = { invalidated: new Set(), types: new Map() };\n this._stores.set(store, set);\n }\n return set;\n }\n\n constructor(config: PolicyConfig) {\n this._stores = new WeakMap();\n\n const _config = arguments.length === 1 ? config : (arguments[1] as unknown as PolicyConfig);\n deprecate(\n `Passing a Store to the CachePolicy is deprecated, please pass only a config instead.`,\n arguments.length === 1,\n {\n id: 'ember-data:request-utils:lifetimes-service-store-arg',\n since: {\n enabled: '5.4',\n available: '5.4',\n },\n for: '@ember-data/request-utils',\n until: '6.0',\n }\n );\n assert(`You must pass a config to the CachePolicy`, _config);\n assert(`You must pass a apiCacheSoftExpires to the CachePolicy`, typeof _config.apiCacheSoftExpires === 'number');\n assert(`You must pass a apiCacheHardExpires to the CachePolicy`, typeof _config.apiCacheHardExpires === 'number');\n this.config = _config;\n }\n\n /**\n * Invalidate a request by its identifier for a given store instance.\n *\n * While the store argument may seem redundant, the CachePolicy\n * is designed to be shared across multiple stores / forks\n * of the store.\n *\n * ```ts\n * store.lifetimes.invalidateRequest(store, identifier);\n * ```\n *\n * @method invalidateRequest\n * @public\n * @param {StableDocumentIdentifier} identifier\n * @param {Store} store\n */\n invalidateRequest(identifier: StableDocumentIdentifier, store: Store): void {\n this._getStore(store).invalidated.add(identifier.lid);\n }\n\n /**\n * Invalidate all requests associated to a specific type\n * for a given store instance.\n *\n * While the store argument may seem redundant, the CachePolicy\n * is designed to be shared across multiple stores / forks\n * of the store.\n *\n * This invalidation is done automatically when using this service\n * for both the CacheHandler and the LegacyNetworkHandler.\n *\n * ```ts\n * store.lifetimes.invalidateRequestsForType(store, 'person');\n * ```\n *\n * @method invalidateRequestsForType\n * @public\n * @param {string} type\n * @param {Store} store\n */\n invalidateRequestsForType(type: string, store: Store): void {\n const storeCache = this._getStore(store);\n const set = storeCache.types.get(type);\n if (set) {\n set.forEach((id) => {\n storeCache.invalidated.add(id);\n });\n }\n }\n\n /**\n * Invoked when a request has been fulfilled from the configured request handlers.\n * This is invoked by the CacheHandler for both foreground and background requests\n * once the cache has been updated.\n *\n * Note, this is invoked by the CacheHandler regardless of whether\n * the request has a cache-key.\n *\n * This method should not be invoked directly by consumers.\n *\n * @method didRequest\n * @public\n * @param {ImmutableRequestInfo} request\n * @param {ImmutableResponse} response\n * @param {Store} store\n * @param {StableDocumentIdentifier | null} identifier\n * @return {void}\n */\n didRequest(\n request: ImmutableRequestInfo,\n response: Response | ResponseInfo | null,\n identifier: StableDocumentIdentifier | null,\n store: Store\n ): void {\n // if this is a successful createRecord request, invalidate the cacheKey for the type\n if (request.op === 'createRecord') {\n const statusNumber = response?.status ?? 0;\n if (statusNumber >= 200 && statusNumber < 400) {\n const types = new Set(request.records?.map((r) => r.type));\n const additionalTypes = request.cacheOptions?.types;\n additionalTypes?.forEach((type) => {\n types.add(type);\n });\n\n types.forEach((type) => {\n this.invalidateRequestsForType(type, store);\n });\n }\n\n // add this document's cacheKey to a map for all associated types\n // it is recommended to only use this for queries\n } else if (identifier && request.cacheOptions?.types?.length) {\n const storeCache = this._getStore(store);\n request.cacheOptions?.types.forEach((type) => {\n const set = storeCache.types.get(type);\n if (set) {\n set.add(identifier.lid);\n storeCache.invalidated.delete(identifier.lid);\n } else {\n storeCache.types.set(type, new Set([identifier.lid]));\n }\n });\n }\n }\n\n /**\n * Invoked to determine if the request may be fulfilled from cache\n * if possible.\n *\n * Note, this is only invoked by the CacheHandler if the request has\n * a cache-key.\n *\n * If no cache entry is found or the entry is hard expired,\n * the request will be fulfilled from the configured request handlers\n * and the cache will be updated before returning the response.\n *\n * @method isHardExpired\n * @public\n * @param {StableDocumentIdentifier} identifier\n * @param {Store} store\n * @return {boolean} true if the request is considered hard expired\n */\n isHardExpired(identifier: StableDocumentIdentifier, store: Store): boolean {\n // if we are explicitly invalidated, we are hard expired\n const storeCache = this._getStore(store);\n if (storeCache.invalidated.has(identifier.lid)) {\n return true;\n }\n const cache = store.cache;\n const cached = cache.peekRequest(identifier);\n return !cached || !cached.response || isStale(cached.response.headers, this.config.apiCacheHardExpires);\n }\n\n /**\n * Invoked if `isHardExpired` is false to determine if the request\n * should be update behind the scenes if cache data is already available.\n *\n * Note, this is only invoked by the CacheHandler if the request has\n * a cache-key.\n *\n * If true, the request will be fulfilled from cache while a backgrounded\n * request is made to update the cache via the configured request handlers.\n *\n * @method isSoftExpired\n * @public\n * @param {StableDocumentIdentifier} identifier\n * @param {Store} store\n * @return {boolean} true if the request is considered soft expired\n */\n isSoftExpired(identifier: StableDocumentIdentifier, store: Store): boolean {\n const cache = store.cache;\n const cached = cache.peekRequest(identifier);\n return !cached || !cached.response || isStale(cached.response.headers, this.config.apiCacheSoftExpires);\n }\n}\n\nexport class LifetimesService extends CachePolicy {\n constructor(config: PolicyConfig) {\n deprecate(\n `\\`import { LifetimesService } from '@ember-data/request-utils';\\` is deprecated, please use \\`import { CachePolicy } from '@ember-data/request-utils';\\` instead.`,\n false,\n {\n id: 'ember-data:deprecate-lifetimes-service-import',\n since: {\n enabled: '5.4',\n available: '5.4',\n },\n for: 'ember-data',\n until: '6.0',\n }\n );\n super(config);\n }\n}\n"],"names":["CONFIG","host","namespace","setBuildURLConfig","config","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","test","Error","endsWith","startsWith","OPERATIONS_WITH_PRIMARY_RECORDS","Set","isOperationWithPrimaryRecord","options","has","op","hasResourcePath","resourcePath","length","resourcePathForType","identifiers","type","identifier","buildBaseURL","urlOptions","Object","assign","Array","isArray","every","i","id","idPath","encodeURIComponent","fieldPath","String","join","includes","hasHost","url","filter","Boolean","DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS","arrayFormat","handleInclude","include","split","filterEmpty","source","result","key","value","undefined","sortQueryParams","params","opts","paramsIsObject","URLSearchParams","urlParams","dictionaryParams","forEach","hasExisting","existingValue","push","sortedKeys","keys","sort","v","append","buildQueryParams","toString","NUMERIC_KEYS","parseCacheControl","header","isParsingKey","cacheControlValue","parseCacheControlValue","stringToParse","parsedValue","Number","parseInt","isNaN","char","charAt","isStale","headers","expirationTime","date","get","time","Date","getTime","now","deadline","CachePolicy","_getStore","store","set","_stores","invalidated","types","Map","constructor","WeakMap","_config","arguments","deprecate","since","enabled","available","for","until","apiCacheSoftExpires","apiCacheHardExpires","invalidateRequest","add","lid","invalidateRequestsForType","storeCache","didRequest","request","response","statusNumber","status","records","map","r","additionalTypes","cacheOptions","delete","isHardExpired","cache","cached","peekRequest","isSoftExpired","LifetimesService"],"mappings":";;;AAYA;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,MAAMA,MAAsB,GAAG;AAC7BC,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,iBAAiBA,CAACC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