@allthings/cloud-toolkit 5.3.1-beta.1 → 5.3.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/alagarr.cjs.js
CHANGED
|
@@ -222,6 +222,27 @@ const stringifyIfNotStringifiedJson = (data) => {
|
|
|
222
222
|
};
|
|
223
223
|
const json = (responseData, _, body, statusCode, options) => makeResponseObject(responseData, stringifyIfNotStringifiedJson(body), statusCode, options, 'application/json');
|
|
224
224
|
|
|
225
|
+
const splitDirectives = (value) => typeof value === 'string'
|
|
226
|
+
? value
|
|
227
|
+
.split(',')
|
|
228
|
+
.map((directive) => directive.trim())
|
|
229
|
+
.filter(Boolean)
|
|
230
|
+
: [];
|
|
231
|
+
const withAcceptEncodingVary = (headers = {}) => {
|
|
232
|
+
const varyKeys = Object.keys(headers).filter((key) => key.toLowerCase() === 'vary');
|
|
233
|
+
const directives = varyKeys
|
|
234
|
+
.flatMap((key) => splitDirectives(headers[key]))
|
|
235
|
+
.filter((directive, index, all) => all.findIndex((other) => other.toLowerCase() === directive.toLowerCase()) === index);
|
|
236
|
+
const hasAcceptEncoding = directives.some((directive) => directive.toLowerCase() === 'accept-encoding');
|
|
237
|
+
const otherHeaders = Object.fromEntries(Object.entries(headers).filter(([key]) => !varyKeys.includes(key)));
|
|
238
|
+
return {
|
|
239
|
+
...otherHeaders,
|
|
240
|
+
[varyKeys[0] ?? 'vary']: (hasAcceptEncoding
|
|
241
|
+
? directives
|
|
242
|
+
: [...directives, 'Accept-Encoding']).join(', '),
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
|
|
225
246
|
const COMPRESSIBLE = [
|
|
226
247
|
'application/activity+json',
|
|
227
248
|
'application/alto-costmap+json',
|
|
@@ -403,11 +424,11 @@ const compressResponse = (response, encoding) => {
|
|
|
403
424
|
return {
|
|
404
425
|
...rest,
|
|
405
426
|
body: compressed.toString('base64'),
|
|
406
|
-
headers: {
|
|
427
|
+
headers: withAcceptEncodingVary({
|
|
407
428
|
...headers,
|
|
408
429
|
'content-encoding': encoding,
|
|
409
430
|
'content-length': compressed.byteLength,
|
|
410
|
-
},
|
|
431
|
+
}),
|
|
411
432
|
isBase64Encoded: true,
|
|
412
433
|
};
|
|
413
434
|
};
|
|
@@ -467,10 +488,10 @@ const cspHeaders = (response, _, options) => {
|
|
|
467
488
|
|
|
468
489
|
const enforcedHeaders = (response, _, options) => ({
|
|
469
490
|
...response,
|
|
470
|
-
headers: {
|
|
491
|
+
headers: withAcceptEncodingVary({
|
|
471
492
|
...response.headers,
|
|
472
493
|
...(options.headers ?? {}),
|
|
473
|
-
},
|
|
494
|
+
}),
|
|
474
495
|
});
|
|
475
496
|
|
|
476
497
|
const EMPTY_ENTITY_TAG = '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"';
|
package/dist/alagarr.esm.mjs
CHANGED
|
@@ -199,6 +199,27 @@ const stringifyIfNotStringifiedJson = (data) => {
|
|
|
199
199
|
};
|
|
200
200
|
const json = (responseData, _, body, statusCode, options) => makeResponseObject(responseData, stringifyIfNotStringifiedJson(body), statusCode, options, 'application/json');
|
|
201
201
|
|
|
202
|
+
const splitDirectives = (value) => typeof value === 'string'
|
|
203
|
+
? value
|
|
204
|
+
.split(',')
|
|
205
|
+
.map((directive) => directive.trim())
|
|
206
|
+
.filter(Boolean)
|
|
207
|
+
: [];
|
|
208
|
+
const withAcceptEncodingVary = (headers = {}) => {
|
|
209
|
+
const varyKeys = Object.keys(headers).filter((key) => key.toLowerCase() === 'vary');
|
|
210
|
+
const directives = varyKeys
|
|
211
|
+
.flatMap((key) => splitDirectives(headers[key]))
|
|
212
|
+
.filter((directive, index, all) => all.findIndex((other) => other.toLowerCase() === directive.toLowerCase()) === index);
|
|
213
|
+
const hasAcceptEncoding = directives.some((directive) => directive.toLowerCase() === 'accept-encoding');
|
|
214
|
+
const otherHeaders = Object.fromEntries(Object.entries(headers).filter(([key]) => !varyKeys.includes(key)));
|
|
215
|
+
return {
|
|
216
|
+
...otherHeaders,
|
|
217
|
+
[varyKeys[0] ?? 'vary']: (hasAcceptEncoding
|
|
218
|
+
? directives
|
|
219
|
+
: [...directives, 'Accept-Encoding']).join(', '),
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
|
|
202
223
|
const COMPRESSIBLE = [
|
|
203
224
|
'application/activity+json',
|
|
204
225
|
'application/alto-costmap+json',
|
|
@@ -380,11 +401,11 @@ const compressResponse = (response, encoding) => {
|
|
|
380
401
|
return {
|
|
381
402
|
...rest,
|
|
382
403
|
body: compressed.toString('base64'),
|
|
383
|
-
headers: {
|
|
404
|
+
headers: withAcceptEncodingVary({
|
|
384
405
|
...headers,
|
|
385
406
|
'content-encoding': encoding,
|
|
386
407
|
'content-length': compressed.byteLength,
|
|
387
|
-
},
|
|
408
|
+
}),
|
|
388
409
|
isBase64Encoded: true,
|
|
389
410
|
};
|
|
390
411
|
};
|
|
@@ -444,10 +465,10 @@ const cspHeaders = (response, _, options) => {
|
|
|
444
465
|
|
|
445
466
|
const enforcedHeaders = (response, _, options) => ({
|
|
446
467
|
...response,
|
|
447
|
-
headers: {
|
|
468
|
+
headers: withAcceptEncodingVary({
|
|
448
469
|
...response.headers,
|
|
449
470
|
...(options.headers ?? {}),
|
|
450
|
-
},
|
|
471
|
+
}),
|
|
451
472
|
});
|
|
452
473
|
|
|
453
474
|
const EMPTY_ENTITY_TAG = '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"';
|
package/dist/lib.cjs.js
CHANGED
|
@@ -231,6 +231,27 @@ const stringifyIfNotStringifiedJson = (data) => {
|
|
|
231
231
|
};
|
|
232
232
|
const json = (responseData, _, body, statusCode, options) => makeResponseObject(responseData, stringifyIfNotStringifiedJson(body), statusCode, options, 'application/json');
|
|
233
233
|
|
|
234
|
+
const splitDirectives = (value) => typeof value === 'string'
|
|
235
|
+
? value
|
|
236
|
+
.split(',')
|
|
237
|
+
.map((directive) => directive.trim())
|
|
238
|
+
.filter(Boolean)
|
|
239
|
+
: [];
|
|
240
|
+
const withAcceptEncodingVary = (headers = {}) => {
|
|
241
|
+
const varyKeys = Object.keys(headers).filter((key) => key.toLowerCase() === 'vary');
|
|
242
|
+
const directives = varyKeys
|
|
243
|
+
.flatMap((key) => splitDirectives(headers[key]))
|
|
244
|
+
.filter((directive, index, all) => all.findIndex((other) => other.toLowerCase() === directive.toLowerCase()) === index);
|
|
245
|
+
const hasAcceptEncoding = directives.some((directive) => directive.toLowerCase() === 'accept-encoding');
|
|
246
|
+
const otherHeaders = Object.fromEntries(Object.entries(headers).filter(([key]) => !varyKeys.includes(key)));
|
|
247
|
+
return {
|
|
248
|
+
...otherHeaders,
|
|
249
|
+
[varyKeys[0] ?? 'vary']: (hasAcceptEncoding
|
|
250
|
+
? directives
|
|
251
|
+
: [...directives, 'Accept-Encoding']).join(', '),
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
|
|
234
255
|
const COMPRESSIBLE = [
|
|
235
256
|
'application/activity+json',
|
|
236
257
|
'application/alto-costmap+json',
|
|
@@ -412,11 +433,11 @@ const compressResponse = (response, encoding) => {
|
|
|
412
433
|
return {
|
|
413
434
|
...rest,
|
|
414
435
|
body: compressed.toString('base64'),
|
|
415
|
-
headers: {
|
|
436
|
+
headers: withAcceptEncodingVary({
|
|
416
437
|
...headers,
|
|
417
438
|
'content-encoding': encoding,
|
|
418
439
|
'content-length': compressed.byteLength,
|
|
419
|
-
},
|
|
440
|
+
}),
|
|
420
441
|
isBase64Encoded: true,
|
|
421
442
|
};
|
|
422
443
|
};
|
|
@@ -476,10 +497,10 @@ const cspHeaders = (response, _, options) => {
|
|
|
476
497
|
|
|
477
498
|
const enforcedHeaders = (response, _, options) => ({
|
|
478
499
|
...response,
|
|
479
|
-
headers: {
|
|
500
|
+
headers: withAcceptEncodingVary({
|
|
480
501
|
...response.headers,
|
|
481
502
|
...(options.headers ?? {}),
|
|
482
|
-
},
|
|
503
|
+
}),
|
|
483
504
|
});
|
|
484
505
|
|
|
485
506
|
const EMPTY_ENTITY_TAG = '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"';
|
package/dist/lib.esm.mjs
CHANGED
|
@@ -209,6 +209,27 @@ const stringifyIfNotStringifiedJson = (data) => {
|
|
|
209
209
|
};
|
|
210
210
|
const json = (responseData, _, body, statusCode, options) => makeResponseObject(responseData, stringifyIfNotStringifiedJson(body), statusCode, options, 'application/json');
|
|
211
211
|
|
|
212
|
+
const splitDirectives = (value) => typeof value === 'string'
|
|
213
|
+
? value
|
|
214
|
+
.split(',')
|
|
215
|
+
.map((directive) => directive.trim())
|
|
216
|
+
.filter(Boolean)
|
|
217
|
+
: [];
|
|
218
|
+
const withAcceptEncodingVary = (headers = {}) => {
|
|
219
|
+
const varyKeys = Object.keys(headers).filter((key) => key.toLowerCase() === 'vary');
|
|
220
|
+
const directives = varyKeys
|
|
221
|
+
.flatMap((key) => splitDirectives(headers[key]))
|
|
222
|
+
.filter((directive, index, all) => all.findIndex((other) => other.toLowerCase() === directive.toLowerCase()) === index);
|
|
223
|
+
const hasAcceptEncoding = directives.some((directive) => directive.toLowerCase() === 'accept-encoding');
|
|
224
|
+
const otherHeaders = Object.fromEntries(Object.entries(headers).filter(([key]) => !varyKeys.includes(key)));
|
|
225
|
+
return {
|
|
226
|
+
...otherHeaders,
|
|
227
|
+
[varyKeys[0] ?? 'vary']: (hasAcceptEncoding
|
|
228
|
+
? directives
|
|
229
|
+
: [...directives, 'Accept-Encoding']).join(', '),
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
|
|
212
233
|
const COMPRESSIBLE = [
|
|
213
234
|
'application/activity+json',
|
|
214
235
|
'application/alto-costmap+json',
|
|
@@ -390,11 +411,11 @@ const compressResponse = (response, encoding) => {
|
|
|
390
411
|
return {
|
|
391
412
|
...rest,
|
|
392
413
|
body: compressed.toString('base64'),
|
|
393
|
-
headers: {
|
|
414
|
+
headers: withAcceptEncodingVary({
|
|
394
415
|
...headers,
|
|
395
416
|
'content-encoding': encoding,
|
|
396
417
|
'content-length': compressed.byteLength,
|
|
397
|
-
},
|
|
418
|
+
}),
|
|
398
419
|
isBase64Encoded: true,
|
|
399
420
|
};
|
|
400
421
|
};
|
|
@@ -454,10 +475,10 @@ const cspHeaders = (response, _, options) => {
|
|
|
454
475
|
|
|
455
476
|
const enforcedHeaders = (response, _, options) => ({
|
|
456
477
|
...response,
|
|
457
|
-
headers: {
|
|
478
|
+
headers: withAcceptEncodingVary({
|
|
458
479
|
...response.headers,
|
|
459
480
|
...(options.headers ?? {}),
|
|
460
|
-
},
|
|
481
|
+
}),
|
|
461
482
|
});
|
|
462
483
|
|
|
463
484
|
const EMPTY_ENTITY_TAG = '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"';
|