@ember-data/request-utils 5.4.0-alpha.30 → 5.4.0-alpha.32
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-data/request-utils",
|
|
3
3
|
"description": "Request Building Utilities for use with EmberData",
|
|
4
|
-
"version": "5.4.0-alpha.
|
|
4
|
+
"version": "5.4.0-alpha.32",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Chris Thoburn <runspired@users.noreply.github.com>",
|
|
@@ -22,13 +22,14 @@
|
|
|
22
22
|
"extends": "../../package.json"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@warp-drive/core-types": "0.0.0-alpha.
|
|
25
|
+
"@warp-drive/core-types": "0.0.0-alpha.18"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"ember-cli-babel": "^8.2.0",
|
|
29
29
|
"pnpm-sync-dependencies-meta-injected": "0.0.10"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
|
+
"unstable-preview-types",
|
|
32
33
|
"addon-main.js",
|
|
33
34
|
"addon",
|
|
34
35
|
"README.md",
|
|
@@ -55,8 +56,8 @@
|
|
|
55
56
|
"@glimmer/component": "^1.1.2",
|
|
56
57
|
"@rollup/plugin-babel": "^6.0.4",
|
|
57
58
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
58
|
-
"@warp-drive/core-types": "0.0.0-alpha.
|
|
59
|
-
"@warp-drive/internal-config": "5.4.0-alpha.
|
|
59
|
+
"@warp-drive/core-types": "0.0.0-alpha.18",
|
|
60
|
+
"@warp-drive/internal-config": "5.4.0-alpha.32",
|
|
60
61
|
"ember-source": "~5.6.0",
|
|
61
62
|
"rollup": "^4.9.6",
|
|
62
63
|
"typescript": "^5.3.3",
|
|
@@ -72,7 +73,7 @@
|
|
|
72
73
|
},
|
|
73
74
|
"scripts": {
|
|
74
75
|
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs --report-unused-disable-directives",
|
|
75
|
-
"build:types": "
|
|
76
|
+
"build:types": "tsc --build",
|
|
76
77
|
"build:client": "rollup --config && babel ./addon --out-dir addon --plugins=../private-build-infra/src/transforms/babel-plugin-transform-ext.js",
|
|
77
78
|
"_build": "bun run build:client && bun run build:types",
|
|
78
79
|
"_syncPnpm": "bun run sync-dependencies-meta-injected"
|
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
import type { Cache } from '@warp-drive/core-types/cache';
|
|
2
|
+
import type { StableDocumentIdentifier } from '@warp-drive/core-types/identifier';
|
|
3
|
+
import type { QueryParamsSerializationOptions, QueryParamsSource, Serializable } from '@warp-drive/core-types/params';
|
|
4
|
+
import type { ImmutableRequestInfo, ResponseInfo } from '@warp-drive/core-types/request';
|
|
5
|
+
type Store = {
|
|
6
|
+
cache: Cache;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Simple utility function to assist in url building,
|
|
10
|
+
* query params, and other common request operations.
|
|
11
|
+
*
|
|
12
|
+
* These primitives may be used directly or composed
|
|
13
|
+
* by request builders to provide a consistent interface
|
|
14
|
+
* for building requests.
|
|
15
|
+
*
|
|
16
|
+
* For instance:
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { buildBaseURL, buildQueryParams } from '@ember-data/request-utils';
|
|
20
|
+
*
|
|
21
|
+
* const baseURL = buildBaseURL({
|
|
22
|
+
* host: 'https://api.example.com',
|
|
23
|
+
* namespace: 'api/v1',
|
|
24
|
+
* resourcePath: 'emberDevelopers',
|
|
25
|
+
* op: 'query',
|
|
26
|
+
* identifier: { type: 'ember-developer' }
|
|
27
|
+
* });
|
|
28
|
+
* const url = `${baseURL}?${buildQueryParams({ name: 'Chris', include:['pets'] })}`;
|
|
29
|
+
* // => 'https://api.example.com/api/v1/emberDevelopers?include=pets&name=Chris'
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* This is useful, but not as useful as the REST request builder for query which is sugar
|
|
33
|
+
* over this (and more!):
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { query } from '@ember-data/rest/request';
|
|
37
|
+
*
|
|
38
|
+
* const options = query('ember-developer', { name: 'Chris', include:['pets'] });
|
|
39
|
+
* // => { url: 'https://api.example.com/api/v1/emberDevelopers?include=pets&name=Chris' }
|
|
40
|
+
* // Note: options will also include other request options like headers, method, etc.
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @module @ember-data/request-utils
|
|
44
|
+
* @main @ember-data/request-utils
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export interface BuildURLConfig {
|
|
48
|
+
host: string | null;
|
|
49
|
+
namespace: string | null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Sets the global configuration for `buildBaseURL`
|
|
53
|
+
* for host and namespace values for the application.
|
|
54
|
+
*
|
|
55
|
+
* These values may still be overridden by passing
|
|
56
|
+
* them to buildBaseURL directly.
|
|
57
|
+
*
|
|
58
|
+
* This method may be called as many times as needed.
|
|
59
|
+
* host values of `''` or `'/'` are equivalent.
|
|
60
|
+
*
|
|
61
|
+
* Except for the value of `/` as host, host should not
|
|
62
|
+
* end with `/`.
|
|
63
|
+
*
|
|
64
|
+
* namespace should not start or end with a `/`.
|
|
65
|
+
*
|
|
66
|
+
* ```ts
|
|
67
|
+
* type BuildURLConfig = {
|
|
68
|
+
* host: string;
|
|
69
|
+
* namespace: string'
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* Example:
|
|
74
|
+
*
|
|
75
|
+
* ```ts
|
|
76
|
+
* import { setBuildURLConfig } from '@ember-data/request-utils';
|
|
77
|
+
*
|
|
78
|
+
* setBuildURLConfig({
|
|
79
|
+
* host: 'https://api.example.com',
|
|
80
|
+
* namespace: 'api/v1'
|
|
81
|
+
* });
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @method setBuildURLConfig
|
|
85
|
+
* @static
|
|
86
|
+
* @public
|
|
87
|
+
* @for @ember-data/request-utils
|
|
88
|
+
* @param {BuildURLConfig} config
|
|
89
|
+
* @return void
|
|
90
|
+
*/
|
|
91
|
+
export declare function setBuildURLConfig(config: BuildURLConfig): void;
|
|
92
|
+
export interface FindRecordUrlOptions {
|
|
93
|
+
op: 'findRecord';
|
|
94
|
+
identifier: {
|
|
95
|
+
type: string;
|
|
96
|
+
id: string;
|
|
97
|
+
};
|
|
98
|
+
resourcePath?: string;
|
|
99
|
+
host?: string;
|
|
100
|
+
namespace?: string;
|
|
101
|
+
}
|
|
102
|
+
export interface QueryUrlOptions {
|
|
103
|
+
op: 'query';
|
|
104
|
+
identifier: {
|
|
105
|
+
type: string;
|
|
106
|
+
};
|
|
107
|
+
resourcePath?: string;
|
|
108
|
+
host?: string;
|
|
109
|
+
namespace?: string;
|
|
110
|
+
}
|
|
111
|
+
export interface FindManyUrlOptions {
|
|
112
|
+
op: 'findMany';
|
|
113
|
+
identifiers: {
|
|
114
|
+
type: string;
|
|
115
|
+
id: string;
|
|
116
|
+
}[];
|
|
117
|
+
resourcePath?: string;
|
|
118
|
+
host?: string;
|
|
119
|
+
namespace?: string;
|
|
120
|
+
}
|
|
121
|
+
export interface FindRelatedCollectionUrlOptions {
|
|
122
|
+
op: 'findRelatedCollection';
|
|
123
|
+
identifier: {
|
|
124
|
+
type: string;
|
|
125
|
+
id: string;
|
|
126
|
+
};
|
|
127
|
+
fieldPath: string;
|
|
128
|
+
resourcePath?: string;
|
|
129
|
+
host?: string;
|
|
130
|
+
namespace?: string;
|
|
131
|
+
}
|
|
132
|
+
export interface FindRelatedResourceUrlOptions {
|
|
133
|
+
op: 'findRelatedRecord';
|
|
134
|
+
identifier: {
|
|
135
|
+
type: string;
|
|
136
|
+
id: string;
|
|
137
|
+
};
|
|
138
|
+
fieldPath: string;
|
|
139
|
+
resourcePath?: string;
|
|
140
|
+
host?: string;
|
|
141
|
+
namespace?: string;
|
|
142
|
+
}
|
|
143
|
+
export interface CreateRecordUrlOptions {
|
|
144
|
+
op: 'createRecord';
|
|
145
|
+
identifier: {
|
|
146
|
+
type: string;
|
|
147
|
+
};
|
|
148
|
+
resourcePath?: string;
|
|
149
|
+
host?: string;
|
|
150
|
+
namespace?: string;
|
|
151
|
+
}
|
|
152
|
+
export interface UpdateRecordUrlOptions {
|
|
153
|
+
op: 'updateRecord';
|
|
154
|
+
identifier: {
|
|
155
|
+
type: string;
|
|
156
|
+
id: string;
|
|
157
|
+
};
|
|
158
|
+
resourcePath?: string;
|
|
159
|
+
host?: string;
|
|
160
|
+
namespace?: string;
|
|
161
|
+
}
|
|
162
|
+
export interface DeleteRecordUrlOptions {
|
|
163
|
+
op: 'deleteRecord';
|
|
164
|
+
identifier: {
|
|
165
|
+
type: string;
|
|
166
|
+
id: string;
|
|
167
|
+
};
|
|
168
|
+
resourcePath?: string;
|
|
169
|
+
host?: string;
|
|
170
|
+
namespace?: string;
|
|
171
|
+
}
|
|
172
|
+
export interface GenericUrlOptions {
|
|
173
|
+
resourcePath: string;
|
|
174
|
+
host?: string;
|
|
175
|
+
namespace?: string;
|
|
176
|
+
}
|
|
177
|
+
export type UrlOptions = FindRecordUrlOptions | QueryUrlOptions | FindManyUrlOptions | FindRelatedCollectionUrlOptions | FindRelatedResourceUrlOptions | CreateRecordUrlOptions | UpdateRecordUrlOptions | DeleteRecordUrlOptions | GenericUrlOptions;
|
|
178
|
+
/**
|
|
179
|
+
* Builds a URL for a request based on the provided options.
|
|
180
|
+
* Does not include support for building query params (see `buildQueryParams`)
|
|
181
|
+
* so that it may be composed cleanly with other query-params strategies.
|
|
182
|
+
*
|
|
183
|
+
* Usage:
|
|
184
|
+
*
|
|
185
|
+
* ```ts
|
|
186
|
+
* import { buildBaseURL } from '@ember-data/request-utils';
|
|
187
|
+
*
|
|
188
|
+
* const url = buildBaseURL({
|
|
189
|
+
* host: 'https://api.example.com',
|
|
190
|
+
* namespace: 'api/v1',
|
|
191
|
+
* resourcePath: 'emberDevelopers',
|
|
192
|
+
* op: 'query',
|
|
193
|
+
* identifier: { type: 'ember-developer' }
|
|
194
|
+
* });
|
|
195
|
+
*
|
|
196
|
+
* // => 'https://api.example.com/api/v1/emberDevelopers'
|
|
197
|
+
* ```
|
|
198
|
+
*
|
|
199
|
+
* On the surface this may seem like a lot of work to do something simple, but
|
|
200
|
+
* it is designed to be composable with other utilities and interfaces that the
|
|
201
|
+
* average product engineer will never need to see or use.
|
|
202
|
+
*
|
|
203
|
+
* A few notes:
|
|
204
|
+
*
|
|
205
|
+
* - `resourcePath` is optional, but if it is not provided, `identifier.type` will be used.
|
|
206
|
+
* - `host` and `namespace` are optional, but if they are not provided, the values globally
|
|
207
|
+
* configured via `setBuildURLConfig` will be used.
|
|
208
|
+
* - `op` is required and must be one of the following:
|
|
209
|
+
* - 'findRecord' 'query' 'findMany' 'findRelatedCollection' 'findRelatedRecord'` 'createRecord' 'updateRecord' 'deleteRecord'
|
|
210
|
+
* - Depending on the value of `op`, `identifier` or `identifiers` will be required.
|
|
211
|
+
*
|
|
212
|
+
* @method buildBaseURL
|
|
213
|
+
* @static
|
|
214
|
+
* @public
|
|
215
|
+
* @for @ember-data/request-utils
|
|
216
|
+
* @param urlOptions
|
|
217
|
+
* @return string
|
|
218
|
+
*/
|
|
219
|
+
export declare function buildBaseURL(urlOptions: UrlOptions): string;
|
|
220
|
+
/**
|
|
221
|
+
* filter out keys of an object that have falsy values or point to empty arrays
|
|
222
|
+
* returning a new object with only those keys that have truthy values / non-empty arrays
|
|
223
|
+
*
|
|
224
|
+
* @method filterEmpty
|
|
225
|
+
* @static
|
|
226
|
+
* @public
|
|
227
|
+
* @for @ember-data/request-utils
|
|
228
|
+
* @param {Record<string, Serializable>} source object to filter keys with empty values from
|
|
229
|
+
* @return {Record<string, Serializable>} A new object with the keys that contained empty values removed
|
|
230
|
+
*/
|
|
231
|
+
export declare function filterEmpty(source: Record<string, Serializable>): Record<string, Serializable>;
|
|
232
|
+
/**
|
|
233
|
+
* Sorts query params by both key and value returning a new URLSearchParams
|
|
234
|
+
* object with the keys inserted in sorted order.
|
|
235
|
+
*
|
|
236
|
+
* Treats `included` specially, splicing it into an array if it is a string and sorting the array.
|
|
237
|
+
*
|
|
238
|
+
* Options:
|
|
239
|
+
* - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'
|
|
240
|
+
*
|
|
241
|
+
* 'bracket': appends [] to the key for every value e.g. `&ids[]=1&ids[]=2`
|
|
242
|
+
* 'indices': appends [i] to the key for every value e.g. `&ids[0]=1&ids[1]=2`
|
|
243
|
+
* 'repeat': appends the key for every value e.g. `&ids=1&ids=2`
|
|
244
|
+
* 'comma' (default): appends the key once with a comma separated list of values e.g. `&ids=1,2`
|
|
245
|
+
*
|
|
246
|
+
* @method sortQueryParams
|
|
247
|
+
* @static
|
|
248
|
+
* @public
|
|
249
|
+
* @for @ember-data/request-utils
|
|
250
|
+
* @param {URLSearchParams | object} params
|
|
251
|
+
* @param {object} options
|
|
252
|
+
* @return {URLSearchParams} A URLSearchParams with keys inserted in sorted order
|
|
253
|
+
*/
|
|
254
|
+
export declare function sortQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): URLSearchParams;
|
|
255
|
+
/**
|
|
256
|
+
* Sorts query params by both key and value, returning a query params string
|
|
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
|
+
* @method buildQueryParams
|
|
269
|
+
* @static
|
|
270
|
+
* @public
|
|
271
|
+
* @for @ember-data/request-utils
|
|
272
|
+
* @param {URLSearchParams | object} params
|
|
273
|
+
* @param {object} [options]
|
|
274
|
+
* @return {string} A sorted query params string without the leading `?`
|
|
275
|
+
*/
|
|
276
|
+
export declare function buildQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): string;
|
|
277
|
+
export interface CacheControlValue {
|
|
278
|
+
immutable?: boolean;
|
|
279
|
+
'max-age'?: number;
|
|
280
|
+
'must-revalidate'?: boolean;
|
|
281
|
+
'must-understand'?: boolean;
|
|
282
|
+
'no-cache'?: boolean;
|
|
283
|
+
'no-store'?: boolean;
|
|
284
|
+
'no-transform'?: boolean;
|
|
285
|
+
'only-if-cached'?: boolean;
|
|
286
|
+
private?: boolean;
|
|
287
|
+
'proxy-revalidate'?: boolean;
|
|
288
|
+
public?: boolean;
|
|
289
|
+
's-maxage'?: number;
|
|
290
|
+
'stale-if-error'?: number;
|
|
291
|
+
'stale-while-revalidate'?: number;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Parses a string Cache-Control header value into an object with the following structure:
|
|
295
|
+
*
|
|
296
|
+
* ```ts
|
|
297
|
+
* interface CacheControlValue {
|
|
298
|
+
* immutable?: boolean;
|
|
299
|
+
* 'max-age'?: number;
|
|
300
|
+
* 'must-revalidate'?: boolean;
|
|
301
|
+
* 'must-understand'?: boolean;
|
|
302
|
+
* 'no-cache'?: boolean;
|
|
303
|
+
* 'no-store'?: boolean;
|
|
304
|
+
* 'no-transform'?: boolean;
|
|
305
|
+
* 'only-if-cached'?: boolean;
|
|
306
|
+
* private?: boolean;
|
|
307
|
+
* 'proxy-revalidate'?: boolean;
|
|
308
|
+
* public?: boolean;
|
|
309
|
+
* 's-maxage'?: number;
|
|
310
|
+
* 'stale-if-error'?: number;
|
|
311
|
+
* 'stale-while-revalidate'?: number;
|
|
312
|
+
* }
|
|
313
|
+
* ```
|
|
314
|
+
* @method parseCacheControl
|
|
315
|
+
* @static
|
|
316
|
+
* @public
|
|
317
|
+
* @for @ember-data/request-utils
|
|
318
|
+
* @param {string} header
|
|
319
|
+
* @return {CacheControlValue}
|
|
320
|
+
*/
|
|
321
|
+
export declare function parseCacheControl(header: string): CacheControlValue;
|
|
322
|
+
export type LifetimesConfig = {
|
|
323
|
+
apiCacheSoftExpires: number;
|
|
324
|
+
apiCacheHardExpires: number;
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* A basic LifetimesService that can be added to the Store service.
|
|
328
|
+
*
|
|
329
|
+
* Determines staleness based on time since the request was last received from the API
|
|
330
|
+
* using the `date` header.
|
|
331
|
+
*
|
|
332
|
+
* Invalidates any request for which `cacheOptions.types` was provided when a createRecord
|
|
333
|
+
* request for that type is successful.
|
|
334
|
+
*
|
|
335
|
+
* This allows the Store's CacheHandler to determine if a request is expired and
|
|
336
|
+
* should be refetched upon next request.
|
|
337
|
+
*
|
|
338
|
+
* The `Fetch` handler provided by `@ember-data/request/fetch` will automatically
|
|
339
|
+
* add the `date` header to responses if it is not present.
|
|
340
|
+
*
|
|
341
|
+
* Note: Date headers do not have millisecond precision, so expiration times should
|
|
342
|
+
* generally be larger than 1000ms.
|
|
343
|
+
*
|
|
344
|
+
* Usage:
|
|
345
|
+
*
|
|
346
|
+
* ```ts
|
|
347
|
+
* import { LifetimesService } from '@ember-data/request-utils';
|
|
348
|
+
* import DataStore from '@ember-data/store';
|
|
349
|
+
*
|
|
350
|
+
* // ...
|
|
351
|
+
*
|
|
352
|
+
* export class Store extends DataStore {
|
|
353
|
+
* constructor(args) {
|
|
354
|
+
* super(args);
|
|
355
|
+
* this.lifetimes = new LifetimesService({ apiCacheSoftExpires: 30_000, apiCacheHardExpires: 60_000 });
|
|
356
|
+
* }
|
|
357
|
+
* }
|
|
358
|
+
* ```
|
|
359
|
+
*
|
|
360
|
+
* @class LifetimesService
|
|
361
|
+
* @public
|
|
362
|
+
* @module @ember-data/request-utils
|
|
363
|
+
*/
|
|
364
|
+
export declare class LifetimesService {
|
|
365
|
+
config: LifetimesConfig;
|
|
366
|
+
_stores: WeakMap<Store, {
|
|
367
|
+
invalidated: Set<string>;
|
|
368
|
+
types: Map<string, Set<string>>;
|
|
369
|
+
}>;
|
|
370
|
+
_getStore(store: Store): {
|
|
371
|
+
invalidated: Set<string>;
|
|
372
|
+
types: Map<string, Set<string>>;
|
|
373
|
+
};
|
|
374
|
+
constructor(config: LifetimesConfig);
|
|
375
|
+
/**
|
|
376
|
+
* Invalidate a request by its identifier for a given store instance.
|
|
377
|
+
*
|
|
378
|
+
* While the store argument may seem redundant, the lifetimes service
|
|
379
|
+
* is designed to be shared across multiple stores / forks
|
|
380
|
+
* of the store.
|
|
381
|
+
*
|
|
382
|
+
* ```ts
|
|
383
|
+
* store.lifetimes.invalidateRequest(store, identifier);
|
|
384
|
+
* ```
|
|
385
|
+
*
|
|
386
|
+
* @method invalidateRequest
|
|
387
|
+
* @public
|
|
388
|
+
* @param {StableDocumentIdentifier} identifier
|
|
389
|
+
* @param {Store} store
|
|
390
|
+
*/
|
|
391
|
+
invalidateRequest(identifier: StableDocumentIdentifier, store: Store): void;
|
|
392
|
+
/**
|
|
393
|
+
* Invalidate all requests associated to a specific type
|
|
394
|
+
* for a given store instance.
|
|
395
|
+
*
|
|
396
|
+
* While the store argument may seem redundant, the lifetimes service
|
|
397
|
+
* is designed to be shared across multiple stores / forks
|
|
398
|
+
* of the store.
|
|
399
|
+
*
|
|
400
|
+
* This invalidation is done automatically when using this service
|
|
401
|
+
* for both the CacheHandler and the LegacyNetworkHandler.
|
|
402
|
+
*
|
|
403
|
+
* ```ts
|
|
404
|
+
* store.lifetimes.invalidateRequestsForType(store, 'person');
|
|
405
|
+
* ```
|
|
406
|
+
*
|
|
407
|
+
* @method invalidateRequestsForType
|
|
408
|
+
* @public
|
|
409
|
+
* @param {string} type
|
|
410
|
+
* @param {Store} store
|
|
411
|
+
*/
|
|
412
|
+
invalidateRequestsForType(type: string, store: Store): void;
|
|
413
|
+
/**
|
|
414
|
+
* Invoked when a request has been fulfilled from the configured request handlers.
|
|
415
|
+
* This is invoked by the CacheHandler for both foreground and background requests
|
|
416
|
+
* once the cache has been updated.
|
|
417
|
+
*
|
|
418
|
+
* Note, this is invoked by the CacheHandler regardless of whether
|
|
419
|
+
* the request has a cache-key.
|
|
420
|
+
*
|
|
421
|
+
* This method should not be invoked directly by consumers.
|
|
422
|
+
*
|
|
423
|
+
* @method didRequest
|
|
424
|
+
* @public
|
|
425
|
+
* @param {ImmutableRequestInfo} request
|
|
426
|
+
* @param {ImmutableResponse} response
|
|
427
|
+
* @param {Store} store
|
|
428
|
+
* @param {StableDocumentIdentifier | null} identifier
|
|
429
|
+
* @return {void}
|
|
430
|
+
*/
|
|
431
|
+
didRequest(request: ImmutableRequestInfo, response: Response | ResponseInfo | null, identifier: StableDocumentIdentifier | null, store: Store): void;
|
|
432
|
+
/**
|
|
433
|
+
* Invoked to determine if the request may be fulfilled from cache
|
|
434
|
+
* if possible.
|
|
435
|
+
*
|
|
436
|
+
* Note, this is only invoked by the CacheHandler if the request has
|
|
437
|
+
* a cache-key.
|
|
438
|
+
*
|
|
439
|
+
* If no cache entry is found or the entry is hard expired,
|
|
440
|
+
* the request will be fulfilled from the configured request handlers
|
|
441
|
+
* and the cache will be updated before returning the response.
|
|
442
|
+
*
|
|
443
|
+
* @method isHardExpired
|
|
444
|
+
* @public
|
|
445
|
+
* @param {StableDocumentIdentifier} identifier
|
|
446
|
+
* @param {Store} store
|
|
447
|
+
* @return {boolean} true if the request is considered hard expired
|
|
448
|
+
*/
|
|
449
|
+
isHardExpired(identifier: StableDocumentIdentifier, store: Store): boolean;
|
|
450
|
+
/**
|
|
451
|
+
* Invoked if `isHardExpired` is false to determine if the request
|
|
452
|
+
* should be update behind the scenes if cache data is already available.
|
|
453
|
+
*
|
|
454
|
+
* Note, this is only invoked by the CacheHandler if the request has
|
|
455
|
+
* a cache-key.
|
|
456
|
+
*
|
|
457
|
+
* If true, the request will be fulfilled from cache while a backgrounded
|
|
458
|
+
* request is made to update the cache via the configured request handlers.
|
|
459
|
+
*
|
|
460
|
+
* @method isSoftExpired
|
|
461
|
+
* @public
|
|
462
|
+
* @param {StableDocumentIdentifier} identifier
|
|
463
|
+
* @param {Store} store
|
|
464
|
+
* @return {boolean} true if the request is considered soft expired
|
|
465
|
+
*/
|
|
466
|
+
isSoftExpired(identifier: StableDocumentIdentifier, store: Store): boolean;
|
|
467
|
+
}
|
|
468
|
+
export {};
|
|
469
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,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,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAOD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,QAsBvD;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,YAAY,CAAC;IACjB,UAAU,EAAE;QAAE,IAAI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