@ember-data/request-utils 5.4.0-alpha.4 → 5.4.0-alpha.41
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/addon/index.js +380 -34
- package/addon/index.js.map +1 -1
- package/package.json +38 -22
- package/unstable-preview-types/index.d.ts +472 -0
- package/unstable-preview-types/index.d.ts.map +1 -0
package/addon/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assert } from '@ember/debug';
|
|
1
|
+
import { assert, deprecate } from '@ember/debug';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Simple utility function to assist in url building,
|
|
@@ -43,18 +43,70 @@ import { assert } from '@ember/debug';
|
|
|
43
43
|
// prevents the final constructed object from needing to add
|
|
44
44
|
// host and namespace which are provided by the final consuming
|
|
45
45
|
// class to the prototype which can result in overwrite errors
|
|
46
|
-
|
|
46
|
+
|
|
47
|
+
const CONFIG = {
|
|
47
48
|
host: '',
|
|
48
49
|
namespace: ''
|
|
49
50
|
};
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Sets the global configuration for `buildBaseURL`
|
|
54
|
+
* for host and namespace values for the application.
|
|
55
|
+
*
|
|
56
|
+
* These values may still be overridden by passing
|
|
57
|
+
* them to buildBaseURL directly.
|
|
58
|
+
*
|
|
59
|
+
* This method may be called as many times as needed.
|
|
60
|
+
* host values of `''` or `'/'` are equivalent.
|
|
61
|
+
*
|
|
62
|
+
* Except for the value of `/` as host, host should not
|
|
63
|
+
* end with `/`.
|
|
64
|
+
*
|
|
65
|
+
* namespace should not start or end with a `/`.
|
|
66
|
+
*
|
|
67
|
+
* ```ts
|
|
68
|
+
* type BuildURLConfig = {
|
|
69
|
+
* host: string;
|
|
70
|
+
* namespace: string'
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* Example:
|
|
75
|
+
*
|
|
76
|
+
* ```ts
|
|
77
|
+
* import { setBuildURLConfig } from '@ember-data/request-utils';
|
|
78
|
+
*
|
|
79
|
+
* setBuildURLConfig({
|
|
80
|
+
* host: 'https://api.example.com',
|
|
81
|
+
* namespace: 'api/v1'
|
|
82
|
+
* });
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @method setBuildURLConfig
|
|
86
|
+
* @static
|
|
87
|
+
* @public
|
|
88
|
+
* @for @ember-data/request-utils
|
|
89
|
+
* @param {BuildURLConfig} config
|
|
90
|
+
* @return void
|
|
91
|
+
*/
|
|
92
|
+
function setBuildURLConfig(config) {
|
|
93
|
+
assert(`setBuildURLConfig: You must pass a config object`, config);
|
|
94
|
+
assert(`setBuildURLConfig: You must pass a config object with a 'host' or 'namespace' property`, 'host' in config || 'namespace' in config);
|
|
95
|
+
CONFIG.host = config.host || '';
|
|
96
|
+
CONFIG.namespace = config.namespace || '';
|
|
97
|
+
assert(`buildBaseURL: host must NOT end with '/', received '${CONFIG.host}'`, CONFIG.host === '/' || !CONFIG.host.endsWith('/'));
|
|
98
|
+
assert(`buildBaseURL: namespace must NOT start with '/', received '${CONFIG.namespace}'`, !CONFIG.namespace.startsWith('/'));
|
|
99
|
+
assert(`buildBaseURL: namespace must NOT end with '/', received '${CONFIG.namespace}'`, !CONFIG.namespace.endsWith('/'));
|
|
52
100
|
}
|
|
53
101
|
const OPERATIONS_WITH_PRIMARY_RECORDS = new Set(['findRecord', 'findRelatedRecord', 'findRelatedCollection', 'updateRecord', 'deleteRecord']);
|
|
54
102
|
function isOperationWithPrimaryRecord(options) {
|
|
55
|
-
return OPERATIONS_WITH_PRIMARY_RECORDS.has(options.op);
|
|
103
|
+
return 'op' in options && OPERATIONS_WITH_PRIMARY_RECORDS.has(options.op);
|
|
104
|
+
}
|
|
105
|
+
function hasResourcePath(options) {
|
|
106
|
+
return 'resourcePath' in options && typeof options.resourcePath === 'string' && options.resourcePath.length > 0;
|
|
56
107
|
}
|
|
57
108
|
function resourcePathForType(options) {
|
|
109
|
+
assert(`resourcePathForType: You must pass a valid op as part of options`, 'op' in options && typeof options.op === 'string');
|
|
58
110
|
return options.op === 'findMany' ? options.identifiers[0].type : options.identifier.type;
|
|
59
111
|
}
|
|
60
112
|
|
|
@@ -97,20 +149,20 @@ function resourcePathForType(options) {
|
|
|
97
149
|
* @public
|
|
98
150
|
* @for @ember-data/request-utils
|
|
99
151
|
* @param urlOptions
|
|
100
|
-
* @
|
|
152
|
+
* @return string
|
|
101
153
|
*/
|
|
102
154
|
function buildBaseURL(urlOptions) {
|
|
103
155
|
const options = Object.assign({
|
|
104
156
|
host: CONFIG.host,
|
|
105
157
|
namespace: CONFIG.namespace
|
|
106
158
|
}, urlOptions);
|
|
107
|
-
assert(`buildBaseURL: You must pass \`op\` as part of options`, typeof options.op === 'string' && options.op.length > 0);
|
|
108
|
-
assert(`buildBaseURL: You must pass \`identifier\` as part of options`, options.op === 'findMany' || options.identifier && typeof options.identifier === 'object');
|
|
109
|
-
assert(`buildBaseURL: You must pass \`identifiers\` as part of options`, options.op !== 'findMany' || options.identifiers && Array.isArray(options.identifiers) && options.identifiers.length > 0 && options.identifiers.every(i => i && typeof i === 'object'));
|
|
110
|
-
assert(`buildBaseURL: You must pass valid \`identifier\` as part of options, expected 'id'`, !isOperationWithPrimaryRecord(options) || typeof options.identifier.id === 'string' && options.identifier.id.length > 0);
|
|
111
|
-
assert(`buildBaseURL: You must pass \`identifiers\` as part of options`, options.op !== 'findMany' || options.identifiers.every(i => typeof i.id === 'string' && i.id.length > 0));
|
|
112
|
-
assert(`buildBaseURL: You must pass valid \`identifier\` as part of options, expected 'type'`, options.op === 'findMany' || typeof options.identifier.type === 'string' && options.identifier.type.length > 0);
|
|
113
|
-
assert(`buildBaseURL: You must pass valid \`identifiers\` as part of options, expected 'type'`, options.op !== 'findMany' || typeof options.identifiers[0].type === 'string' && options.identifiers[0].type.length > 0);
|
|
159
|
+
assert(`buildBaseURL: You must pass \`op\` as part of options`, hasResourcePath(options) || typeof options.op === 'string' && options.op.length > 0);
|
|
160
|
+
assert(`buildBaseURL: You must pass \`identifier\` as part of options`, hasResourcePath(options) || options.op === 'findMany' || options.identifier && typeof options.identifier === 'object');
|
|
161
|
+
assert(`buildBaseURL: You must pass \`identifiers\` as part of options`, hasResourcePath(options) || options.op !== 'findMany' || options.identifiers && Array.isArray(options.identifiers) && options.identifiers.length > 0 && options.identifiers.every(i => i && typeof i === 'object'));
|
|
162
|
+
assert(`buildBaseURL: You must pass valid \`identifier\` as part of options, expected 'id'`, hasResourcePath(options) || !isOperationWithPrimaryRecord(options) || typeof options.identifier.id === 'string' && options.identifier.id.length > 0);
|
|
163
|
+
assert(`buildBaseURL: You must pass \`identifiers\` as part of options`, hasResourcePath(options) || options.op !== 'findMany' || options.identifiers.every(i => typeof i.id === 'string' && i.id.length > 0));
|
|
164
|
+
assert(`buildBaseURL: You must pass valid \`identifier\` as part of options, expected 'type'`, hasResourcePath(options) || options.op === 'findMany' || typeof options.identifier.type === 'string' && options.identifier.type.length > 0);
|
|
165
|
+
assert(`buildBaseURL: You must pass valid \`identifiers\` as part of options, expected 'type'`, hasResourcePath(options) || options.op !== 'findMany' || typeof options.identifiers[0].type === 'string' && options.identifiers[0].type.length > 0);
|
|
114
166
|
|
|
115
167
|
// prettier-ignore
|
|
116
168
|
const idPath = isOperationWithPrimaryRecord(options) ? encodeURIComponent(options.identifier.id) : '';
|
|
@@ -120,7 +172,7 @@ function buildBaseURL(urlOptions) {
|
|
|
120
172
|
namespace
|
|
121
173
|
} = options;
|
|
122
174
|
const fieldPath = 'fieldPath' in options ? options.fieldPath : '';
|
|
123
|
-
assert(`buildBaseURL: You tried to build a ${String(options.op)}
|
|
175
|
+
assert(`buildBaseURL: You tried to build a url for a ${String('op' in options ? options.op + ' ' : '')}request to ${resourcePath} but resourcePath must be set or op must be one of "${['findRecord', 'findRelatedRecord', 'findRelatedCollection', 'updateRecord', 'deleteRecord', 'createRecord', 'query', 'findMany'].join('","')}".`, hasResourcePath(options) || ['findRecord', 'query', 'findMany', 'findRelatedCollection', 'findRelatedRecord', 'createRecord', 'updateRecord', 'deleteRecord'].includes(options.op));
|
|
124
176
|
assert(`buildBaseURL: host must NOT end with '/', received '${host}'`, host === '/' || !host.endsWith('/'));
|
|
125
177
|
assert(`buildBaseURL: namespace must NOT start with '/', received '${namespace}'`, !namespace.startsWith('/'));
|
|
126
178
|
assert(`buildBaseURL: namespace must NOT end with '/', received '${namespace}'`, !namespace.endsWith('/'));
|
|
@@ -130,8 +182,9 @@ function buildBaseURL(urlOptions) {
|
|
|
130
182
|
assert(`buildBaseURL: fieldPath must NOT end with '/', received '${fieldPath}'`, !fieldPath.endsWith('/'));
|
|
131
183
|
assert(`buildBaseURL: idPath must NOT start with '/', received '${idPath}'`, !idPath.startsWith('/'));
|
|
132
184
|
assert(`buildBaseURL: idPath must NOT end with '/', received '${idPath}'`, !idPath.endsWith('/'));
|
|
133
|
-
const
|
|
134
|
-
|
|
185
|
+
const hasHost = host !== '' && host !== '/';
|
|
186
|
+
const url = [hasHost ? host : '', namespace, resourcePath, idPath, fieldPath].filter(Boolean).join('/');
|
|
187
|
+
return hasHost ? url : `/${url}`;
|
|
135
188
|
}
|
|
136
189
|
const DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS = {
|
|
137
190
|
arrayFormat: 'comma'
|
|
@@ -140,20 +193,56 @@ function handleInclude(include) {
|
|
|
140
193
|
assert(`Expected include to be a string or array, got ${typeof include}`, typeof include === 'string' || Array.isArray(include));
|
|
141
194
|
return typeof include === 'string' ? include.split(',') : include;
|
|
142
195
|
}
|
|
143
|
-
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* filter out keys of an object that have falsy values or point to empty arrays
|
|
199
|
+
* returning a new object with only those keys that have truthy values / non-empty arrays
|
|
200
|
+
*
|
|
201
|
+
* @method filterEmpty
|
|
202
|
+
* @static
|
|
203
|
+
* @public
|
|
204
|
+
* @for @ember-data/request-utils
|
|
205
|
+
* @param {Record<string, Serializable>} source object to filter keys with empty values from
|
|
206
|
+
* @return {Record<string, Serializable>} A new object with the keys that contained empty values removed
|
|
207
|
+
*/
|
|
208
|
+
function filterEmpty(source) {
|
|
144
209
|
const result = {};
|
|
145
|
-
for (const key in
|
|
146
|
-
const value =
|
|
147
|
-
|
|
210
|
+
for (const key in source) {
|
|
211
|
+
const value = source[key];
|
|
212
|
+
// Allow `0` and `false` but filter falsy values that indicate "empty"
|
|
213
|
+
if (value !== undefined && value !== null && value !== '') {
|
|
148
214
|
if (!Array.isArray(value) || value.length > 0) {
|
|
149
|
-
result[key] =
|
|
215
|
+
result[key] = source[key];
|
|
150
216
|
}
|
|
151
217
|
}
|
|
152
218
|
}
|
|
153
219
|
return result;
|
|
154
220
|
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Sorts query params by both key and value returning a new URLSearchParams
|
|
224
|
+
* object with the keys inserted in sorted order.
|
|
225
|
+
*
|
|
226
|
+
* Treats `included` specially, splicing it into an array if it is a string and sorting the array.
|
|
227
|
+
*
|
|
228
|
+
* Options:
|
|
229
|
+
* - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'
|
|
230
|
+
*
|
|
231
|
+
* 'bracket': appends [] to the key for every value e.g. `&ids[]=1&ids[]=2`
|
|
232
|
+
* 'indices': appends [i] to the key for every value e.g. `&ids[0]=1&ids[1]=2`
|
|
233
|
+
* 'repeat': appends the key for every value e.g. `&ids=1&ids=2`
|
|
234
|
+
* 'comma' (default): appends the key once with a comma separated list of values e.g. `&ids=1,2`
|
|
235
|
+
*
|
|
236
|
+
* @method sortQueryParams
|
|
237
|
+
* @static
|
|
238
|
+
* @public
|
|
239
|
+
* @for @ember-data/request-utils
|
|
240
|
+
* @param {URLSearchParams | object} params
|
|
241
|
+
* @param {object} options
|
|
242
|
+
* @return {URLSearchParams} A URLSearchParams with keys inserted in sorted order
|
|
243
|
+
*/
|
|
155
244
|
function sortQueryParams(params, options) {
|
|
156
|
-
|
|
245
|
+
const opts = Object.assign({}, DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS, options);
|
|
157
246
|
const paramsIsObject = !(params instanceof URLSearchParams);
|
|
158
247
|
const urlParams = new URLSearchParams();
|
|
159
248
|
const dictionaryParams = paramsIsObject ? params : {};
|
|
@@ -180,7 +269,7 @@ function sortQueryParams(params, options) {
|
|
|
180
269
|
const value = dictionaryParams[key];
|
|
181
270
|
if (Array.isArray(value)) {
|
|
182
271
|
value.sort();
|
|
183
|
-
switch (
|
|
272
|
+
switch (opts.arrayFormat) {
|
|
184
273
|
case 'indices':
|
|
185
274
|
value.forEach((v, i) => {
|
|
186
275
|
urlParams.append(`${key}[${i}]`, String(v));
|
|
@@ -207,22 +296,79 @@ function sortQueryParams(params, options) {
|
|
|
207
296
|
});
|
|
208
297
|
return urlParams;
|
|
209
298
|
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Sorts query params by both key and value, returning a query params string
|
|
302
|
+
*
|
|
303
|
+
* Treats `included` specially, splicing it into an array if it is a string and sorting the array.
|
|
304
|
+
*
|
|
305
|
+
* Options:
|
|
306
|
+
* - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'
|
|
307
|
+
*
|
|
308
|
+
* 'bracket': appends [] to the key for every value e.g. `ids[]=1&ids[]=2`
|
|
309
|
+
* 'indices': appends [i] to the key for every value e.g. `ids[0]=1&ids[1]=2`
|
|
310
|
+
* 'repeat': appends the key for every value e.g. `ids=1&ids=2`
|
|
311
|
+
* 'comma' (default): appends the key once with a comma separated list of values e.g. `ids=1,2`
|
|
312
|
+
*
|
|
313
|
+
* @method buildQueryParams
|
|
314
|
+
* @static
|
|
315
|
+
* @public
|
|
316
|
+
* @for @ember-data/request-utils
|
|
317
|
+
* @param {URLSearchParams | object} params
|
|
318
|
+
* @param {object} [options]
|
|
319
|
+
* @return {string} A sorted query params string without the leading `?`
|
|
320
|
+
*/
|
|
210
321
|
function buildQueryParams(params, options) {
|
|
211
322
|
return sortQueryParams(params, options).toString();
|
|
212
323
|
}
|
|
213
324
|
const NUMERIC_KEYS = new Set(['max-age', 's-maxage', 'stale-if-error', 'stale-while-revalidate']);
|
|
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
|
+
*/
|
|
214
354
|
function parseCacheControl(header) {
|
|
215
355
|
let key = '';
|
|
216
356
|
let value = '';
|
|
217
357
|
let isParsingKey = true;
|
|
218
|
-
|
|
358
|
+
const cacheControlValue = {};
|
|
359
|
+
function parseCacheControlValue(stringToParse) {
|
|
360
|
+
const parsedValue = Number.parseInt(stringToParse);
|
|
361
|
+
assert(`Invalid Cache-Control value, expected a number but got - ${stringToParse}`, !Number.isNaN(parsedValue));
|
|
362
|
+
return parsedValue;
|
|
363
|
+
}
|
|
219
364
|
for (let i = 0; i < header.length; i++) {
|
|
220
|
-
|
|
365
|
+
const char = header.charAt(i);
|
|
221
366
|
if (char === ',') {
|
|
222
367
|
assert(`Invalid Cache-Control value, expected a value`, !isParsingKey || !NUMERIC_KEYS.has(key));
|
|
223
368
|
assert(`Invalid Cache-Control value, expected a value after "=" but got ","`, i === 0 || header.charAt(i - 1) !== '=');
|
|
224
369
|
isParsingKey = true;
|
|
225
|
-
|
|
370
|
+
// @ts-expect-error TS incorrectly thinks that optional keys must have a type that includes undefined
|
|
371
|
+
cacheControlValue[key] = NUMERIC_KEYS.has(key) ? parseCacheControlValue(value) : true;
|
|
226
372
|
key = '';
|
|
227
373
|
value = '';
|
|
228
374
|
continue;
|
|
@@ -237,7 +383,8 @@ function parseCacheControl(header) {
|
|
|
237
383
|
value += char;
|
|
238
384
|
}
|
|
239
385
|
if (i === header.length - 1) {
|
|
240
|
-
|
|
386
|
+
// @ts-expect-error TS incorrectly thinks that optional keys must have a type that includes undefined
|
|
387
|
+
cacheControlValue[key] = NUMERIC_KEYS.has(key) ? parseCacheControlValue(value) : true;
|
|
241
388
|
}
|
|
242
389
|
}
|
|
243
390
|
return cacheControlValue;
|
|
@@ -257,17 +404,216 @@ function isStale(headers, expirationTime) {
|
|
|
257
404
|
const result = now > deadline;
|
|
258
405
|
return result;
|
|
259
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* A basic LifetimesService that can be added to the Store service.
|
|
409
|
+
*
|
|
410
|
+
* Determines staleness based on time since the request was last received from the API
|
|
411
|
+
* using the `date` header.
|
|
412
|
+
*
|
|
413
|
+
* Invalidates any request for which `cacheOptions.types` was provided when a createRecord
|
|
414
|
+
* request for that type is successful.
|
|
415
|
+
*
|
|
416
|
+
* This allows the Store's CacheHandler to determine if a request is expired and
|
|
417
|
+
* should be refetched upon next request.
|
|
418
|
+
*
|
|
419
|
+
* The `Fetch` handler provided by `@ember-data/request/fetch` will automatically
|
|
420
|
+
* add the `date` header to responses if it is not present.
|
|
421
|
+
*
|
|
422
|
+
* Note: Date headers do not have millisecond precision, so expiration times should
|
|
423
|
+
* generally be larger than 1000ms.
|
|
424
|
+
*
|
|
425
|
+
* Usage:
|
|
426
|
+
*
|
|
427
|
+
* ```ts
|
|
428
|
+
* import { LifetimesService } from '@ember-data/request-utils';
|
|
429
|
+
* import DataStore from '@ember-data/store';
|
|
430
|
+
*
|
|
431
|
+
* // ...
|
|
432
|
+
*
|
|
433
|
+
* export class Store extends DataStore {
|
|
434
|
+
* constructor(args) {
|
|
435
|
+
* super(args);
|
|
436
|
+
* this.lifetimes = new LifetimesService({ apiCacheSoftExpires: 30_000, apiCacheHardExpires: 60_000 });
|
|
437
|
+
* }
|
|
438
|
+
* }
|
|
439
|
+
* ```
|
|
440
|
+
*
|
|
441
|
+
* @class LifetimesService
|
|
442
|
+
* @public
|
|
443
|
+
* @module @ember-data/request-utils
|
|
444
|
+
*/
|
|
260
445
|
class LifetimesService {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
446
|
+
_getStore(store) {
|
|
447
|
+
let set = this._stores.get(store);
|
|
448
|
+
if (!set) {
|
|
449
|
+
set = {
|
|
450
|
+
invalidated: new Set(),
|
|
451
|
+
types: new Map()
|
|
452
|
+
};
|
|
453
|
+
this._stores.set(store, set);
|
|
454
|
+
}
|
|
455
|
+
return set;
|
|
264
456
|
}
|
|
265
|
-
|
|
266
|
-
|
|
457
|
+
constructor(config) {
|
|
458
|
+
this._stores = new WeakMap();
|
|
459
|
+
const _config = arguments.length === 1 ? config : arguments[1];
|
|
460
|
+
deprecate(`Passing a Store to the LifetimesService is deprecated, please pass only a config instead.`, arguments.length === 1, {
|
|
461
|
+
id: 'ember-data:request-utils:lifetimes-service-store-arg',
|
|
462
|
+
since: {
|
|
463
|
+
enabled: '5.4',
|
|
464
|
+
available: '5.4'
|
|
465
|
+
},
|
|
466
|
+
for: '@ember-data/request-utils',
|
|
467
|
+
until: '6.0'
|
|
468
|
+
});
|
|
469
|
+
assert(`You must pass a config to the LifetimesService`, _config);
|
|
470
|
+
assert(`You must pass a apiCacheSoftExpires to the LifetimesService`, typeof _config.apiCacheSoftExpires === 'number');
|
|
471
|
+
assert(`You must pass a apiCacheHardExpires to the LifetimesService`, typeof _config.apiCacheHardExpires === 'number');
|
|
472
|
+
this.config = _config;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Invalidate a request by its identifier for a given store instance.
|
|
477
|
+
*
|
|
478
|
+
* While the store argument may seem redundant, the lifetimes service
|
|
479
|
+
* is designed to be shared across multiple stores / forks
|
|
480
|
+
* of the store.
|
|
481
|
+
*
|
|
482
|
+
* ```ts
|
|
483
|
+
* store.lifetimes.invalidateRequest(store, identifier);
|
|
484
|
+
* ```
|
|
485
|
+
*
|
|
486
|
+
* @method invalidateRequest
|
|
487
|
+
* @public
|
|
488
|
+
* @param {StableDocumentIdentifier} identifier
|
|
489
|
+
* @param {Store} store
|
|
490
|
+
*/
|
|
491
|
+
invalidateRequest(identifier, store) {
|
|
492
|
+
this._getStore(store).invalidated.add(identifier.lid);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Invalidate all requests associated to a specific type
|
|
497
|
+
* for a given store instance.
|
|
498
|
+
*
|
|
499
|
+
* While the store argument may seem redundant, the lifetimes service
|
|
500
|
+
* is designed to be shared across multiple stores / forks
|
|
501
|
+
* of the store.
|
|
502
|
+
*
|
|
503
|
+
* This invalidation is done automatically when using this service
|
|
504
|
+
* for both the CacheHandler and the LegacyNetworkHandler.
|
|
505
|
+
*
|
|
506
|
+
* ```ts
|
|
507
|
+
* store.lifetimes.invalidateRequestsForType(store, 'person');
|
|
508
|
+
* ```
|
|
509
|
+
*
|
|
510
|
+
* @method invalidateRequestsForType
|
|
511
|
+
* @public
|
|
512
|
+
* @param {string} type
|
|
513
|
+
* @param {Store} store
|
|
514
|
+
*/
|
|
515
|
+
invalidateRequestsForType(type, store) {
|
|
516
|
+
const storeCache = this._getStore(store);
|
|
517
|
+
const set = storeCache.types.get(type);
|
|
518
|
+
if (set) {
|
|
519
|
+
set.forEach(id => {
|
|
520
|
+
storeCache.invalidated.add(id);
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Invoked when a request has been fulfilled from the configured request handlers.
|
|
527
|
+
* This is invoked by the CacheHandler for both foreground and background requests
|
|
528
|
+
* once the cache has been updated.
|
|
529
|
+
*
|
|
530
|
+
* Note, this is invoked by the CacheHandler regardless of whether
|
|
531
|
+
* the request has a cache-key.
|
|
532
|
+
*
|
|
533
|
+
* This method should not be invoked directly by consumers.
|
|
534
|
+
*
|
|
535
|
+
* @method didRequest
|
|
536
|
+
* @public
|
|
537
|
+
* @param {ImmutableRequestInfo} request
|
|
538
|
+
* @param {ImmutableResponse} response
|
|
539
|
+
* @param {Store} store
|
|
540
|
+
* @param {StableDocumentIdentifier | null} identifier
|
|
541
|
+
* @return {void}
|
|
542
|
+
*/
|
|
543
|
+
didRequest(request, response, identifier, store) {
|
|
544
|
+
// if this is a successful createRecord request, invalidate the cacheKey for the type
|
|
545
|
+
if (request.op === 'createRecord') {
|
|
546
|
+
const statusNumber = response?.status ?? 0;
|
|
547
|
+
if (statusNumber >= 200 && statusNumber < 400) {
|
|
548
|
+
const types = new Set(request.records?.map(r => r.type));
|
|
549
|
+
types.forEach(type => {
|
|
550
|
+
this.invalidateRequestsForType(type, store);
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// add this document's cacheKey to a map for all associated types
|
|
555
|
+
// it is recommended to only use this for queries
|
|
556
|
+
} else if (identifier && request.cacheOptions?.types?.length) {
|
|
557
|
+
const storeCache = this._getStore(store);
|
|
558
|
+
request.cacheOptions?.types.forEach(type => {
|
|
559
|
+
const set = storeCache.types.get(type);
|
|
560
|
+
if (set) {
|
|
561
|
+
set.add(identifier.lid);
|
|
562
|
+
storeCache.invalidated.delete(identifier.lid);
|
|
563
|
+
} else {
|
|
564
|
+
storeCache.types.set(type, new Set([identifier.lid]));
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Invoked to determine if the request may be fulfilled from cache
|
|
572
|
+
* if possible.
|
|
573
|
+
*
|
|
574
|
+
* Note, this is only invoked by the CacheHandler if the request has
|
|
575
|
+
* a cache-key.
|
|
576
|
+
*
|
|
577
|
+
* If no cache entry is found or the entry is hard expired,
|
|
578
|
+
* the request will be fulfilled from the configured request handlers
|
|
579
|
+
* and the cache will be updated before returning the response.
|
|
580
|
+
*
|
|
581
|
+
* @method isHardExpired
|
|
582
|
+
* @public
|
|
583
|
+
* @param {StableDocumentIdentifier} identifier
|
|
584
|
+
* @param {Store} store
|
|
585
|
+
* @return {boolean} true if the request is considered hard expired
|
|
586
|
+
*/
|
|
587
|
+
isHardExpired(identifier, store) {
|
|
588
|
+
// if we are explicitly invalidated, we are hard expired
|
|
589
|
+
const storeCache = this._getStore(store);
|
|
590
|
+
if (storeCache.invalidated.has(identifier.lid)) {
|
|
591
|
+
return true;
|
|
592
|
+
}
|
|
593
|
+
const cache = store.cache;
|
|
594
|
+
const cached = cache.peekRequest(identifier);
|
|
267
595
|
return !cached || !cached.response || isStale(cached.response.headers, this.config.apiCacheHardExpires);
|
|
268
596
|
}
|
|
269
|
-
|
|
270
|
-
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Invoked if `isHardExpired` is false to determine if the request
|
|
600
|
+
* should be update behind the scenes if cache data is already available.
|
|
601
|
+
*
|
|
602
|
+
* Note, this is only invoked by the CacheHandler if the request has
|
|
603
|
+
* a cache-key.
|
|
604
|
+
*
|
|
605
|
+
* If true, the request will be fulfilled from cache while a backgrounded
|
|
606
|
+
* request is made to update the cache via the configured request handlers.
|
|
607
|
+
*
|
|
608
|
+
* @method isSoftExpired
|
|
609
|
+
* @public
|
|
610
|
+
* @param {StableDocumentIdentifier} identifier
|
|
611
|
+
* @param {Store} store
|
|
612
|
+
* @return {boolean} true if the request is considered soft expired
|
|
613
|
+
*/
|
|
614
|
+
isSoftExpired(identifier, store) {
|
|
615
|
+
const cache = store.cache;
|
|
616
|
+
const cached = cache.peekRequest(identifier);
|
|
271
617
|
return !cached || !cached.response || isStale(cached.response.headers, this.config.apiCacheSoftExpires);
|
|
272
618
|
}
|
|
273
619
|
}
|
package/addon/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { assert } from '@ember/debug';\n\nimport type Store from '@ember-data/store';\nimport { StableDocumentIdentifier } from '@ember-data/types/cache/identifier';\n\n/**\n * Simple utility function to assist in url building,\n * query params, and other common request operations.\n *\n * These primitives may be used directly or composed\n * by request builders to provide a consistent interface\n * for building requests.\n *\n * For instance:\n *\n * ```ts\n * import { buildBaseURL, buildQueryParams } from '@ember-data/request-utils';\n *\n * const baseURL = buildBaseURL({\n * host: 'https://api.example.com',\n * namespace: 'api/v1',\n * resourcePath: 'emberDevelopers',\n * op: 'query',\n * identifier: { type: 'ember-developer' }\n * });\n * const url = `${baseURL}?${buildQueryParams({ name: 'Chris', include:['pets'] })}`;\n * // => 'https://api.example.com/api/v1/emberDevelopers?include=pets&name=Chris'\n * ```\n *\n * This is useful, but not as useful as the REST request builder for query which is sugar\n * over this (and more!):\n *\n * ```ts\n * import { query } from '@ember-data/rest/request';\n *\n * const options = query('ember-developer', { name: 'Chris', include:['pets'] });\n * // => { url: 'https://api.example.com/api/v1/emberDevelopers?include=pets&name=Chris' }\n * // Note: options will also include other request options like headers, method, etc.\n * ```\n *\n * @module @ember-data/request-utils\n * @main @ember-data/request-utils\n * @public\n */\n\n// prevents the final constructed object from needing to add\n// host and namespace which are provided by the final consuming\n// class to the prototype which can result in overwrite errors\n\ninterface BuildURLConfig {\n host: string | null;\n namespace: string | null;\n}\n\nlet CONFIG: BuildURLConfig = {\n host: '',\n namespace: '',\n};\n\nexport function setBuildURLConfig(values: BuildURLConfig) {\n CONFIG = values;\n}\n\nexport interface FindRecordUrlOptions {\n op: 'findRecord';\n identifier: { type: string; id: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface QueryUrlOptions {\n op: 'query';\n identifier: { type: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface FindManyUrlOptions {\n op: 'findMany';\n identifiers: { type: string; id: string }[];\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\nexport interface FindRelatedCollectionUrlOptions {\n op: 'findRelatedCollection';\n identifier: { type: string; id: string };\n fieldPath: string;\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface FindRelatedResourceUrlOptions {\n op: 'findRelatedRecord';\n identifier: { type: string; id: string };\n fieldPath: string;\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface CreateRecordUrlOptions {\n op: 'createRecord';\n identifier: { type: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface UpdateRecordUrlOptions {\n op: 'updateRecord';\n identifier: { type: string; id: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface DeleteRecordUrlOptions {\n op: 'deleteRecord';\n identifier: { type: string; id: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport type UrlOptions =\n | FindRecordUrlOptions\n | QueryUrlOptions\n | FindManyUrlOptions\n | FindRelatedCollectionUrlOptions\n | FindRelatedResourceUrlOptions\n | CreateRecordUrlOptions\n | UpdateRecordUrlOptions\n | DeleteRecordUrlOptions;\n\nconst OPERATIONS_WITH_PRIMARY_RECORDS = new Set([\n 'findRecord',\n 'findRelatedRecord',\n 'findRelatedCollection',\n 'updateRecord',\n 'deleteRecord',\n]);\n\nfunction isOperationWithPrimaryRecord(\n options: UrlOptions\n): options is\n | FindRecordUrlOptions\n | FindRelatedCollectionUrlOptions\n | FindRelatedResourceUrlOptions\n | UpdateRecordUrlOptions\n | DeleteRecordUrlOptions {\n return OPERATIONS_WITH_PRIMARY_RECORDS.has(options.op);\n}\n\nfunction resourcePathForType(options: UrlOptions): string {\n return options.op === 'findMany' ? options.identifiers[0].type : options.identifier.type;\n}\n\n/**\n * Builds a URL for a request based on the provided options.\n * Does not include support for building query params (see `buildQueryParams`)\n * so that it may be composed cleanly with other query-params strategies.\n *\n * Usage:\n *\n * ```ts\n * import { buildBaseURL } from '@ember-data/request-utils';\n *\n * const url = buildBaseURL({\n * host: 'https://api.example.com',\n * namespace: 'api/v1',\n * resourcePath: 'emberDevelopers',\n * op: 'query',\n * identifier: { type: 'ember-developer' }\n * });\n *\n * // => 'https://api.example.com/api/v1/emberDevelopers'\n * ```\n *\n * On the surface this may seem like a lot of work to do something simple, but\n * it is designed to be composable with other utilities and interfaces that the\n * average product engineer will never need to see or use.\n *\n * A few notes:\n *\n * - `resourcePath` is optional, but if it is not provided, `identifier.type` will be used.\n * - `host` and `namespace` are optional, but if they are not provided, the values globally\n * configured via `setBuildURLConfig` will be used.\n * - `op` is required and must be one of the following:\n * - 'findRecord' 'query' 'findMany' 'findRelatedCollection' 'findRelatedRecord'` 'createRecord' 'updateRecord' 'deleteRecord'\n * - Depending on the value of `op`, `identifier` or `identifiers` will be required.\n *\n * @method buildBaseURL\n * @static\n * @public\n * @for @ember-data/request-utils\n * @param urlOptions\n * @returns string\n */\nexport function buildBaseURL(urlOptions: UrlOptions): string {\n const options = Object.assign(\n {\n host: CONFIG.host,\n namespace: CONFIG.namespace,\n },\n urlOptions\n );\n assert(\n `buildBaseURL: You must pass \\`op\\` as part of options`,\n typeof options.op === 'string' && options.op.length > 0\n );\n assert(\n `buildBaseURL: You must pass \\`identifier\\` as part of options`,\n options.op === 'findMany' || (options.identifier && typeof options.identifier === 'object')\n );\n assert(\n `buildBaseURL: You must pass \\`identifiers\\` as part of options`,\n options.op !== 'findMany' ||\n (options.identifiers &&\n Array.isArray(options.identifiers) &&\n options.identifiers.length > 0 &&\n options.identifiers.every((i) => i && typeof i === 'object'))\n );\n assert(\n `buildBaseURL: You must pass valid \\`identifier\\` as part of options, expected 'id'`,\n !isOperationWithPrimaryRecord(options) ||\n (typeof options.identifier.id === 'string' && options.identifier.id.length > 0)\n );\n assert(\n `buildBaseURL: You must pass \\`identifiers\\` as part of options`,\n options.op !== 'findMany' || options.identifiers.every((i) => typeof i.id === 'string' && i.id.length > 0)\n );\n assert(\n `buildBaseURL: You must pass valid \\`identifier\\` as part of options, expected 'type'`,\n options.op === 'findMany' || (typeof options.identifier.type === 'string' && options.identifier.type.length > 0)\n );\n assert(\n `buildBaseURL: You must pass valid \\`identifiers\\` as part of options, expected 'type'`,\n options.op !== 'findMany' ||\n (typeof options.identifiers[0].type === 'string' && options.identifiers[0].type.length > 0)\n );\n\n // prettier-ignore\n const idPath: string =\n isOperationWithPrimaryRecord(options) ? encodeURIComponent(options.identifier.id)\n : '';\n const resourcePath = options.resourcePath || resourcePathForType(options);\n const { host, namespace } = options;\n const fieldPath = 'fieldPath' in options ? options.fieldPath : '';\n\n assert(\n `buildBaseURL: You tried to build a ${String(\n (options as { op: string }).op\n )} request to ${resourcePath} but op must be one of \"${[\n 'findRecord',\n 'findRelatedRecord',\n 'findRelatedCollection',\n 'updateRecord',\n 'deleteRecord',\n 'createRecord',\n 'query',\n 'findMany',\n ].join('\",\"')}\".`,\n [\n 'findRecord',\n 'query',\n 'findMany',\n 'findRelatedCollection',\n 'findRelatedRecord',\n 'createRecord',\n 'updateRecord',\n 'deleteRecord',\n ].includes(options.op)\n );\n\n assert(`buildBaseURL: host must NOT end with '/', received '${host}'`, host === '/' || !host.endsWith('/'));\n assert(`buildBaseURL: namespace must NOT start with '/', received '${namespace}'`, !namespace.startsWith('/'));\n assert(`buildBaseURL: namespace must NOT end with '/', received '${namespace}'`, !namespace.endsWith('/'));\n assert(\n `buildBaseURL: resourcePath must NOT start with '/', received '${resourcePath}'`,\n !resourcePath.startsWith('/')\n );\n assert(`buildBaseURL: resourcePath must NOT end with '/', received '${resourcePath}'`, !resourcePath.endsWith('/'));\n assert(`buildBaseURL: fieldPath must NOT start with '/', received '${fieldPath}'`, !fieldPath.startsWith('/'));\n assert(`buildBaseURL: fieldPath must NOT end with '/', received '${fieldPath}'`, !fieldPath.endsWith('/'));\n assert(`buildBaseURL: idPath must NOT start with '/', received '${idPath}'`, !idPath.startsWith('/'));\n assert(`buildBaseURL: idPath must NOT end with '/', received '${idPath}'`, !idPath.endsWith('/'));\n\n const url = [host === '/' ? '' : host, namespace, resourcePath, idPath, fieldPath].filter(Boolean).join('/');\n return host ? url : `/${url}`;\n}\n\ntype SerializablePrimitive = string | number | boolean | null;\ntype Serializable = SerializablePrimitive | SerializablePrimitive[];\nexport type QueryParamsSerializationOptions = {\n arrayFormat?: 'bracket' | 'indices' | 'repeat' | 'comma';\n};\nexport type QueryParamsSource = Record<string, Serializable> | URLSearchParams;\n\nconst DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS: QueryParamsSerializationOptions = {\n arrayFormat: 'comma',\n};\n\nfunction handleInclude(include: string | string[]): string[] {\n assert(\n `Expected include to be a string or array, got ${typeof include}`,\n typeof include === 'string' || Array.isArray(include)\n );\n return typeof include === 'string' ? include.split(',') : include;\n}\n\nexport function filterEmpty(obj: Record<string, Serializable>): Record<string, Serializable> {\n const result: Record<string, Serializable> = {};\n for (const key in obj) {\n const value = obj[key];\n if (value) {\n if (!Array.isArray(value) || value.length > 0) {\n result[key] = obj[key];\n }\n }\n }\n return result;\n}\n\nexport function sortQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): URLSearchParams {\n options = Object.assign({}, DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS, options);\n const paramsIsObject = !(params instanceof URLSearchParams);\n const urlParams = new URLSearchParams();\n const dictionaryParams: Record<string, Serializable> = paramsIsObject ? params : {};\n\n if (!paramsIsObject) {\n params.forEach((value, key) => {\n const hasExisting = key in dictionaryParams;\n if (!hasExisting) {\n dictionaryParams[key] = value;\n } else {\n const existingValue = dictionaryParams[key];\n if (Array.isArray(existingValue)) {\n existingValue.push(value);\n } else {\n dictionaryParams[key] = [existingValue, value];\n }\n }\n });\n }\n\n if ('include' in dictionaryParams) {\n dictionaryParams.include = handleInclude(dictionaryParams.include as string | string[]);\n }\n\n const sortedKeys = Object.keys(dictionaryParams).sort();\n sortedKeys.forEach((key) => {\n const value = dictionaryParams[key];\n if (Array.isArray(value)) {\n value.sort();\n switch (options!.arrayFormat) {\n case 'indices':\n value.forEach((v, i) => {\n urlParams.append(`${key}[${i}]`, String(v));\n });\n return;\n case 'bracket':\n value.forEach((v) => {\n urlParams.append(`${key}[]`, String(v));\n });\n return;\n case 'repeat':\n value.forEach((v) => {\n urlParams.append(key, String(v));\n });\n return;\n case 'comma':\n default:\n urlParams.append(key, value.join(','));\n return;\n }\n } else {\n urlParams.append(key, String(value));\n }\n });\n\n return urlParams;\n}\n\nexport function buildQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): string {\n return sortQueryParams(params, options).toString();\n}\nexport interface CacheControlValue {\n immutable?: boolean;\n 'max-age'?: number;\n 'must-revalidate'?: boolean;\n 'must-understand'?: boolean;\n 'no-cache'?: boolean;\n 'no-store'?: boolean;\n 'no-transform'?: boolean;\n 'only-if-cached'?: boolean;\n private?: boolean;\n 'proxy-revalidate'?: boolean;\n public?: boolean;\n 's-maxage'?: number;\n 'stale-if-error'?: number;\n 'stale-while-revalidate'?: number;\n}\n\nconst NUMERIC_KEYS = new Set(['max-age', 's-maxage', 'stale-if-error', 'stale-while-revalidate']);\n\nexport function parseCacheControl(header: string): CacheControlValue {\n let key = '';\n let value = '';\n let isParsingKey = true;\n let cacheControlValue: CacheControlValue = {};\n\n for (let i = 0; i < header.length; i++) {\n let char = header.charAt(i);\n if (char === ',') {\n assert(`Invalid Cache-Control value, expected a value`, !isParsingKey || !NUMERIC_KEYS.has(key));\n assert(\n `Invalid Cache-Control value, expected a value after \"=\" but got \",\"`,\n i === 0 || header.charAt(i - 1) !== '='\n );\n isParsingKey = true;\n cacheControlValue[key] = NUMERIC_KEYS.has(key) ? Number.parseInt(value) : true;\n key = '';\n value = '';\n continue;\n } else if (char === '=') {\n assert(`Invalid Cache-Control value, expected a value after \"=\"`, i + 1 !== header.length);\n isParsingKey = false;\n } else if (char === ' ' || char === `\\t` || char === `\\n`) {\n continue;\n } else if (isParsingKey) {\n key += char;\n } else {\n value += char;\n }\n\n if (i === header.length - 1) {\n cacheControlValue[key] = NUMERIC_KEYS.has(key) ? Number.parseInt(value) : true;\n }\n }\n\n return cacheControlValue;\n}\n\nfunction isStale(headers: Headers, expirationTime: number): boolean {\n // const age = headers.get('age');\n // const cacheControl = parseCacheControl(headers.get('cache-control') || '');\n // const expires = headers.get('expires');\n // const lastModified = headers.get('last-modified');\n const date = headers.get('date');\n\n if (!date) {\n return true;\n }\n\n const time = new Date(date).getTime();\n const now = Date.now();\n const deadline = time + expirationTime;\n\n const result = now > deadline;\n\n return result;\n}\n\nexport type LifetimesConfig = { apiCacheSoftExpires: number; apiCacheHardExpires: number };\n\nexport class LifetimesService {\n declare store: Store;\n declare config: LifetimesConfig;\n constructor(store: Store, config: LifetimesConfig) {\n this.store = store;\n this.config = config;\n }\n\n isHardExpired(identifier: StableDocumentIdentifier): boolean {\n const cached = this.store.cache.peekRequest(identifier);\n return !cached || !cached.response || isStale(cached.response.headers, this.config.apiCacheHardExpires);\n }\n isSoftExpired(identifier: StableDocumentIdentifier): boolean {\n const cached = this.store.cache.peekRequest(identifier);\n return !cached || !cached.response || isStale(cached.response.headers, this.config.apiCacheSoftExpires);\n }\n}\n"],"names":["CONFIG","host","namespace","setBuildURLConfig","values","OPERATIONS_WITH_PRIMARY_RECORDS","Set","isOperationWithPrimaryRecord","options","has","op","resourcePathForType","identifiers","type","identifier","buildBaseURL","urlOptions","Object","assign","assert","length","Array","isArray","every","i","id","idPath","encodeURIComponent","resourcePath","fieldPath","String","join","includes","endsWith","startsWith","url","filter","Boolean","DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS","arrayFormat","handleInclude","include","split","filterEmpty","obj","result","key","value","sortQueryParams","params","paramsIsObject","URLSearchParams","urlParams","dictionaryParams","forEach","hasExisting","existingValue","push","sortedKeys","keys","sort","v","append","buildQueryParams","toString","NUMERIC_KEYS","parseCacheControl","header","isParsingKey","cacheControlValue","char","charAt","Number","parseInt","isStale","headers","expirationTime","date","get","time","Date","getTime","now","deadline","LifetimesService","constructor","store","config","isHardExpired","cached","cache","peekRequest","response","apiCacheHardExpires","isSoftExpired","apiCacheSoftExpires"],"mappings":";;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AAOA,IAAIA,MAAsB,GAAG;AAC3BC,EAAAA,IAAI,EAAE,EAAE;AACRC,EAAAA,SAAS,EAAE,EAAA;AACb,CAAC,CAAA;AAEM,SAASC,iBAAiBA,CAACC,MAAsB,EAAE;AACxDJ,EAAAA,MAAM,GAAGI,MAAM,CAAA;AACjB,CAAA;AA6EA,MAAMC,+BAA+B,GAAG,IAAIC,GAAG,CAAC,CAC9C,YAAY,EACZ,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,cAAc,CACf,CAAC,CAAA;AAEF,SAASC,4BAA4BA,CACnCC,OAAmB,EAMM;AACzB,EAAA,OAAOH,+BAA+B,CAACI,GAAG,CAACD,OAAO,CAACE,EAAE,CAAC,CAAA;AACxD,CAAA;AAEA,SAASC,mBAAmBA,CAACH,OAAmB,EAAU;AACxD,EAAA,OAAOA,OAAO,CAACE,EAAE,KAAK,UAAU,GAAGF,OAAO,CAACI,WAAW,CAAC,CAAC,CAAC,CAACC,IAAI,GAAGL,OAAO,CAACM,UAAU,CAACD,IAAI,CAAA;AAC1F,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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AA;AACb,GAAA;EAEA,MAAME,IAAI,GAAG,IAAIC,IAAI,CAACH,IAAI,CAAC,CAACI,OAAO,EAAE,CAAA;AACrC,EAAA,MAAMC,GAAG,GAAGF,IAAI,CAACE,GAAG,EAAE,CAAA;AACtB,EAAA,MAAMC,QAAQ,GAAGJ,IAAI,GAAGH,cAAc,CAAA;AAEtC,EAAA,MAAM/B,MAAM,GAAGqC,GAAG,GAAGC,QAAQ,CAAA;AAE7B,EAAA,OAAOtC,MAAM,CAAA;AACf,CAAA;AAIO,MAAMuC,gBAAgB,CAAC;AAG5BC,EAAAA,WAAWA,CAACC,KAAY,EAAEC,MAAuB,EAAE;IACjD,IAAI,CAACD,KAAK,GAAGA,KAAK,CAAA;IAClB,IAAI,CAACC,MAAM,GAAGA,MAAM,CAAA;AACtB,GAAA;EAEAC,aAAaA,CAAC1E,UAAoC,EAAW;IAC3D,MAAM2E,MAAM,GAAG,IAAI,CAACH,KAAK,CAACI,KAAK,CAACC,WAAW,CAAC7E,UAAU,CAAC,CAAA;IACvD,OAAO,CAAC2E,MAAM,IAAI,CAACA,MAAM,CAACG,QAAQ,IAAIlB,OAAO,CAACe,MAAM,CAACG,QAAQ,CAACjB,OAAO,EAAE,IAAI,CAACY,MAAM,CAACM,mBAAmB,CAAC,CAAA;AACzG,GAAA;EACAC,aAAaA,CAAChF,UAAoC,EAAW;IAC3D,MAAM2E,MAAM,GAAG,IAAI,CAACH,KAAK,CAACI,KAAK,CAACC,WAAW,CAAC7E,UAAU,CAAC,CAAA;IACvD,OAAO,CAAC2E,MAAM,IAAI,CAACA,MAAM,CAACG,QAAQ,IAAIlB,OAAO,CAACe,MAAM,CAACG,QAAQ,CAACjB,OAAO,EAAE,IAAI,CAACY,MAAM,CAACQ,mBAAmB,CAAC,CAAA;AACzG,GAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { assert, deprecate } from '@ember/debug';\n\nimport type { Cache } from '@warp-drive/core-types/cache';\nimport type { StableDocumentIdentifier } from '@warp-drive/core-types/identifier';\nimport type { QueryParamsSerializationOptions, QueryParamsSource, Serializable } from '@warp-drive/core-types/params';\nimport type { ImmutableRequestInfo, ResponseInfo } from '@warp-drive/core-types/request';\n\ntype Store = {\n cache: Cache;\n};\n\n/**\n * Simple utility function to assist in url building,\n * query params, and other common request operations.\n *\n * These primitives may be used directly or composed\n * by request builders to provide a consistent interface\n * for building requests.\n *\n * For instance:\n *\n * ```ts\n * import { buildBaseURL, buildQueryParams } from '@ember-data/request-utils';\n *\n * const baseURL = buildBaseURL({\n * host: 'https://api.example.com',\n * namespace: 'api/v1',\n * resourcePath: 'emberDevelopers',\n * op: 'query',\n * identifier: { type: 'ember-developer' }\n * });\n * const url = `${baseURL}?${buildQueryParams({ name: 'Chris', include:['pets'] })}`;\n * // => 'https://api.example.com/api/v1/emberDevelopers?include=pets&name=Chris'\n * ```\n *\n * This is useful, but not as useful as the REST request builder for query which is sugar\n * over this (and more!):\n *\n * ```ts\n * import { query } from '@ember-data/rest/request';\n *\n * const options = query('ember-developer', { name: 'Chris', include:['pets'] });\n * // => { url: 'https://api.example.com/api/v1/emberDevelopers?include=pets&name=Chris' }\n * // Note: options will also include other request options like headers, method, etc.\n * ```\n *\n * @module @ember-data/request-utils\n * @main @ember-data/request-utils\n * @public\n */\n\n// prevents the final constructed object from needing to add\n// host and namespace which are provided by the final consuming\n// class to the prototype which can result in overwrite errors\n\nexport interface BuildURLConfig {\n host: string | null;\n namespace: string | null;\n}\n\nconst CONFIG: BuildURLConfig = {\n host: '',\n namespace: '',\n};\n\n/**\n * Sets the global configuration for `buildBaseURL`\n * for host and namespace values for the application.\n *\n * These values may still be overridden by passing\n * them to buildBaseURL directly.\n *\n * This method may be called as many times as needed.\n * host values of `''` or `'/'` are equivalent.\n *\n * Except for the value of `/` as host, host should not\n * end with `/`.\n *\n * namespace should not start or end with a `/`.\n *\n * ```ts\n * type BuildURLConfig = {\n * host: string;\n * namespace: string'\n * }\n * ```\n *\n * Example:\n *\n * ```ts\n * import { setBuildURLConfig } from '@ember-data/request-utils';\n *\n * setBuildURLConfig({\n * host: 'https://api.example.com',\n * namespace: 'api/v1'\n * });\n * ```\n *\n * @method setBuildURLConfig\n * @static\n * @public\n * @for @ember-data/request-utils\n * @param {BuildURLConfig} config\n * @return void\n */\nexport function setBuildURLConfig(config: BuildURLConfig) {\n assert(`setBuildURLConfig: You must pass a config object`, config);\n assert(\n `setBuildURLConfig: You must pass a config object with a 'host' or 'namespace' property`,\n 'host' in config || 'namespace' in config\n );\n\n CONFIG.host = config.host || '';\n CONFIG.namespace = config.namespace || '';\n\n assert(\n `buildBaseURL: host must NOT end with '/', received '${CONFIG.host}'`,\n CONFIG.host === '/' || !CONFIG.host.endsWith('/')\n );\n assert(\n `buildBaseURL: namespace must NOT start with '/', received '${CONFIG.namespace}'`,\n !CONFIG.namespace.startsWith('/')\n );\n assert(\n `buildBaseURL: namespace must NOT end with '/', received '${CONFIG.namespace}'`,\n !CONFIG.namespace.endsWith('/')\n );\n}\n\nexport interface FindRecordUrlOptions {\n op: 'findRecord';\n identifier: { type: string; id: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface QueryUrlOptions {\n op: 'query';\n identifier: { type: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface FindManyUrlOptions {\n op: 'findMany';\n identifiers: { type: string; id: string }[];\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\nexport interface FindRelatedCollectionUrlOptions {\n op: 'findRelatedCollection';\n identifier: { type: string; id: string };\n fieldPath: string;\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface FindRelatedResourceUrlOptions {\n op: 'findRelatedRecord';\n identifier: { type: string; id: string };\n fieldPath: string;\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface CreateRecordUrlOptions {\n op: 'createRecord';\n identifier: { type: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface UpdateRecordUrlOptions {\n op: 'updateRecord';\n identifier: { type: string; id: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface DeleteRecordUrlOptions {\n op: 'deleteRecord';\n identifier: { type: string; id: string };\n resourcePath?: string;\n host?: string;\n namespace?: string;\n}\n\nexport interface GenericUrlOptions {\n resourcePath: string;\n host?: string;\n namespace?: string;\n}\n\nexport type UrlOptions =\n | FindRecordUrlOptions\n | QueryUrlOptions\n | FindManyUrlOptions\n | FindRelatedCollectionUrlOptions\n | FindRelatedResourceUrlOptions\n | CreateRecordUrlOptions\n | UpdateRecordUrlOptions\n | DeleteRecordUrlOptions\n | GenericUrlOptions;\n\nconst OPERATIONS_WITH_PRIMARY_RECORDS = new Set([\n 'findRecord',\n 'findRelatedRecord',\n 'findRelatedCollection',\n 'updateRecord',\n 'deleteRecord',\n]);\n\nfunction isOperationWithPrimaryRecord(\n options: UrlOptions\n): options is\n | FindRecordUrlOptions\n | FindRelatedCollectionUrlOptions\n | FindRelatedResourceUrlOptions\n | UpdateRecordUrlOptions\n | DeleteRecordUrlOptions {\n return 'op' in options && OPERATIONS_WITH_PRIMARY_RECORDS.has(options.op);\n}\n\nfunction hasResourcePath(options: UrlOptions): options is GenericUrlOptions {\n return 'resourcePath' in options && typeof options.resourcePath === 'string' && options.resourcePath.length > 0;\n}\n\nfunction resourcePathForType(options: UrlOptions): string {\n assert(\n `resourcePathForType: You must pass a valid op as part of options`,\n 'op' in options && typeof options.op === 'string'\n );\n return options.op === 'findMany' ? options.identifiers[0].type : options.identifier.type;\n}\n\n/**\n * Builds a URL for a request based on the provided options.\n * Does not include support for building query params (see `buildQueryParams`)\n * so that it may be composed cleanly with other query-params strategies.\n *\n * Usage:\n *\n * ```ts\n * import { buildBaseURL } from '@ember-data/request-utils';\n *\n * const url = buildBaseURL({\n * host: 'https://api.example.com',\n * namespace: 'api/v1',\n * resourcePath: 'emberDevelopers',\n * op: 'query',\n * identifier: { type: 'ember-developer' }\n * });\n *\n * // => 'https://api.example.com/api/v1/emberDevelopers'\n * ```\n *\n * On the surface this may seem like a lot of work to do something simple, but\n * it is designed to be composable with other utilities and interfaces that the\n * average product engineer will never need to see or use.\n *\n * A few notes:\n *\n * - `resourcePath` is optional, but if it is not provided, `identifier.type` will be used.\n * - `host` and `namespace` are optional, but if they are not provided, the values globally\n * configured via `setBuildURLConfig` will be used.\n * - `op` is required and must be one of the following:\n * - 'findRecord' 'query' 'findMany' 'findRelatedCollection' 'findRelatedRecord'` 'createRecord' 'updateRecord' 'deleteRecord'\n * - Depending on the value of `op`, `identifier` or `identifiers` will be required.\n *\n * @method buildBaseURL\n * @static\n * @public\n * @for @ember-data/request-utils\n * @param urlOptions\n * @return string\n */\nexport function buildBaseURL(urlOptions: UrlOptions): string {\n const options = Object.assign(\n {\n host: CONFIG.host,\n namespace: CONFIG.namespace,\n },\n urlOptions\n );\n assert(\n `buildBaseURL: You must pass \\`op\\` as part of options`,\n hasResourcePath(options) || (typeof options.op === 'string' && options.op.length > 0)\n );\n assert(\n `buildBaseURL: You must pass \\`identifier\\` as part of options`,\n hasResourcePath(options) ||\n options.op === 'findMany' ||\n (options.identifier && typeof options.identifier === 'object')\n );\n assert(\n `buildBaseURL: You must pass \\`identifiers\\` as part of options`,\n hasResourcePath(options) ||\n options.op !== 'findMany' ||\n (options.identifiers &&\n Array.isArray(options.identifiers) &&\n options.identifiers.length > 0 &&\n options.identifiers.every((i) => i && typeof i === 'object'))\n );\n assert(\n `buildBaseURL: You must pass valid \\`identifier\\` as part of options, expected 'id'`,\n hasResourcePath(options) ||\n !isOperationWithPrimaryRecord(options) ||\n (typeof options.identifier.id === 'string' && options.identifier.id.length > 0)\n );\n assert(\n `buildBaseURL: You must pass \\`identifiers\\` as part of options`,\n hasResourcePath(options) ||\n options.op !== 'findMany' ||\n options.identifiers.every((i) => typeof i.id === 'string' && i.id.length > 0)\n );\n assert(\n `buildBaseURL: You must pass valid \\`identifier\\` as part of options, expected 'type'`,\n hasResourcePath(options) ||\n options.op === 'findMany' ||\n (typeof options.identifier.type === 'string' && options.identifier.type.length > 0)\n );\n assert(\n `buildBaseURL: You must pass valid \\`identifiers\\` as part of options, expected 'type'`,\n hasResourcePath(options) ||\n options.op !== 'findMany' ||\n (typeof options.identifiers[0].type === 'string' && options.identifiers[0].type.length > 0)\n );\n\n // prettier-ignore\n const idPath: string =\n isOperationWithPrimaryRecord(options) ? encodeURIComponent(options.identifier.id)\n : '';\n const resourcePath = options.resourcePath || resourcePathForType(options);\n const { host, namespace } = options;\n const fieldPath = 'fieldPath' in options ? options.fieldPath : '';\n\n assert(\n `buildBaseURL: You tried to build a url for a ${String(\n 'op' in options ? options.op + ' ' : ''\n )}request to ${resourcePath} but resourcePath must be set or op must be one of \"${[\n 'findRecord',\n 'findRelatedRecord',\n 'findRelatedCollection',\n 'updateRecord',\n 'deleteRecord',\n 'createRecord',\n 'query',\n 'findMany',\n ].join('\",\"')}\".`,\n hasResourcePath(options) ||\n [\n 'findRecord',\n 'query',\n 'findMany',\n 'findRelatedCollection',\n 'findRelatedRecord',\n 'createRecord',\n 'updateRecord',\n 'deleteRecord',\n ].includes(options.op)\n );\n\n assert(`buildBaseURL: host must NOT end with '/', received '${host}'`, host === '/' || !host.endsWith('/'));\n assert(`buildBaseURL: namespace must NOT start with '/', received '${namespace}'`, !namespace.startsWith('/'));\n assert(`buildBaseURL: namespace must NOT end with '/', received '${namespace}'`, !namespace.endsWith('/'));\n assert(\n `buildBaseURL: resourcePath must NOT start with '/', received '${resourcePath}'`,\n !resourcePath.startsWith('/')\n );\n assert(`buildBaseURL: resourcePath must NOT end with '/', received '${resourcePath}'`, !resourcePath.endsWith('/'));\n assert(`buildBaseURL: fieldPath must NOT start with '/', received '${fieldPath}'`, !fieldPath.startsWith('/'));\n assert(`buildBaseURL: fieldPath must NOT end with '/', received '${fieldPath}'`, !fieldPath.endsWith('/'));\n assert(`buildBaseURL: idPath must NOT start with '/', received '${idPath}'`, !idPath.startsWith('/'));\n assert(`buildBaseURL: idPath must NOT end with '/', received '${idPath}'`, !idPath.endsWith('/'));\n\n const hasHost = host !== '' && host !== '/';\n const url = [hasHost ? host : '', namespace, resourcePath, idPath, fieldPath].filter(Boolean).join('/');\n return hasHost ? url : `/${url}`;\n}\n\nconst DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS: QueryParamsSerializationOptions = {\n arrayFormat: 'comma',\n};\n\nfunction handleInclude(include: string | string[]): string[] {\n assert(\n `Expected include to be a string or array, got ${typeof include}`,\n typeof include === 'string' || Array.isArray(include)\n );\n return typeof include === 'string' ? include.split(',') : include;\n}\n\n/**\n * filter out keys of an object that have falsy values or point to empty arrays\n * returning a new object with only those keys that have truthy values / non-empty arrays\n *\n * @method filterEmpty\n * @static\n * @public\n * @for @ember-data/request-utils\n * @param {Record<string, Serializable>} source object to filter keys with empty values from\n * @return {Record<string, Serializable>} A new object with the keys that contained empty values removed\n */\nexport function filterEmpty(source: Record<string, Serializable>): Record<string, Serializable> {\n const result: Record<string, Serializable> = {};\n for (const key in source) {\n const value = source[key];\n // Allow `0` and `false` but filter falsy values that indicate \"empty\"\n if (value !== undefined && value !== null && value !== '') {\n if (!Array.isArray(value) || value.length > 0) {\n result[key] = source[key];\n }\n }\n }\n return result;\n}\n\n/**\n * Sorts query params by both key and value returning a new URLSearchParams\n * object with the keys inserted in sorted order.\n *\n * Treats `included` specially, splicing it into an array if it is a string and sorting the array.\n *\n * Options:\n * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'\n *\n * 'bracket': appends [] to the key for every value e.g. `&ids[]=1&ids[]=2`\n * 'indices': appends [i] to the key for every value e.g. `&ids[0]=1&ids[1]=2`\n * 'repeat': appends the key for every value e.g. `&ids=1&ids=2`\n * 'comma' (default): appends the key once with a comma separated list of values e.g. `&ids=1,2`\n *\n * @method sortQueryParams\n * @static\n * @public\n * @for @ember-data/request-utils\n * @param {URLSearchParams | object} params\n * @param {object} options\n * @return {URLSearchParams} A URLSearchParams with keys inserted in sorted order\n */\nexport function sortQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): URLSearchParams {\n const opts = Object.assign({}, DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS, options);\n const paramsIsObject = !(params instanceof URLSearchParams);\n const urlParams = new URLSearchParams();\n const dictionaryParams: Record<string, Serializable> = paramsIsObject ? params : {};\n\n if (!paramsIsObject) {\n params.forEach((value, key) => {\n const hasExisting = key in dictionaryParams;\n if (!hasExisting) {\n dictionaryParams[key] = value;\n } else {\n const existingValue = dictionaryParams[key];\n if (Array.isArray(existingValue)) {\n existingValue.push(value);\n } else {\n dictionaryParams[key] = [existingValue, value];\n }\n }\n });\n }\n\n if ('include' in dictionaryParams) {\n dictionaryParams.include = handleInclude(dictionaryParams.include as string | string[]);\n }\n\n const sortedKeys = Object.keys(dictionaryParams).sort();\n sortedKeys.forEach((key) => {\n const value = dictionaryParams[key];\n if (Array.isArray(value)) {\n value.sort();\n switch (opts.arrayFormat) {\n case 'indices':\n value.forEach((v, i) => {\n urlParams.append(`${key}[${i}]`, String(v));\n });\n return;\n case 'bracket':\n value.forEach((v) => {\n urlParams.append(`${key}[]`, String(v));\n });\n return;\n case 'repeat':\n value.forEach((v) => {\n urlParams.append(key, String(v));\n });\n return;\n case 'comma':\n default:\n urlParams.append(key, value.join(','));\n return;\n }\n } else {\n urlParams.append(key, String(value));\n }\n });\n\n return urlParams;\n}\n\n/**\n * Sorts query params by both key and value, returning a query params string\n *\n * Treats `included` specially, splicing it into an array if it is a string and sorting the array.\n *\n * Options:\n * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'\n *\n * 'bracket': appends [] to the key for every value e.g. `ids[]=1&ids[]=2`\n * 'indices': appends [i] to the key for every value e.g. `ids[0]=1&ids[1]=2`\n * 'repeat': appends the key for every value e.g. `ids=1&ids=2`\n * 'comma' (default): appends the key once with a comma separated list of values e.g. `ids=1,2`\n *\n * @method buildQueryParams\n * @static\n * @public\n * @for @ember-data/request-utils\n * @param {URLSearchParams | object} params\n * @param {object} [options]\n * @return {string} A sorted query params string without the leading `?`\n */\nexport function buildQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): string {\n return sortQueryParams(params, options).toString();\n}\nexport interface CacheControlValue {\n immutable?: boolean;\n 'max-age'?: number;\n 'must-revalidate'?: boolean;\n 'must-understand'?: boolean;\n 'no-cache'?: boolean;\n 'no-store'?: boolean;\n 'no-transform'?: boolean;\n 'only-if-cached'?: boolean;\n private?: boolean;\n 'proxy-revalidate'?: boolean;\n public?: boolean;\n 's-maxage'?: number;\n 'stale-if-error'?: number;\n 'stale-while-revalidate'?: number;\n}\n\ntype CacheControlKey = keyof CacheControlValue;\n\nconst NUMERIC_KEYS = new Set(['max-age', 's-maxage', 'stale-if-error', 'stale-while-revalidate']);\n\n/**\n * Parses a string Cache-Control header value into an object with the following structure:\n *\n * ```ts\n * interface CacheControlValue {\n * immutable?: boolean;\n * 'max-age'?: number;\n * 'must-revalidate'?: boolean;\n * 'must-understand'?: boolean;\n * 'no-cache'?: boolean;\n * 'no-store'?: boolean;\n * 'no-transform'?: boolean;\n * 'only-if-cached'?: boolean;\n * private?: boolean;\n * 'proxy-revalidate'?: boolean;\n * public?: boolean;\n * 's-maxage'?: number;\n * 'stale-if-error'?: number;\n * 'stale-while-revalidate'?: number;\n * }\n * ```\n * @method parseCacheControl\n * @static\n * @public\n * @for @ember-data/request-utils\n * @param {string} header\n * @return {CacheControlValue}\n */\nexport function parseCacheControl(header: string): CacheControlValue {\n let key: CacheControlKey = '' as CacheControlKey;\n let value = '';\n let isParsingKey = true;\n const cacheControlValue: CacheControlValue = {};\n\n function parseCacheControlValue(stringToParse: string): number {\n const parsedValue = Number.parseInt(stringToParse);\n assert(`Invalid Cache-Control value, expected a number but got - ${stringToParse}`, !Number.isNaN(parsedValue));\n return parsedValue;\n }\n\n for (let i = 0; i < header.length; i++) {\n const char = header.charAt(i);\n if (char === ',') {\n assert(`Invalid Cache-Control value, expected a value`, !isParsingKey || !NUMERIC_KEYS.has(key));\n assert(\n `Invalid Cache-Control value, expected a value after \"=\" but got \",\"`,\n i === 0 || header.charAt(i - 1) !== '='\n );\n isParsingKey = true;\n // @ts-expect-error TS incorrectly thinks that optional keys must have a type that includes undefined\n cacheControlValue[key] = NUMERIC_KEYS.has(key) ? parseCacheControlValue(value) : true;\n key = '' as CacheControlKey;\n value = '';\n continue;\n } else if (char === '=') {\n assert(`Invalid Cache-Control value, expected a value after \"=\"`, i + 1 !== header.length);\n isParsingKey = false;\n } else if (char === ' ' || char === `\\t` || char === `\\n`) {\n continue;\n } else if (isParsingKey) {\n key += char;\n } else {\n value += char;\n }\n\n if (i === header.length - 1) {\n // @ts-expect-error TS incorrectly thinks that optional keys must have a type that includes undefined\n cacheControlValue[key] = NUMERIC_KEYS.has(key) ? parseCacheControlValue(value) : true;\n }\n }\n\n return cacheControlValue;\n}\n\nfunction isStale(headers: Headers, expirationTime: number): boolean {\n // const age = headers.get('age');\n // const cacheControl = parseCacheControl(headers.get('cache-control') || '');\n // const expires = headers.get('expires');\n // const lastModified = headers.get('last-modified');\n const date = headers.get('date');\n\n if (!date) {\n return true;\n }\n\n const time = new Date(date).getTime();\n const now = Date.now();\n const deadline = time + expirationTime;\n\n const result = now > deadline;\n\n return result;\n}\n\nexport type LifetimesConfig = { apiCacheSoftExpires: number; apiCacheHardExpires: number };\n\n/**\n * A basic LifetimesService that can be added to the Store service.\n *\n * Determines staleness based on time since the request was last received from the API\n * using the `date` header.\n *\n * Invalidates any request for which `cacheOptions.types` was provided when a createRecord\n * request for that type is successful.\n *\n * This allows the Store's CacheHandler to determine if a request is expired and\n * should be refetched upon next request.\n *\n * The `Fetch` handler provided by `@ember-data/request/fetch` will automatically\n * add the `date` header to responses if it is not present.\n *\n * Note: Date headers do not have millisecond precision, so expiration times should\n * generally be larger than 1000ms.\n *\n * Usage:\n *\n * ```ts\n * import { LifetimesService } from '@ember-data/request-utils';\n * import DataStore from '@ember-data/store';\n *\n * // ...\n *\n * export class Store extends DataStore {\n * constructor(args) {\n * super(args);\n * this.lifetimes = new LifetimesService({ apiCacheSoftExpires: 30_000, apiCacheHardExpires: 60_000 });\n * }\n * }\n * ```\n *\n * @class LifetimesService\n * @public\n * @module @ember-data/request-utils\n */\nexport class LifetimesService {\n declare config: LifetimesConfig;\n declare _stores: WeakMap<Store, { invalidated: Set<string>; types: Map<string, Set<string>> }>;\n\n _getStore(store: Store): { invalidated: Set<string>; types: Map<string, Set<string>> } {\n let set = this._stores.get(store);\n if (!set) {\n set = { invalidated: new Set(), types: new Map() };\n this._stores.set(store, set);\n }\n return set;\n }\n\n constructor(config: LifetimesConfig) {\n this._stores = new WeakMap();\n\n const _config = arguments.length === 1 ? config : (arguments[1] as unknown as LifetimesConfig);\n deprecate(\n `Passing a Store to the LifetimesService is deprecated, please pass only a config instead.`,\n arguments.length === 1,\n {\n id: 'ember-data:request-utils:lifetimes-service-store-arg',\n since: {\n enabled: '5.4',\n available: '5.4',\n },\n for: '@ember-data/request-utils',\n until: '6.0',\n }\n );\n assert(`You must pass a config to the LifetimesService`, _config);\n assert(\n `You must pass a apiCacheSoftExpires to the LifetimesService`,\n typeof _config.apiCacheSoftExpires === 'number'\n );\n assert(\n `You must pass a apiCacheHardExpires to the LifetimesService`,\n typeof _config.apiCacheHardExpires === 'number'\n );\n this.config = _config;\n }\n\n /**\n * Invalidate a request by its identifier for a given store instance.\n *\n * While the store argument may seem redundant, the lifetimes service\n * is designed to be shared across multiple stores / forks\n * of the store.\n *\n * ```ts\n * store.lifetimes.invalidateRequest(store, identifier);\n * ```\n *\n * @method invalidateRequest\n * @public\n * @param {StableDocumentIdentifier} identifier\n * @param {Store} store\n */\n invalidateRequest(identifier: StableDocumentIdentifier, store: Store): void {\n this._getStore(store).invalidated.add(identifier.lid);\n }\n\n /**\n * Invalidate all requests associated to a specific type\n * for a given store instance.\n *\n * While the store argument may seem redundant, the lifetimes service\n * is designed to be shared across multiple stores / forks\n * of the store.\n *\n * This invalidation is done automatically when using this service\n * for both the CacheHandler and the LegacyNetworkHandler.\n *\n * ```ts\n * store.lifetimes.invalidateRequestsForType(store, 'person');\n * ```\n *\n * @method invalidateRequestsForType\n * @public\n * @param {string} type\n * @param {Store} store\n */\n invalidateRequestsForType(type: string, store: Store): void {\n const storeCache = this._getStore(store);\n const set = storeCache.types.get(type);\n if (set) {\n set.forEach((id) => {\n storeCache.invalidated.add(id);\n });\n }\n }\n\n /**\n * Invoked when a request has been fulfilled from the configured request handlers.\n * This is invoked by the CacheHandler for both foreground and background requests\n * once the cache has been updated.\n *\n * Note, this is invoked by the CacheHandler regardless of whether\n * the request has a cache-key.\n *\n * This method should not be invoked directly by consumers.\n *\n * @method didRequest\n * @public\n * @param {ImmutableRequestInfo} request\n * @param {ImmutableResponse} response\n * @param {Store} store\n * @param {StableDocumentIdentifier | null} identifier\n * @return {void}\n */\n didRequest(\n request: ImmutableRequestInfo,\n response: Response | ResponseInfo | null,\n identifier: StableDocumentIdentifier | null,\n store: Store\n ): void {\n // if this is a successful createRecord request, invalidate the cacheKey for the type\n if (request.op === 'createRecord') {\n const statusNumber = response?.status ?? 0;\n if (statusNumber >= 200 && statusNumber < 400) {\n const types = new Set(request.records?.map((r) => r.type));\n types.forEach((type) => {\n this.invalidateRequestsForType(type, store);\n });\n }\n\n // add this document's cacheKey to a map for all associated types\n // it is recommended to only use this for queries\n } else if (identifier && request.cacheOptions?.types?.length) {\n const storeCache = this._getStore(store);\n request.cacheOptions?.types.forEach((type) => {\n const set = storeCache.types.get(type);\n if (set) {\n set.add(identifier.lid);\n storeCache.invalidated.delete(identifier.lid);\n } else {\n storeCache.types.set(type, new Set([identifier.lid]));\n }\n });\n }\n }\n\n /**\n * Invoked to determine if the request may be fulfilled from cache\n * if possible.\n *\n * Note, this is only invoked by the CacheHandler if the request has\n * a cache-key.\n *\n * If no cache entry is found or the entry is hard expired,\n * the request will be fulfilled from the configured request handlers\n * and the cache will be updated before returning the response.\n *\n * @method isHardExpired\n * @public\n * @param {StableDocumentIdentifier} identifier\n * @param {Store} store\n * @return {boolean} true if the request is considered hard expired\n */\n isHardExpired(identifier: StableDocumentIdentifier, store: Store): boolean {\n // if we are explicitly invalidated, we are hard expired\n const storeCache = this._getStore(store);\n if (storeCache.invalidated.has(identifier.lid)) {\n return true;\n }\n const cache = store.cache;\n const cached = cache.peekRequest(identifier);\n return !cached || !cached.response || isStale(cached.response.headers, this.config.apiCacheHardExpires);\n }\n\n /**\n * Invoked if `isHardExpired` is false to determine if the request\n * should be update behind the scenes if cache data is already available.\n *\n * Note, this is only invoked by the CacheHandler if the request has\n * a cache-key.\n *\n * If true, the request will be fulfilled from cache while a backgrounded\n * request is made to update the cache via the configured request handlers.\n *\n * @method isSoftExpired\n * @public\n * @param {StableDocumentIdentifier} identifier\n * @param {Store} store\n * @return {boolean} true if the request is considered soft expired\n */\n isSoftExpired(identifier: StableDocumentIdentifier, store: Store): boolean {\n const cache = store.cache;\n const cached = cache.peekRequest(identifier);\n return !cached || !cached.response || isStale(cached.response.headers, this.config.apiCacheSoftExpires);\n }\n}\n"],"names":["CONFIG","host","namespace","setBuildURLConfig","config","assert","endsWith","startsWith","OPERATIONS_WITH_PRIMARY_RECORDS","Set","isOperationWithPrimaryRecord","options","has","op","hasResourcePath","resourcePath","length","resourcePathForType","identifiers","type","identifier","buildBaseURL","urlOptions","Object","assign","Array","isArray","every","i","id","idPath","encodeURIComponent","fieldPath","String","join","includes","hasHost","url","filter","Boolean","DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS","arrayFormat","handleInclude","include","split","filterEmpty","source","result","key","value","undefined","sortQueryParams","params","opts","paramsIsObject","URLSearchParams","urlParams","dictionaryParams","forEach","hasExisting","existingValue","push","sortedKeys","keys","sort","v","append","buildQueryParams","toString","NUMERIC_KEYS","parseCacheControl","header","isParsingKey","cacheControlValue","parseCacheControlValue","stringToParse","parsedValue","Number","parseInt","isNaN","char","charAt","isStale","headers","expirationTime","date","get","time","Date","getTime","now","deadline","LifetimesService","_getStore","store","set","_stores","invalidated","types","Map","constructor","WeakMap","_config","arguments","deprecate","since","enabled","available","for","until","apiCacheSoftExpires","apiCacheHardExpires","invalidateRequest","add","lid","invalidateRequestsForType","storeCache","didRequest","request","response","statusNumber","status","records","map","r","cacheOptions","delete","isHardExpired","cache","cached","peekRequest","isSoftExpired"],"mappings":";;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAOA,MAAMA,MAAsB,GAAG;AAC7BC,EAAAA,IAAI,EAAE,EAAE;AACRC,EAAAA,SAAS,EAAE,EAAA;AACb,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,iBAAiBA,CAACC,MAAsB,EAAE;AACxDC,EAAAA,MAAM,CAAE,CAAA,gDAAA,CAAiD,EAAED,MAAM,CAAC,CAAA;EAClEC,MAAM,CACH,CAAuF,sFAAA,CAAA,EACxF,MAAM,IAAID,MAAM,IAAI,WAAW,IAAIA,MACrC,CAAC,CAAA;AAEDJ,EAAAA,MAAM,CAACC,IAAI,GAAGG,MAAM,CAACH,IAAI,IAAI,EAAE,CAAA;AAC/BD,EAAAA,MAAM,CAACE,SAAS,GAAGE,MAAM,CAACF,SAAS,IAAI,EAAE,CAAA;EAEzCG,MAAM,CACH,uDAAsDL,MAAM,CAACC,IAAK,CAAE,CAAA,CAAA,EACrED,MAAM,CAACC,IAAI,KAAK,GAAG,IAAI,CAACD,MAAM,CAACC,IAAI,CAACK,QAAQ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AC,CAAA;AACzG,GAAA;AACF;;;;"}
|
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.41",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Chris Thoburn <runspired@users.noreply.github.com>",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"homepage": "https://github.com/emberjs/data",
|
|
14
14
|
"bugs": "https://github.com/emberjs/data/issues",
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": "
|
|
16
|
+
"node": ">= 18.19.1"
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|
|
19
19
|
"ember-addon"
|
|
@@ -21,10 +21,14 @@
|
|
|
21
21
|
"volta": {
|
|
22
22
|
"extends": "../../package.json"
|
|
23
23
|
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@warp-drive/core-types": "workspace:0.0.0-alpha.27"
|
|
26
|
+
},
|
|
24
27
|
"dependencies": {
|
|
25
|
-
"ember-cli-babel": "^8.
|
|
28
|
+
"ember-cli-babel": "^8.2.0"
|
|
26
29
|
},
|
|
27
30
|
"files": [
|
|
31
|
+
"unstable-preview-types",
|
|
28
32
|
"addon-main.js",
|
|
29
33
|
"addon",
|
|
30
34
|
"README.md",
|
|
@@ -32,34 +36,46 @@
|
|
|
32
36
|
"ember-data-logo-dark.svg",
|
|
33
37
|
"ember-data-logo-light.svg"
|
|
34
38
|
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs --report-unused-disable-directives",
|
|
41
|
+
"build:types": "tsc --build",
|
|
42
|
+
"build:client": "rollup --config && babel ./addon --out-dir addon --plugins=../private-build-infra/src/transforms/babel-plugin-transform-ext.js",
|
|
43
|
+
"_build": "bun run build:client && bun run build:types",
|
|
44
|
+
"_syncPnpm": "bun run sync-dependencies-meta-injected"
|
|
45
|
+
},
|
|
35
46
|
"ember-addon": {
|
|
36
47
|
"main": "addon-main.js",
|
|
37
48
|
"type": "addon",
|
|
38
49
|
"version": 1
|
|
39
50
|
},
|
|
40
51
|
"devDependencies": {
|
|
41
|
-
"@babel/cli": "^7.
|
|
42
|
-
"@babel/core": "^7.
|
|
43
|
-
"@babel/plugin-proposal-decorators": "^7.
|
|
44
|
-
"@babel/plugin-transform-class-properties": "^7.
|
|
45
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
46
|
-
"@babel/plugin-transform-typescript": "^7.
|
|
47
|
-
"@babel/preset-env": "^7.
|
|
48
|
-
"@babel/preset-typescript": "^7.
|
|
49
|
-
"@babel/runtime": "^7.
|
|
50
|
-
"@embroider/addon-dev": "^4.1
|
|
51
|
-
"@
|
|
52
|
-
"@rollup/plugin-
|
|
53
|
-
"rollup": "^
|
|
54
|
-
"
|
|
55
|
-
"
|
|
52
|
+
"@babel/cli": "^7.24.1",
|
|
53
|
+
"@babel/core": "^7.24.1",
|
|
54
|
+
"@babel/plugin-proposal-decorators": "^7.24.1",
|
|
55
|
+
"@babel/plugin-transform-class-properties": "^7.24.1",
|
|
56
|
+
"@babel/plugin-transform-runtime": "^7.24.1",
|
|
57
|
+
"@babel/plugin-transform-typescript": "^7.24.1",
|
|
58
|
+
"@babel/preset-env": "^7.24.1",
|
|
59
|
+
"@babel/preset-typescript": "^7.24.1",
|
|
60
|
+
"@babel/runtime": "^7.24.1",
|
|
61
|
+
"@embroider/addon-dev": "^4.2.1",
|
|
62
|
+
"@glimmer/component": "^1.1.2",
|
|
63
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
64
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
65
|
+
"@warp-drive/core-types": "workspace:0.0.0-alpha.27",
|
|
66
|
+
"@warp-drive/internal-config": "workspace:5.4.0-alpha.41",
|
|
67
|
+
"ember-source": "~5.7.0",
|
|
68
|
+
"pnpm-sync-dependencies-meta-injected": "0.0.10",
|
|
69
|
+
"rollup": "^4.13.0",
|
|
70
|
+
"typescript": "^5.4.3",
|
|
56
71
|
"walk-sync": "^3.0.0"
|
|
57
72
|
},
|
|
58
73
|
"ember": {
|
|
59
74
|
"edition": "octane"
|
|
60
75
|
},
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
|
|
76
|
+
"dependenciesMeta": {
|
|
77
|
+
"@warp-drive/core-types": {
|
|
78
|
+
"injected": true
|
|
79
|
+
}
|
|
64
80
|
}
|
|
65
|
-
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
|
|
2
|
+
declare module '@ember-data/request-utils' {
|
|
3
|
+
import type { Cache } from '@warp-drive/core-types/cache';
|
|
4
|
+
import type { StableDocumentIdentifier } from '@warp-drive/core-types/identifier';
|
|
5
|
+
import type { QueryParamsSerializationOptions, QueryParamsSource, Serializable } from '@warp-drive/core-types/params';
|
|
6
|
+
import type { ImmutableRequestInfo, ResponseInfo } from '@warp-drive/core-types/request';
|
|
7
|
+
type Store = {
|
|
8
|
+
cache: Cache;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Simple utility function to assist in url building,
|
|
12
|
+
* query params, and other common request operations.
|
|
13
|
+
*
|
|
14
|
+
* These primitives may be used directly or composed
|
|
15
|
+
* by request builders to provide a consistent interface
|
|
16
|
+
* for building requests.
|
|
17
|
+
*
|
|
18
|
+
* For instance:
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { buildBaseURL, buildQueryParams } from '@ember-data/request-utils';
|
|
22
|
+
*
|
|
23
|
+
* const baseURL = buildBaseURL({
|
|
24
|
+
* host: 'https://api.example.com',
|
|
25
|
+
* namespace: 'api/v1',
|
|
26
|
+
* resourcePath: 'emberDevelopers',
|
|
27
|
+
* op: 'query',
|
|
28
|
+
* identifier: { type: 'ember-developer' }
|
|
29
|
+
* });
|
|
30
|
+
* const url = `${baseURL}?${buildQueryParams({ name: 'Chris', include:['pets'] })}`;
|
|
31
|
+
* // => 'https://api.example.com/api/v1/emberDevelopers?include=pets&name=Chris'
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* This is useful, but not as useful as the REST request builder for query which is sugar
|
|
35
|
+
* over this (and more!):
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { query } from '@ember-data/rest/request';
|
|
39
|
+
*
|
|
40
|
+
* const options = query('ember-developer', { name: 'Chris', include:['pets'] });
|
|
41
|
+
* // => { url: 'https://api.example.com/api/v1/emberDevelopers?include=pets&name=Chris' }
|
|
42
|
+
* // Note: options will also include other request options like headers, method, etc.
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @module @ember-data/request-utils
|
|
46
|
+
* @main @ember-data/request-utils
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export interface BuildURLConfig {
|
|
50
|
+
host: string | null;
|
|
51
|
+
namespace: string | null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Sets the global configuration for `buildBaseURL`
|
|
55
|
+
* for host and namespace values for the application.
|
|
56
|
+
*
|
|
57
|
+
* These values may still be overridden by passing
|
|
58
|
+
* them to buildBaseURL directly.
|
|
59
|
+
*
|
|
60
|
+
* This method may be called as many times as needed.
|
|
61
|
+
* host values of `''` or `'/'` are equivalent.
|
|
62
|
+
*
|
|
63
|
+
* Except for the value of `/` as host, host should not
|
|
64
|
+
* end with `/`.
|
|
65
|
+
*
|
|
66
|
+
* namespace should not start or end with a `/`.
|
|
67
|
+
*
|
|
68
|
+
* ```ts
|
|
69
|
+
* type BuildURLConfig = {
|
|
70
|
+
* host: string;
|
|
71
|
+
* namespace: string'
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* Example:
|
|
76
|
+
*
|
|
77
|
+
* ```ts
|
|
78
|
+
* import { setBuildURLConfig } from '@ember-data/request-utils';
|
|
79
|
+
*
|
|
80
|
+
* setBuildURLConfig({
|
|
81
|
+
* host: 'https://api.example.com',
|
|
82
|
+
* namespace: 'api/v1'
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @method setBuildURLConfig
|
|
87
|
+
* @static
|
|
88
|
+
* @public
|
|
89
|
+
* @for @ember-data/request-utils
|
|
90
|
+
* @param {BuildURLConfig} config
|
|
91
|
+
* @return void
|
|
92
|
+
*/
|
|
93
|
+
export function setBuildURLConfig(config: BuildURLConfig): void;
|
|
94
|
+
export interface FindRecordUrlOptions {
|
|
95
|
+
op: 'findRecord';
|
|
96
|
+
identifier: {
|
|
97
|
+
type: string;
|
|
98
|
+
id: string;
|
|
99
|
+
};
|
|
100
|
+
resourcePath?: string;
|
|
101
|
+
host?: string;
|
|
102
|
+
namespace?: string;
|
|
103
|
+
}
|
|
104
|
+
export interface QueryUrlOptions {
|
|
105
|
+
op: 'query';
|
|
106
|
+
identifier: {
|
|
107
|
+
type: string;
|
|
108
|
+
};
|
|
109
|
+
resourcePath?: string;
|
|
110
|
+
host?: string;
|
|
111
|
+
namespace?: string;
|
|
112
|
+
}
|
|
113
|
+
export interface FindManyUrlOptions {
|
|
114
|
+
op: 'findMany';
|
|
115
|
+
identifiers: {
|
|
116
|
+
type: string;
|
|
117
|
+
id: string;
|
|
118
|
+
}[];
|
|
119
|
+
resourcePath?: string;
|
|
120
|
+
host?: string;
|
|
121
|
+
namespace?: string;
|
|
122
|
+
}
|
|
123
|
+
export interface FindRelatedCollectionUrlOptions {
|
|
124
|
+
op: 'findRelatedCollection';
|
|
125
|
+
identifier: {
|
|
126
|
+
type: string;
|
|
127
|
+
id: string;
|
|
128
|
+
};
|
|
129
|
+
fieldPath: string;
|
|
130
|
+
resourcePath?: string;
|
|
131
|
+
host?: string;
|
|
132
|
+
namespace?: string;
|
|
133
|
+
}
|
|
134
|
+
export interface FindRelatedResourceUrlOptions {
|
|
135
|
+
op: 'findRelatedRecord';
|
|
136
|
+
identifier: {
|
|
137
|
+
type: string;
|
|
138
|
+
id: string;
|
|
139
|
+
};
|
|
140
|
+
fieldPath: string;
|
|
141
|
+
resourcePath?: string;
|
|
142
|
+
host?: string;
|
|
143
|
+
namespace?: string;
|
|
144
|
+
}
|
|
145
|
+
export interface CreateRecordUrlOptions {
|
|
146
|
+
op: 'createRecord';
|
|
147
|
+
identifier: {
|
|
148
|
+
type: string;
|
|
149
|
+
};
|
|
150
|
+
resourcePath?: string;
|
|
151
|
+
host?: string;
|
|
152
|
+
namespace?: string;
|
|
153
|
+
}
|
|
154
|
+
export interface UpdateRecordUrlOptions {
|
|
155
|
+
op: 'updateRecord';
|
|
156
|
+
identifier: {
|
|
157
|
+
type: string;
|
|
158
|
+
id: string;
|
|
159
|
+
};
|
|
160
|
+
resourcePath?: string;
|
|
161
|
+
host?: string;
|
|
162
|
+
namespace?: string;
|
|
163
|
+
}
|
|
164
|
+
export interface DeleteRecordUrlOptions {
|
|
165
|
+
op: 'deleteRecord';
|
|
166
|
+
identifier: {
|
|
167
|
+
type: string;
|
|
168
|
+
id: string;
|
|
169
|
+
};
|
|
170
|
+
resourcePath?: string;
|
|
171
|
+
host?: string;
|
|
172
|
+
namespace?: string;
|
|
173
|
+
}
|
|
174
|
+
export interface GenericUrlOptions {
|
|
175
|
+
resourcePath: string;
|
|
176
|
+
host?: string;
|
|
177
|
+
namespace?: string;
|
|
178
|
+
}
|
|
179
|
+
export type UrlOptions = FindRecordUrlOptions | QueryUrlOptions | FindManyUrlOptions | FindRelatedCollectionUrlOptions | FindRelatedResourceUrlOptions | CreateRecordUrlOptions | UpdateRecordUrlOptions | DeleteRecordUrlOptions | GenericUrlOptions;
|
|
180
|
+
/**
|
|
181
|
+
* Builds a URL for a request based on the provided options.
|
|
182
|
+
* Does not include support for building query params (see `buildQueryParams`)
|
|
183
|
+
* so that it may be composed cleanly with other query-params strategies.
|
|
184
|
+
*
|
|
185
|
+
* Usage:
|
|
186
|
+
*
|
|
187
|
+
* ```ts
|
|
188
|
+
* import { buildBaseURL } from '@ember-data/request-utils';
|
|
189
|
+
*
|
|
190
|
+
* const url = buildBaseURL({
|
|
191
|
+
* host: 'https://api.example.com',
|
|
192
|
+
* namespace: 'api/v1',
|
|
193
|
+
* resourcePath: 'emberDevelopers',
|
|
194
|
+
* op: 'query',
|
|
195
|
+
* identifier: { type: 'ember-developer' }
|
|
196
|
+
* });
|
|
197
|
+
*
|
|
198
|
+
* // => 'https://api.example.com/api/v1/emberDevelopers'
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
201
|
+
* On the surface this may seem like a lot of work to do something simple, but
|
|
202
|
+
* it is designed to be composable with other utilities and interfaces that the
|
|
203
|
+
* average product engineer will never need to see or use.
|
|
204
|
+
*
|
|
205
|
+
* A few notes:
|
|
206
|
+
*
|
|
207
|
+
* - `resourcePath` is optional, but if it is not provided, `identifier.type` will be used.
|
|
208
|
+
* - `host` and `namespace` are optional, but if they are not provided, the values globally
|
|
209
|
+
* configured via `setBuildURLConfig` will be used.
|
|
210
|
+
* - `op` is required and must be one of the following:
|
|
211
|
+
* - 'findRecord' 'query' 'findMany' 'findRelatedCollection' 'findRelatedRecord'` 'createRecord' 'updateRecord' 'deleteRecord'
|
|
212
|
+
* - Depending on the value of `op`, `identifier` or `identifiers` will be required.
|
|
213
|
+
*
|
|
214
|
+
* @method buildBaseURL
|
|
215
|
+
* @static
|
|
216
|
+
* @public
|
|
217
|
+
* @for @ember-data/request-utils
|
|
218
|
+
* @param urlOptions
|
|
219
|
+
* @return string
|
|
220
|
+
*/
|
|
221
|
+
export function buildBaseURL(urlOptions: UrlOptions): string;
|
|
222
|
+
/**
|
|
223
|
+
* filter out keys of an object that have falsy values or point to empty arrays
|
|
224
|
+
* returning a new object with only those keys that have truthy values / non-empty arrays
|
|
225
|
+
*
|
|
226
|
+
* @method filterEmpty
|
|
227
|
+
* @static
|
|
228
|
+
* @public
|
|
229
|
+
* @for @ember-data/request-utils
|
|
230
|
+
* @param {Record<string, Serializable>} source object to filter keys with empty values from
|
|
231
|
+
* @return {Record<string, Serializable>} A new object with the keys that contained empty values removed
|
|
232
|
+
*/
|
|
233
|
+
export function filterEmpty(source: Record<string, Serializable>): Record<string, Serializable>;
|
|
234
|
+
/**
|
|
235
|
+
* Sorts query params by both key and value returning a new URLSearchParams
|
|
236
|
+
* object with the keys inserted in sorted order.
|
|
237
|
+
*
|
|
238
|
+
* Treats `included` specially, splicing it into an array if it is a string and sorting the array.
|
|
239
|
+
*
|
|
240
|
+
* Options:
|
|
241
|
+
* - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'
|
|
242
|
+
*
|
|
243
|
+
* 'bracket': appends [] to the key for every value e.g. `&ids[]=1&ids[]=2`
|
|
244
|
+
* 'indices': appends [i] to the key for every value e.g. `&ids[0]=1&ids[1]=2`
|
|
245
|
+
* 'repeat': appends the key for every value e.g. `&ids=1&ids=2`
|
|
246
|
+
* 'comma' (default): appends the key once with a comma separated list of values e.g. `&ids=1,2`
|
|
247
|
+
*
|
|
248
|
+
* @method sortQueryParams
|
|
249
|
+
* @static
|
|
250
|
+
* @public
|
|
251
|
+
* @for @ember-data/request-utils
|
|
252
|
+
* @param {URLSearchParams | object} params
|
|
253
|
+
* @param {object} options
|
|
254
|
+
* @return {URLSearchParams} A URLSearchParams with keys inserted in sorted order
|
|
255
|
+
*/
|
|
256
|
+
export function sortQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): URLSearchParams;
|
|
257
|
+
/**
|
|
258
|
+
* Sorts query params by both key and value, returning a query params string
|
|
259
|
+
*
|
|
260
|
+
* Treats `included` specially, splicing it into an array if it is a string and sorting the array.
|
|
261
|
+
*
|
|
262
|
+
* Options:
|
|
263
|
+
* - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'
|
|
264
|
+
*
|
|
265
|
+
* 'bracket': appends [] to the key for every value e.g. `ids[]=1&ids[]=2`
|
|
266
|
+
* 'indices': appends [i] to the key for every value e.g. `ids[0]=1&ids[1]=2`
|
|
267
|
+
* 'repeat': appends the key for every value e.g. `ids=1&ids=2`
|
|
268
|
+
* 'comma' (default): appends the key once with a comma separated list of values e.g. `ids=1,2`
|
|
269
|
+
*
|
|
270
|
+
* @method buildQueryParams
|
|
271
|
+
* @static
|
|
272
|
+
* @public
|
|
273
|
+
* @for @ember-data/request-utils
|
|
274
|
+
* @param {URLSearchParams | object} params
|
|
275
|
+
* @param {object} [options]
|
|
276
|
+
* @return {string} A sorted query params string without the leading `?`
|
|
277
|
+
*/
|
|
278
|
+
export function buildQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): string;
|
|
279
|
+
export interface CacheControlValue {
|
|
280
|
+
immutable?: boolean;
|
|
281
|
+
'max-age'?: number;
|
|
282
|
+
'must-revalidate'?: boolean;
|
|
283
|
+
'must-understand'?: boolean;
|
|
284
|
+
'no-cache'?: boolean;
|
|
285
|
+
'no-store'?: boolean;
|
|
286
|
+
'no-transform'?: boolean;
|
|
287
|
+
'only-if-cached'?: boolean;
|
|
288
|
+
private?: boolean;
|
|
289
|
+
'proxy-revalidate'?: boolean;
|
|
290
|
+
public?: boolean;
|
|
291
|
+
's-maxage'?: number;
|
|
292
|
+
'stale-if-error'?: number;
|
|
293
|
+
'stale-while-revalidate'?: number;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Parses a string Cache-Control header value into an object with the following structure:
|
|
297
|
+
*
|
|
298
|
+
* ```ts
|
|
299
|
+
* interface CacheControlValue {
|
|
300
|
+
* immutable?: boolean;
|
|
301
|
+
* 'max-age'?: number;
|
|
302
|
+
* 'must-revalidate'?: boolean;
|
|
303
|
+
* 'must-understand'?: boolean;
|
|
304
|
+
* 'no-cache'?: boolean;
|
|
305
|
+
* 'no-store'?: boolean;
|
|
306
|
+
* 'no-transform'?: boolean;
|
|
307
|
+
* 'only-if-cached'?: boolean;
|
|
308
|
+
* private?: boolean;
|
|
309
|
+
* 'proxy-revalidate'?: boolean;
|
|
310
|
+
* public?: boolean;
|
|
311
|
+
* 's-maxage'?: number;
|
|
312
|
+
* 'stale-if-error'?: number;
|
|
313
|
+
* 'stale-while-revalidate'?: number;
|
|
314
|
+
* }
|
|
315
|
+
* ```
|
|
316
|
+
* @method parseCacheControl
|
|
317
|
+
* @static
|
|
318
|
+
* @public
|
|
319
|
+
* @for @ember-data/request-utils
|
|
320
|
+
* @param {string} header
|
|
321
|
+
* @return {CacheControlValue}
|
|
322
|
+
*/
|
|
323
|
+
export function parseCacheControl(header: string): CacheControlValue;
|
|
324
|
+
export type LifetimesConfig = {
|
|
325
|
+
apiCacheSoftExpires: number;
|
|
326
|
+
apiCacheHardExpires: number;
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
* A basic LifetimesService that can be added to the Store service.
|
|
330
|
+
*
|
|
331
|
+
* Determines staleness based on time since the request was last received from the API
|
|
332
|
+
* using the `date` header.
|
|
333
|
+
*
|
|
334
|
+
* Invalidates any request for which `cacheOptions.types` was provided when a createRecord
|
|
335
|
+
* request for that type is successful.
|
|
336
|
+
*
|
|
337
|
+
* This allows the Store's CacheHandler to determine if a request is expired and
|
|
338
|
+
* should be refetched upon next request.
|
|
339
|
+
*
|
|
340
|
+
* The `Fetch` handler provided by `@ember-data/request/fetch` will automatically
|
|
341
|
+
* add the `date` header to responses if it is not present.
|
|
342
|
+
*
|
|
343
|
+
* Note: Date headers do not have millisecond precision, so expiration times should
|
|
344
|
+
* generally be larger than 1000ms.
|
|
345
|
+
*
|
|
346
|
+
* Usage:
|
|
347
|
+
*
|
|
348
|
+
* ```ts
|
|
349
|
+
* import { LifetimesService } from '@ember-data/request-utils';
|
|
350
|
+
* import DataStore from '@ember-data/store';
|
|
351
|
+
*
|
|
352
|
+
* // ...
|
|
353
|
+
*
|
|
354
|
+
* export class Store extends DataStore {
|
|
355
|
+
* constructor(args) {
|
|
356
|
+
* super(args);
|
|
357
|
+
* this.lifetimes = new LifetimesService({ apiCacheSoftExpires: 30_000, apiCacheHardExpires: 60_000 });
|
|
358
|
+
* }
|
|
359
|
+
* }
|
|
360
|
+
* ```
|
|
361
|
+
*
|
|
362
|
+
* @class LifetimesService
|
|
363
|
+
* @public
|
|
364
|
+
* @module @ember-data/request-utils
|
|
365
|
+
*/
|
|
366
|
+
export class LifetimesService {
|
|
367
|
+
config: LifetimesConfig;
|
|
368
|
+
_stores: WeakMap<Store, {
|
|
369
|
+
invalidated: Set<string>;
|
|
370
|
+
types: Map<string, Set<string>>;
|
|
371
|
+
}>;
|
|
372
|
+
_getStore(store: Store): {
|
|
373
|
+
invalidated: Set<string>;
|
|
374
|
+
types: Map<string, Set<string>>;
|
|
375
|
+
};
|
|
376
|
+
constructor(config: LifetimesConfig);
|
|
377
|
+
/**
|
|
378
|
+
* Invalidate a request by its identifier for a given store instance.
|
|
379
|
+
*
|
|
380
|
+
* While the store argument may seem redundant, the lifetimes service
|
|
381
|
+
* is designed to be shared across multiple stores / forks
|
|
382
|
+
* of the store.
|
|
383
|
+
*
|
|
384
|
+
* ```ts
|
|
385
|
+
* store.lifetimes.invalidateRequest(store, identifier);
|
|
386
|
+
* ```
|
|
387
|
+
*
|
|
388
|
+
* @method invalidateRequest
|
|
389
|
+
* @public
|
|
390
|
+
* @param {StableDocumentIdentifier} identifier
|
|
391
|
+
* @param {Store} store
|
|
392
|
+
*/
|
|
393
|
+
invalidateRequest(identifier: StableDocumentIdentifier, store: Store): void;
|
|
394
|
+
/**
|
|
395
|
+
* Invalidate all requests associated to a specific type
|
|
396
|
+
* for a given store instance.
|
|
397
|
+
*
|
|
398
|
+
* While the store argument may seem redundant, the lifetimes service
|
|
399
|
+
* is designed to be shared across multiple stores / forks
|
|
400
|
+
* of the store.
|
|
401
|
+
*
|
|
402
|
+
* This invalidation is done automatically when using this service
|
|
403
|
+
* for both the CacheHandler and the LegacyNetworkHandler.
|
|
404
|
+
*
|
|
405
|
+
* ```ts
|
|
406
|
+
* store.lifetimes.invalidateRequestsForType(store, 'person');
|
|
407
|
+
* ```
|
|
408
|
+
*
|
|
409
|
+
* @method invalidateRequestsForType
|
|
410
|
+
* @public
|
|
411
|
+
* @param {string} type
|
|
412
|
+
* @param {Store} store
|
|
413
|
+
*/
|
|
414
|
+
invalidateRequestsForType(type: string, store: Store): void;
|
|
415
|
+
/**
|
|
416
|
+
* Invoked when a request has been fulfilled from the configured request handlers.
|
|
417
|
+
* This is invoked by the CacheHandler for both foreground and background requests
|
|
418
|
+
* once the cache has been updated.
|
|
419
|
+
*
|
|
420
|
+
* Note, this is invoked by the CacheHandler regardless of whether
|
|
421
|
+
* the request has a cache-key.
|
|
422
|
+
*
|
|
423
|
+
* This method should not be invoked directly by consumers.
|
|
424
|
+
*
|
|
425
|
+
* @method didRequest
|
|
426
|
+
* @public
|
|
427
|
+
* @param {ImmutableRequestInfo} request
|
|
428
|
+
* @param {ImmutableResponse} response
|
|
429
|
+
* @param {Store} store
|
|
430
|
+
* @param {StableDocumentIdentifier | null} identifier
|
|
431
|
+
* @return {void}
|
|
432
|
+
*/
|
|
433
|
+
didRequest(request: ImmutableRequestInfo, response: Response | ResponseInfo | null, identifier: StableDocumentIdentifier | null, store: Store): void;
|
|
434
|
+
/**
|
|
435
|
+
* Invoked to determine if the request may be fulfilled from cache
|
|
436
|
+
* if possible.
|
|
437
|
+
*
|
|
438
|
+
* Note, this is only invoked by the CacheHandler if the request has
|
|
439
|
+
* a cache-key.
|
|
440
|
+
*
|
|
441
|
+
* If no cache entry is found or the entry is hard expired,
|
|
442
|
+
* the request will be fulfilled from the configured request handlers
|
|
443
|
+
* and the cache will be updated before returning the response.
|
|
444
|
+
*
|
|
445
|
+
* @method isHardExpired
|
|
446
|
+
* @public
|
|
447
|
+
* @param {StableDocumentIdentifier} identifier
|
|
448
|
+
* @param {Store} store
|
|
449
|
+
* @return {boolean} true if the request is considered hard expired
|
|
450
|
+
*/
|
|
451
|
+
isHardExpired(identifier: StableDocumentIdentifier, store: Store): boolean;
|
|
452
|
+
/**
|
|
453
|
+
* Invoked if `isHardExpired` is false to determine if the request
|
|
454
|
+
* should be update behind the scenes if cache data is already available.
|
|
455
|
+
*
|
|
456
|
+
* Note, this is only invoked by the CacheHandler if the request has
|
|
457
|
+
* a cache-key.
|
|
458
|
+
*
|
|
459
|
+
* If true, the request will be fulfilled from cache while a backgrounded
|
|
460
|
+
* request is made to update the cache via the configured request handlers.
|
|
461
|
+
*
|
|
462
|
+
* @method isSoftExpired
|
|
463
|
+
* @public
|
|
464
|
+
* @param {StableDocumentIdentifier} identifier
|
|
465
|
+
* @param {Store} store
|
|
466
|
+
* @return {boolean} true if the request is considered soft expired
|
|
467
|
+
*/
|
|
468
|
+
isSoftExpired(identifier: StableDocumentIdentifier, store: Store): boolean;
|
|
469
|
+
}
|
|
470
|
+
export {};
|
|
471
|
+
}
|
|
472
|
+
//# 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,C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