@nmshd/content 2.3.2 → 2.3.4

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.
@@ -301,6 +301,79 @@ var AttributeValues;
301
301
 
302
302
  /***/ }),
303
303
 
304
+ /***/ "./dist/attributes/IQLQuery.js":
305
+ /*!*************************************!*\
306
+ !*** ./dist/attributes/IQLQuery.js ***!
307
+ \*************************************/
308
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
309
+
310
+
311
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
312
+ if (k2 === undefined) k2 = k;
313
+ var desc = Object.getOwnPropertyDescriptor(m, k);
314
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
315
+ desc = { enumerable: true, get: function() { return m[k]; } };
316
+ }
317
+ Object.defineProperty(o, k2, desc);
318
+ }) : (function(o, m, k, k2) {
319
+ if (k2 === undefined) k2 = k;
320
+ o[k2] = m[k];
321
+ }));
322
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
323
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
324
+ }) : function(o, v) {
325
+ o["default"] = v;
326
+ });
327
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
328
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
329
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
330
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
331
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
332
+ };
333
+ var __importStar = (this && this.__importStar) || function (mod) {
334
+ if (mod && mod.__esModule) return mod;
335
+ var result = {};
336
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
337
+ __setModuleDefault(result, mod);
338
+ return result;
339
+ };
340
+ var __metadata = (this && this.__metadata) || function (k, v) {
341
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
342
+ };
343
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
344
+ exports.IQLQuery = void 0;
345
+ const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
346
+ const Iql = __importStar(__webpack_require__(/*! @nmshd/iql */ "./node_modules/@nmshd/iql/dist/src/index.js"));
347
+ const AbstractAttributeQuery_1 = __webpack_require__(/*! ./AbstractAttributeQuery */ "./dist/attributes/AbstractAttributeQuery.js");
348
+ let IQLQuery = class IQLQuery extends AbstractAttributeQuery_1.AbstractAttributeQuery {
349
+ static from(value) {
350
+ return this.fromAny(value);
351
+ }
352
+ toJSON(verbose, serializeAsString) {
353
+ return super.toJSON(verbose, serializeAsString);
354
+ }
355
+ };
356
+ __decorate([
357
+ (0, ts_serval_1.serialize)(),
358
+ (0, ts_serval_1.validate)({
359
+ max: 4096,
360
+ customValidator: (v) => {
361
+ const result = Iql.validate(v);
362
+ return !result.isValid
363
+ ? `invalid IQL query at character offset ${result.error?.location.start.column}`
364
+ : undefined;
365
+ }
366
+ }),
367
+ __metadata("design:type", String)
368
+ ], IQLQuery.prototype, "queryString", void 0);
369
+ IQLQuery = __decorate([
370
+ (0, ts_serval_1.type)("IQLQuery")
371
+ ], IQLQuery);
372
+ exports.IQLQuery = IQLQuery;
373
+ //# sourceMappingURL=IQLQuery.js.map
374
+
375
+ /***/ }),
376
+
304
377
  /***/ "./dist/attributes/IdentityAttribute.js":
305
378
  /*!**********************************************!*\
306
379
  !*** ./dist/attributes/IdentityAttribute.js ***!
@@ -2120,14 +2193,15 @@ __exportStar(__webpack_require__(/*! ./AbstractAttributeQuery */ "./dist/attribu
2120
2193
  __exportStar(__webpack_require__(/*! ./AbstractAttributeValue */ "./dist/attributes/AbstractAttributeValue.js"), exports);
2121
2194
  __exportStar(__webpack_require__(/*! ./AbstractComplexValue */ "./dist/attributes/AbstractComplexValue.js"), exports);
2122
2195
  __exportStar(__webpack_require__(/*! ./AttributeValueTypes */ "./dist/attributes/AttributeValueTypes.js"), exports);
2123
- __exportStar(__webpack_require__(/*! ./constants */ "./dist/attributes/constants/index.js"), exports);
2124
- __exportStar(__webpack_require__(/*! ./hints */ "./dist/attributes/hints/index.js"), exports);
2196
+ __exportStar(__webpack_require__(/*! ./IQLQuery */ "./dist/attributes/IQLQuery.js"), exports);
2125
2197
  __exportStar(__webpack_require__(/*! ./IdentityAttribute */ "./dist/attributes/IdentityAttribute.js"), exports);
2126
2198
  __exportStar(__webpack_require__(/*! ./IdentityAttributeQuery */ "./dist/attributes/IdentityAttributeQuery.js"), exports);
2127
2199
  __exportStar(__webpack_require__(/*! ./RelationshipAttribute */ "./dist/attributes/RelationshipAttribute.js"), exports);
2128
2200
  __exportStar(__webpack_require__(/*! ./RelationshipAttributeConfidentiality */ "./dist/attributes/RelationshipAttributeConfidentiality.js"), exports);
2129
2201
  __exportStar(__webpack_require__(/*! ./RelationshipAttributeQuery */ "./dist/attributes/RelationshipAttributeQuery.js"), exports);
2130
2202
  __exportStar(__webpack_require__(/*! ./ThirdPartyRelationshipAttributeQuery */ "./dist/attributes/ThirdPartyRelationshipAttributeQuery.js"), exports);
2203
+ __exportStar(__webpack_require__(/*! ./constants */ "./dist/attributes/constants/index.js"), exports);
2204
+ __exportStar(__webpack_require__(/*! ./hints */ "./dist/attributes/hints/index.js"), exports);
2131
2205
  __exportStar(__webpack_require__(/*! ./types */ "./dist/attributes/types/index.js"), exports);
2132
2206
  //# sourceMappingURL=index.js.map
2133
2207
 
@@ -6147,11 +6221,11 @@ const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-s
6147
6221
  const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
6148
6222
  const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
6149
6223
  exports.buildInformation = {
6150
- version: "2.3.2",
6151
- build: "131",
6152
- date: "2023-03-10T13:12:31+00:00",
6153
- commit: "f4019fec7c50631a3418f2ea9726f2b915adc020",
6154
- dependencies: {"@js-soft/logging-abstractions":"^1.0.0","easy-tsnameof":"^3.0.6","mocha-param":"^2.0.1"},
6224
+ version: "2.3.4",
6225
+ build: "133",
6226
+ date: "2023-07-11T09:29:28+00:00",
6227
+ commit: "a49345a45fb570dad40eff05c82ebbeebec6cdfe",
6228
+ dependencies: {"@js-soft/logging-abstractions":"^1.0.0","@nmshd/iql":"^0.0.1","easy-tsnameof":"^3.0.6","mocha-param":"^2.0.1"},
6155
6229
  libraries: {
6156
6230
  serval: ts_serval_1.buildInformation,
6157
6231
  crypto: crypto_1.buildInformation,
@@ -6959,11 +7033,13 @@ let ProposeAttributeRequestItem = ProposeAttributeRequestItem_1 = class ProposeA
6959
7033
  throw new ts_serval_1.ValidationError(ProposeAttributeRequestItem_1.name, `${(0, ts_simple_nameof_1.nameof)((x) => x.query)}.${(0, ts_simple_nameof_1.nameof)((x) => x.valueType)}`, `You cannot propose an Attribute whose type of the value ('${attributeValueType}') is different from the value type of the query ('${queryValueType}').`);
6960
7034
  }
6961
7035
  }
7036
+ // IQL queries might also be possible for Relationship Attributes in the future
6962
7037
  if (value.attribute instanceof attributes_1.RelationshipAttribute && !(value.query instanceof attributes_1.RelationshipAttributeQuery)) {
6963
7038
  throw new ts_serval_1.ValidationError(ProposeAttributeRequestItem_1.name, "", "When proposing a RelationshipAttribute, the corresponding query has to be a RelationshipAttributeQuery.");
6964
7039
  }
6965
- if (value.attribute instanceof attributes_1.IdentityAttribute && !(value.query instanceof attributes_1.IdentityAttributeQuery)) {
6966
- throw new ts_serval_1.ValidationError(ProposeAttributeRequestItem_1.name, "", "When proposing an IdentityAttribute, the corresponding query has to be a IdentityAttributeQuery.");
7040
+ if (value.attribute instanceof attributes_1.IdentityAttribute &&
7041
+ !(value.query instanceof attributes_1.IdentityAttributeQuery || value.query instanceof attributes_1.IQLQuery)) {
7042
+ throw new ts_serval_1.ValidationError(ProposeAttributeRequestItem_1.name, "", "When proposing an IdentityAttribute, the corresponding query has to be a IdentityAttributeQuery or IQLQuery");
6967
7043
  }
6968
7044
  return value;
6969
7045
  }
@@ -6972,7 +7048,7 @@ let ProposeAttributeRequestItem = ProposeAttributeRequestItem_1 = class ProposeA
6972
7048
  }
6973
7049
  };
6974
7050
  __decorate([
6975
- (0, ts_serval_1.serialize)({ unionTypes: [attributes_1.IdentityAttributeQuery, attributes_1.RelationshipAttributeQuery] }),
7051
+ (0, ts_serval_1.serialize)({ unionTypes: [attributes_1.IdentityAttributeQuery, attributes_1.RelationshipAttributeQuery, attributes_1.IQLQuery] }),
6976
7052
  (0, ts_serval_1.validate)(),
6977
7053
  __metadata("design:type", Object)
6978
7054
  ], ProposeAttributeRequestItem.prototype, "query", void 0);
@@ -7065,7 +7141,7 @@ let ReadAttributeRequestItem = class ReadAttributeRequestItem extends RequestIte
7065
7141
  };
