@ember-data/request-utils 5.6.0-alpha.5 → 5.6.0-beta.1

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.
Files changed (30) hide show
  1. package/addon-main.cjs +1 -1
  2. package/dist/deprecation-support.js +9 -8
  3. package/dist/handlers.js +1 -141
  4. package/dist/index.js +6 -909
  5. package/dist/string.js +1 -2
  6. package/package.json +5 -11
  7. package/unstable-preview-types/deprecation-support.d.ts +2 -2
  8. package/unstable-preview-types/handlers.d.ts +8 -8
  9. package/unstable-preview-types/index.d.ts +10 -649
  10. package/unstable-preview-types/string.d.ts +13 -14
  11. package/dist/deprecation-support.js.map +0 -1
  12. package/dist/handlers.js.map +0 -1
  13. package/dist/index.js.map +0 -1
  14. package/dist/inflect-SV-gOUrZ.js +0 -267
  15. package/dist/inflect-SV-gOUrZ.js.map +0 -1
  16. package/dist/string.js.map +0 -1
  17. package/dist/transform-BixPrO0I.js +0 -173
  18. package/dist/transform-BixPrO0I.js.map +0 -1
  19. package/unstable-preview-types/-private/handlers/auto-compress.d.ts +0 -155
  20. package/unstable-preview-types/-private/handlers/auto-compress.d.ts.map +0 -1
  21. package/unstable-preview-types/-private/string/inflect.d.ts +0 -107
  22. package/unstable-preview-types/-private/string/inflect.d.ts.map +0 -1
  23. package/unstable-preview-types/-private/string/inflections.d.ts +0 -12
  24. package/unstable-preview-types/-private/string/inflections.d.ts.map +0 -1
  25. package/unstable-preview-types/-private/string/transform.d.ts +0 -102
  26. package/unstable-preview-types/-private/string/transform.d.ts.map +0 -1
  27. package/unstable-preview-types/deprecation-support.d.ts.map +0 -1
  28. package/unstable-preview-types/handlers.d.ts.map +0 -1
  29. package/unstable-preview-types/index.d.ts.map +0 -1
  30. package/unstable-preview-types/string.d.ts.map +0 -1
@@ -1,652 +1,13 @@
1
+ /// <reference path="./deprecation-support.d.ts" />
1
2
  /// <reference path="./handlers.d.ts" />
2
3
  /// <reference path="./string.d.ts" />
