@nmshd/transport 1.1.5 → 1.1.9

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.
@@ -15,11 +15,11 @@ exports.buildInformation = void 0;
15
15
  const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
16
16
  const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
17
17
  exports.buildInformation = {
18
- version: "1.1.5",
19
- build: "17",
20
- date: "2022-01-03T13:16:27+00:00",
21
- commit: "84aa2cdf19c200c50a429b31d5e4b83a658f5820",
22
- dependencies: {"@js-soft/docdb-access-abstractions":"1.0.1","@js-soft/logging-abstractions":"1.0.0","@js-soft/simple-logger":"1.0.0","@js-soft/ts-utils":"1.1.1","axios":"^0.24.0","deep-equal":"^2.0.5","fast-json-patch":"^3.1.0","form-data":"^4.0.0","json-stringify-safe":"^5.0.1","lodash":"^4.17.21","luxon":"^2.2.0","qs":"^6.10.2","reflect-metadata":"^0.1.13","ts-simple-nameof":"^1.3.1","uuid":"^8.3.2"},
18
+ version: "1.1.9",
19
+ build: "21",
20
+ date: "2022-02-04T12:41:52+00:00",
21
+ commit: "a3d954a1746fd2cf627ecc834de1bafe59b7db8d",
22
+ dependencies: {"@js-soft/docdb-access-abstractions":"1.0.1","@js-soft/logging-abstractions":"1.0.0","@js-soft/simple-logger":"1.0.1","@js-soft/ts-utils":"1.1.1","axios":"^0.25.0","deep-equal":"^2.0.5","fast-json-patch":"^3.1.0","form-data":"^4.0.0","json-stringify-safe":"^5.0.1","lodash":"^4.17.21","luxon":"^2.3.0","qs":"^6.10.3","reflect-metadata":"^0.1.13","ts-simple-nameof":"^1.3.1","uuid":"^8.3.2"},
23
23
  libraries: {
24
24
  crypto: crypto_1.buildInformation,
25
25
  serval: ts_serval_1.buildInformation
@@ -5252,29 +5252,12 @@ class FileController extends TransportController_1.TransportController {
5252
5252
  if (ids.length < 1) {
5253
5253
  return [];
5254
5254
  }
5255
+ // TODO: JSSNMSHDD-2820 (check for items that couldn't be fetched e.g. because it is expired)
5256
+ const resultItems = (await this.client.getFiles({ ids })).value;
5255
5257
  const promises = [];
5256
- for (const id of ids) {
5257
- const result = await this.client.getFile(id);
5258
- if (result.isError) {
5259
- if (result.error.code === "error.transport.recordNotFound" ||
5260
- result.error.code === "error.transport.request.notFound" ||
5261
- result.error.code === "error.platform.recordNotFound") {
5262
- this.log.warn(`Record id ${id} could not be found on backbone. It might be expired.`, result.error);
5263
- continue;
5264
- }
5265
- throw result.error;
5266
- }
5267
- const resultItem = result.value;
5268
- promises.push(this.updateCacheOfExistingFileInDb(resultItem.id, resultItem));
5269
- }
5270
- /*
5271
- // TODO: Optimize once backbone handling is clarified
5272
- const resultItems = (await this.client.getFiles({ ids })).value
5273
- const promises = []
5274
5258
  for await (const resultItem of resultItems) {
5275
- promises.push(this.updateCacheOfExistingFileInDb(resultItem.id, resultItem))
5259
+ promises.push(this.updateCacheOfExistingFileInDb(resultItem.id, resultItem));
5276
5260
  }
5277
- */
5278
5261
  return await Promise.all(promises);
5279
5262
  }
5280
5263
  async updateCacheOfExistingFileInDb(id, response) {
@@ -7160,29 +7143,12 @@ class RelationshipTemplateController extends TransportController_1.TransportCont
7160
7143
  if (ids.length < 1) {
7161
7144
  return [];
7162
7145
  }
7146
+ // TODO: JSSNMSHDD-2820 (check for items that couldn't be fetched e.g. because it is expired)
7147
+ const resultItems = (await this.client.getRelationshipTemplates({ ids })).value;
7163
7148
  const promises = [];
7164
- for (const id of ids) {
7165
- const result = await this.client.getRelationshipTemplate(id);
7166
- if (result.isError) {
7167
- if (result.error.code === "error.transport.recordNotFound" ||
7168
- result.error.code === "error.transport.request.notFound" ||
7169
- result.error.code === "error.platform.recordNotFound") {
7170
- this.log.warn(`Record id ${id} could not be found on backbone. It might be expired.`, result.error);
7171
- continue;
7172
- }
7173
- throw result.error;
7174
- }
7175
- const resultItem = result.value;
7176
- promises.push(this.updateCacheOfExistingTemplateInDb(resultItem.id, resultItem));
7177
- }
7178
- /*
7179
- // TODO: Optimize once backbone handling is clarified
7180
- const resultItems = (await this.client.getRelationshipTemplates({ ids })).value
7181
- const promises = []
7182
7149
  for await (const resultItem of resultItems) {
7183
- promises.push(this.updateCacheOfExistingTemplateInDb(resultItem.id, resultItem))
7150
+ promises.push(this.updateCacheOfExistingTemplateInDb(resultItem.id, resultItem));
7184
7151
  }
7185
- */
7186
7152
  return await Promise.all(promises);
7187
7153
  }
7188
7154
  async fetchCaches(ids) {
@@ -11067,30 +11033,14 @@ class TokenController extends TransportController_1.TransportController {
11067
11033
  if (ids.length < 1) {
11068
11034
  return [];
11069
11035
  }
11036
+ // TODO: JSSNMSHDD-2820 (check for items that couldn't be fetched e.g. because it is expired)
11037
+ const resultItems = (await this.client.getTokens({ ids })).value;
11070
11038
  const promises = [];
11071
- for (const id of ids) {
11072
- const result = await this.client.getToken(id);
11073
- if (result.isError) {
11074
- if (result.error.code === "error.transport.recordNotFound" ||
11075
- result.error.code === "error.transport.request.notFound" ||
11076
- result.error.code === "error.platform.recordNotFound") {
11077
- this.log.warn(`Record id ${id} could not be found on backbone. It might be expired.`, result.error);
11078
- continue;
11079
- }
11080
- throw result.error;
11081
- }
11082
- const resultItem = result.value;
11083
- promises.push(this.updateCacheOfExistingTokenInDb(resultItem.id, resultItem));
11084
- }
11085
- /*
11086
- // TODO: Optimize once backbone handling is clarified
11087
- const resultItems = (await this.client.getTokens({ ids })).value
11088
- const promises = []
11089
11039
  for await (const resultItem of resultItems) {
11090
- promises.push(this.updateCacheOfExistingTokenInDb(resultItem.id, resultItem))
11040
+ promises.push(this.updateCacheOfExistingTokenInDb(resultItem.id, resultItem));
11091
11041
  }
11092
- */
11093
- return await Promise.all(promises);
11042
+ const isToken = (item) => !!item;
11043
+ return (await Promise.all(promises)).filter(isToken);
11094
11044
  }
11095
11045
  async fetchCaches(ids) {
11096
11046
  if (ids.length === 0)
@@ -11106,7 +11056,8 @@ class TokenController extends TransportController_1.TransportController {
11106
11056
  async updateCacheOfExistingTokenInDb(id, response) {
11107
11057
  const tokenDoc = await this.tokens.read(id);
11108
11058
  if (!tokenDoc) {
11109
- throw core_1.TransportErrors.general.recordNotFound(Token_1.Token, id).logWith(this._log);
11059
+ core_1.TransportErrors.general.recordNotFound(Token_1.Token, id).logWith(this._log);
11060
+ return;
11110
11061
  }
11111
11062
  const token = await Token_1.Token.from(tokenDoc);
11112
11063
  await this.updateCacheOfToken(token, response);
@@ -11149,7 +11100,16 @@ class TokenController extends TransportController_1.TransportController {
11149
11100
  async loadPeerToken(id, secretKey, ephemeral) {
11150
11101
  const tokenDoc = await this.tokens.read(id.toString());
11151
11102
  if (tokenDoc) {
11152
- return await this.updateCacheOfExistingTokenInDb(id.toString());
11103
+ let token = await Token_1.Token.from(tokenDoc);
11104
+ if (token.cache) {
11105
+ return token;
11106
+ }
11107
+ token = await this.updateCacheOfExistingTokenInDb(id.toString());
11108
+ if (!token) {
11109
+ // This should not happen, we only update the cache if we found the tokenDoc
11110
+ throw new Error(`Tried to update a token (with ID: '${id.toString()}') that doesn't exist in the local database.`);
11111
+ }
11112
+ return token;
11153
11113
  }
11154
11114
  const token = await Token_1.Token.from({
11155
11115
  id: id,
@@ -12081,7 +12041,7 @@ class SimpleLogger {
12081
12041
  if (arg instanceof Error) {
12082
12042
  return (_a = arg.stack) !== null && _a !== void 0 ? _a : `${arg.name}: ${arg.message}`;
12083
12043
  }
12084
- return json_stringify_safe_1.default(arg);
12044
+ return (0, json_stringify_safe_1.default)(arg);
12085
12045
  })
12086
12046
  .join("\n");
12087
12047
  return { msg: message };
@@ -13141,14 +13101,18 @@ function Axios(instanceConfig) {
13141
13101
  *
13142
13102
  * @param {Object} config The config specific for this request (merged with this.defaults)
13143
13103
  */
13144
- Axios.prototype.request = function request(config) {
13104
+ Axios.prototype.request = function request(configOrUrl, config) {
13145
13105
  /*eslint no-param-reassign:0*/
13146
13106
  // Allow for axios('example/url'[, config]) a la fetch API
13147
- if (typeof config === 'string') {
13148
- config = arguments[1] || {};
13149
- config.url = arguments[0];
13150
- } else {
13107
+ if (typeof configOrUrl === 'string') {
13151
13108
  config = config || {};
13109
+ config.url = configOrUrl;
13110
+ } else {
13111
+ config = configOrUrl || {};
13112
+ }
13113
+
13114
+ if (!config.url) {
13115
+ throw new Error('Provided config url is not valid');
13152
13116
  }
13153
13117
 
13154
13118
  config = mergeConfig(this.defaults, config);
@@ -13233,6 +13197,9 @@ Axios.prototype.request = function request(config) {
13233
13197
  };
13234
13198
 
13235
13199
  Axios.prototype.getUri = function getUri(config) {
13200
+ if (!config.url) {
13201
+ throw new Error('Provided config url is not valid');
13202
+ }
13236
13203
  config = mergeConfig(this.defaults, config);
13237
13204
  return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
13238
13205
  };
@@ -13873,7 +13840,7 @@ module.exports = defaults;
13873
13840
  /***/ ((module) => {
13874
13841
 
13875
13842
  module.exports = {
13876
- "version": "0.24.0"
13843
+ "version": "0.25.0"
13877
13844
  };
13878
13845
 
13879
13846
  /***/ }),
@@ -14089,7 +14056,7 @@ module.exports = function isAbsoluteURL(url) {
14089
14056
  // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
14090
14057
  // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
14091
14058
  // by any combination of letters, digits, plus, period, or hyphen.
14092
- return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
14059
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
14093
14060
  };
14094
14061
 
14095
14062
 
@@ -14099,11 +14066,13 @@ module.exports = function isAbsoluteURL(url) {
14099
14066
  /*!********************************************************!*\
14100
14067
  !*** ./node_modules/axios/lib/helpers/isAxiosError.js ***!
14101
14068
  \********************************************************/
14102
- /***/ ((module) => {
14069
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
14103
14070
 
14104
14071
  "use strict";
14105
14072
 
14106
14073
 
14074
+ var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
14075
+
14107
14076
  /**
14108
14077
  * Determines whether the payload is an error thrown by Axios
14109
14078
  *
@@ -14111,7 +14080,7 @@ module.exports = function isAbsoluteURL(url) {
14111
14080
  * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
14112
14081
  */
14113
14082
  module.exports = function isAxiosError(payload) {
14114
- return (typeof payload === 'object') && (payload.isAxiosError === true);
14083
+ return utils.isObject(payload) && (payload.isAxiosError === true);
14115
14084
  };
14116
14085
 
14117
14086
 
@@ -14436,7 +14405,7 @@ var toString = Object.prototype.toString;
14436
14405
  * @returns {boolean} True if value is an Array, otherwise false
14437
14406
  */
14438
14407
  function isArray(val) {
14439
- return toString.call(val) === '[object Array]';
14408
+ return Array.isArray(val);
14440
14409
  }
14441
14410
 
14442
14411
  /**
@@ -14477,7 +14446,7 @@ function isArrayBuffer(val) {
14477
14446
  * @returns {boolean} True if value is an FormData, otherwise false
14478
14447
  */
14479
14448
  function isFormData(val) {
14480
- return (typeof FormData !== 'undefined') && (val instanceof FormData);
14449
+ return toString.call(val) === '[object FormData]';
14481
14450
  }
14482
14451
 
14483
14452
  /**
@@ -14491,7 +14460,7 @@ function isArrayBufferView(val) {
14491
14460
  if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
14492
14461
  result = ArrayBuffer.isView(val);
14493
14462
  } else {
14494
- result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
14463
+ result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
14495
14464
  }
14496
14465
  return result;
14497
14466
  }
@@ -14598,7 +14567,7 @@ function isStream(val) {
14598
14567
  * @returns {boolean} True if value is a URLSearchParams object, otherwise false
14599
14568
  */
14600
14569
  function isURLSearchParams(val) {
14601
- return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
14570
+ return toString.call(val) === '[object URLSearchParams]';
14602
14571
  }
14603
14572
 
14604
14573
  /**
@@ -35011,17 +34980,16 @@ function padStart(input, n) {
35011
34980
  n = 2;
35012
34981
  }
35013
34982
 
35014
- var minus = input < 0 ? "-" : "";
35015
- var target = minus ? input * -1 : input;
35016
- var result;
34983
+ var isNeg = input < 0;
34984
+ var padded;
35017
34985
 
35018
- if (target.toString().length < n) {
35019
- result = ("0".repeat(n) + target).slice(-n);
34986
+ if (isNeg) {
34987
+ padded = "-" + ("" + -input).padStart(n, "0");
35020
34988
  } else {
35021
- result = target.toString();
34989
+ padded = ("" + input).padStart(n, "0");
35022
34990
  }
35023
34991
 
35024
- return "" + minus + result;
34992
+ return padded;
35025
34993
  }
35026
34994
  function parseInteger(string) {
35027
34995
  if (isUndefined(string) || string === null || string === "") {
@@ -36643,7 +36611,27 @@ var Settings = /*#__PURE__*/function () {
36643
36611
  return Settings;
36644
36612
  }();
36645
36613
 
36646
- var _excluded = ["base"];
36614
+ var _excluded = ["base"],
36615
+ _excluded2 = ["padTo", "floor"];
36616
+
36617
+ var intlLFCache = {};
36618
+
36619
+ function getCachedLF(locString, opts) {
36620
+ if (opts === void 0) {
36621
+ opts = {};
36622
+ }
36623
+
36624
+ var key = JSON.stringify([locString, opts]);
36625
+ var dtf = intlLFCache[key];
36626
+
36627
+ if (!dtf) {
36628
+ dtf = new Intl.ListFormat(locString, opts);
36629
+ intlLFCache[key] = dtf;
36630
+ }
36631
+
36632
+ return dtf;
36633
+ }
36634
+
36647
36635
  var intlDTCache = {};
36648
36636
 
36649
36637
  function getCachedDTF(locString, opts) {
@@ -36812,10 +36800,15 @@ var PolyNumberFormatter = /*#__PURE__*/function () {
36812
36800
  this.padTo = opts.padTo || 0;
36813
36801
  this.floor = opts.floor || false;
36814
36802
 
36815
- if (!forceSimple) {
36816
- var intlOpts = {
36803
+ opts.padTo;
36804
+ opts.floor;
36805
+ var otherOpts = _objectWithoutPropertiesLoose(opts, _excluded2);
36806
+
36807
+ if (!forceSimple || Object.keys(otherOpts).length > 0) {
36808
+ var intlOpts = _extends({
36817
36809
  useGrouping: false
36818
- };
36810
+ }, opts);
36811
+
36819
36812
  if (opts.padTo > 0) intlOpts.minimumIntegerDigits = opts.padTo;
36820
36813
  this.inf = getCachedINF(intl, intlOpts);
36821
36814
  }
@@ -37009,8 +37002,7 @@ var Locale = /*#__PURE__*/function () {
37009
37002
 
37010
37003
  var _proto4 = Locale.prototype;
37011
37004
 
37012
- _proto4.listingMode = function listingMode(defaultOK) {
37013
-
37005
+ _proto4.listingMode = function listingMode() {
37014
37006
  var isActuallyEn = this.isEnglish();
37015
37007
  var hasNoWeirdness = (this.numberingSystem === null || this.numberingSystem === "latn") && (this.outputCalendar === null || this.outputCalendar === "gregory");
37016
37008
  return isActuallyEn && hasNoWeirdness ? "en" : "intl";
@@ -37190,6 +37182,14 @@ var Locale = /*#__PURE__*/function () {
37190
37182
  return new PolyRelFormatter(this.intl, this.isEnglish(), opts);
37191
37183
  };
37192
37184
 
37185
+ _proto4.listFormatter = function listFormatter(opts) {
37186
+ if (opts === void 0) {
37187
+ opts = {};
37188
+ }
37189
+
37190
+ return getCachedLF(this.intl, opts);
37191
+ };
37192
+
37193
37193
  _proto4.isEnglish = function isEnglish() {
37194
37194
  return this.locale === "en" || this.locale.toLowerCase() === "en-us" || new Intl.DateTimeFormat(this.intl).resolvedOptions().locale.startsWith("en-us");
37195
37195
  };
@@ -37935,6 +37935,48 @@ var Duration = /*#__PURE__*/function () {
37935
37935
 
37936
37936
  return this.isValid ? Formatter.create(this.loc, fmtOpts).formatDurationFromString(this, fmt) : INVALID$2;
37937
37937
  }
37938
+ /**
37939
+ * Returns a string representation of a Duration with all units included
37940
+ * To modify its behavior use the `listStyle` and any Intl.NumberFormat option, though `unitDisplay` is especially relevant. See {@link Intl.NumberFormat}.
37941
+ * @param opts - On option object to override the formatting. Accepts the same keys as the options parameter of the native `Int.NumberFormat` constructor, as well as `listStyle`.
37942
+ * @example
37943
+ * ```js
37944
+ * var dur = Duration.fromObject({ days: 1, hours: 5, minutes: 6 })
37945
+ * dur.toHuman() //=> '1 day, 5 hours, 6 minutes'
37946
+ * dur.toHuman({ listStyle: "long" }) //=> '1 day, 5 hours, and 6 minutes'
37947
+ * dur.toHuman({ unitDisplay: "short" }) //=> '1 day, 5 hr, 6 min'
37948
+ * ```
37949
+ */
37950
+ ;
37951
+
37952
+ _proto.toHuman = function toHuman(opts) {
37953
+ var _this = this;
37954
+
37955
+ if (opts === void 0) {
37956
+ opts = {};
37957
+ }
37958
+
37959
+ var l = orderedUnits$1.map(function (unit) {
37960
+ var val = _this.values[unit];
37961
+
37962
+ if (isUndefined(val)) {
37963
+ return null;
37964
+ }
37965
+
37966
+ return _this.loc.numberFormatter(_extends({
37967
+ style: "unit",
37968
+ unitDisplay: "long"
37969
+ }, opts, {
37970
+ unit: unit.slice(0, -1)
37971
+ })).format(val);
37972
+ }).filter(function (n) {
37973
+ return n;
37974
+ });
37975
+ return this.loc.listFormatter(_extends({
37976
+ type: "conjunction",
37977
+ style: opts.listStyle || "narrow"
37978
+ }, opts)).format(l);
37979
+ }
37938
37980
  /**
37939
37981
  * Returns a JavaScript object with this Duration's values.
37940
37982
  * @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toObject() //=> { years: 1, days: 6, seconds: 2 }
@@ -40472,51 +40514,67 @@ function toTechFormat(dt, format, allowZ) {
40472
40514
  allowZ: allowZ,
40473
40515
  forceSimple: true
40474
40516
  }).formatDateTimeFromString(dt, format) : null;
40475
- } // technical time formats (e.g. the time part of ISO 8601), take some options
40476
- // and this commonizes their handling
40517
+ }
40518
+
40519
+ function _toISODate(o, extended) {
40520
+ var longFormat = o.c.year > 9999 || o.c.year < 0;
40521
+ var c = "";
40522
+ if (longFormat && o.c.year >= 0) c += "+";
40523
+ c += padStart(o.c.year, longFormat ? 6 : 4);
40524
+
40525
+ if (extended) {
40526
+ c += "-";
40527
+ c += padStart(o.c.month);
40528
+ c += "-";
40529
+ c += padStart(o.c.day);
40530
+ } else {
40531
+ c += padStart(o.c.month);
40532
+ c += padStart(o.c.day);
40533
+ }
40477
40534
 
40535
+ return c;
40536
+ }
40478
40537
 
40479
- function toTechTimeFormat(dt, _ref) {
40480
- var _ref$suppressSeconds = _ref.suppressSeconds,
40481
- suppressSeconds = _ref$suppressSeconds === void 0 ? false : _ref$suppressSeconds,
40482
- _ref$suppressMillisec = _ref.suppressMilliseconds,
40483
- suppressMilliseconds = _ref$suppressMillisec === void 0 ? false : _ref$suppressMillisec,
40484
- includeOffset = _ref.includeOffset,
40485
- _ref$includePrefix = _ref.includePrefix,
40486
- includePrefix = _ref$includePrefix === void 0 ? false : _ref$includePrefix,
40487
- _ref$includeZone = _ref.includeZone,
40488
- includeZone = _ref$includeZone === void 0 ? false : _ref$includeZone,
40489
- _ref$spaceZone = _ref.spaceZone,
40490
- spaceZone = _ref$spaceZone === void 0 ? false : _ref$spaceZone,
40491
- _ref$format = _ref.format,
40492
- format = _ref$format === void 0 ? "extended" : _ref$format;
40493
- var fmt = format === "basic" ? "HHmm" : "HH:mm";
40538
+ function _toISOTime(o, extended, suppressSeconds, suppressMilliseconds, includeOffset) {
40539
+ var c = padStart(o.c.hour);
40494
40540
 
40495
- if (!suppressSeconds || dt.second !== 0 || dt.millisecond !== 0) {
40496
- fmt += format === "basic" ? "ss" : ":ss";
40541
+ if (extended) {
40542
+ c += ":";
40543
+ c += padStart(o.c.minute);
40497
40544
 
40498
- if (!suppressMilliseconds || dt.millisecond !== 0) {
40499
- fmt += ".SSS";
40545
+ if (o.c.second !== 0 || !suppressSeconds) {
40546
+ c += ":";
40500
40547
  }
40548
+ } else {
40549
+ c += padStart(o.c.minute);
40501
40550
  }
40502
40551
 
40503
- if ((includeZone || includeOffset) && spaceZone) {
40504
- fmt += " ";
40505
- }
40552
+ if (o.c.second !== 0 || !suppressSeconds) {
40553
+ c += padStart(o.c.second);
40506
40554
 
40507
- if (includeZone) {
40508
- fmt += "z";
40509
- } else if (includeOffset) {
40510
- fmt += format === "basic" ? "ZZZ" : "ZZ";
40555
+ if (o.c.millisecond !== 0 || !suppressMilliseconds) {
40556
+ c += ".";
40557
+ c += padStart(o.c.millisecond, 3);
40558
+ }
40511
40559
  }
40512
40560
 
40513
- var str = toTechFormat(dt, fmt);
40514
-
40515
- if (includePrefix) {
40516
- str = "T" + str;
40561
+ if (includeOffset) {
40562
+ if (o.isOffsetFixed && o.offset === 0) {
40563
+ c += "Z";
40564
+ } else if (o.o < 0) {
40565
+ c += "-";
40566
+ c += padStart(Math.trunc(-o.o / 60));
40567
+ c += ":";
40568
+ c += padStart(Math.trunc(-o.o % 60));
40569
+ } else {
40570
+ c += "+";
40571
+ c += padStart(Math.trunc(o.o / 60));
40572
+ c += ":";
40573
+ c += padStart(Math.trunc(o.o % 60));
40574
+ }
40517
40575
  }
40518
40576
 
40519
- return str;
40577
+ return c;
40520
40578
  } // defaults for unspecified units in the supported calendars
40521
40579
 
40522
40580
 
@@ -40711,9 +40769,9 @@ var DateTime = /*#__PURE__*/function () {
40711
40769
  var unchanged = config.old && config.old.ts === this.ts && config.old.zone.equals(zone);
40712
40770
 
40713
40771
  if (unchanged) {
40714
- var _ref2 = [config.old.c, config.old.o];
40715
- c = _ref2[0];
40716
- o = _ref2[1];
40772
+ var _ref = [config.old.c, config.old.o];
40773
+ c = _ref[0];
40774
+ o = _ref[1];
40717
40775
  } else {
40718
40776
  var ot = zone.offset(this.ts);
40719
40777
  c = tsToObj(this.ts, ot);
@@ -41383,11 +41441,11 @@ var DateTime = /*#__PURE__*/function () {
41383
41441
  ;
41384
41442
 
41385
41443
  _proto.setZone = function setZone(zone, _temp) {
41386
- var _ref3 = _temp === void 0 ? {} : _temp,
41387
- _ref3$keepLocalTime = _ref3.keepLocalTime,
41388
- keepLocalTime = _ref3$keepLocalTime === void 0 ? false : _ref3$keepLocalTime,
41389
- _ref3$keepCalendarTim = _ref3.keepCalendarTime,
41390
- keepCalendarTime = _ref3$keepCalendarTim === void 0 ? false : _ref3$keepCalendarTim;
41444
+ var _ref2 = _temp === void 0 ? {} : _temp,
41445
+ _ref2$keepLocalTime = _ref2.keepLocalTime,
41446
+ keepLocalTime = _ref2$keepLocalTime === void 0 ? false : _ref2$keepLocalTime,
41447
+ _ref2$keepCalendarTim = _ref2.keepCalendarTime,
41448
+ keepCalendarTime = _ref2$keepCalendarTim === void 0 ? false : _ref2$keepCalendarTim;
41391
41449
 
41392
41450
  zone = normalizeZone(zone, Settings.defaultZone);
41393
41451
 
@@ -41422,10 +41480,10 @@ var DateTime = /*#__PURE__*/function () {
41422
41480
  ;
41423
41481
 
41424
41482
  _proto.reconfigure = function reconfigure(_temp2) {
41425
- var _ref4 = _temp2 === void 0 ? {} : _temp2,
41426
- locale = _ref4.locale,
41427
- numberingSystem = _ref4.numberingSystem,
41428
- outputCalendar = _ref4.outputCalendar;
41483
+ var _ref3 = _temp2 === void 0 ? {} : _temp2,
41484
+ locale = _ref3.locale,
41485
+ numberingSystem = _ref3.numberingSystem,
41486
+ outputCalendar = _ref3.outputCalendar;
41429
41487
 
41430
41488
  var loc = this.loc.clone({
41431
41489
  locale: locale,
@@ -41528,7 +41586,7 @@ var DateTime = /*#__PURE__*/function () {
41528
41586
  * See {@link DateTime#plus}
41529
41587
  * @param {Duration|Object|number} duration - The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
41530
41588
  @return {DateTime}
41531
- */
41589
+ */
41532
41590
  ;
41533
41591
 
41534
41592
  _proto.minus = function minus(duration) {
@@ -41693,7 +41751,7 @@ var DateTime = /*#__PURE__*/function () {
41693
41751
  * @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0
41694
41752
  * @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
41695
41753
  * @param {string} [opts.format='extended'] - choose between the basic and extended format
41696
- * @example DateTime.utc(1982, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z'
41754
+ * @example DateTime.utc(1983, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z'
41697
41755
  * @example DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00'
41698
41756
  * @example DateTime.now().toISO({ includeOffset: false }) //=> '2017-04-22T20:47:05.335'
41699
41757
  * @example DateTime.now().toISO({ format: 'basic' }) //=> '20170422T204705.335-0400'
@@ -41701,16 +41759,28 @@ var DateTime = /*#__PURE__*/function () {
41701
41759
  */
41702
41760
  ;
41703
41761
 
41704
- _proto.toISO = function toISO(opts) {
41705
- if (opts === void 0) {
41706
- opts = {};
41707
- }
41762
+ _proto.toISO = function toISO(_temp3) {
41763
+ var _ref4 = _temp3 === void 0 ? {} : _temp3,
41764
+ _ref4$format = _ref4.format,
41765
+ format = _ref4$format === void 0 ? "extended" : _ref4$format,
41766
+ _ref4$suppressSeconds = _ref4.suppressSeconds,
41767
+ suppressSeconds = _ref4$suppressSeconds === void 0 ? false : _ref4$suppressSeconds,
41768
+ _ref4$suppressMillise = _ref4.suppressMilliseconds,
41769
+ suppressMilliseconds = _ref4$suppressMillise === void 0 ? false : _ref4$suppressMillise,
41770
+ _ref4$includeOffset = _ref4.includeOffset,
41771
+ includeOffset = _ref4$includeOffset === void 0 ? true : _ref4$includeOffset;
41708
41772
 
41709
41773
  if (!this.isValid) {
41710
41774
  return null;
41711
41775
  }
41712
41776
 
41713
- return this.toISODate(opts) + "T" + this.toISOTime(opts);
41777
+ var ext = format === "extended";
41778
+
41779
+ var c = _toISODate(this, ext);
41780
+
41781
+ c += "T";
41782
+ c += _toISOTime(this, ext, suppressSeconds, suppressMilliseconds, includeOffset);
41783
+ return c;
41714
41784
  }
41715
41785
  /**
41716
41786
  * Returns an ISO 8601-compliant string representation of this DateTime's date component
@@ -41722,18 +41792,16 @@ var DateTime = /*#__PURE__*/function () {
41722
41792
  */
41723
41793
  ;
41724
41794
 
41725
- _proto.toISODate = function toISODate(_temp3) {
41726
- var _ref5 = _temp3 === void 0 ? {} : _temp3,
41795
+ _proto.toISODate = function toISODate(_temp4) {
41796
+ var _ref5 = _temp4 === void 0 ? {} : _temp4,
41727
41797
  _ref5$format = _ref5.format,
41728
41798
  format = _ref5$format === void 0 ? "extended" : _ref5$format;
41729
41799
 
41730
- var fmt = format === "basic" ? "yyyyMMdd" : "yyyy-MM-dd";
41731
-
41732
- if (this.year > 9999) {
41733
- fmt = "+" + fmt;
41800
+ if (!this.isValid) {
41801
+ return null;
41734
41802
  }
41735
41803
 
41736
- return toTechFormat(this, fmt);
41804
+ return _toISODate(this, format === "extended");
41737
41805
  }
41738
41806
  /**
41739
41807
  * Returns an ISO 8601-compliant string representation of this DateTime's week date
@@ -41761,8 +41829,8 @@ var DateTime = /*#__PURE__*/function () {
41761
41829
  */
41762
41830
  ;
41763
41831
 
41764
- _proto.toISOTime = function toISOTime(_temp4) {
41765
- var _ref6 = _temp4 === void 0 ? {} : _temp4,
41832
+ _proto.toISOTime = function toISOTime(_temp5) {
41833
+ var _ref6 = _temp5 === void 0 ? {} : _temp5,
41766
41834
  _ref6$suppressMillise = _ref6.suppressMilliseconds,
41767
41835
  suppressMilliseconds = _ref6$suppressMillise === void 0 ? false : _ref6$suppressMillise,
41768
41836
  _ref6$suppressSeconds = _ref6.suppressSeconds,
@@ -41774,16 +41842,15 @@ var DateTime = /*#__PURE__*/function () {
41774
41842
  _ref6$format = _ref6.format,
41775
41843
  format = _ref6$format === void 0 ? "extended" : _ref6$format;
41776
41844
 
41777
- return toTechTimeFormat(this, {
41778
- suppressSeconds: suppressSeconds,
41779
- suppressMilliseconds: suppressMilliseconds,
41780
- includeOffset: includeOffset,
41781
- includePrefix: includePrefix,
41782
- format: format
41783
- });
41845
+ if (!this.isValid) {
41846
+ return null;
41847
+ }
41848
+
41849
+ var c = includePrefix ? "T" : "";
41850
+ return c + _toISOTime(this, format === "extended", suppressSeconds, suppressMilliseconds, includeOffset);
41784
41851
  }
41785
41852
  /**
41786
- * Returns an RFC 2822-compatible string representation of this DateTime, always in UTC
41853
+ * Returns an RFC 2822-compatible string representation of this DateTime
41787
41854
  * @example DateTime.utc(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 +0000'
41788
41855
  * @example DateTime.local(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 -0400'
41789
41856
  * @return {string}
@@ -41794,7 +41861,7 @@ var DateTime = /*#__PURE__*/function () {
41794
41861
  return toTechFormat(this, "EEE, dd LLL yyyy HH:mm:ss ZZZ", false);
41795
41862
  }
41796
41863
  /**
41797
- * Returns a string representation of this DateTime appropriate for use in HTTP headers.
41864
+ * Returns a string representation of this DateTime appropriate for use in HTTP headers. The output is always expressed in GMT.
41798
41865
  * Specifically, the string conforms to RFC 1123.
41799
41866
  * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
41800
41867
  * @example DateTime.utc(2014, 7, 13).toHTTP() //=> 'Sun, 13 Jul 2014 00:00:00 GMT'
@@ -41814,7 +41881,11 @@ var DateTime = /*#__PURE__*/function () {
41814
41881
  ;
41815
41882
 
41816
41883
  _proto.toSQLDate = function toSQLDate() {
41817
- return toTechFormat(this, "yyyy-MM-dd");
41884
+ if (!this.isValid) {
41885
+ return null;
41886
+ }
41887
+
41888
+ return _toISODate(this, true);
41818
41889
  }
41819
41890
  /**
41820
41891
  * Returns a string representation of this DateTime appropriate for use in SQL Time
@@ -41829,18 +41900,26 @@ var DateTime = /*#__PURE__*/function () {
41829
41900
  */
41830
41901
  ;
41831
41902
 
41832
- _proto.toSQLTime = function toSQLTime(_temp5) {
41833
- var _ref7 = _temp5 === void 0 ? {} : _temp5,
41903
+ _proto.toSQLTime = function toSQLTime(_temp6) {
41904
+ var _ref7 = _temp6 === void 0 ? {} : _temp6,
41834
41905
  _ref7$includeOffset = _ref7.includeOffset,
41835
41906
  includeOffset = _ref7$includeOffset === void 0 ? true : _ref7$includeOffset,
41836
41907
  _ref7$includeZone = _ref7.includeZone,
41837
41908
  includeZone = _ref7$includeZone === void 0 ? false : _ref7$includeZone;
41838
41909
 
41839
- return toTechTimeFormat(this, {
41840
- includeOffset: includeOffset,
41841
- includeZone: includeZone,
41842
- spaceZone: true
41843
- });
41910
+ var fmt = "HH:mm:ss.SSS";
41911
+
41912
+ if (includeZone || includeOffset) {
41913
+ fmt += " ";
41914
+
41915
+ if (includeZone) {
41916
+ fmt += "z";
41917
+ } else if (includeOffset) {
41918
+ fmt += "ZZ";
41919
+ }
41920
+ }
41921
+
41922
+ return toTechFormat(this, fmt, true);
41844
41923
  }
41845
41924
  /**
41846
41925
  * Returns a string representation of this DateTime appropriate for use in SQL DateTime
@@ -42044,10 +42123,10 @@ var DateTime = /*#__PURE__*/function () {
42044
42123
  _proto.hasSame = function hasSame(otherDateTime, unit) {
42045
42124
  if (!this.isValid) return false;
42046
42125
  var inputMs = otherDateTime.valueOf();
42047
- var otherZoneDateTime = this.setZone(otherDateTime.zone, {
42126
+ var adjustedToZone = this.setZone(otherDateTime.zone, {
42048
42127
  keepLocalTime: true
42049
42128
  });
42050
- return otherZoneDateTime.startOf(unit) <= inputMs && inputMs <= otherZoneDateTime.endOf(unit);
42129
+ return adjustedToZone.startOf(unit) <= inputMs && inputMs <= adjustedToZone.endOf(unit);
42051
42130
  }
42052
42131
  /**
42053
42132
  * Equality check
@@ -42846,7 +42925,7 @@ function friendlyDateTime(dateTimeish) {
42846
42925
  }
42847
42926
  }
42848
42927
 
42849
- var VERSION = "2.2.0";
42928
+ var VERSION = "2.3.0";
42850
42929
 
42851
42930
  exports.DateTime = DateTime;
42852
42931
  exports.Duration = Duration;
@@ -43543,7 +43622,7 @@ var parseObject = function (chain, val, options, valuesParsed) {
43543
43622
  ) {
43544
43623
  obj = [];
43545
43624
  obj[index] = leaf;
43546
- } else {
43625
+ } else if (cleanRoot !== '__proto__') {
43547
43626
  obj[cleanRoot] = leaf;
43548
43627
  }
43549
43628
  }
@@ -43761,7 +43840,7 @@ var stringify = function stringify(
43761
43840
  var tmpSc = sideChannel;
43762
43841
  var step = 0;
43763
43842
  var findFlag = false;
43764
- while ((tmpSc = tmpSc.get(sentinel)) !== undefined && !findFlag) {
43843
+ while ((tmpSc = tmpSc.get(sentinel)) !== void undefined && !findFlag) {
43765
43844
  // Where object last appeared in the ref tree
43766
43845
  var pos = tmpSc.get(object);
43767
43846
  step += 1;
@@ -43823,7 +43902,7 @@ var stringify = function stringify(
43823
43902
  var objKeys;
43824
43903
  if (generateArrayPrefix === 'comma' && isArray(obj)) {
43825
43904
  // we need to join elements in
43826
- objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : undefined }];
43905
+ objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : void undefined }];
43827
43906
  } else if (isArray(filter)) {
43828
43907
  objKeys = filter;
43829
43908
  } else {
@@ -43833,7 +43912,7 @@ var stringify = function stringify(
43833
43912
 
43834
43913
  for (var j = 0; j < objKeys.length; ++j) {
43835
43914
  var key = objKeys[j];
43836
- var value = typeof key === 'object' && key.value !== undefined ? key.value : obj[key];
43915
+ var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];
43837
43916
 
43838
43917
  if (skipNulls && value === null) {
43839
43918
  continue;
@@ -43873,7 +43952,7 @@ var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
43873
43952
  return defaults;
43874
43953
  }
43875
43954
 
43876
- if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') {
43955
+ if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') {
43877
43956
  throw new TypeError('Encoder has to be a function.');
43878
43957
  }
43879
43958