7066
7142
  __decorate([
7067
7143
  (0, ts_serval_1.serialize)({
7068
- unionTypes: [attributes_1.IdentityAttributeQuery, attributes_1.RelationshipAttributeQuery, attributes_1.ThirdPartyRelationshipAttributeQuery]
7144
+ unionTypes: [attributes_1.IdentityAttributeQuery, attributes_1.RelationshipAttributeQuery, attributes_1.ThirdPartyRelationshipAttributeQuery, attributes_1.IQLQuery]
7069
7145
  }),
7070
7146
  (0, ts_serval_1.validate)(),
7071
7147
  __metadata("design:type", Object)
@@ -7678,6 +7754,1572 @@ __exportStar(__webpack_require__(/*! ./ResponseItemResult */ "./dist/requests/re
7678
7754
 
7679
7755
  /***/ }),
7680
7756
 
7757
+ /***/ "./node_modules/@nmshd/iql/dist/generated/iql.js":
7758
+ /*!*******************************************************!*\
7759
+ !*** ./node_modules/@nmshd/iql/dist/generated/iql.js ***!
7760
+ \*******************************************************/
7761
+ /***/ ((module) => {
7762
+
7763
+ // Generated by Peggy 3.0.2.
7764
+ //
7765
+ // https://peggyjs.org/
7766
+
7767
+ /**
7768
+ * Takes the path through a nested dict as an array of strings and returns
7769
+ * the value, or a fallback value, if the path does not exist.
7770
+ */
7771
+ function resolvePath(dict, path, fallback = null) {
7772
+ let val = dict;
7773
+ for (const e of path) {
7774
+ if (!Object.keys(val).includes(e)) {
7775
+ return fallback;
7776
+ }
7777
+ val = val[e];
7778
+ }
7779
+ return val;
7780
+ }
7781
+ /**
7782
+ * Generic matching function for attributes.
7783
+ *
7784
+ * attributes: Array of attributes
7785
+ * path: Path to data field to apply matchFn to, represented as an
7786
+ * array of strings. E.g. Foo.bar.baz is represented as ["Foo",
7787
+ * "bar", "baz"].
7788
+ * matchFn: Predicate function applied to the value of the extracted
7789
+ * attribute data field represented by 'path'.
7790
+ * attributeType: See comment below.
7791
+ */
7792
+ function match(attributes, path, matchFn, attributeType = undefined) {
7793
+ const indices = [];
7794
+ for (let ii = 0; ii < attributes.length; ii++) {
7795
+ const val = resolvePath(attributes[ii], path, null);
7796
+ // If attributeType is defined, assert that it matches the attribute's
7797
+ // type. When matching primary fields the mechanism presented by matchFn
7798
+ // below is insufficient as it's not given the full attribute but only
7799
+ // the selected data field.
7800
+ if (attributeType !== undefined && attributes[ii].value["@type"] !== attributeType) {
7801
+ continue;
7802
+ }
7803
+ if (val !== null && matchFn(val)) {
7804
+ indices.push(ii);
7805
+ }
7806
+ }
7807
+ return indices;
7808
+ }
7809
+ /**
7810
+ * Returns the union of two sets (represented as arrays of primitive
7811
+ * elements).
7812
+ */
7813
+ function union(arr1, arr2) {
7814
+ const result = Array.from(new Set([...arr1, ...arr2]));
7815
+ result.sort((a, b) => { return a - b; });
7816
+ return result;
7817
+ }
7818
+ /**
7819
+ * Returns the intersection of two sets (represented as arrays of primitive
7820
+ * elements).
7821
+ */
7822
+ function intersect(b, ...a) {
7823
+ const result = [b, ...a].reduce((p, c) => p.filter(e => c.includes(e)));
7824
+ result.sort((a, b) => { return a - b; });
7825
+ return result;
7826
+ }
7827
+ /**
7828
+ * Returns the asymmetric difference of two sets (represented as arrays of
7829
+ * primitive elements).
7830
+ */
7831
+ function diffAsym(arr1, arr2) {
7832
+ const result = arr1.filter((x) => { return !arr2.includes(x); });
7833
+ result.sort((a, b) => { return a - b; });
7834
+ return result;
7835
+ }
7836
+ function peg$subclass(child, parent) {
7837
+ function C() { this.constructor = child; }
7838
+ C.prototype = parent.prototype;
7839
+ child.prototype = new C();
7840
+ }
7841
+ function peg$SyntaxError(message, expected, found, location) {
7842
+ var self = Error.call(this, message);
7843
+ // istanbul ignore next Check is a necessary evil to support older environments
7844
+ if (Object.setPrototypeOf) {
7845
+ Object.setPrototypeOf(self, peg$SyntaxError.prototype);
7846
+ }
7847
+ self.expected = expected;
7848
+ self.found = found;
7849
+ self.location = location;
7850
+ self.name = "SyntaxError";
7851
+ return self;
7852
+ }
7853
+ peg$subclass(peg$SyntaxError, Error);
7854
+ function peg$padEnd(str, targetLength, padString) {
7855
+ padString = padString || " ";
7856
+ if (str.length > targetLength) {
7857
+ return str;
7858
+ }
7859
+ targetLength -= str.length;
7860
+ padString += padString.repeat(targetLength);
7861
+ return str + padString.slice(0, targetLength);
7862
+ }
7863
+ peg$SyntaxError.prototype.format = function (sources) {
7864
+ var str = "Error: " + this.message;
7865
+ if (this.location) {
7866
+ var src = null;
7867
+ var k;
7868
+ for (k = 0; k < sources.length; k++) {
7869
+ if (sources[k].source === this.location.source) {
7870
+ src = sources[k].text.split(/\r\n|\n|\r/g);
7871
+ break;
7872
+ }
7873
+ }
7874
+ var s = this.location.start;
7875
+ var offset_s = (this.location.source && (typeof this.location.source.offset === "function"))
7876
+ ? this.location.source.offset(s)
7877
+ : s;
7878
+ var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
7879
+ if (src) {
7880
+ var e = this.location.end;
7881
+ var filler = peg$padEnd("", offset_s.line.toString().length, ' ');
7882
+ var line = src[s.line - 1];
7883
+ var last = s.line === e.line ? e.column : line.length + 1;
7884
+ var hatLen = (last - s.column) || 1;
7885
+ str += "\n --> " + loc + "\n"
7886
+ + filler + " |\n"
7887
+ + offset_s.line + " | " + line + "\n"
7888
+ + filler + " | " + peg$padEnd("", s.column - 1, ' ')
7889
+ + peg$padEnd("", hatLen, "^");
7890
+ }
7891
+ else {
7892
+ str += "\n at " + loc;
7893
+ }
7894
+ }
7895
+ return str;
7896
+ };
7897
+ peg$SyntaxError.buildMessage = function (expected, found) {
7898
+ var DESCRIBE_EXPECTATION_FNS = {
7899
+ literal: function (expectation) {
7900
+ return "\"" + literalEscape(expectation.text) + "\"";
7901
+ },
7902
+ class: function (expectation) {
7903
+ var escapedParts = expectation.parts.map(function (part) {
7904
+ return Array.isArray(part)
7905
+ ? classEscape(part[0]) + "-" + classEscape(part[1])
7906
+ : classEscape(part);
7907
+ });
7908
+ return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
7909
+ },
7910
+ any: function () {
7911
+ return "any character";
7912
+ },
7913
+ end: function () {
7914
+ return "end of input";
7915
+ },
7916
+ other: function (expectation) {
7917
+ return expectation.description;
7918
+ }
7919
+ };
7920
+ function hex(ch) {
7921
+ return ch.charCodeAt(0).toString(16).toUpperCase();
7922
+ }
7923
+ function literalEscape(s) {
7924
+ return s
7925
+ .replace(/\\/g, "\\\\")
7926
+ .replace(/"/g, "\\\"")
7927
+ .replace(/\0/g, "\\0")
7928
+ .replace(/\t/g, "\\t")
7929
+ .replace(/\n/g, "\\n")
7930
+ .replace(/\r/g, "\\r")
7931
+ .replace(/[\x00-\x0F]/g, function (ch) { return "\\x0" + hex(ch); })
7932
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return "\\x" + hex(ch); });
7933
+ }
7934
+ function classEscape(s) {
7935
+ return s
7936
+ .replace(/\\/g, "\\\\")
7937
+ .replace(/\]/g, "\\]")
7938
+ .replace(/\^/g, "\\^")
7939
+ .replace(/-/g, "\\-")
7940
+ .replace(/\0/g, "\\0")
7941
+ .replace(/\t/g, "\\t")
7942
+ .replace(/\n/g, "\\n")
7943
+ .replace(/\r/g, "\\r")
7944
+ .replace(/[\x00-\x0F]/g, function (ch) { return "\\x0" + hex(ch); })
7945
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return "\\x" + hex(ch); });
7946
+ }
7947
+ function describeExpectation(expectation) {
7948
+ return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
7949
+ }
7950
+ function describeExpected(expected) {
7951
+ var descriptions = expected.map(describeExpectation);
7952
+ var i, j;
7953
+ descriptions.sort();
7954
+ if (descriptions.length > 0) {
7955
+ for (i = 1, j = 1; i < descriptions.length; i++) {
7956
+ if (descriptions[i - 1] !== descriptions[i]) {
7957
+ descriptions[j] = descriptions[i];
7958
+ j++;
7959
+ }
7960
+ }
7961
+ descriptions.length = j;
7962
+ }
7963
+ switch (descriptions.length) {
7964
+ case 1:
7965
+ return descriptions[0];
7966
+ case 2:
7967
+ return descriptions[0] + " or " + descriptions[1];
7968
+ default:
7969
+ return descriptions.slice(0, -1).join(", ")
7970
+ + ", or "
7971
+ + descriptions[descriptions.length - 1];
7972
+ }
7973
+ }
7974
+ function describeFound(found) {
7975
+ return found ? "\"" + literalEscape(found) + "\"" : "end of input";
7976
+ }
7977
+ return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
7978
+ };
7979
+ function peg$parse(input, options) {
7980
+ options = options !== undefined ? options : {};
7981
+ var peg$FAILED = {};
7982
+ var peg$source = options.grammarSource;
7983
+ var peg$startRuleFunctions = { Expr: peg$parseExpr };
7984
+ var peg$startRuleFunction = peg$parseExpr;
7985
+ var peg$c0 = "||";
7986
+ var peg$c1 = "&&";
7987
+ var peg$c2 = "!";
7988
+ var peg$c3 = "(";
7989
+ var peg$c4 = ")";
7990
+ var peg$c5 = ".";
7991
+ var peg$c6 = "#";
7992
+ var peg$c7 = "'";
7993
+ var peg$c8 = "\\\\";
7994
+ var peg$c9 = "\\'";
7995
+ var peg$r0 = /^[=><~]/;
7996
+ var peg$r1 = /^[?]/;
7997
+ var peg$r2 = /^[^'\\]/;
7998
+ var peg$r3 = /^[^'\\ ]/;
7999
+ var peg$r4 = /^[a-z]/;
8000
+ var peg$r5 = /^[A-za-z0-9]/;
8001
+ var peg$r6 = /^[A-Z]/;
8002
+ var peg$r7 = /^[A-Za-z0-9]/;
8003
+ var peg$r8 = /^[ \t\n\r]/;
8004
+ var peg$e0 = peg$literalExpectation("||", false);
8005
+ var peg$e1 = peg$literalExpectation("&&", false);
8006
+ var peg$e2 = peg$literalExpectation("!", false);
8007
+ var peg$e3 = peg$literalExpectation("(", false);
8008
+ var peg$e4 = peg$literalExpectation(")", false);
8009
+ var peg$e5 = peg$otherExpectation("metadata field term");
8010
+ var peg$e6 = peg$literalExpectation(".", false);
8011
+ var peg$e7 = peg$otherExpectation("tag term");
8012
+ var peg$e8 = peg$literalExpectation("#", false);
8013
+ var peg$e9 = peg$otherExpectation("primary field term");
8014
+ var peg$e10 = peg$classExpectation(["=", ">", "<", "~"], false, false);
8015
+ var peg$e11 = peg$classExpectation(["?"], false, false);
8016
+ var peg$e12 = peg$literalExpectation("'", false);
8017
+ var peg$e13 = peg$literalExpectation("\\\\", false);
8018
+ var peg$e14 = peg$literalExpectation("\\'", false);
8019
+ var peg$e15 = peg$classExpectation(["'", "\\"], true, false);
8020
+ var peg$e16 = peg$classExpectation(["'", "\\", " "], true, false);
8021
+ var peg$e17 = peg$classExpectation([["a", "z"]], false, false);
8022
+ var peg$e18 = peg$classExpectation([["A", "z"], ["a", "z"], ["0", "9"]], false, false);
8023
+ var peg$e19 = peg$otherExpectation("attribute type");
8024
+ var peg$e20 = peg$classExpectation([["A", "Z"]], false, false);
8025
+ var peg$e21 = peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"]], false, false);
8026
+ var peg$e22 = peg$otherExpectation("whitespace");
8027
+ var peg$e23 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false);
8028
+ var peg$f0 = function (h, t) {
8029
+ return t.reduce((acc, element) => {
8030
+ return union(acc, element);
8031
+ }, h);
8032
+ };
8033
+ var peg$f1 = function (h, t) {
8034
+ return t.reduce((acc, element) => {
8035
+ return intersect(acc, element);
8036
+ }, h);
8037
+ };
8038
+ var peg$f2 = function (expr) {
8039
+ const allIndices = [...Array(options.attributes.length).keys()];
8040
+ return diffAsym(allIndices, expr);
8041
+ };
8042
+ var peg$f3 = function (pathPrefix, pathSuffix, matchFn) {
8043
+ return match(options.attributes, [pathPrefix, ...pathSuffix], matchFn);
8044
+ };
8045
+ var peg$f4 = function (tag) {
8046
+ return match(options.attributes, ["tags"], (fieldVal) => { return Array.isArray(fieldVal) && fieldVal.includes(tag); });
8047
+ };
8048
+ var peg$f5 = function (attributeType, path, matchFn) {
8049
+ const result = match(options.attributes, ["value", ...path], matchFn, attributeType);
8050
+ return result;
8051
+ };
8052
+ var peg$f6 = function (attributeType, matchFn) {
8053
+ return match(options.attributes, ["value", "value"], matchFn, attributeType);
8054
+ };
8055
+ var peg$f7 = function (attributeType) {
8056
+ // Providing only the attribute type returns attributes whose type
8057
+ // matches. E.g. 'PhoneNumber' will return all attributes whose type is
8058
+ // 'PhoneNumber', regardless of the values of any of their fields.
8059
+ return match(options.attributes, ["value", "@type"], (fieldVal) => { return fieldVal === attributeType; });
8060
+ };
8061
+ var peg$f8 = function (op, rhs) {
8062
+ switch (op) {
8063
+ case "=":
8064
+ return (fieldVal) => { return String(fieldVal) === rhs; };
8065
+ case ">":
8066
+ return (fieldVal) => { return new Date(fieldVal) >= new Date(rhs); };
8067
+ case "<":
8068
+ return (fieldVal) => { return new Date(fieldVal) <= new Date(rhs); };
8069
+ case "~":
8070
+ return (fieldVal) => { return Array.isArray(fieldVal) && fieldVal.includes(rhs); };
8071
+ }
8072
+ };
8073
+ var peg$f9 = function (op) {
8074
+ switch (op) {
8075
+ case "?":
8076
+ return (fieldVal) => { return fieldVal != undefined; };
8077
+ }
8078
+ };
8079
+ var peg$f10 = function (val) {
8080
+ return val.join("").replaceAll("\\\\", "\\").replaceAll("\\'", "'");
8081
+ };
8082
+ var peg$f11 = function (val) {
8083
+ return val.join("").replaceAll("\\\\", "\\").replaceAll("\\'", "'");
8084
+ };
8085
+ var peg$currPos = 0;
8086
+ var peg$savedPos = 0;
8087
+ var peg$posDetailsCache = [{ line: 1, column: 1 }];
8088
+ var peg$maxFailPos = 0;
8089
+ var peg$maxFailExpected = [];
8090
+ var peg$silentFails = 0;
8091
+ var peg$result;
8092
+ if ("startRule" in options) {
8093
+ if (!(options.startRule in peg$startRuleFunctions)) {
8094
+ throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
8095
+ }
8096
+ peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
8097
+ }
8098
+ function text() {
8099
+ return input.substring(peg$savedPos, peg$currPos);
8100
+ }
8101
+ function offset() {
8102
+ return peg$savedPos;
8103
+ }
8104
+ function range() {
8105
+ return {
8106
+ source: peg$source,
8107
+ start: peg$savedPos,
8108
+ end: peg$currPos
8109
+ };
8110
+ }
8111
+ function location() {
8112
+ return peg$computeLocation(peg$savedPos, peg$currPos);
8113
+ }
8114
+ function expected(description, location) {
8115
+ location = location !== undefined
8116
+ ? location
8117
+ : peg$computeLocation(peg$savedPos, peg$currPos);
8118
+ throw peg$buildStructuredError([peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location);
8119
+ }
8120
+ function error(message, location) {
8121
+ location = location !== undefined
8122
+ ? location
8123
+ : peg$computeLocation(peg$savedPos, peg$currPos);
8124
+ throw peg$buildSimpleError(message, location);
8125
+ }
8126
+ function peg$literalExpectation(text, ignoreCase) {
8127
+ return { type: "literal", text: text, ignoreCase: ignoreCase };
8128
+ }
8129
+ function peg$classExpectation(parts, inverted, ignoreCase) {
8130
+ return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
8131
+ }
8132
+ function peg$anyExpectation() {
8133
+ return { type: "any" };
8134
+ }
8135
+ function peg$endExpectation() {
8136
+ return { type: "end" };
8137
+ }
8138
+ function peg$otherExpectation(description) {
8139
+ return { type: "other", description: description };
8140
+ }
8141
+ function peg$computePosDetails(pos) {
8142
+ var details = peg$posDetailsCache[pos];
8143
+ var p;
8144
+ if (details) {
8145
+ return details;
8146
+ }
8147
+ else {
8148
+ p = pos - 1;
8149
+ while (!peg$posDetailsCache[p]) {
8150
+ p--;
8151
+ }
8152
+ details = peg$posDetailsCache[p];
8153
+ details = {
8154
+ line: details.line,
8155
+ column: details.column
8156
+ };
8157
+ while (p < pos) {
8158
+ if (input.charCodeAt(p) === 10) {
8159
+ details.line++;
8160
+ details.column = 1;
8161
+ }
8162
+ else {
8163
+ details.column++;
8164
+ }
8165
+ p++;
8166
+ }
8167
+ peg$posDetailsCache[pos] = details;
8168
+ return details;
8169
+ }
8170
+ }
8171
+ function peg$computeLocation(startPos, endPos, offset) {
8172
+ var startPosDetails = peg$computePosDetails(startPos);
8173
+ var endPosDetails = peg$computePosDetails(endPos);
8174
+ var res = {
8175
+ source: peg$source,
8176
+ start: {
8177
+ offset: startPos,
8178
+ line: startPosDetails.line,
8179
+ column: startPosDetails.column
8180
+ },
8181
+ end: {
8182
+ offset: endPos,
8183
+ line: endPosDetails.line,
8184
+ column: endPosDetails.column
8185
+ }
8186
+ };
8187
+ if (offset && peg$source && (typeof peg$source.offset === "function")) {
8188
+ res.start = peg$source.offset(res.start);
8189
+ res.end = peg$source.offset(res.end);
8190
+ }
8191
+ return res;
8192
+ }
8193
+ function peg$fail(expected) {
8194
+ if (peg$currPos < peg$maxFailPos) {
8195
+ return;
8196
+ }
8197
+ if (peg$currPos > peg$maxFailPos) {
8198
+ peg$maxFailPos = peg$currPos;
8199
+ peg$maxFailExpected = [];
8200
+ }
8201
+ peg$maxFailExpected.push(expected);
8202
+ }
8203
+ function peg$buildSimpleError(message, location) {
8204
+ return new peg$SyntaxError(message, null, null, location);
8205
+ }
8206
+ function peg$buildStructuredError(expected, found, location) {
8207
+ return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location);
8208
+ }
8209
+ function peg$parseExpr() {
8210
+ var s0, s1, s2, s3, s4, s5, s6, s7;
8211
+ s0 = peg$currPos;
8212
+ s1 = peg$parseExpr0();
8213
+ if (s1 !== peg$FAILED) {
8214
+ s2 = [];
8215
+ s3 = peg$currPos;
8216
+ s4 = [];
8217
+ s5 = peg$parse_();
8218
+ if (s5 !== peg$FAILED) {
8219
+ while (s5 !== peg$FAILED) {
8220
+ s4.push(s5);
8221
+ s5 = peg$parse_();
8222
+ }
8223
+ }
8224
+ else {
8225
+ s4 = peg$FAILED;
8226
+ }
8227
+ if (s4 !== peg$FAILED) {
8228
+ if (input.substr(peg$currPos, 2) === peg$c0) {
8229
+ s5 = peg$c0;
8230
+ peg$currPos += 2;
8231
+ }
8232
+ else {
8233
+ s5 = peg$FAILED;
8234
+ if (peg$silentFails === 0) {
8235
+ peg$fail(peg$e0);
8236
+ }
8237
+ }
8238
+ if (s5 !== peg$FAILED) {
8239
+ s6 = [];
8240
+ s7 = peg$parse_();
8241
+ if (s7 !== peg$FAILED) {
8242
+ while (s7 !== peg$FAILED) {
8243
+ s6.push(s7);
8244
+ s7 = peg$parse_();
8245
+ }
8246
+ }
8247
+ else {
8248
+ s6 = peg$FAILED;
8249
+ }
8250
+ if (s6 !== peg$FAILED) {
8251
+ s7 = peg$parseExpr0();
8252
+ if (s7 !== peg$FAILED) {
8253
+ s3 = s7;
8254
+ }
8255
+ else {
8256
+ peg$currPos = s3;
8257
+ s3 = peg$FAILED;
8258
+ }
8259
+ }
8260
+ else {
8261
+ peg$currPos = s3;
8262
+ s3 = peg$FAILED;
8263
+ }
8264
+ }
8265
+ else {
8266
+ peg$currPos = s3;
8267
+ s3 = peg$FAILED;
8268
+ }
8269
+ }
8270
+ else {
8271
+ peg$currPos = s3;
8272
+ s3 = peg$FAILED;
8273
+ }
8274
+ while (s3 !== peg$FAILED) {
8275
+ s2.push(s3);
8276
+ s3 = peg$currPos;
8277
+ s4 = [];
8278
+ s5 = peg$parse_();
8279
+ if (s5 !== peg$FAILED) {
8280
+ while (s5 !== peg$FAILED) {
8281
+ s4.push(s5);
8282
+ s5 = peg$parse_();
8283
+ }
8284
+ }
8285
+ else {
8286
+ s4 = peg$FAILED;
8287
+ }
8288
+ if (s4 !== peg$FAILED) {
8289
+ if (input.substr(peg$currPos, 2) === peg$c0) {
8290
+ s5 = peg$c0;
8291
+ peg$currPos += 2;
8292
+ }
8293
+ else {
8294
+ s5 = peg$FAILED;
8295
+ if (peg$silentFails === 0) {
8296
+ peg$fail(peg$e0);
8297
+ }
8298
+ }
8299
+ if (s5 !== peg$FAILED) {
8300
+ s6 = [];
8301
+ s7 = peg$parse_();
8302
+ if (s7 !== peg$FAILED) {
8303
+ while (s7 !== peg$FAILED) {
8304
+ s6.push(s7);
8305
+ s7 = peg$parse_();
8306
+ }
8307
+ }
8308
+ else {
8309
+ s6 = peg$FAILED;
8310
+ }
8311
+ if (s6 !== peg$FAILED) {
8312
+ s7 = peg$parseExpr0();
8313
+ if (s7 !== peg$FAILED) {
8314
+ s3 = s7;
8315
+ }
8316
+ else {
8317
+ peg$currPos = s3;
8318
+ s3 = peg$FAILED;
8319
+ }
8320
+ }
8321
+ else {
8322
+ peg$currPos = s3;
8323
+ s3 = peg$FAILED;
8324
+ }
8325
+ }
8326
+ else {
8327
+ peg$currPos = s3;
8328
+ s3 = peg$FAILED;
8329
+ }
8330
+ }
8331
+ else {
8332
+ peg$currPos = s3;
8333
+ s3 = peg$FAILED;
8334
+ }
8335
+ }
8336
+ peg$savedPos = s0;
8337
+ s0 = peg$f0(s1, s2);
8338
+ }
8339
+ else {
8340
+ peg$currPos = s0;
8341
+ s0 = peg$FAILED;
8342
+ }
8343
+ return s0;
8344
+ }
8345
+ function peg$parseExpr0() {
8346
+ var s0, s1, s2, s3, s4, s5, s6, s7;
8347
+ s0 = peg$currPos;
8348
+ s1 = peg$parseExpr1();
8349
+ if (s1 !== peg$FAILED) {
8350
+ s2 = [];
8351
+ s3 = peg$currPos;
8352
+ s4 = [];
8353
+ s5 = peg$parse_();
8354
+ if (s5 !== peg$FAILED) {
8355
+ while (s5 !== peg$FAILED) {
8356
+ s4.push(s5);
8357
+ s5 = peg$parse_();
8358
+ }
8359
+ }
8360
+ else {
8361
+ s4 = peg$FAILED;
8362
+ }
8363
+ if (s4 !== peg$FAILED) {
8364
+ if (input.substr(peg$currPos, 2) === peg$c1) {
8365
+ s5 = peg$c1;
8366
+ peg$currPos += 2;
8367
+ }
8368
+ else {
8369
+ s5 = peg$FAILED;
8370
+ if (peg$silentFails === 0) {
8371
+ peg$fail(peg$e1);
8372
+ }
8373
+ }
8374
+ if (s5 !== peg$FAILED) {
8375
+ s6 = [];
8376
+ s7 = peg$parse_();
8377
+ if (s7 !== peg$FAILED) {
8378
+ while (s7 !== peg$FAILED) {
8379
+ s6.push(s7);
8380
+ s7 = peg$parse_();
8381
+ }
8382
+ }
8383
+ else {
8384
+ s6 = peg$FAILED;
8385
+ }
8386
+ if (s6 !== peg$FAILED) {
8387
+ s7 = peg$parseExpr1();
8388
+ if (s7 !== peg$FAILED) {
8389
+ s3 = s7;
8390
+ }
8391
+ else {
8392
+ peg$currPos = s3;
8393
+ s3 = peg$FAILED;
8394
+ }
8395
+ }
8396
+ else {
8397
+ peg$currPos = s3;
8398
+ s3 = peg$FAILED;
8399
+ }
8400
+ }
8401
+ else {
8402
+ peg$currPos = s3;
8403
+ s3 = peg$FAILED;
8404
+ }
8405
+ }
8406
+ else {
8407
+ peg$currPos = s3;
8408
+ s3 = peg$FAILED;
8409
+ }
8410
+ while (s3 !== peg$FAILED) {
8411
+ s2.push(s3);
8412
+ s3 = peg$currPos;
8413
+ s4 = [];
8414
+ s5 = peg$parse_();
8415
+ if (s5 !== peg$FAILED) {
8416
+ while (s5 !== peg$FAILED) {
8417
+ s4.push(s5);
8418
+ s5 = peg$parse_();
8419
+ }
8420
+ }
8421
+ else {
8422
+ s4 = peg$FAILED;
8423
+ }
8424
+ if (s4 !== peg$FAILED) {
8425
+ if (input.substr(peg$currPos, 2) === peg$c1) {
8426
+ s5 = peg$c1;
8427
+ peg$currPos += 2;
8428
+ }
8429
+ else {
8430
+ s5 = peg$FAILED;
8431
+ if (peg$silentFails === 0) {
8432
+ peg$fail(peg$e1);
8433
+ }
8434
+ }
8435
+ if (s5 !== peg$FAILED) {
8436
+ s6 = [];
8437
+ s7 = peg$parse_();
8438
+ if (s7 !== peg$FAILED) {
8439
+ while (s7 !== peg$FAILED) {
8440
+ s6.push(s7);
8441
+ s7 = peg$parse_();
8442
+ }
8443
+ }
8444
+ else {
8445
+ s6 = peg$FAILED;
8446
+ }
8447
+ if (s6 !== peg$FAILED) {
8448
+ s7 = peg$parseExpr1();
8449
+ if (s7 !== peg$FAILED) {
8450
+ s3 = s7;
8451
+ }
8452
+ else {
8453
+ peg$currPos = s3;
8454
+ s3 = peg$FAILED;
8455
+ }
8456
+ }
8457
+ else {
8458
+ peg$currPos = s3;
8459
+ s3 = peg$FAILED;
8460
+ }
8461
+ }
8462
+ else {
8463
+ peg$currPos = s3;
8464
+ s3 = peg$FAILED;
8465
+ }
8466
+ }
8467
+ else {
8468
+ peg$currPos = s3;
8469
+ s3 = peg$FAILED;
8470
+ }
8471
+ }
8472
+ peg$savedPos = s0;
8473
+ s0 = peg$f1(s1, s2);
8474
+ }
8475
+ else {
8476
+ peg$currPos = s0;
8477
+ s0 = peg$FAILED;
8478
+ }
8479
+ return s0;
8480
+ }
8481
+ function peg$parseExpr1() {
8482
+ var s0, s1, s2;
8483
+ s0 = peg$currPos;
8484
+ if (input.charCodeAt(peg$currPos) === 33) {
8485
+ s1 = peg$c2;
8486
+ peg$currPos++;
8487
+ }
8488
+ else {
8489
+ s1 = peg$FAILED;
8490
+ if (peg$silentFails === 0) {
8491
+ peg$fail(peg$e2);
8492
+ }
8493
+ }
8494
+ if (s1 !== peg$FAILED) {
8495
+ s2 = peg$parseExpr1();
8496
+ if (s2 !== peg$FAILED) {
8497
+ peg$savedPos = s0;
8498
+ s0 = peg$f2(s2);
8499
+ }
8500
+ else {
8501
+ peg$currPos = s0;
8502
+ s0 = peg$FAILED;
8503
+ }
8504
+ }
8505
+ else {
8506
+ peg$currPos = s0;
8507
+ s0 = peg$FAILED;
8508
+ }
8509
+ if (s0 === peg$FAILED) {
8510
+ s0 = peg$parseExpr2();
8511
+ }
8512
+ return s0;
8513
+ }
8514
+ function peg$parseExpr2() {
8515
+ var s0, s1, s2, s3, s4, s5;
8516
+ s0 = peg$currPos;
8517
+ if (input.charCodeAt(peg$currPos) === 40) {
8518
+ s1 = peg$c3;
8519
+ peg$currPos++;
8520
+ }
8521
+ else {
8522
+ s1 = peg$FAILED;
8523
+ if (peg$silentFails === 0) {
8524
+ peg$fail(peg$e3);
8525
+ }
8526
+ }
8527
+ if (s1 !== peg$FAILED) {
8528
+ s2 = [];
8529
+ s3 = peg$parse_();
8530
+ if (s3 !== peg$FAILED) {
8531
+ while (s3 !== peg$FAILED) {
8532
+ s2.push(s3);
8533
+ s3 = peg$parse_();
8534
+ }
8535
+ }
8536
+ else {
8537
+ s2 = peg$FAILED;
8538
+ }
8539
+ if (s2 !== peg$FAILED) {
8540
+ s3 = peg$parseExpr();
8541
+ if (s3 !== peg$FAILED) {
8542
+ s4 = [];
8543
+ s5 = peg$parse_();
8544
+ if (s5 !== peg$FAILED) {
8545
+ while (s5 !== peg$FAILED) {
8546
+ s4.push(s5);
8547
+ s5 = peg$parse_();
8548
+ }
8549
+ }
8550
+ else {
8551
+ s4 = peg$FAILED;
8552
+ }
8553
+ if (s4 !== peg$FAILED) {
8554
+ if (input.charCodeAt(peg$currPos) === 41) {
8555
+ s5 = peg$c4;
8556
+ peg$currPos++;
8557
+ }
8558
+ else {
8559
+ s5 = peg$FAILED;
8560
+ if (peg$silentFails === 0) {
8561
+ peg$fail(peg$e4);
8562
+ }
8563
+ }
8564
+ if (s5 !== peg$FAILED) {
8565
+ s0 = s3;
8566
+ }
8567
+ else {
8568
+ peg$currPos = s0;
8569
+ s0 = peg$FAILED;
8570
+ }
8571
+ }
8572
+ else {
8573
+ peg$currPos = s0;
8574
+ s0 = peg$FAILED;
8575
+ }
8576
+ }
8577
+ else {
8578
+ peg$currPos = s0;
8579
+ s0 = peg$FAILED;
8580
+ }
8581
+ }
8582
+ else {
8583
+ peg$currPos = s0;
8584
+ s0 = peg$FAILED;
8585
+ }
8586
+ }
8587
+ else {
8588
+ peg$currPos = s0;
8589
+ s0 = peg$FAILED;
8590
+ }
8591
+ if (s0 === peg$FAILED) {
8592
+ s0 = peg$parseTerm();
8593
+ }
8594
+ return s0;
8595
+ }
8596
+ function peg$parseTerm() {
8597
+ var s0;
8598
+ s0 = peg$parsePrimaryFieldTerm();
8599
+ if (s0 === peg$FAILED) {
8600
+ s0 = peg$parseMetadataFieldTerm();
8601
+ if (s0 === peg$FAILED) {
8602
+ s0 = peg$parseTagTerm();
8603
+ }
8604
+ }
8605
+ return s0;
8606
+ }
8607
+ function peg$parseMetadataFieldTerm() {
8608
+ var s0, s1, s2, s3, s4, s5;
8609
+ peg$silentFails++;
8610
+ s0 = peg$currPos;
8611
+ s1 = peg$parsePathSegment();
8612
+ if (s1 !== peg$FAILED) {
8613
+ s2 = [];
8614
+ s3 = peg$currPos;
8615
+ if (input.charCodeAt(peg$currPos) === 46) {
8616
+ s4 = peg$c5;
8617
+ peg$currPos++;
8618
+ }
8619
+ else {
8620
+ s4 = peg$FAILED;
8621
+ if (peg$silentFails === 0) {
8622
+ peg$fail(peg$e6);
8623
+ }
8624
+ }
8625
+ if (s4 !== peg$FAILED) {
8626
+ s5 = peg$parsePathSegment();
8627
+ if (s5 !== peg$FAILED) {
8628
+ s3 = s5;
8629
+ }
8630
+ else {
8631
+ peg$currPos = s3;
8632
+ s3 = peg$FAILED;
8633
+ }
8634
+ }
8635
+ else {
8636
+ peg$currPos = s3;
8637
+ s3 = peg$FAILED;
8638
+ }
8639
+ while (s3 !== peg$FAILED) {
8640
+ s2.push(s3);
8641
+ s3 = peg$currPos;
8642
+ if (input.charCodeAt(peg$currPos) === 46) {
8643
+ s4 = peg$c5;
8644
+ peg$currPos++;
8645
+ }
8646
+ else {
8647
+ s4 = peg$FAILED;
8648
+ if (peg$silentFails === 0) {
8649
+ peg$fail(peg$e6);
8650
+ }
8651
+ }
8652
+ if (s4 !== peg$FAILED) {
8653
+ s5 = peg$parsePathSegment();
8654
+ if (s5 !== peg$FAILED) {
8655
+ s3 = s5;
8656
+ }
8657
+ else {
8658
+ peg$currPos = s3;
8659
+ s3 = peg$FAILED;
8660
+ }
8661
+ }
8662
+ else {
8663
+ peg$currPos = s3;
8664
+ s3 = peg$FAILED;
8665
+ }
8666
+ }
8667
+ s3 = peg$parsePredicate();
8668
+ if (s3 !== peg$FAILED) {
8669
+ peg$savedPos = s0;
8670
+ s0 = peg$f3(s1, s2, s3);
8671
+ }
8672
+ else {
8673
+ peg$currPos = s0;
8674
+ s0 = peg$FAILED;
8675
+ }
8676
+ }
8677
+ else {
8678
+ peg$currPos = s0;
8679
+ s0 = peg$FAILED;
8680
+ }
8681
+ peg$silentFails--;
8682
+ if (s0 === peg$FAILED) {
8683
+ s1 = peg$FAILED;
8684
+ if (peg$silentFails === 0) {
8685
+ peg$fail(peg$e5);
8686
+ }
8687
+ }
8688
+ return s0;
8689
+ }
8690
+ function peg$parseTagTerm() {
8691
+ var s0, s1, s2;
8692
+ peg$silentFails++;
8693
+ s0 = peg$currPos;
8694
+ if (input.charCodeAt(peg$currPos) === 35) {
8695
+ s1 = peg$c6;
8696
+ peg$currPos++;
8697
+ }
8698
+ else {
8699
+ s1 = peg$FAILED;
8700
+ if (peg$silentFails === 0) {
8701
+ peg$fail(peg$e8);
8702
+ }
8703
+ }
8704
+ if (s1 !== peg$FAILED) {
8705
+ s2 = peg$parsePredicateRHS();
8706
+ if (s2 !== peg$FAILED) {
8707
+ peg$savedPos = s0;
8708
+ s0 = peg$f4(s2);
8709
+ }
8710
+ else {
8711
+ peg$currPos = s0;
8712
+ s0 = peg$FAILED;
8713
+ }
8714
+ }
8715
+ else {
8716
+ peg$currPos = s0;
8717
+ s0 = peg$FAILED;
8718
+ }
8719
+ peg$silentFails--;
8720
+ if (s0 === peg$FAILED) {
8721
+ s1 = peg$FAILED;
8722
+ if (peg$silentFails === 0) {
8723
+ peg$fail(peg$e7);
8724
+ }
8725
+ }
8726
+ return s0;
8727
+ }
8728
+ function peg$parsePrimaryFieldTerm() {
8729
+ var s0, s1, s2, s3, s4, s5;
8730
+ peg$silentFails++;
8731
+ s0 = peg$currPos;
8732
+ s1 = peg$parseAttributeType();
8733
+ if (s1 !== peg$FAILED) {
8734
+ s2 = [];
8735
+ s3 = peg$currPos;
8736
+ if (input.charCodeAt(peg$currPos) === 46) {
8737
+ s4 = peg$c5;
8738
+ peg$currPos++;
8739
+ }
8740
+ else {
8741
+ s4 = peg$FAILED;
8742
+ if (peg$silentFails === 0) {
8743
+ peg$fail(peg$e6);
8744
+ }
8745
+ }
8746
+ if (s4 !== peg$FAILED) {
8747
+ s5 = peg$parsePathSegment();
8748
+ if (s5 !== peg$FAILED) {
8749
+ s3 = s5;
8750
+ }
8751
+ else {
8752
+ peg$currPos = s3;
8753
+ s3 = peg$FAILED;
8754
+ }
8755
+ }
8756
+ else {
8757
+ peg$currPos = s3;
8758
+ s3 = peg$FAILED;
8759
+ }
8760
+ if (s3 !== peg$FAILED) {
8761
+ while (s3 !== peg$FAILED) {
8762
+ s2.push(s3);
8763
+ s3 = peg$currPos;
8764
+ if (input.charCodeAt(peg$currPos) === 46) {
8765
+ s4 = peg$c5;
8766
+ peg$currPos++;
8767
+ }
8768
+ else {
8769
+ s4 = peg$FAILED;
8770
+ if (peg$silentFails === 0) {
8771
+ peg$fail(peg$e6);
8772
+ }
8773
+ }
8774
+ if (s4 !== peg$FAILED) {
8775
+ s5 = peg$parsePathSegment();
8776
+ if (s5 !== peg$FAILED) {
8777
+ s3 = s5;
8778
+ }
8779
+ else {
8780
+ peg$currPos = s3;
8781
+ s3 = peg$FAILED;
8782
+ }
8783
+ }
8784
+ else {
8785
+ peg$currPos = s3;
8786
+ s3 = peg$FAILED;
8787
+ }
8788
+ }
8789
+ }
8790
+ else {
8791
+ s2 = peg$FAILED;
8792
+ }
8793
+ if (s2 !== peg$FAILED) {
8794
+ s3 = peg$parsePredicate();
8795
+ if (s3 !== peg$FAILED) {
8796
+ peg$savedPos = s0;
8797
+ s0 = peg$f5(s1, s2, s3);
8798
+ }
8799
+ else {
8800
+ peg$currPos = s0;
8801
+ s0 = peg$FAILED;
8802
+ }
8803
+ }
8804
+ else {
8805
+ peg$currPos = s0;
8806
+ s0 = peg$FAILED;
8807
+ }
8808
+ }
8809
+ else {
8810
+ peg$currPos = s0;
8811
+ s0 = peg$FAILED;
8812
+ }
8813
+ if (s0 === peg$FAILED) {
8814
+ s0 = peg$currPos;
8815
+ s1 = peg$parseAttributeType();
8816
+ if (s1 !== peg$FAILED) {
8817
+ s2 = peg$parsePredicate();
8818
+ if (s2 !== peg$FAILED) {
8819
+ peg$savedPos = s0;
8820
+ s0 = peg$f6(s1, s2);
8821
+ }
8822
+ else {
8823
+ peg$currPos = s0;
8824
+ s0 = peg$FAILED;
8825
+ }
8826
+ }
8827
+ else {
8828
+ peg$currPos = s0;
8829
+ s0 = peg$FAILED;
8830
+ }
8831
+ if (s0 === peg$FAILED) {
8832
+ s0 = peg$currPos;
8833
+ s1 = peg$parseAttributeType();
8834
+ if (s1 !== peg$FAILED) {
8835
+ peg$savedPos = s0;
8836
+ s1 = peg$f7(s1);
8837
+ }
8838
+ s0 = s1;
8839
+ }
8840
+ }
8841
+ peg$silentFails--;
8842
+ if (s0 === peg$FAILED) {
8843
+ s1 = peg$FAILED;
8844
+ if (peg$silentFails === 0) {
8845
+ peg$fail(peg$e9);
8846
+ }
8847
+ }
8848
+ return s0;
8849
+ }
8850
+ function peg$parsePredicate() {
8851
+ var s0, s1, s2;
8852
+ s0 = peg$currPos;
8853
+ if (peg$r0.test(input.charAt(peg$currPos))) {
8854
+ s1 = input.charAt(peg$currPos);
8855
+ peg$currPos++;
8856
+ }
8857
+ else {
8858
+ s1 = peg$FAILED;
8859
+ if (peg$silentFails === 0) {
8860
+ peg$fail(peg$e10);
8861
+ }
8862
+ }
8863
+ if (s1 !== peg$FAILED) {
8864
+ s2 = peg$parsePredicateRHS();
8865
+ if (s2 !== peg$FAILED) {
8866
+ peg$savedPos = s0;
8867
+ s0 = peg$f8(s1, s2);
8868
+ }
8869
+ else {
8870
+ peg$currPos = s0;
8871
+ s0 = peg$FAILED;
8872
+ }
8873
+ }
8874
+ else {
8875
+ peg$currPos = s0;
8876
+ s0 = peg$FAILED;
8877
+ }
8878
+ if (s0 === peg$FAILED) {
8879
+ s0 = peg$currPos;
8880
+ if (peg$r1.test(input.charAt(peg$currPos))) {
8881
+ s1 = input.charAt(peg$currPos);
8882
+ peg$currPos++;
8883
+ }
8884
+ else {
8885
+ s1 = peg$FAILED;
8886
+ if (peg$silentFails === 0) {
8887
+ peg$fail(peg$e11);
8888
+ }
8889
+ }
8890
+ if (s1 !== peg$FAILED) {
8891
+ peg$savedPos = s0;
8892
+ s1 = peg$f9(s1);
8893
+ }
8894
+ s0 = s1;
8895
+ }
8896
+ return s0;
8897
+ }
8898
+ function peg$parsePredicateRHS() {
8899
+ var s0, s1, s2, s3;
8900
+ s0 = peg$currPos;
8901
+ if (input.charCodeAt(peg$currPos) === 39) {
8902
+ s1 = peg$c7;
8903
+ peg$currPos++;
8904
+ }
8905
+ else {
8906
+ s1 = peg$FAILED;
8907
+ if (peg$silentFails === 0) {
8908
+ peg$fail(peg$e12);
8909
+ }
8910
+ }
8911
+ if (s1 !== peg$FAILED) {
8912
+ s2 = [];
8913
+ if (input.substr(peg$currPos, 2) === peg$c8) {
8914
+ s3 = peg$c8;
8915
+ peg$currPos += 2;
8916
+ }
8917
+ else {
8918
+ s3 = peg$FAILED;
8919
+ if (peg$silentFails === 0) {
8920
+ peg$fail(peg$e13);
8921
+ }
8922
+ }
8923
+ if (s3 === peg$FAILED) {
8924
+ if (input.substr(peg$currPos, 2) === peg$c9) {
8925
+ s3 = peg$c9;
8926
+ peg$currPos += 2;
8927
+ }
8928
+ else {
8929
+ s3 = peg$FAILED;
8930
+ if (peg$silentFails === 0) {
8931
+ peg$fail(peg$e14);
8932
+ }
8933
+ }
8934
+ if (s3 === peg$FAILED) {
8935
+ if (peg$r2.test(input.charAt(peg$currPos))) {
8936
+ s3 = input.charAt(peg$currPos);
8937
+ peg$currPos++;
8938
+ }
8939
+ else {
8940
+ s3 = peg$FAILED;
8941
+ if (peg$silentFails === 0) {
8942
+ peg$fail(peg$e15);
8943
+ }
8944
+ }
8945
+ }
8946
+ }
8947
+ while (s3 !== peg$FAILED) {
8948
+ s2.push(s3);
8949
+ if (input.substr(peg$currPos, 2) === peg$c8) {
8950
+ s3 = peg$c8;
8951
+ peg$currPos += 2;
8952
+ }
8953
+ else {
8954
+ s3 = peg$FAILED;
8955
+ if (peg$silentFails === 0) {
8956
+ peg$fail(peg$e13);
8957
+ }
8958
+ }
8959
+ if (s3 === peg$FAILED) {
8960
+ if (input.substr(peg$currPos, 2) === peg$c9) {
8961
+ s3 = peg$c9;
8962
+ peg$currPos += 2;
8963
+ }
8964
+ else {
8965
+ s3 = peg$FAILED;
8966
+ if (peg$silentFails === 0) {
8967
+ peg$fail(peg$e14);
8968
+ }
8969
+ }
8970
+ if (s3 === peg$FAILED) {
8971
+ if (peg$r2.test(input.charAt(peg$currPos))) {
8972
+ s3 = input.charAt(peg$currPos);
8973
+ peg$currPos++;
8974
+ }
8975
+ else {
8976
+ s3 = peg$FAILED;
8977
+ if (peg$silentFails === 0) {
8978
+ peg$fail(peg$e15);
8979
+ }
8980
+ }
8981
+ }
8982
+ }
8983
+ }
8984
+ if (input.charCodeAt(peg$currPos) === 39) {
8985
+ s3 = peg$c7;
8986
+ peg$currPos++;
8987
+ }
8988
+ else {
8989
+ s3 = peg$FAILED;
8990
+ if (peg$silentFails === 0) {
8991
+ peg$fail(peg$e12);
8992
+ }
8993
+ }
8994
+ if (s3 !== peg$FAILED) {
8995
+ peg$savedPos = s0;
8996
+ s0 = peg$f10(s2);
8997
+ }
8998
+ else {
8999
+ peg$currPos = s0;
9000
+ s0 = peg$FAILED;
9001
+ }
9002
+ }
9003
+ else {
9004
+ peg$currPos = s0;
9005
+ s0 = peg$FAILED;
9006
+ }
9007
+ if (s0 === peg$FAILED) {
9008
+ s0 = peg$currPos;
9009
+ s1 = [];
9010
+ if (input.substr(peg$currPos, 2) === peg$c8) {
9011
+ s2 = peg$c8;
9012
+ peg$currPos += 2;
9013
+ }
9014
+ else {
9015
+ s2 = peg$FAILED;
9016
+ if (peg$silentFails === 0) {
9017
+ peg$fail(peg$e13);
9018
+ }
9019
+ }
9020
+ if (s2 === peg$FAILED) {
9021
+ if (input.substr(peg$currPos, 2) === peg$c9) {
9022
+ s2 = peg$c9;
9023
+ peg$currPos += 2;
9024
+ }
9025
+ else {
9026
+ s2 = peg$FAILED;
9027
+ if (peg$silentFails === 0) {
9028
+ peg$fail(peg$e14);
9029
+ }
9030
+ }
9031
+ if (s2 === peg$FAILED) {
9032
+ if (peg$r3.test(input.charAt(peg$currPos))) {
9033
+ s2 = input.charAt(peg$currPos);
9034
+ peg$currPos++;
9035
+ }
9036
+ else {
9037
+ s2 = peg$FAILED;
9038
+ if (peg$silentFails === 0) {
9039
+ peg$fail(peg$e16);
9040
+ }
9041
+ }
9042
+ }
9043
+ }
9044
+ while (s2 !== peg$FAILED) {
9045
+ s1.push(s2);
9046
+ if (input.substr(peg$currPos, 2) === peg$c8) {
9047
+ s2 = peg$c8;
9048
+ peg$currPos += 2;
9049
+ }
9050
+ else {
9051
+ s2 = peg$FAILED;
9052
+ if (peg$silentFails === 0) {
9053
+ peg$fail(peg$e13);
9054
+ }
9055
+ }
9056
+ if (s2 === peg$FAILED) {
9057
+ if (input.substr(peg$currPos, 2) === peg$c9) {
9058
+ s2 = peg$c9;
9059
+ peg$currPos += 2;
9060
+ }
9061
+ else {
9062
+ s2 = peg$FAILED;
9063
+ if (peg$silentFails === 0) {
9064
+ peg$fail(peg$e14);
9065
+ }
9066
+ }
9067
+ if (s2 === peg$FAILED) {
9068
+ if (peg$r3.test(input.charAt(peg$currPos))) {
9069
+ s2 = input.charAt(peg$currPos);
9070
+ peg$currPos++;
9071
+ }
9072
+ else {
9073
+ s2 = peg$FAILED;
9074
+ if (peg$silentFails === 0) {
9075
+ peg$fail(peg$e16);
9076
+ }
9077
+ }
9078
+ }
9079
+ }
9080
+ }
9081
+ peg$savedPos = s0;
9082
+ s1 = peg$f11(s1);
9083
+ s0 = s1;
9084
+ }
9085
+ return s0;
9086
+ }
9087
+ function peg$parsePathSegment() {
9088
+ var s0, s1, s2, s3, s4;
9089
+ s0 = peg$currPos;
9090
+ s1 = peg$currPos;
9091
+ if (peg$r4.test(input.charAt(peg$currPos))) {
9092
+ s2 = input.charAt(peg$currPos);
9093
+ peg$currPos++;
9094
+ }
9095
+ else {
9096
+ s2 = peg$FAILED;
9097
+ if (peg$silentFails === 0) {
9098
+ peg$fail(peg$e17);
9099
+ }
9100
+ }
9101
+ if (s2 !== peg$FAILED) {
9102
+ s3 = [];
9103
+ if (peg$r5.test(input.charAt(peg$currPos))) {
9104
+ s4 = input.charAt(peg$currPos);
9105
+ peg$currPos++;
9106
+ }
9107
+ else {
9108
+ s4 = peg$FAILED;
9109
+ if (peg$silentFails === 0) {
9110
+ peg$fail(peg$e18);
9111
+ }
9112
+ }
9113
+ if (s4 !== peg$FAILED) {
9114
+ while (s4 !== peg$FAILED) {
9115
+ s3.push(s4);
9116
+ if (peg$r5.test(input.charAt(peg$currPos))) {
9117
+ s4 = input.charAt(peg$currPos);
9118
+ peg$currPos++;
9119
+ }
9120
+ else {
9121
+ s4 = peg$FAILED;
9122
+ if (peg$silentFails === 0) {
9123
+ peg$fail(peg$e18);
9124
+ }
9125
+ }
9126
+ }
9127
+ }
9128
+ else {
9129
+ s3 = peg$FAILED;
9130
+ }
9131
+ if (s3 !== peg$FAILED) {
9132
+ s2 = [s2, s3];
9133
+ s1 = s2;
9134
+ }
9135
+ else {
9136
+ peg$currPos = s1;
9137
+ s1 = peg$FAILED;
9138
+ }
9139
+ }
9140
+ else {
9141
+ peg$currPos = s1;
9142
+ s1 = peg$FAILED;
9143
+ }
9144
+ if (s1 !== peg$FAILED) {
9145
+ s0 = input.substring(s0, peg$currPos);
9146
+ }
9147
+ else {
9148
+ s0 = s1;
9149
+ }
9150
+ return s0;
9151
+ }
9152
+ function peg$parseAttributeType() {
9153
+ var s0, s1, s2, s3, s4;
9154
+ peg$silentFails++;
9155
+ s0 = peg$currPos;
9156
+ s1 = peg$currPos;
9157
+ if (peg$r6.test(input.charAt(peg$currPos))) {
9158
+ s2 = input.charAt(peg$currPos);
9159
+ peg$currPos++;
9160
+ }
9161
+ else {
9162
+ s2 = peg$FAILED;
9163
+ if (peg$silentFails === 0) {
9164
+ peg$fail(peg$e20);
9165
+ }
9166
+ }
9167
+ if (s2 !== peg$FAILED) {
9168
+ s3 = [];
9169
+ if (peg$r7.test(input.charAt(peg$currPos))) {
9170
+ s4 = input.charAt(peg$currPos);
9171
+ peg$currPos++;
9172
+ }
9173
+ else {
9174
+ s4 = peg$FAILED;
9175
+ if (peg$silentFails === 0) {
9176
+ peg$fail(peg$e21);
9177
+ }
9178
+ }
9179
+ while (s4 !== peg$FAILED) {
9180
+ s3.push(s4);
9181
+ if (peg$r7.test(input.charAt(peg$currPos))) {
9182
+ s4 = input.charAt(peg$currPos);
9183
+ peg$currPos++;
9184
+ }
9185
+ else {
9186
+ s4 = peg$FAILED;
9187
+ if (peg$silentFails === 0) {
9188
+ peg$fail(peg$e21);
9189
+ }
9190
+ }
9191
+ }
9192
+ s2 = [s2, s3];
9193
+ s1 = s2;
9194
+ }
9195
+ else {
9196
+ peg$currPos = s1;
9197
+ s1 = peg$FAILED;
9198
+ }
9199
+ if (s1 !== peg$FAILED) {
9200
+ s0 = input.substring(s0, peg$currPos);
9201
+ }
9202
+ else {
9203
+ s0 = s1;
9204
+ }
9205
+ peg$silentFails--;
9206
+ if (s0 === peg$FAILED) {
9207
+ s1 = peg$FAILED;
9208
+ if (peg$silentFails === 0) {
9209
+ peg$fail(peg$e19);
9210
+ }
9211
+ }
9212
+ return s0;
9213
+ }
9214
+ function peg$parse_() {
9215
+ var s0, s1;
9216
+ peg$silentFails++;
9217
+ if (peg$r8.test(input.charAt(peg$currPos))) {
9218
+ s0 = input.charAt(peg$currPos);
9219
+ peg$currPos++;
9220
+ }
9221
+ else {
9222
+ s0 = peg$FAILED;
9223
+ if (peg$silentFails === 0) {
9224
+ peg$fail(peg$e23);
9225
+ }
9226
+ }
9227
+ peg$silentFails--;
9228
+ if (s0 === peg$FAILED) {
9229
+ s1 = peg$FAILED;
9230
+ if (peg$silentFails === 0) {
9231
+ peg$fail(peg$e22);
9232
+ }
9233
+ }
9234
+ return s0;
9235
+ }
9236
+ peg$result = peg$startRuleFunction();
9237
+ if (peg$result !== peg$FAILED && peg$currPos === input.length) {
9238
+ return peg$result;
9239
+ }
9240
+ else {
9241
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
9242
+ peg$fail(peg$endExpectation());
9243
+ }
9244
+ throw peg$buildStructuredError(peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length
9245
+ ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
9246
+ : peg$computeLocation(peg$maxFailPos, peg$maxFailPos));
9247
+ }
9248
+ }
9249
+ module.exports = {
9250
+ SyntaxError: peg$SyntaxError,
9251
+ parse: peg$parse
9252
+ };
9253
+ //# sourceMappingURL=iql.js.map
9254
+
9255
+ /***/ }),
9256
+
9257
+ /***/ "./node_modules/@nmshd/iql/dist/src/index.js":
9258
+ /*!***************************************************!*\
9259
+ !*** ./node_modules/@nmshd/iql/dist/src/index.js ***!
9260
+ \***************************************************/
9261
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
9262
+
9263
+
9264
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
9265
+ exports.validate = exports.execute = void 0;
9266
+ const iql_js_1 = __webpack_require__(/*! ../generated/iql.js */ "./node_modules/@nmshd/iql/dist/generated/iql.js");
9267
+ /**
9268
+ * Executes IQL query, returning array of indicies of matched attributes in
9269
+ * attribute array.
9270
+ */
9271
+ function execute(iqlQuery, attributes) {
9272
+ return (0, iql_js_1.parse)(iqlQuery, { attributes });
9273
+ }
9274
+ exports.execute = execute;
9275
+ function validate(iqlQuery) {
9276
+ try {
9277
+ (0, iql_js_1.parse)(iqlQuery, { attributes: [] });
9278
+ return { isValid: true };
9279
+ }
9280
+ catch (error) {
9281
+ // FIXME: Is there a cleaner way to catch IQL SyntaxErrors?
9282
+ // For the sake of backwards compatibility peggy compiles to old
9283
+ // js without the use of classes. Thus the static type inference
9284
+ // for the SyntaxError type is severely crippled.
9285
+ if (error instanceof iql_js_1.SyntaxError) {
9286
+ const err = error; // see FIXME above.
9287
+ return {
9288
+ isValid: false,
9289
+ error: {
9290
+ message: err.message,
9291
+ location: {
9292
+ start: err.location.start,
9293
+ end: err.location.end
9294
+ }
9295
+ }
9296
+ };
9297
+ }
9298
+ return {
9299
+ isValid: false,
9300
+ error: {
9301
+ message: JSON.stringify(error),
9302
+ location: {
9303
+ start: {
9304
+ column: 0,
9305
+ line: 0,
9306
+ offset: 0
9307
+ },
9308
+ end: {
9309
+ column: 0,
9310
+ line: 0,
9311
+ offset: 0
9312
+ }
9313
+ }
9314
+ }
9315
+ };
9316
+ }
9317
+ }
9318
+ exports.validate = validate;
9319
+ //# sourceMappingURL=index.js.map
9320
+
9321
+ /***/ }),
9322
+
7681
9323
  /***/ "./node_modules/easy-tsnameof/dist/easy-tsnameof.esm.js":