3
- /// <reference path="./deprecation-support.d.ts" />
4
- /// <reference path="./-private/handlers/auto-compress.d.ts" />
5
- /// <reference path="./-private/string/inflect.d.ts" />
6
- /// <reference path="./-private/string/inflections.d.ts" />
7
- /// <reference path="./-private/string/transform.d.ts" />
8
4
  declare module '@ember-data/request-utils' {
9
- import type { Cache } from '@warp-drive/core/types/cache';
10
- import type { StableDocumentIdentifier, StableRecordIdentifier } from '@warp-drive/core/types/identifier';
11
- import type { QueryParamsSerializationOptions, QueryParamsSource, Serializable } from '@warp-drive/core/types/params';
12
- import type { ImmutableRequestInfo, ResponseInfo, StructuredDocument } from '@warp-drive/core/types/request';
13
- import type { ResourceDocument } from '@warp-drive/core/types/spec/document';
14
- type UnsubscribeToken = object;
15
- type CacheOperation = 'added' | 'removed' | 'updated' | 'state';
16
- type DocumentCacheOperation = 'invalidated' | 'added' | 'removed' | 'updated' | 'state';
17
- export interface NotificationCallback {
18
- (identifier: StableRecordIdentifier, notificationType: 'attributes' | 'relationships', key?: string): void;
19
- (identifier: StableRecordIdentifier, notificationType: 'errors' | 'meta' | 'identity' | 'state'): void;
20
- }
21
- interface ResourceOperationCallback {
22
- (identifier: StableRecordIdentifier, notificationType: CacheOperation): void;
23
- }
24
- interface DocumentOperationCallback {
25
- (identifier: StableDocumentIdentifier, notificationType: DocumentCacheOperation): void;
26
- }
27
- type NotificationManager = {
28
- subscribe(identifier: StableRecordIdentifier, callback: NotificationCallback): UnsubscribeToken;
29
- subscribe(identifier: 'resource', callback: ResourceOperationCallback): UnsubscribeToken;
30
- subscribe(identifier: 'document' | StableDocumentIdentifier, callback: DocumentOperationCallback): UnsubscribeToken;
31
- notify(identifier: StableRecordIdentifier, value: 'attributes' | 'relationships', key?: string): boolean;
32
- notify(identifier: StableRecordIdentifier, value: 'errors' | 'meta' | 'identity' | 'state'): boolean;
33
- notify(identifier: StableRecordIdentifier, value: CacheOperation): boolean;
34
- notify(identifier: StableDocumentIdentifier, value: DocumentCacheOperation): boolean;
35
- };
36
- type Store = {
37
- cache: Cache;
38
- notifications: NotificationManager;
39
- };
40
- /**
41
- * Simple utility function to assist in url building,
42
- * query params, and other common request operations.
43
- *
44
- * These primitives may be used directly or composed
45
- * by request builders to provide a consistent interface
46
- * for building requests.
47
- *
48
- * For instance:
49
- *
50
- * ```ts
51
- * import { buildBaseURL, buildQueryParams } from '@ember-data/request-utils';
52
- *
53
- * const baseURL = buildBaseURL({
54
- * host: 'https://api.example.com',
55
- * namespace: 'api/v1',
56
- * resourcePath: 'emberDevelopers',
57
- * op: 'query',
58
- * identifier: { type: 'ember-developer' }
59
- * });
60
- * const url = `${baseURL}?${buildQueryParams({ name: 'Chris', include:['pets'] })}`;
61
- * // => 'https://api.example.com/api/v1/emberDevelopers?include=pets&name=Chris'
62
- * ```
63
- *
64
- * This is useful, but not as useful as the REST request builder for query which is sugar
65
- * over this (and more!):
66
- *
67
- * ```ts
68
- * import { query } from '@ember-data/rest/request';
69
- *
70
- * const options = query('ember-developer', { name: 'Chris', include:['pets'] });
71
- * // => { url: 'https://api.example.com/api/v1/emberDevelopers?include=pets&name=Chris' }
72
- * // Note: options will also include other request options like headers, method, etc.
73
- * ```
74
- *
75
- * @module
76
- * @public
77
- */
78
- export interface BuildURLConfig {
79
- host: string | null;
80
- namespace: string | null;
81
- }
82
- /**
83
- * Sets the global configuration for `buildBaseURL`
84
- * for host and namespace values for the application.
85
- *
86
- * These values may still be overridden by passing
87
- * them to buildBaseURL directly.
88
- *
89
- * This method may be called as many times as needed.
90
- * host values of `''` or `'/'` are equivalent.
91
- *
92
- * Except for the value of `/` as host, host should not
93
- * end with `/`.
94
- *
95
- * namespace should not start or end with a `/`.
96
- *
97
- * ```ts
98
- * type BuildURLConfig = {
99
- * host: string;
100
- * namespace: string'
101
- * }
102
- * ```
103
- *
104
- * Example:
105
- *
106
- * ```ts
107
- * import { setBuildURLConfig } from '@ember-data/request-utils';
108
- *
109
- * setBuildURLConfig({
110
- * host: 'https://api.example.com',
111
- * namespace: 'api/v1'
112
- * });
113
- * ```
114
- *
115
- * @public
116
- * @param {BuildURLConfig} config
117
- * @return {void}
118
- */
119
- export function setBuildURLConfig(config: BuildURLConfig): void;
120
- export interface FindRecordUrlOptions {
121
- op: 'findRecord';
122
- identifier: {
123
- type: string;
124
- id: string;
125
- };
126
- resourcePath?: string;
127
- host?: string;
128
- namespace?: string;
129
- }
130
- export interface QueryUrlOptions {
131
- op: 'query';
132
- identifier: {
133
- type: string;
134
- };
135
- resourcePath?: string;
136
- host?: string;
137
- namespace?: string;
138
- }
139
- export interface FindManyUrlOptions {
140
- op: 'findMany';
141
- identifiers: {
142
- type: string;
143
- id: string;
144
- }[];
145
- resourcePath?: string;
146
- host?: string;
147
- namespace?: string;
148
- }
149
- export interface FindRelatedCollectionUrlOptions {
150
- op: 'findRelatedCollection';
151
- identifier: {
152
- type: string;
153
- id: string;
154
- };
155
- fieldPath: string;
156
- resourcePath?: string;
157
- host?: string;
158
- namespace?: string;
159
- }
160
- export interface FindRelatedResourceUrlOptions {
161
- op: 'findRelatedRecord';
162
- identifier: {
163
- type: string;
164
- id: string;
165
- };
166
- fieldPath: string;
167
- resourcePath?: string;
168
- host?: string;
169
- namespace?: string;
170
- }
171
- export interface CreateRecordUrlOptions {
172
- op: 'createRecord';
173
- identifier: {
174
- type: string;
175
- };
176
- resourcePath?: string;
177
- host?: string;
178
- namespace?: string;
179
- }
180
- export interface UpdateRecordUrlOptions {
181
- op: 'updateRecord';
182
- identifier: {
183
- type: string;
184
- id: string;
185
- };
186
- resourcePath?: string;
187
- host?: string;
188
- namespace?: string;
189
- }
190
- export interface DeleteRecordUrlOptions {
191
- op: 'deleteRecord';
192
- identifier: {
193
- type: string;
194
- id: string;
195
- };
196
- resourcePath?: string;
197
- host?: string;
198
- namespace?: string;
199
- }
200
- export interface GenericUrlOptions {
201
- resourcePath: string;
202
- host?: string;
203
- namespace?: string;
204
- }
205
- export type UrlOptions = FindRecordUrlOptions | QueryUrlOptions | FindManyUrlOptions | FindRelatedCollectionUrlOptions | FindRelatedResourceUrlOptions | CreateRecordUrlOptions | UpdateRecordUrlOptions | DeleteRecordUrlOptions | GenericUrlOptions;
206
- /**
207
- * Builds a URL for a request based on the provided options.
208
- * Does not include support for building query params (see `buildQueryParams`)
209
- * so that it may be composed cleanly with other query-params strategies.
210
- *
211
- * Usage:
212
- *
213
- * ```ts
214
- * import { buildBaseURL } from '@ember-data/request-utils';
215
- *
216
- * const url = buildBaseURL({
217
- * host: 'https://api.example.com',
218
- * namespace: 'api/v1',
219
- * resourcePath: 'emberDevelopers',
220
- * op: 'query',
221
- * identifier: { type: 'ember-developer' }
222
- * });
223
- *
224
- * // => 'https://api.example.com/api/v1/emberDevelopers'
225
- * ```
226
- *
227
- * On the surface this may seem like a lot of work to do something simple, but
228
- * it is designed to be composable with other utilities and interfaces that the
229
- * average product engineer will never need to see or use.
230
- *
231
- * A few notes:
232
- *
233
- * - `resourcePath` is optional, but if it is not provided, `identifier.type` will be used.
234
- * - `host` and `namespace` are optional, but if they are not provided, the values globally
235
- * configured via `setBuildURLConfig` will be used.
236
- * - `op` is required and must be one of the following:
237
- * - 'findRecord' 'query' 'findMany' 'findRelatedCollection' 'findRelatedRecord'` 'createRecord' 'updateRecord' 'deleteRecord'
238
- * - Depending on the value of `op`, `identifier` or `identifiers` will be required.
239
- *
240
- * @public
241
- * @param urlOptions
242
- * @return {String}
243
- */
244
- export function buildBaseURL(urlOptions: UrlOptions): string;
245
- /**
246
- * filter out keys of an object that have falsy values or point to empty arrays
247
- * returning a new object with only those keys that have truthy values / non-empty arrays
248
- *
249
- * @public
250
- * @param {Record<string, Serializable>} source object to filter keys with empty values from
251
- * @return {Record<string, Serializable>} A new object with the keys that contained empty values removed
252
- */
253
- export function filterEmpty(source: Record<string, Serializable>): Record<string, Serializable>;
254
- /**
255
- * Sorts query params by both key and value returning a new URLSearchParams
256
- * object with the keys inserted in sorted order.
257
- *
258
- * Treats `included` specially, splicing it into an array if it is a string and sorting the array.
259
- *
260
- * Options:
261
- * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'
262
- *
263
- * 'bracket': appends [] to the key for every value e.g. `&ids[]=1&ids[]=2`
264
- * 'indices': appends [i] to the key for every value e.g. `&ids[0]=1&ids[1]=2`
265
- * 'repeat': appends the key for every value e.g. `&ids=1&ids=2`
266
- * 'comma' (default): appends the key once with a comma separated list of values e.g. `&ids=1,2`
267
- *
268
- * @public
269
- * @param {URLSearchParams | object} params
270
- * @param {Object} options
271
- * @return {URLSearchParams} A URLSearchParams with keys inserted in sorted order
272
- */
273
- export function sortQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): URLSearchParams;
274
- /**
275
- * Sorts query params by both key and value, returning a query params string
276
- *
277
- * Treats `included` specially, splicing it into an array if it is a string and sorting the array.
278
- *
279
- * Options:
280
- * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'
281
- *
282
- * 'bracket': appends [] to the key for every value e.g. `ids[]=1&ids[]=2`
283
- * 'indices': appends [i] to the key for every value e.g. `ids[0]=1&ids[1]=2`
284
- * 'repeat': appends the key for every value e.g. `ids=1&ids=2`
285
- * 'comma' (default): appends the key once with a comma separated list of values e.g. `ids=1,2`
286
- *
287
- * @public
288
- * @param {URLSearchParams | Object} params
289
- * @param {Object} [options]
290
- * @return {String} A sorted query params string without the leading `?`
291
- */
292
- export function buildQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): string;
293
- export interface CacheControlValue {
294
- immutable?: boolean;
295
- 'max-age'?: number;
296
- 'must-revalidate'?: boolean;
297
- 'must-understand'?: boolean;
298
- 'no-cache'?: boolean;
299
- 'no-store'?: boolean;
300
- 'no-transform'?: boolean;
301
- 'only-if-cached'?: boolean;
302
- private?: boolean;
303
- 'proxy-revalidate'?: boolean;
304
- public?: boolean;
305
- 's-maxage'?: number;
306
- 'stale-if-error'?: number;
307
- 'stale-while-revalidate'?: number;
308
- }
309
- /**
310
- * Parses a string Cache-Control header value into an object with the following structure:
311
- *
312
- * ```ts
313
- * interface CacheControlValue {
314
- * immutable?: boolean;
315
- * 'max-age'?: number;
316
- * 'must-revalidate'?: boolean;
317
- * 'must-understand'?: boolean;
318
- * 'no-cache'?: boolean;
319
- * 'no-store'?: boolean;
320
- * 'no-transform'?: boolean;
321
- * 'only-if-cached'?: boolean;
322
- * private?: boolean;
323
- * 'proxy-revalidate'?: boolean;
324
- * public?: boolean;
325
- * 's-maxage'?: number;
326
- * 'stale-if-error'?: number;
327
- * 'stale-while-revalidate'?: number;
328
- * }
329
- * ```
330
- * @public
331
- * @param {String} header
332
- * @return {CacheControlValue}
333
- */
334
- export function parseCacheControl(header: string): CacheControlValue;
335
- /**
336
- * The configuration options for the CachePolicy
337
- * provided by `@ember-data/request-utils`.
338
- *
339
- * ```ts
340
- * import { CachePolicy } from '@ember-data/request-utils';
341
- *
342
- * new CachePolicy({
343
- * // ... PolicyConfig Settings ... //
344
- * });
345
- * ```
346
- *
347
- */
348
- export type PolicyConfig = {
349
- /**
350
- * the number of milliseconds after which a request is considered
351
- * stale. If a request is issued again after this time, the request
352
- * will respond from cache immediately while a background request
353
- * is made to update the cache.
354
- *
355
- * This is calculated against the `date` header of the response.
356
- *
357
- * If your API does not provide a `date` header, the `Fetch` handler
358
- * provided by `@ember-data/request/fetch` will automatically add
359
- * it to responses if it is not present. Responses without a `date`
360
- * header will be considered stale immediately.
361
- *
362
- */
363
- apiCacheSoftExpires: number;
364
- /**
365
- * the number of milliseconds after which a request is considered
366
- * expired and should be re-fetched. If a request is issued again
367
- * after this time, the request will disregard the cache and
368
- * wait for a fresh response from the API.
369
- *
370
- * This is calculated against the `date` header of the response.
371
- *
372
- * If your API does not provide a `date` header, the `Fetch` handler
373
- * provided by `@ember-data/request/fetch` will automatically add
374
- * it to responses if it is not present. Responses without a `date`
375
- * header will be considered hard expired immediately.
376
- *
377
- */
378
- apiCacheHardExpires: number;
379
- /**
380
- * In Testing environments, the `apiCacheSoftExpires` will always be `false`
381
- * and `apiCacheHardExpires` will use the `apiCacheSoftExpires` value.
382
- *
383
- * This helps reduce flakiness and produce predictably rendered results in test suites.
384
- *
385
- * Requests that specifically set `cacheOptions.backgroundReload = true` will
386
- * still be background reloaded in tests.
387
- *
388
- * This behavior can be opted out of by setting this value to `true`.
389
- *
390
- */
391
- disableTestOptimization?: boolean;
392
- /**
393
- * In addition to the simple time-based expiration strategy, CachePolicy
394
- * supports various common server-supplied expiration strategies via
395
- * headers, as well as custom expiration strategies via the `isExpired`
396
- * function.
397
- *
398
- * Requests will be validated for expiration against these constraints.
399
- * If any of these constraints are not met, the request will be considered
400
- * expired. If all constraints are met, the request will be considered
401
- * valid and the time based expiration strategy will NOT be used.
402
- *
403
- * Meeting a constraint means BOTH that the properties the constraint
404
- * requires are present AND that the expiration time indicated by those
405
- * properties has not been exceeded.
406
- *
407
- * In other words, if the properties for a constraint are not present,
408
- * this does not count either as meeting or as not meeting the constraint,
409
- * the constraint simply does not apply.
410
- *
411
- * The `isExpired` function is called with the request and should return
412
- * `true` if the request is expired, `false` if it is not expired, and
413
- * `null` if the expiration status is unknown.
414
- *
415
- * In order constraints are checked:
416
- *
417
- * - isExpired function
418
- * - ↳ (if null) X-WarpDrive-Expires header
419
- * - ↳ (if null) Cache-Control header
420
- * - ↳ (if null) Expires header
421
- *
422
- */
423
- constraints?: {
424
- /**
425
- * Headers that should be checked for expiration.
426
- *
427
- */
428
- headers?: {
429
- /**
430
- * Whether the `Cache-Control` header should be checked for expiration.
431
- * If `true`, then the `max-age` and `s-maxage` directives are used alongside
432
- * the `Age` and `Date` headers to determine if the expiration time has passed.
433
- *
434
- * Other directives are ignored.
435
- *
436
- * 'Cache-Control' will take precedence over 'Expires' if both are present
437
- * and both configured to be checked.
438
- *
439
- */
440
- 'Cache-Control'?: boolean;
441
- /**
442
- * Whether the `Expires` header should be checked for expiration.
443
- *
444
- * If `true`, then the `Expires` header is used to caclulate the expiration time
445
- * and determine if the expiration time has passed.
446
- *
447
- * 'Cache-Control' will take precedence over 'Expires' if both are present.
448
- *
449
- */
450
- Expires?: boolean;
451
- /**
452
- * Whether the `X-WarpDrive-Expires` header should be checked for expiration.
453
- *
454
- * If `true`, then the `X-WarpDrive-Expires` header is used to caclulate the expiration time
455
- * and determine if the expiration time has passed.
456
- *
457
- * This header will take precedence over 'Cache-Control' and 'Expires' if all three are present.
458
- *
459
- * The header's value should be a [UTC date string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString).
460
- *
461
- */
462
- 'X-WarpDrive-Expires'?: boolean;
463
- };
464
- /**
465
- * A function that should be called to determine if the request is expired.
466
- *
467
- * If present, this function will be called with the request and should return
468
- * `true` if the request is expired, `false` if it is not expired, and
469
- * `null` if the expiration status is unknown.
470
- *
471
- * If the function does not return `null`,
472
- *
473
- */
474
- isExpired?: (request: StructuredDocument<ResourceDocument>) => boolean | null;
475
- };
476
- };
477
- /**
478
- * A basic CachePolicy that can be added to the Store service.
479
- *
480
- * Determines staleness based on time since the request was last received from the API
481
- * using the `date` header.
482
- *
483
- * Determines expiration based on configured constraints as well as a time based
484
- * expiration strategy based on the `date` header.
485
- *
486
- * In order expiration is determined by:
487
- *
488
- * - Is explicitly invalidated
489
- * - ↳ (if null) isExpired function \<IF Constraint Active>
490
- * - ↳ (if null) X-WarpDrive-Expires header \<IF Constraint Active>
491
- * - ↳ (if null) Cache-Control header \<IF Constraint Active>
492
- * - ↳ (if null) Expires header \<IF Constraint Active>
493
- * - ↳ (if null) Date header + apiCacheHardExpires \< current time
494
- *
495
- * Invalidates any request for which `cacheOptions.types` was provided when a createRecord
496
- * request for that type is successful.
497
- *
498
- * For this to work, the `createRecord` request must include the `cacheOptions.types` array
499
- * with the types that should be invalidated, or its request should specify the identifiers
500
- * of the records that are being created via `records`. Providing both is valid.
501
- *
502
- * > [!NOTE]
503
- * > only requests that had specified `cacheOptions.types` and occurred prior to the
504
- * > createRecord request will be invalidated. This means that a given request should always
505
- * > specify the types that would invalidate it to opt into this behavior. Abstracting this
506
- * > behavior via builders is recommended to ensure consistency.
507
- *
508
- * This allows the Store's CacheHandler to determine if a request is expired and
509
- * should be refetched upon next request.
510
- *
511
- * The `Fetch` handler provided by `@ember-data/request/fetch` will automatically
512
- * add the `date` header to responses if it is not present.
513
- *
514
- * > [!NOTE]
515
- * > Date headers do not have millisecond precision, so expiration times should
516
- * > generally be larger than 1000ms.
517
- *
518
- * Usage:
519
- *
520
- * ```ts
521
- * import { CachePolicy } from '@ember-data/request-utils';
522
- * import DataStore from '@ember-data/store';
523
- *
524
- * // ...
525
- *
526
- * export class Store extends DataStore {
527
- * constructor(args) {
528
- * super(args);
529
- * this.lifetimes = new CachePolicy({ apiCacheSoftExpires: 30_000, apiCacheHardExpires: 60_000 });
530
- * }
531
- * }
532
- * ```
533
- *
534
- * In Testing environments, the `apiCacheSoftExpires` will always be `false`
535
- * and `apiCacheHardExpires` will use the `apiCacheSoftExpires` value.
536
- *
537
- * This helps reduce flakiness and produce predictably rendered results in test suites.
538
- *
539
- * Requests that specifically set `cacheOptions.backgroundReload = true` will
540
- * still be background reloaded in tests.
541
- *
542
- * This behavior can be opted out of by setting `disableTestOptimization = true`
543
- * in the policy config.
544
- *
545
- * @class CachePolicy
546
- * @public
547
- */
548
- export class CachePolicy {
549
- config: PolicyConfig;
550
- _stores: WeakMap<Store, {
551
- invalidated: Set<StableDocumentIdentifier>;
552
- types: Map<string, Set<StableDocumentIdentifier>>;
553
- }>;
554
- _getStore(store: Store): {
555
- invalidated: Set<StableDocumentIdentifier>;
556
- types: Map<string, Set<StableDocumentIdentifier>>;
557
- };
558
- constructor(config: PolicyConfig);
559
- /**
560
- * Invalidate a request by its identifier for a given store instance.
561
- *
562
- * While the store argument may seem redundant, the CachePolicy
563
- * is designed to be shared across multiple stores / forks
564
- * of the store.
565
- *
566
- * ```ts
567
- * store.lifetimes.invalidateRequest(store, identifier);
568
- * ```
569
- *
570
- * @public
571
- * @param {StableDocumentIdentifier} identifier
572
- * @param {Store} store
573
- */
574
- invalidateRequest(identifier: StableDocumentIdentifier, store: Store): void;
575
- /**
576
- * Invalidate all requests associated to a specific type
577
- * for a given store instance.
578
- *
579
- * While the store argument may seem redundant, the CachePolicy
580
- * is designed to be shared across multiple stores / forks
581
- * of the store.
582
- *
583
- * This invalidation is done automatically when using this service
584
- * for both the CacheHandler and the LegacyNetworkHandler.
585
- *
586
- * ```ts
587
- * store.lifetimes.invalidateRequestsForType(store, 'person');
588
- * ```
589
- *
590
- * @public
591
- * @param {String} type
592
- * @param {Store} store
593
- */
594
- invalidateRequestsForType(type: string, store: Store): void;
595
- /**
596
- * Invoked when a request has been fulfilled from the configured request handlers.
597
- * This is invoked by the CacheHandler for both foreground and background requests
598
- * once the cache has been updated.
599
- *
600
- * Note, this is invoked by the CacheHandler regardless of whether
601
- * the request has a cache-key.
602
- *
603
- * This method should not be invoked directly by consumers.
604
- *
605
- * @public
606
- * @param {ImmutableRequestInfo} request
607
- * @param {ImmutableResponse} response
608
- * @param {Store} store
609
- * @param {StableDocumentIdentifier | null} identifier
610
- * @return {void}
611
- */
612
- didRequest(request: ImmutableRequestInfo, response: Response | ResponseInfo | null, identifier: StableDocumentIdentifier | null, store: Store): void;
613
- /**
614
- * Invoked to determine if the request may be fulfilled from cache
615
- * if possible.
616
- *
617
- * Note, this is only invoked by the CacheHandler if the request has
618
- * a cache-key.
619
- *
620
- * If no cache entry is found or the entry is hard expired,
621
- * the request will be fulfilled from the configured request handlers
622
- * and the cache will be updated before returning the response.
623
- *
624
- * @public
625
- * @param {StableDocumentIdentifier} identifier
626
- * @param {Store} store
627
- * @return {Boolean} true if the request is considered hard expired
628
- */
629
- isHardExpired(identifier: StableDocumentIdentifier, store: Store): boolean;
630
- /**
631
- * Invoked if `isHardExpired` is false to determine if the request
632
- * should be update behind the scenes if cache data is already available.
633
- *
634
- * Note, this is only invoked by the CacheHandler if the request has
635
- * a cache-key.
636
- *
637
- * If true, the request will be fulfilled from cache while a backgrounded
638
- * request is made to update the cache via the configured request handlers.
639
- *
640
- * @public
641
- * @param {StableDocumentIdentifier} identifier
642
- * @param {Store} store
643
- * @return {Boolean} true if the request is considered soft expired
644
- */
645
- isSoftExpired(identifier: StableDocumentIdentifier, store: Store): boolean;
646
- }
647
- export class LifetimesService extends CachePolicy {
648
- constructor(config: PolicyConfig);
649
- }
650
- export {};
651
- }
652
- //# sourceMappingURL=index.d.ts.map
5
+ import { type CacheControlValue, DefaultCachePolicy, parseCacheControl, type PolicyConfig } from "@warp-drive/core/store";
6
+ export * from "@warp-drive/utilities";
7
+ export type * from "@warp-drive/utilities";
8
+ export { DefaultCachePolicy as CachePolicy, type PolicyConfig, type CacheControlValue, parseCacheControl };
9
+ export class LifetimesService extends DefaultCachePolicy {
10
+ constructor(config: PolicyConfig);
11
+ }
12
+
13
+ }
@@ -1,16 +1,15 @@
1
1
  declare module '@ember-data/request-utils/string' {
2
2
  /**
3
- * String utilties for transforming and inflecting strings useful for
4
- * when the format provided by the server is not the format you want to use
5
- * in your application.
6
- *
7
- * Each transformation function stores its results in an LRUCache to avoid
8
- * recomputing the same value multiple times. The cache size can be set
9
- * using the `setMaxLRUCacheSize` function. The default size is 10,000.
10
- *
11
- * @module
12
- */
13
- export { pluralize, singularize, singular, plural, loadIrregular, loadUncountable, irregular, uncountable, resetToDefaults, clear, clearRules, } from '@ember-data/request-utils/-private/string/inflect.ts';
14
- export { dasherize, camelize, capitalize, underscore, setMaxLRUCacheSize } from '@ember-data/request-utils/-private/string/transform.ts';
15
- }
16
- //# sourceMappingURL=string.d.ts.map
3
+ * String utilties for transforming and inflecting strings useful for
4
+ * when the format provided by the server is not the format you want to use
5
+ * in your application.
6
+ *
7
+ * Each transformation function stores its results in an LRUCache to avoid
8
+ * recomputing the same value multiple times. The cache size can be set
9
+ * using the `setMaxLRUCacheSize` function. The default size is 10,000.
10
+ *
11
+ * @module
12
+ */
13
+ export * from "@warp-drive/utilities/string";
14
+
15
+ }