@ember-data/request-utils 5.4.0-beta.0 → 5.4.0-beta.10

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.
@@ -0,0 +1,14 @@
1
+ declare module '@ember-data/request-utils/-private/string/inflect' {
2
+ export function uncountable(word: string): void;
3
+ export function loadUncountable(uncountables: string[]): void;
4
+ export function irregular(single: string, plur: string): void;
5
+ export function loadIrregular(irregularPairs: Array<[string, string]>): void;
6
+ export function clear(): void;
7
+ export function resetToDefaults(): void;
8
+ export function clearRules(): void;
9
+ export function singularize(word: string): string;
10
+ export function pluralize(word: string): string;
11
+ export function plural(regex: RegExp, string: string): void;
12
+ export function singular(regex: RegExp, string: string): void;
13
+ }
14
+ //# sourceMappingURL=inflect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inflect.d.ts","sourceRoot":"","sources":["../../../src/-private/string/inflect.ts"],"names":[],"mappings":"AAsBA,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,QAEvC;AAED,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,QAIrD;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAQrD;AAED,wBAAgB,aAAa,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,QAUpE;AAGD,wBAAgB,KAAK,SAGpB;AAED,wBAAgB,eAAe,SAM9B;AAED,wBAAgB,UAAU,SAQzB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAIvC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,UAIrC;AAWD,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAQnD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAQrD"}
@@ -0,0 +1,12 @@
1
+ declare module '@ember-data/request-utils/-private/string/inflections' {
2
+ export type RulesArray = Array<[RegExp, string]>;
3
+ type DefaultRulesType = {
4
+ plurals: RulesArray;
5
+ singular: RulesArray;
6
+ irregularPairs: Array<[string, string]>;
7
+ uncountable: string[];
8
+ };
9
+ export const defaultRules: DefaultRulesType;
10
+ export {};
11
+ }
12
+ //# sourceMappingURL=inflections.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inflections.d.ts","sourceRoot":"","sources":["../../../src/-private/string/inflections.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AACjD,KAAK,gBAAgB,GAAG;IACtB,OAAO,EAAE,UAAU,CAAC;IACpB,QAAQ,EAAE,UAAU,CAAC;IACrB,cAAc,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACxC,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,gBAkE1B,CAAC"}
@@ -0,0 +1,81 @@
1
+ declare module '@ember-data/request-utils/-private/string/transform' {
2
+ export class LRUCache<T, V> {
3
+ size: number;
4
+ state: Map<T, V>;
5
+ doWork: (k: T) => V;
6
+ _hits: number;
7
+ _misses: number;
8
+ _ejected: number;
9
+ constructor(doWork: (k: T) => V, size?: number);
10
+ get(key: T): V;
11
+ set(key: T, value: V): void;
12
+ clear(): void;
13
+ }
14
+ /**
15
+ Replaces underscores, spaces, or camelCase with dashes.
16
+
17
+ ```js
18
+ import { dasherize } from '@ember-data/request-utils/string';
19
+
20
+ dasherize('innerHTML'); // 'inner-html'
21
+ dasherize('action_name'); // 'action-name'
22
+ dasherize('css-class-name'); // 'css-class-name'
23
+ dasherize('my favorite items'); // 'my-favorite-items'
24
+ dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'
25
+ ```
26
+
27
+ @typedoc
28
+ */
29
+ export function dasherize(str: string): string;
30
+ /**
31
+ Returns the lowerCamelCase form of a string.
32
+
33
+ ```js
34
+ import { camelize } from '@ember-data/request-utils/string';
35
+
36
+ camelize('innerHTML'); // 'innerHTML'
37
+ camelize('action_name'); // 'actionName'
38
+ camelize('css-class-name'); // 'cssClassName'
39
+ camelize('my favorite items'); // 'myFavoriteItems'
40
+ camelize('My Favorite Items'); // 'myFavoriteItems'
41
+ camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'
42
+ ```
43
+
44
+ @typedoc
45
+ */
46
+ export function camelize(str: string): string;
47
+ /**
48
+ Returns the lower\_case\_and\_underscored form of a string.
49
+
50
+ ```js
51
+ import { underscore } from '@ember-data/request-utils/string';
52
+
53
+ underscore('innerHTML'); // 'inner_html'
54
+ underscore('action_name'); // 'action_name'
55
+ underscore('css-class-name'); // 'css_class_name'
56
+ underscore('my favorite items'); // 'my_favorite_items'
57
+ underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'
58
+ ```
59
+
60
+ @typedoc
61
+ */
62
+ export function underscore(str: string): string;
63
+ /**
64
+ Returns the Capitalized form of a string
65
+
66
+ ```js
67
+ import { capitalize } from '@ember-data/request-utils/string';
68
+
69
+ capitalize('innerHTML') // 'InnerHTML'
70
+ capitalize('action_name') // 'Action_name'
71
+ capitalize('css-class-name') // 'Css-class-name'
72
+ capitalize('my favorite items') // 'My favorite items'
73
+ capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'
74
+ ```
75
+
76
+ @typedoc
77
+ */
78
+ export function capitalize(str: string): string;
79
+ export function setMaxLRUCacheSize(size: number): void;
80
+ }
81
+ //# sourceMappingURL=transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/-private/string/transform.ts"],"names":[],"mappings":"AAGA,qBAAa,QAAQ,CAAC,CAAC,EAAE,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjB,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IAGpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;gBAEb,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM;IAW9C,GAAG,CAAC,GAAG,EAAE,CAAC;IAmBV,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC;IAapB,KAAK;CAQN;AA6BD;;;;;;;;;;;;;;EAcE;AACF,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;;;;;;;;;;;;;EAeE;AACF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED;;;;;;;;;;;;;;EAcE;AACF,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;;;;;;;;;;;;EAcE;AACF,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,QAK9C"}
@@ -0,0 +1,4 @@
1
+ declare module '@ember-data/request-utils/deprecation-support' {
2
+ export {};
3
+ }
4
+ //# sourceMappingURL=deprecation-support.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deprecation-support.d.ts","sourceRoot":"","sources":["../src/deprecation-support.ts"],"names":[],"mappings":""}
@@ -0,0 +1,490 @@
1
+ /// <reference path="./string.d.ts" />
2
+ /// <reference path="./deprecation-support.d.ts" />
3
+ /// <reference path="./-private/string/inflections.d.ts" />
4
+ /// <reference path="./-private/string/inflect.d.ts" />
5
+ /// <reference path="./-private/string/transform.d.ts" />
6
+ declare module '@ember-data/request-utils' {
7
+ import type { Cache } from '@warp-drive/core-types/cache';
8
+ import type { StableDocumentIdentifier } from '@warp-drive/core-types/identifier';
9
+ import type { QueryParamsSerializationOptions, QueryParamsSource, Serializable } from '@warp-drive/core-types/params';
10
+ import type { ImmutableRequestInfo, ResponseInfo } from '@warp-drive/core-types/request';
11
+ type Store = {
12
+ cache: Cache;
13
+ };
14
+ /**
15
+ * Simple utility function to assist in url building,
16
+ * query params, and other common request operations.
17
+ *
18
+ * These primitives may be used directly or composed
19
+ * by request builders to provide a consistent interface
20
+ * for building requests.
21
+ *
22
+ * For instance:
23
+ *
24
+ * ```ts
25
+ * import { buildBaseURL, buildQueryParams } from '@ember-data/request-utils';
26
+ *
27
+ * const baseURL = buildBaseURL({
28
+ * host: 'https://api.example.com',
29
+ * namespace: 'api/v1',
30
+ * resourcePath: 'emberDevelopers',
31
+ * op: 'query',
32
+ * identifier: { type: 'ember-developer' }
33
+ * });
34
+ * const url = `${baseURL}?${buildQueryParams({ name: 'Chris', include:['pets'] })}`;
35
+ * // => 'https://api.example.com/api/v1/emberDevelopers?include=pets&name=Chris'
36
+ * ```
37
+ *
38
+ * This is useful, but not as useful as the REST request builder for query which is sugar
39
+ * over this (and more!):
40
+ *
41
+ * ```ts
42
+ * import { query } from '@ember-data/rest/request';
43
+ *
44
+ * const options = query('ember-developer', { name: 'Chris', include:['pets'] });
45
+ * // => { url: 'https://api.example.com/api/v1/emberDevelopers?include=pets&name=Chris' }
46
+ * // Note: options will also include other request options like headers, method, etc.
47
+ * ```
48
+ *
49
+ * @module @ember-data/request-utils
50
+ * @main @ember-data/request-utils
51
+ * @public
52
+ */
53
+ export interface BuildURLConfig {
54
+ host: string | null;
55
+ namespace: string | null;
56
+ }
57
+ /**
58
+ * Sets the global configuration for `buildBaseURL`
59
+ * for host and namespace values for the application.
60
+ *
61
+ * These values may still be overridden by passing
62
+ * them to buildBaseURL directly.
63
+ *
64
+ * This method may be called as many times as needed.
65
+ * host values of `''` or `'/'` are equivalent.
66
+ *
67
+ * Except for the value of `/` as host, host should not
68
+ * end with `/`.
69
+ *
70
+ * namespace should not start or end with a `/`.
71
+ *
72
+ * ```ts
73
+ * type BuildURLConfig = {
74
+ * host: string;
75
+ * namespace: string'
76
+ * }
77
+ * ```
78
+ *
79
+ * Example:
80
+ *
81
+ * ```ts
82
+ * import { setBuildURLConfig } from '@ember-data/request-utils';
83
+ *
84
+ * setBuildURLConfig({
85
+ * host: 'https://api.example.com',
86
+ * namespace: 'api/v1'
87
+ * });
88
+ * ```
89
+ *
90
+ * @method setBuildURLConfig
91
+ * @static
92
+ * @public
93
+ * @for @ember-data/request-utils
94
+ * @param {BuildURLConfig} config
95
+ * @return void
96
+ */
97
+ export function setBuildURLConfig(config: BuildURLConfig): void;
98
+ export interface FindRecordUrlOptions {
99
+ op: 'findRecord';
100
+ identifier: {
101
+ type: string;
102
+ id: string;
103
+ };
104
+ resourcePath?: string;
105
+ host?: string;
106
+ namespace?: string;
107
+ }
108
+ export interface QueryUrlOptions {
109
+ op: 'query';
110
+ identifier: {
111
+ type: string;
112
+ };
113
+ resourcePath?: string;
114
+ host?: string;
115
+ namespace?: string;
116
+ }
117
+ export interface FindManyUrlOptions {
118
+ op: 'findMany';
119
+ identifiers: {
120
+ type: string;
121
+ id: string;
122
+ }[];
123
+ resourcePath?: string;
124
+ host?: string;
125
+ namespace?: string;
126
+ }
127
+ export interface FindRelatedCollectionUrlOptions {
128
+ op: 'findRelatedCollection';
129
+ identifier: {
130
+ type: string;
131
+ id: string;
132
+ };
133
+ fieldPath: string;
134
+ resourcePath?: string;
135
+ host?: string;
136
+ namespace?: string;
137
+ }
138
+ export interface FindRelatedResourceUrlOptions {
139
+ op: 'findRelatedRecord';
140
+ identifier: {
141
+ type: string;
142
+ id: string;
143
+ };
144
+ fieldPath: string;
145
+ resourcePath?: string;
146
+ host?: string;
147
+ namespace?: string;
148
+ }
149
+ export interface CreateRecordUrlOptions {
150
+ op: 'createRecord';
151
+ identifier: {
152
+ type: string;
153
+ };
154
+ resourcePath?: string;
155
+ host?: string;
156
+ namespace?: string;
157
+ }
158
+ export interface UpdateRecordUrlOptions {
159
+ op: 'updateRecord';
160
+ identifier: {
161
+ type: string;
162
+ id: string;
163
+ };
164
+ resourcePath?: string;
165
+ host?: string;
166
+ namespace?: string;
167
+ }
168
+ export interface DeleteRecordUrlOptions {
169
+ op: 'deleteRecord';
170
+ identifier: {
171
+ type: string;
172
+ id: string;
173
+ };
174
+ resourcePath?: string;
175
+ host?: string;
176
+ namespace?: string;
177
+ }
178
+ export interface GenericUrlOptions {
179
+ resourcePath: string;
180
+ host?: string;
181
+ namespace?: string;
182
+ }
183
+ export type UrlOptions = FindRecordUrlOptions | QueryUrlOptions | FindManyUrlOptions | FindRelatedCollectionUrlOptions | FindRelatedResourceUrlOptions | CreateRecordUrlOptions | UpdateRecordUrlOptions | DeleteRecordUrlOptions | GenericUrlOptions;
184
+ /**
185
+ * Builds a URL for a request based on the provided options.
186
+ * Does not include support for building query params (see `buildQueryParams`)
187
+ * so that it may be composed cleanly with other query-params strategies.
188
+ *
189
+ * Usage:
190
+ *
191
+ * ```ts
192
+ * import { buildBaseURL } from '@ember-data/request-utils';
193
+ *
194
+ * const url = buildBaseURL({
195
+ * host: 'https://api.example.com',
196
+ * namespace: 'api/v1',
197
+ * resourcePath: 'emberDevelopers',
198
+ * op: 'query',
199
+ * identifier: { type: 'ember-developer' }
200
+ * });
201
+ *
202
+ * // => 'https://api.example.com/api/v1/emberDevelopers'
203
+ * ```
204
+ *
205
+ * On the surface this may seem like a lot of work to do something simple, but
206
+ * it is designed to be composable with other utilities and interfaces that the
207
+ * average product engineer will never need to see or use.
208
+ *
209
+ * A few notes:
210
+ *
211
+ * - `resourcePath` is optional, but if it is not provided, `identifier.type` will be used.
212
+ * - `host` and `namespace` are optional, but if they are not provided, the values globally
213
+ * configured via `setBuildURLConfig` will be used.
214
+ * - `op` is required and must be one of the following:
215
+ * - 'findRecord' 'query' 'findMany' 'findRelatedCollection' 'findRelatedRecord'` 'createRecord' 'updateRecord' 'deleteRecord'
216
+ * - Depending on the value of `op`, `identifier` or `identifiers` will be required.
217
+ *
218
+ * @method buildBaseURL
219
+ * @static
220
+ * @public
221
+ * @for @ember-data/request-utils
222
+ * @param urlOptions
223
+ * @return string
224
+ */
225
+ export function buildBaseURL(urlOptions: UrlOptions): string;
226
+ /**
227
+ * filter out keys of an object that have falsy values or point to empty arrays
228
+ * returning a new object with only those keys that have truthy values / non-empty arrays
229
+ *
230
+ * @method filterEmpty
231
+ * @static
232
+ * @public
233
+ * @for @ember-data/request-utils
234
+ * @param {Record<string, Serializable>} source object to filter keys with empty values from
235
+ * @return {Record<string, Serializable>} A new object with the keys that contained empty values removed
236
+ */
237
+ export function filterEmpty(source: Record<string, Serializable>): Record<string, Serializable>;
238
+ /**
239
+ * Sorts query params by both key and value returning a new URLSearchParams
240
+ * object with the keys inserted in sorted order.
241
+ *
242
+ * Treats `included` specially, splicing it into an array if it is a string and sorting the array.
243
+ *
244
+ * Options:
245
+ * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'
246
+ *
247
+ * 'bracket': appends [] to the key for every value e.g. `&ids[]=1&ids[]=2`
248
+ * 'indices': appends [i] to the key for every value e.g. `&ids[0]=1&ids[1]=2`
249
+ * 'repeat': appends the key for every value e.g. `&ids=1&ids=2`
250
+ * 'comma' (default): appends the key once with a comma separated list of values e.g. `&ids=1,2`
251
+ *
252
+ * @method sortQueryParams
253
+ * @static
254
+ * @public
255
+ * @for @ember-data/request-utils
256
+ * @param {URLSearchParams | object} params
257
+ * @param {object} options
258
+ * @return {URLSearchParams} A URLSearchParams with keys inserted in sorted order
259
+ */
260
+ export function sortQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): URLSearchParams;
261
+ /**
262
+ * Sorts query params by both key and value, returning a query params string
263
+ *
264
+ * Treats `included` specially, splicing it into an array if it is a string and sorting the array.
265
+ *
266
+ * Options:
267
+ * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'
268
+ *
269
+ * 'bracket': appends [] to the key for every value e.g. `ids[]=1&ids[]=2`
270
+ * 'indices': appends [i] to the key for every value e.g. `ids[0]=1&ids[1]=2`
271
+ * 'repeat': appends the key for every value e.g. `ids=1&ids=2`
272
+ * 'comma' (default): appends the key once with a comma separated list of values e.g. `ids=1,2`
273
+ *
274
+ * @method buildQueryParams
275
+ * @static
276
+ * @public
277
+ * @for @ember-data/request-utils
278
+ * @param {URLSearchParams | object} params
279
+ * @param {object} [options]
280
+ * @return {string} A sorted query params string without the leading `?`
281
+ */
282
+ export function buildQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): string;
283
+ export interface CacheControlValue {
284
+ immutable?: boolean;
285
+ 'max-age'?: number;
286
+ 'must-revalidate'?: boolean;
287
+ 'must-understand'?: boolean;
288
+ 'no-cache'?: boolean;
289
+ 'no-store'?: boolean;
290
+ 'no-transform'?: boolean;
291
+ 'only-if-cached'?: boolean;
292
+ private?: boolean;
293
+ 'proxy-revalidate'?: boolean;
294
+ public?: boolean;
295
+ 's-maxage'?: number;
296
+ 'stale-if-error'?: number;
297
+ 'stale-while-revalidate'?: number;
298
+ }
299
+ /**
300
+ * Parses a string Cache-Control header value into an object with the following structure:
301
+ *
302
+ * ```ts
303
+ * interface CacheControlValue {
304
+ * immutable?: boolean;
305
+ * 'max-age'?: number;
306
+ * 'must-revalidate'?: boolean;
307
+ * 'must-understand'?: boolean;
308
+ * 'no-cache'?: boolean;
309
+ * 'no-store'?: boolean;
310
+ * 'no-transform'?: boolean;
311
+ * 'only-if-cached'?: boolean;
312
+ * private?: boolean;
313
+ * 'proxy-revalidate'?: boolean;
314
+ * public?: boolean;
315
+ * 's-maxage'?: number;
316
+ * 'stale-if-error'?: number;
317
+ * 'stale-while-revalidate'?: number;
318
+ * }
319
+ * ```
320
+ * @method parseCacheControl
321
+ * @static
322
+ * @public
323
+ * @for @ember-data/request-utils
324
+ * @param {string} header
325
+ * @return {CacheControlValue}
326
+ */
327
+ export function parseCacheControl(header: string): CacheControlValue;
328
+ export type PolicyConfig = {
329
+ apiCacheSoftExpires: number;
330
+ apiCacheHardExpires: number;
331
+ };
332
+ /**
333
+ * A basic CachePolicy that can be added to the Store service.
334
+ *
335
+ * Determines staleness based on time since the request was last received from the API
336
+ * using the `date` header.
337
+ *
338
+ * Invalidates any request for which `cacheOptions.types` was provided when a createRecord
339
+ * request for that type is successful.
340
+ *
341
+ * For this to work, the `createRecord` request must include the `cacheOptions.types` array
342
+ * with the types that should be invalidated, or its request should specify the identifiers
343
+ * of the records that are being created via `records`. Providing both is valid.
344
+ *
345
+ * > [!NOTE]
346
+ * > only requests that had specified `cacheOptions.types` and occurred prior to the
347
+ * > createRecord request will be invalidated. This means that a given request should always
348
+ * > specify the types that would invalidate it to opt into this behavior. Abstracting this
349
+ * > behavior via builders is recommended to ensure consistency.
350
+ *
351
+ * This allows the Store's CacheHandler to determine if a request is expired and
352
+ * should be refetched upon next request.
353
+ *
354
+ * The `Fetch` handler provided by `@ember-data/request/fetch` will automatically
355
+ * add the `date` header to responses if it is not present.
356
+ *
357
+ * > [!NOTE]
358
+ * > Date headers do not have millisecond precision, so expiration times should
359
+ * > generally be larger than 1000ms.
360
+ *
361
+ * Usage:
362
+ *
363
+ * ```ts
364
+ * import { CachePolicy } from '@ember-data/request-utils';
365
+ * import DataStore from '@ember-data/store';
366
+ *
367
+ * // ...
368
+ *
369
+ * export class Store extends DataStore {
370
+ * constructor(args) {
371
+ * super(args);
372
+ * this.lifetimes = new CachePolicy({ apiCacheSoftExpires: 30_000, apiCacheHardExpires: 60_000 });
373
+ * }
374
+ * }
375
+ * ```
376
+ *
377
+ * @class CachePolicy
378
+ * @public
379
+ * @module @ember-data/request-utils
380
+ */
381
+ export class CachePolicy {
382
+ config: PolicyConfig;
383
+ _stores: WeakMap<Store, {
384
+ invalidated: Set<string>;
385
+ types: Map<string, Set<string>>;
386
+ }>;
387
+ _getStore(store: Store): {
388
+ invalidated: Set<string>;
389
+ types: Map<string, Set<string>>;
390
+ };
391
+ constructor(config: PolicyConfig);
392
+ /**
393
+ * Invalidate a request by its identifier for a given store instance.
394
+ *
395
+ * While the store argument may seem redundant, the CachePolicy
396
+ * is designed to be shared across multiple stores / forks
397
+ * of the store.
398
+ *
399
+ * ```ts
400
+ * store.lifetimes.invalidateRequest(store, identifier);
401
+ * ```
402
+ *
403
+ * @method invalidateRequest
404
+ * @public
405
+ * @param {StableDocumentIdentifier} identifier
406
+ * @param {Store} store
407
+ */
408
+ invalidateRequest(identifier: StableDocumentIdentifier, store: Store): void;
409
+ /**
410
+ * Invalidate all requests associated to a specific type
411
+ * for a given store instance.
412
+ *
413
+ * While the store argument may seem redundant, the CachePolicy
414
+ * is designed to be shared across multiple stores / forks
415
+ * of the store.
416
+ *
417
+ * This invalidation is done automatically when using this service
418
+ * for both the CacheHandler and the LegacyNetworkHandler.
419
+ *
420
+ * ```ts
421
+ * store.lifetimes.invalidateRequestsForType(store, 'person');
422
+ * ```
423
+ *
424
+ * @method invalidateRequestsForType
425
+ * @public
426
+ * @param {string} type
427
+ * @param {Store} store
428
+ */
429
+ invalidateRequestsForType(type: string, store: Store): void;
430
+ /**
431
+ * Invoked when a request has been fulfilled from the configured request handlers.
432
+ * This is invoked by the CacheHandler for both foreground and background requests
433
+ * once the cache has been updated.
434
+ *
435
+ * Note, this is invoked by the CacheHandler regardless of whether
436
+ * the request has a cache-key.
437
+ *
438
+ * This method should not be invoked directly by consumers.
439
+ *
440
+ * @method didRequest
441
+ * @public
442
+ * @param {ImmutableRequestInfo} request
443
+ * @param {ImmutableResponse} response
444
+ * @param {Store} store
445
+ * @param {StableDocumentIdentifier | null} identifier
446
+ * @return {void}
447
+ */
448
+ didRequest(request: ImmutableRequestInfo, response: Response | ResponseInfo | null, identifier: StableDocumentIdentifier | null, store: Store): void;
449
+ /**
450
+ * Invoked to determine if the request may be fulfilled from cache
451
+ * if possible.
452
+ *
453
+ * Note, this is only invoked by the CacheHandler if the request has
454
+ * a cache-key.
455
+ *
456
+ * If no cache entry is found or the entry is hard expired,
457
+ * the request will be fulfilled from the configured request handlers
458
+ * and the cache will be updated before returning the response.
459
+ *
460
+ * @method isHardExpired
461
+ * @public
462
+ * @param {StableDocumentIdentifier} identifier
463
+ * @param {Store} store
464
+ * @return {boolean} true if the request is considered hard expired
465
+ */
466
+ isHardExpired(identifier: StableDocumentIdentifier, store: Store): boolean;
467
+ /**
468
+ * Invoked if `isHardExpired` is false to determine if the request
469
+ * should be update behind the scenes if cache data is already available.
470
+ *
471
+ * Note, this is only invoked by the CacheHandler if the request has
472
+ * a cache-key.
473
+ *
474
+ * If true, the request will be fulfilled from cache while a backgrounded
475
+ * request is made to update the cache via the configured request handlers.
476
+ *
477
+ * @method isSoftExpired
478
+ * @public
479
+ * @param {StableDocumentIdentifier} identifier
480
+ * @param {Store} store
481
+ * @return {boolean} true if the request is considered soft expired
482
+ */
483
+ isSoftExpired(identifier: StableDocumentIdentifier, store: Store): boolean;
484
+ }
485
+ export class LifetimesService extends CachePolicy {
486
+ constructor(config: PolicyConfig);
487
+ }
488
+ export {};
489
+ }
490
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,KAAK,EAAE,+BAA+B,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACtH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEzF,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAMH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,SAAS,E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BAAwB,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO;CAK3E;AAED,qBAAa,gBAAiB,SAAQ,WAAW;gBACnC,MAAM,EAAE,YAAY;CAgBjC"}
@@ -0,0 +1,5 @@
1
+ declare module '@ember-data/request-utils/string' {
2
+ export { pluralize, singularize, singular, plural, loadIrregular, loadUncountable, irregular, uncountable, resetToDefaults, clear, clearRules, } from '@ember-data/request-utils/-private/string/inflect';
3
+ export { dasherize, camelize, capitalize, underscore, setMaxLRUCacheSize } from '@ember-data/request-utils/-private/string/transform';
4
+ }
5
+ //# sourceMappingURL=string.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,WAAW,EACX,QAAQ,EACR,MAAM,EACN,aAAa,EACb,eAAe,EACf,SAAS,EACT,WAAW,EACX,eAAe,EACf,KAAK,EACL,UAAU,GACX,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC"}