7682
9324
  /*!**************************************************************!*\
7683
9325
  !*** ./node_modules/easy-tsnameof/dist/easy-tsnameof.esm.js ***!
@@ -7687,7 +9329,7 @@ __exportStar(__webpack_require__(/*! ./ResponseItemResult */ "./dist/requests/re
7687
9329
  __webpack_require__.r(__webpack_exports__);
7688
9330
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7689
9331
  /* harmony export */ "default": () => (/* binding */ nameOf),
7690
- /* harmony export */ "nameOf": () => (/* binding */ nameOf)
9332
+ /* harmony export */ nameOf: () => (/* binding */ nameOf)
7691
9333
  /* harmony export */ });
7692
9334
  var _handlersConfig;
7693
9335
 
@@ -8520,8 +10162,12 @@ class PolyNumberFormatter {
8520
10162
  class PolyDateFormatter {
8521
10163
  constructor(dt, intl, opts) {
8522
10164
  this.opts = opts;
10165
+ this.originalZone = undefined;
8523
10166
  let z = undefined;
8524
- if (dt.zone.isUniversal) {
10167
+ if (this.opts.timeZone) {
10168
+ // Don't apply any workarounds if a timeZone is explicitly provided in opts
10169
+ this.dt = dt;
10170
+ } else if (dt.zone.type === "fixed") {
8525
10171
  // UTC-8 or Etc/UTC-8 are not part of tzdata, only Etc/GMT+8 and the like.
8526
10172
  // That is why fixed-offset TZ is set to that unless it is:
8527
10173
  // 1. Representing offset 0 when UTC is used to maintain previous behavior and does not become GMT.
@@ -8534,25 +10180,27 @@ class PolyDateFormatter {
8534
10180
  z = offsetZ;
8535
10181
  this.dt = dt;
8536
10182
  } else {
8537
- // Not all fixed-offset zones like Etc/+4:30 are present in tzdata.
8538
- // So we have to make do. Two cases:
8539
- // 1. The format options tell us to show the zone. We can't do that, so the best
8540
- // we can do is format the date in UTC.
8541
- // 2. The format options don't tell us to show the zone. Then we can adjust them
8542
- // the time and tell the formatter to show it to us in UTC, so that the time is right
8543
- // and the bad zone doesn't show up.
10183
+ // Not all fixed-offset zones like Etc/+4:30 are present in tzdata so
10184
+ // we manually apply the offset and substitute the zone as needed.
8544
10185
  z = "UTC";
8545
- if (opts.timeZoneName) {
8546
- this.dt = dt;
8547
- } else {
8548
- this.dt = dt.offset === 0 ? dt : DateTime.fromMillis(dt.ts + dt.offset * 60 * 1000);
8549
- }
10186
+ this.dt = dt.offset === 0 ? dt : dt.setZone("UTC").plus({
10187
+ minutes: dt.offset
10188
+ });
10189
+ this.originalZone = dt.zone;
8550
10190
  }
8551
10191
  } else if (dt.zone.type === "system") {
8552
10192
  this.dt = dt;
8553
- } else {
10193
+ } else if (dt.zone.type === "iana") {
8554
10194
  this.dt = dt;
8555
10195
  z = dt.zone.name;
10196
+ } else {
10197
+ // Custom zones can have any offset / offsetName so we just manually
10198
+ // apply the offset and substitute the zone as needed.
10199
+ z = "UTC";
10200
+ this.dt = dt.setZone("UTC").plus({
10201
+ minutes: dt.offset
10202
+ });
10203
+ this.originalZone = dt.zone;
8556
10204
  }
8557
10205
  const intlOpts = {
8558
10206
  ...this.opts
@@ -8561,10 +10209,34 @@ class PolyDateFormatter {
8561
10209
  this.dtf = getCachedDTF(intl, intlOpts);
8562
10210
  }
8563
10211
  format() {
10212
+ if (this.originalZone) {
10213
+ // If we have to substitute in the actual zone name, we have to use
10214
+ // formatToParts so that the timezone can be replaced.
10215
+ return this.formatToParts().map(({
10216
+ value
10217
+ }) => value).join("");
10218
+ }
8564
10219
  return this.dtf.format(this.dt.toJSDate());
8565
10220
  }
8566
10221
  formatToParts() {
8567
- return this.dtf.formatToParts(this.dt.toJSDate());
10222
+ const parts = this.dtf.formatToParts(this.dt.toJSDate());
10223
+ if (this.originalZone) {
10224
+ return parts.map(part => {
10225
+ if (part.type === "timeZoneName") {
10226
+ const offsetName = this.originalZone.offsetName(this.dt.ts, {
10227
+ locale: this.dt.locale,
10228
+ format: this.opts.timeZoneName
10229
+ });
10230
+ return {
10231
+ ...part,
10232
+ value: offsetName
10233
+ };
10234
+ } else {
10235
+ return part;
10236
+ }
10237
+ });
10238
+ }
10239
+ return parts;
8568
10240
  }
8569
10241
  resolvedOptions() {
8570
10242
  return this.dtf.resolvedOptions();
@@ -9223,7 +10895,10 @@ function objToLocalTS(obj) {
9223
10895
  // for legacy reasons, years between 0 and 99 are interpreted as 19XX; revert that
9224
10896
  if (obj.year < 100 && obj.year >= 0) {
9225
10897
  d = new Date(d);
9226
- d.setUTCFullYear(d.getUTCFullYear() - 1900);
10898
+ // set the month and day again, this is necessary because year 2000 is a leap year, but year 100 is not
10899
+ // so if obj.year is in 99, but obj.day makes it roll over into year 100,
10900
+ // the calculations done by Date.UTC are using year 2000 - which is incorrect
10901
+ d.setUTCFullYear(obj.year, obj.month - 1, obj.day);
9227
10902
  }
9228
10903
  return +d;
9229
10904
  }
@@ -9455,6 +11130,9 @@ class Formatter {
9455
11130
  return new Formatter(locale, opts);
9456
11131
  }
9457
11132
  static parseFormat(fmt) {
11133
+ // white-space is always considered a literal in user-provided formats
11134
+ // the " " token has a special meaning (see unitForToken)
11135
+
9458
11136
  let current = null,
9459
11137
  currentFull = "",
9460
11138
  bracketed = false;
@@ -9464,7 +11142,7 @@ class Formatter {
9464
11142
  if (c === "'") {
9465
11143
  if (currentFull.length > 0) {
9466
11144
  splits.push({
9467
- literal: bracketed,
11145
+ literal: bracketed || /^\s+$/.test(currentFull),
9468
11146
  val: currentFull
9469
11147
  });
9470
11148
  }
@@ -9478,7 +11156,7 @@ class Formatter {
9478
11156
  } else {
9479
11157
  if (currentFull.length > 0) {
9480
11158
  splits.push({
9481
- literal: false,
11159
+ literal: /^\s+$/.test(currentFull),
9482
11160
  val: currentFull
9483
11161
  });
9484
11162
  }
@@ -9488,7 +11166,7 @@ class Formatter {
9488
11166
  }
9489
11167
  if (currentFull.length > 0) {
9490
11168
  splits.push({
9491
- literal: bracketed,
11169
+ literal: bracketed || /^\s+$/.test(currentFull),
9492
11170
  val: currentFull
9493
11171
  });
9494
11172
  }
@@ -11216,7 +12894,7 @@ class Interval {
11216
12894
  if (!this.isValid) return NaN;
11217
12895
  const start = this.start.startOf(unit),
11218
12896
  end = this.end.startOf(unit);
11219
- return Math.floor(end.diff(start, unit).get(unit)) + 1;
12897
+ return Math.floor(end.diff(start, unit).get(unit)) + (end.valueOf() !== this.end.valueOf());
11220
12898
  }
11221
12899
 
11222
12900
  /**
@@ -12082,6 +13760,10 @@ function unitForToken(token, loc) {
12082
13760
  // because we don't have any way to figure out what they are
12083
13761
  case "z":
12084
13762
  return simple(/[a-z_+-/]{1,256}?/i);
13763
+ // this special-case "token" represents a place where a macro-token expanded into a white-space literal
13764
+ // in this case we accept any non-newline white-space
13765
+ case " ":
13766
+ return simple(/[^\S\n\r]/);
12085
13767
  default:
12086
13768
  return literal(t);
12087
13769
  }
@@ -12136,9 +13818,10 @@ function tokenForPart(part, formatOpts) {
12136
13818
  value
12137
13819
  } = part;
12138
13820
  if (type === "literal") {
13821
+ const isSpace = /^\s+$/.test(value);
12139
13822
  return {
12140
- literal: true,
12141
- val: value
13823
+ literal: !isSpace,
13824
+ val: isSpace ? " " : value
12142
13825
  };
12143
13826
  }
12144
13827
  const style = formatOpts[type];
@@ -12613,7 +14296,7 @@ function parseDataToDateTime(parsed, parsedZone, opts, format, text, specificOff
12613
14296
  setZone,
12614
14297
  zone
12615
14298
  } = opts;
12616
- if (parsed && Object.keys(parsed).length !== 0) {
14299
+ if (parsed && Object.keys(parsed).length !== 0 || parsedZone) {
12617
14300
  const interpretationZone = parsedZone || zone,
12618
14301
  inst = DateTime.fromObject(parsed, {
12619
14302
  ...opts,
@@ -14660,7 +16343,7 @@ function friendlyDateTime(dateTimeish) {
14660
16343
  }
14661
16344
  }
14662
16345
 
14663
- const VERSION = "3.2.1";
16346
+ const VERSION = "3.3.0";
14664
16347
 
14665
16348
  exports.DateTime = DateTime;
14666
16349
  exports.Duration = Duration;