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