@nmshd/consumption 3.1.2 → 3.2.0

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.
@@ -17,11 +17,11 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
17
17
  const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
18
18
  const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
19
19
  exports.buildInformation = {
20
- version: "3.1.2",
21
- build: "97",
22
- date: "2023-02-28T12:26:08+00:00",
23
- commit: "2f1f5663ab45e7557fb87876c98f508204e96daf",
24
- dependencies: {"@js-soft/docdb-querytranslator":"^1.1.0","ts-simple-nameof":"^1.3.1"},
20
+ version: "3.2.0",
21
+ build: "102",
22
+ date: "2023-07-10T07:56:22+00:00",
23
+ commit: "0f70e157bc91ea540ca63666ac145278990cb29e",
24
+ dependencies: {"@js-soft/docdb-querytranslator":"^1.1.0","@nmshd/iql":"^0.0.1","ts-simple-nameof":"^1.3.1"},
25
25
  libraries: {
26
26
  transport: transport_1.buildInformation,
27
27
  crypto: crypto_1.buildInformation,
@@ -559,13 +559,37 @@ exports.LocalAttributeListener = LocalAttributeListener;
559
559
  /*!*********************************************************!*\
560
560
  !*** ./dist/modules/attributes/AttributesController.js ***!
561
561
  \*********************************************************/
562
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
562
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
563
563
 
564
564
  "use strict";
565
565
 
566
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
567
+ if (k2 === undefined) k2 = k;
568
+ var desc = Object.getOwnPropertyDescriptor(m, k);
569
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
570
+ desc = { enumerable: true, get: function() { return m[k]; } };
571
+ }
572
+ Object.defineProperty(o, k2, desc);
573
+ }) : (function(o, m, k, k2) {
574
+ if (k2 === undefined) k2 = k;
575
+ o[k2] = m[k];
576
+ }));
577
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
578
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
579
+ }) : function(o, v) {
580
+ o["default"] = v;
581
+ });
582
+ var __importStar = (this && this.__importStar) || function (mod) {
583
+ if (mod && mod.__esModule) return mod;
584
+ var result = {};
585
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
586
+ __setModuleDefault(result, mod);
587
+ return result;
588
+ };
566
589
  Object.defineProperty(exports, "__esModule", ({ value: true }));
567
590
  exports.AttributesController = void 0;
568
591
  const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
592
+ const Iql = __importStar(__webpack_require__(/*! @nmshd/iql */ "./node_modules/@nmshd/iql/dist/src/index.js"));
569
593
  const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
570
594
  const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
571
595
  const consumption_1 = __webpack_require__(/*! ../../consumption */ "./dist/consumption/index.js");
@@ -676,6 +700,23 @@ class AttributesController extends consumption_1.ConsumptionBaseController {
676
700
  async getValidLocalAttributes(query, hideTechnical = false) {
677
701
  return await this.getLocalAttributes(query, hideTechnical, true);
678
702
  }
703
+ async executeIQLQuery(query) {
704
+ /* Fetch subset of attributes relevant for IQL queries. We filter for
705
+ * local identity attributes. */
706
+ const envelopedAttributes = (await this.attributes.find()).filter((e) => {
707
+ return e["@type"] === "LocalAttribute" && e.content["@type"] === "IdentityAttribute";
708
+ });
709
+ /* Remove envelope from attributes and execute query. IQL makes no use
710
+ * of the envelope data. */
711
+ const attributes = envelopedAttributes.map((e) => {
712
+ return e.content;
713
+ });
714
+ const indices = Iql.execute(query.queryString, attributes);
715
+ /* Map matched indices back to their respective attributes and return. */
716
+ const matchedAttributes = indices.map((ii) => envelopedAttributes[ii]);
717
+ const result = this.parseArray(matchedAttributes, LocalAttribute_1.LocalAttribute);
718
+ return result;
719
+ }
679
720
  async executeRelationshipAttributeQuery(query) {
680
721
  const parsedQuery = content_1.RelationshipAttributeQuery.from(query);
681
722
  const dbQuery = QueryTranslator_1.RelationshipAttributeQueryTranslator.translate(parsedQuery);
@@ -3401,6 +3442,7 @@ exports.ShareAttributeRequestItemProcessor = ShareAttributeRequestItemProcessor;
3401
3442
 
3402
3443
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3403
3444
  const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
3445
+ const iql_1 = __webpack_require__(/*! @nmshd/iql */ "./node_modules/@nmshd/iql/dist/src/index.js");
3404
3446
  const consumption_1 = __webpack_require__(/*! ../../../../consumption */ "./dist/consumption/index.js");
3405
3447
  const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
3406
3448
  function validateQuery(query, sender, recipient) {
@@ -3414,6 +3456,12 @@ function validateQuery(query, sender, recipient) {
3414
3456
  return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.invalidRequestItem("Cannot query own Attributes from a third party."));
3415
3457
  }
3416
3458
  }
3459
+ else if (query instanceof content_1.IQLQuery) {
3460
+ const validationResult = (0, iql_1.validate)(query.queryString);
3461
+ if (!validationResult.isValid) {
3462
+ return ValidationResult_1.ValidationResult.error(consumption_1.CoreErrors.requests.invalidRequestItem(`IQL query syntax error at character ${validationResult.error?.location.start.column}`));
3463
+ }
3464
+ }
3417
3465
  return ValidationResult_1.ValidationResult.success();
3418
3466
  }
3419
3467
  exports["default"] = validateQuery;
@@ -5043,218 +5091,1786 @@ function log(params) {
5043
5091
  if (params?.logParams) {
5044
5092
  thisT.log.trace(`Calling ${propertyName}(${args.map((a) => (0, json_stringify_safe_1.default)(a)).join(", ")})`);
5045
5093
  }
5046
- else {
5047
- thisT.log.trace(`Calling ${propertyName}`);
5094
+ else {
5095
+ thisT.log.trace(`Calling ${propertyName}`);
5096
+ }
5097
+ const returnValue = method.apply(this, args);
5098
+ if (params?.logReturnValue) {
5099
+ thisT.log.trace(`Returning from ${propertyName} with: ${(0, json_stringify_safe_1.default)(returnValue)}`);
5100
+ }
5101
+ else {
5102
+ thisT.log.trace(`Returning from ${propertyName}`);
5103
+ }
5104
+ return returnValue;
5105
+ }
5106
+ catch (error) {
5107
+ if (error instanceof Error && error.stack) {
5108
+ error.stack = error.stack
5109
+ .split("\n")
5110
+ .filter((s) => !s.includes(".propertyDescriptorDoNotChangeMyNamePlease.value"))
5111
+ .join("\n");
5112
+ }
5113
+ thisT.log.error(`Error in ${propertyName}:`, error);
5114
+ throw error;
5115
+ }
5116
+ };
5117
+ return propertyDescriptorDoNotChangeMyNamePlease;
5118
+ };
5119
+ }
5120
+ exports.log = log;
5121
+ //# sourceMappingURL=logDecorator.js.map
5122
+
5123
+ /***/ }),
5124
+
5125
+ /***/ "./node_modules/@js-soft/ts-utils/dist/measureExcecutionTime.js":
5126
+ /*!**********************************************************************!*\
5127
+ !*** ./node_modules/@js-soft/ts-utils/dist/measureExcecutionTime.js ***!
5128
+ \**********************************************************************/
5129
+ /***/ ((__unused_webpack_module, exports) => {
5130
+
5131
+ "use strict";
5132
+
5133
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
5134
+ exports.measureExcecutionTime = void 0;
5135
+ /* eslint-disable no-console */
5136
+ function measureExcecutionTime(_target, _propertyName, propertyDesciptor) {
5137
+ const method = propertyDesciptor.value;
5138
+ propertyDesciptor.value = async function (...args) {
5139
+ const t0 = Date.now();
5140
+ const result = await method.apply(this, args);
5141
+ const t1 = Date.now();
5142
+ console.info(`Execution time: ${t1 - t0}ms`);
5143
+ return result;
5144
+ };
5145
+ return propertyDesciptor;
5146
+ }
5147
+ exports.measureExcecutionTime = measureExcecutionTime;
5148
+ //# sourceMappingURL=measureExcecutionTime.js.map
5149
+
5150
+ /***/ }),
5151
+
5152
+ /***/ "./node_modules/@js-soft/ts-utils/dist/randomString.js":
5153
+ /*!*************************************************************!*\
5154
+ !*** ./node_modules/@js-soft/ts-utils/dist/randomString.js ***!
5155
+ \*************************************************************/
5156
+ /***/ ((__unused_webpack_module, exports) => {
5157
+
5158
+ "use strict";
5159
+
5160
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
5161
+ exports.randomString = void 0;
5162
+ function randomString(length, characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") {
5163
+ let result = "";
5164
+ const charactersLength = characters.length;
5165
+ for (let i = 0; i < length; i++) {
5166
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
5167
+ }
5168
+ return result;
5169
+ }
5170
+ exports.randomString = randomString;
5171
+ //# sourceMappingURL=randomString.js.map
5172
+
5173
+ /***/ }),
5174
+
5175
+ /***/ "./node_modules/@js-soft/ts-utils/dist/result/ApplicationError.js":
5176
+ /*!************************************************************************!*\
5177
+ !*** ./node_modules/@js-soft/ts-utils/dist/result/ApplicationError.js ***!
5178
+ \************************************************************************/
5179
+ /***/ ((__unused_webpack_module, exports) => {
5180
+
5181
+ "use strict";
5182
+
5183
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
5184
+ exports.ApplicationError = void 0;
5185
+ class ApplicationError extends Error {
5186
+ code;
5187
+ data;
5188
+ constructor(code, message, data) {
5189
+ super(message);
5190
+ this.code = code;
5191
+ this.data = data;
5192
+ }
5193
+ equals(error) {
5194
+ return this.code === error.code;
5195
+ }
5196
+ toString() {
5197
+ return JSON.stringify({ code: this.code, message: this.message, data: this.data }, undefined, 2);
5198
+ }
5199
+ }
5200
+ exports.ApplicationError = ApplicationError;
5201
+ //# sourceMappingURL=ApplicationError.js.map
5202
+
5203
+ /***/ }),
5204
+
5205
+ /***/ "./node_modules/@js-soft/ts-utils/dist/result/Result.js":
5206
+ /*!**************************************************************!*\
5207
+ !*** ./node_modules/@js-soft/ts-utils/dist/result/Result.js ***!
5208
+ \**************************************************************/
5209
+ /***/ ((__unused_webpack_module, exports) => {
5210
+
5211
+ "use strict";
5212
+
5213
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
5214
+ exports.Result = void 0;
5215
+ class Result {
5216
+ _isSuccess;
5217
+ _error;
5218
+ _value;
5219
+ constructor(isSuccess, value, error) {
5220
+ if (isSuccess && error) {
5221
+ throw new Error("InvalidOperation: A result cannot be successful and contain an error");
5222
+ }
5223
+ if (!isSuccess && !error) {
5224
+ throw new Error("InvalidOperation: A failing result needs to contain an error");
5225
+ }
5226
+ if (value !== undefined && !isSuccess) {
5227
+ throw new Error("InvalidOperation: A value is only useful in case of a success.");
5228
+ }
5229
+ this._value = value;
5230
+ this._isSuccess = isSuccess;
5231
+ this._error = error;
5232
+ }
5233
+ get isSuccess() {
5234
+ return this._isSuccess;
5235
+ }
5236
+ get isError() {
5237
+ return !this._isSuccess;
5238
+ }
5239
+ get error() {
5240
+ return this._error;
5241
+ }
5242
+ get value() {
5243
+ if (!this.isSuccess) {
5244
+ throw new Error(`Can't get the value of an error result. Use 'error' instead. Root error: \r\n${this.error}`);
5245
+ }
5246
+ return this._value;
5247
+ }
5248
+ static ok(value) {
5249
+ return new Result(true, value);
5250
+ }
5251
+ static fail(error) {
5252
+ return new Result(false, undefined, error);
5253
+ }
5254
+ }
5255
+ exports.Result = Result;
5256
+ //# sourceMappingURL=Result.js.map
5257
+
5258
+ /***/ }),
5259
+
5260
+ /***/ "./node_modules/@js-soft/ts-utils/dist/result/index.js":
5261
+ /*!*************************************************************!*\
5262
+ !*** ./node_modules/@js-soft/ts-utils/dist/result/index.js ***!
5263
+ \*************************************************************/
5264
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
5265
+
5266
+ "use strict";
5267
+
5268
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5269
+ if (k2 === undefined) k2 = k;
5270
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5271
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5272
+ desc = { enumerable: true, get: function() { return m[k]; } };
5273
+ }
5274
+ Object.defineProperty(o, k2, desc);
5275
+ }) : (function(o, m, k, k2) {
5276
+ if (k2 === undefined) k2 = k;
5277
+ o[k2] = m[k];
5278
+ }));
5279
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
5280
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
5281
+ };
5282
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
5283
+ __exportStar(__webpack_require__(/*! ./ApplicationError */ "./node_modules/@js-soft/ts-utils/dist/result/ApplicationError.js"), exports);
5284
+ __exportStar(__webpack_require__(/*! ./Result */ "./node_modules/@js-soft/ts-utils/dist/result/Result.js"), exports);
5285
+ //# sourceMappingURL=index.js.map
5286
+
5287
+ /***/ }),
5288
+
5289
+ /***/ "./node_modules/@js-soft/ts-utils/dist/sleep.js":
5290
+ /*!******************************************************!*\
5291
+ !*** ./node_modules/@js-soft/ts-utils/dist/sleep.js ***!
5292
+ \******************************************************/
5293
+ /***/ ((__unused_webpack_module, exports) => {
5294
+
5295
+ "use strict";
5296
+
5297
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
5298
+ exports.sleep = void 0;
5299
+ function sleep(ms) {
5300
+ return new Promise((resolve) => {
5301
+ setTimeout(resolve, ms);
5302
+ });
5303
+ }
5304
+ exports.sleep = sleep;
5305
+ //# sourceMappingURL=sleep.js.map
5306
+
5307
+ /***/ }),
5308
+
5309
+ /***/ "./node_modules/@nmshd/iql/dist/generated/iql.js":
5310
+ /*!*******************************************************!*\
5311
+ !*** ./node_modules/@nmshd/iql/dist/generated/iql.js ***!
5312
+ \*******************************************************/
5313
+ /***/ ((module) => {
5314
+
5315
+ "use strict";
5316
+ // Generated by Peggy 3.0.2.
5317
+ //
5318
+ // https://peggyjs.org/
5319
+
5320
+ /**
5321
+ * Takes the path through a nested dict as an array of strings and returns
5322
+ * the value, or a fallback value, if the path does not exist.
5323
+ */
5324
+ function resolvePath(dict, path, fallback = null) {
5325
+ let val = dict;
5326
+ for (const e of path) {
5327
+ if (!Object.keys(val).includes(e)) {
5328
+ return fallback;
5329
+ }
5330
+ val = val[e];
5331
+ }
5332
+ return val;
5333
+ }
5334
+ /**
5335
+ * Generic matching function for attributes.
5336
+ *
5337
+ * attributes: Array of attributes
5338
+ * path: Path to data field to apply matchFn to, represented as an
5339
+ * array of strings. E.g. Foo.bar.baz is represented as ["Foo",
5340
+ * "bar", "baz"].
5341
+ * matchFn: Predicate function applied to the value of the extracted
5342
+ * attribute data field represented by 'path'.
5343
+ * attributeType: See comment below.
5344
+ */
5345
+ function match(attributes, path, matchFn, attributeType = undefined) {
5346
+ const indices = [];
5347
+ for (let ii = 0; ii < attributes.length; ii++) {
5348
+ const val = resolvePath(attributes[ii], path, null);
5349
+ // If attributeType is defined, assert that it matches the attribute's
5350
+ // type. When matching primary fields the mechanism presented by matchFn
5351
+ // below is insufficient as it's not given the full attribute but only
5352
+ // the selected data field.
5353
+ if (attributeType !== undefined && attributes[ii].value["@type"] !== attributeType) {
5354
+ continue;
5355
+ }
5356
+ if (val !== null && matchFn(val)) {
5357
+ indices.push(ii);
5358
+ }
5359
+ }
5360
+ return indices;
5361
+ }
5362
+ /**
5363
+ * Returns the union of two sets (represented as arrays of primitive
5364
+ * elements).
5365
+ */
5366
+ function union(arr1, arr2) {
5367
+ const result = Array.from(new Set([...arr1, ...arr2]));
5368
+ result.sort((a, b) => { return a - b; });
5369
+ return result;
5370
+ }
5371
+ /**
5372
+ * Returns the intersection of two sets (represented as arrays of primitive
5373
+ * elements).
5374
+ */
5375
+ function intersect(b, ...a) {
5376
+ const result = [b, ...a].reduce((p, c) => p.filter(e => c.includes(e)));
5377
+ result.sort((a, b) => { return a - b; });
5378
+ return result;
5379
+ }
5380
+ /**
5381
+ * Returns the asymmetric difference of two sets (represented as arrays of
5382
+ * primitive elements).
5383
+ */
5384
+ function diffAsym(arr1, arr2) {
5385
+ const result = arr1.filter((x) => { return !arr2.includes(x); });
5386
+ result.sort((a, b) => { return a - b; });
5387
+ return result;
5388
+ }
5389
+ function peg$subclass(child, parent) {
5390
+ function C() { this.constructor = child; }
5391
+ C.prototype = parent.prototype;
5392
+ child.prototype = new C();
5393
+ }
5394
+ function peg$SyntaxError(message, expected, found, location) {
5395
+ var self = Error.call(this, message);
5396
+ // istanbul ignore next Check is a necessary evil to support older environments
5397
+ if (Object.setPrototypeOf) {
5398
+ Object.setPrototypeOf(self, peg$SyntaxError.prototype);
5399
+ }
5400
+ self.expected = expected;
5401
+ self.found = found;
5402
+ self.location = location;
5403
+ self.name = "SyntaxError";
5404
+ return self;
5405
+ }
5406
+ peg$subclass(peg$SyntaxError, Error);
5407
+ function peg$padEnd(str, targetLength, padString) {
5408
+ padString = padString || " ";
5409
+ if (str.length > targetLength) {
5410
+ return str;
5411
+ }
5412
+ targetLength -= str.length;
5413
+ padString += padString.repeat(targetLength);
5414
+ return str + padString.slice(0, targetLength);
5415
+ }
5416
+ peg$SyntaxError.prototype.format = function (sources) {
5417
+ var str = "Error: " + this.message;
5418
+ if (this.location) {
5419
+ var src = null;
5420
+ var k;
5421
+ for (k = 0; k < sources.length; k++) {
5422
+ if (sources[k].source === this.location.source) {
5423
+ src = sources[k].text.split(/\r\n|\n|\r/g);
5424
+ break;
5425
+ }
5426
+ }
5427
+ var s = this.location.start;
5428
+ var offset_s = (this.location.source && (typeof this.location.source.offset === "function"))
5429
+ ? this.location.source.offset(s)
5430
+ : s;
5431
+ var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
5432
+ if (src) {
5433
+ var e = this.location.end;
5434
+ var filler = peg$padEnd("", offset_s.line.toString().length, ' ');
5435
+ var line = src[s.line - 1];
5436
+ var last = s.line === e.line ? e.column : line.length + 1;
5437
+ var hatLen = (last - s.column) || 1;
5438
+ str += "\n --> " + loc + "\n"
5439
+ + filler + " |\n"
5440
+ + offset_s.line + " | " + line + "\n"
5441
+ + filler + " | " + peg$padEnd("", s.column - 1, ' ')
5442
+ + peg$padEnd("", hatLen, "^");
5443
+ }
5444
+ else {
5445
+ str += "\n at " + loc;
5446
+ }
5447
+ }
5448
+ return str;
5449
+ };
5450
+ peg$SyntaxError.buildMessage = function (expected, found) {
5451
+ var DESCRIBE_EXPECTATION_FNS = {
5452
+ literal: function (expectation) {
5453
+ return "\"" + literalEscape(expectation.text) + "\"";
5454
+ },
5455
+ class: function (expectation) {
5456
+ var escapedParts = expectation.parts.map(function (part) {
5457
+ return Array.isArray(part)
5458
+ ? classEscape(part[0]) + "-" + classEscape(part[1])
5459
+ : classEscape(part);
5460
+ });
5461
+ return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
5462
+ },
5463
+ any: function () {
5464
+ return "any character";
5465
+ },
5466
+ end: function () {
5467
+ return "end of input";
5468
+ },
5469
+ other: function (expectation) {
5470
+ return expectation.description;
5471
+ }
5472
+ };
5473
+ function hex(ch) {
5474
+ return ch.charCodeAt(0).toString(16).toUpperCase();
5475
+ }
5476
+ function literalEscape(s) {
5477
+ return s
5478
+ .replace(/\\/g, "\\\\")
5479
+ .replace(/"/g, "\\\"")
5480
+ .replace(/\0/g, "\\0")
5481
+ .replace(/\t/g, "\\t")
5482
+ .replace(/\n/g, "\\n")
5483
+ .replace(/\r/g, "\\r")
5484
+ .replace(/[\x00-\x0F]/g, function (ch) { return "\\x0" + hex(ch); })
5485
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return "\\x" + hex(ch); });
5486
+ }
5487
+ function classEscape(s) {
5488
+ return s
5489
+ .replace(/\\/g, "\\\\")
5490
+ .replace(/\]/g, "\\]")
5491
+ .replace(/\^/g, "\\^")
5492
+ .replace(/-/g, "\\-")
5493
+ .replace(/\0/g, "\\0")
5494
+ .replace(/\t/g, "\\t")
5495
+ .replace(/\n/g, "\\n")
5496
+ .replace(/\r/g, "\\r")
5497
+ .replace(/[\x00-\x0F]/g, function (ch) { return "\\x0" + hex(ch); })
5498
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return "\\x" + hex(ch); });
5499
+ }
5500
+ function describeExpectation(expectation) {
5501
+ return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
5502
+ }
5503
+ function describeExpected(expected) {
5504
+ var descriptions = expected.map(describeExpectation);
5505
+ var i, j;
5506
+ descriptions.sort();
5507
+ if (descriptions.length > 0) {
5508
+ for (i = 1, j = 1; i < descriptions.length; i++) {
5509
+ if (descriptions[i - 1] !== descriptions[i]) {
5510
+ descriptions[j] = descriptions[i];
5511
+ j++;
5512
+ }
5513
+ }
5514
+ descriptions.length = j;
5515
+ }
5516
+ switch (descriptions.length) {
5517
+ case 1:
5518
+ return descriptions[0];
5519
+ case 2:
5520
+ return descriptions[0] + " or " + descriptions[1];
5521
+ default:
5522
+ return descriptions.slice(0, -1).join(", ")
5523
+ + ", or "
5524
+ + descriptions[descriptions.length - 1];
5525
+ }
5526
+ }
5527
+ function describeFound(found) {
5528
+ return found ? "\"" + literalEscape(found) + "\"" : "end of input";
5529
+ }
5530
+ return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
5531
+ };
5532
+ function peg$parse(input, options) {
5533
+ options = options !== undefined ? options : {};
5534
+ var peg$FAILED = {};
5535
+ var peg$source = options.grammarSource;
5536
+ var peg$startRuleFunctions = { Expr: peg$parseExpr };
5537
+ var peg$startRuleFunction = peg$parseExpr;
5538
+ var peg$c0 = "||";
5539
+ var peg$c1 = "&&";
5540
+ var peg$c2 = "!";
5541
+ var peg$c3 = "(";
5542
+ var peg$c4 = ")";
5543
+ var peg$c5 = ".";
5544
+ var peg$c6 = "#";
5545
+ var peg$c7 = "'";
5546
+ var peg$c8 = "\\\\";
5547
+ var peg$c9 = "\\'";
5548
+ var peg$r0 = /^[=><~]/;
5549
+ var peg$r1 = /^[?]/;
5550
+ var peg$r2 = /^[^'\\]/;
5551
+ var peg$r3 = /^[^'\\ ]/;
5552
+ var peg$r4 = /^[a-z]/;
5553
+ var peg$r5 = /^[A-za-z0-9]/;
5554
+ var peg$r6 = /^[A-Z]/;
5555
+ var peg$r7 = /^[A-Za-z0-9]/;
5556
+ var peg$r8 = /^[ \t\n\r]/;
5557
+ var peg$e0 = peg$literalExpectation("||", false);
5558
+ var peg$e1 = peg$literalExpectation("&&", false);
5559
+ var peg$e2 = peg$literalExpectation("!", false);
5560
+ var peg$e3 = peg$literalExpectation("(", false);
5561
+ var peg$e4 = peg$literalExpectation(")", false);
5562
+ var peg$e5 = peg$otherExpectation("metadata field term");
5563
+ var peg$e6 = peg$literalExpectation(".", false);
5564
+ var peg$e7 = peg$otherExpectation("tag term");
5565
+ var peg$e8 = peg$literalExpectation("#", false);
5566
+ var peg$e9 = peg$otherExpectation("primary field term");
5567
+ var peg$e10 = peg$classExpectation(["=", ">", "<", "~"], false, false);
5568
+ var peg$e11 = peg$classExpectation(["?"], false, false);
5569
+ var peg$e12 = peg$literalExpectation("'", false);
5570
+ var peg$e13 = peg$literalExpectation("\\\\", false);
5571
+ var peg$e14 = peg$literalExpectation("\\'", false);
5572
+ var peg$e15 = peg$classExpectation(["'", "\\"], true, false);
5573
+ var peg$e16 = peg$classExpectation(["'", "\\", " "], true, false);
5574
+ var peg$e17 = peg$classExpectation([["a", "z"]], false, false);
5575
+ var peg$e18 = peg$classExpectation([["A", "z"], ["a", "z"], ["0", "9"]], false, false);
5576
+ var peg$e19 = peg$otherExpectation("attribute type");
5577
+ var peg$e20 = peg$classExpectation([["A", "Z"]], false, false);
5578
+ var peg$e21 = peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"]], false, false);
5579
+ var peg$e22 = peg$otherExpectation("whitespace");
5580
+ var peg$e23 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false);
5581
+ var peg$f0 = function (h, t) {
5582
+ return t.reduce((acc, element) => {
5583
+ return union(acc, element);
5584
+ }, h);
5585
+ };
5586
+ var peg$f1 = function (h, t) {
5587
+ return t.reduce((acc, element) => {
5588
+ return intersect(acc, element);
5589
+ }, h);
5590
+ };
5591
+ var peg$f2 = function (expr) {
5592
+ const allIndices = [...Array(options.attributes.length).keys()];
5593
+ return diffAsym(allIndices, expr);
5594
+ };
5595
+ var peg$f3 = function (pathPrefix, pathSuffix, matchFn) {
5596
+ return match(options.attributes, [pathPrefix, ...pathSuffix], matchFn);
5597
+ };
5598
+ var peg$f4 = function (tag) {
5599
+ return match(options.attributes, ["tags"], (fieldVal) => { return Array.isArray(fieldVal) && fieldVal.includes(tag); });
5600
+ };
5601
+ var peg$f5 = function (attributeType, path, matchFn) {
5602
+ const result = match(options.attributes, ["value", ...path], matchFn, attributeType);
5603
+ return result;
5604
+ };
5605
+ var peg$f6 = function (attributeType, matchFn) {
5606
+ return match(options.attributes, ["value", "value"], matchFn, attributeType);
5607
+ };
5608
+ var peg$f7 = function (attributeType) {
5609
+ // Providing only the attribute type returns attributes whose type
5610
+ // matches. E.g. 'PhoneNumber' will return all attributes whose type is
5611
+ // 'PhoneNumber', regardless of the values of any of their fields.
5612
+ return match(options.attributes, ["value", "@type"], (fieldVal) => { return fieldVal === attributeType; });
5613
+ };
5614
+ var peg$f8 = function (op, rhs) {
5615
+ switch (op) {
5616
+ case "=":
5617
+ return (fieldVal) => { return String(fieldVal) === rhs; };
5618
+ case ">":
5619
+ return (fieldVal) => { return new Date(fieldVal) >= new Date(rhs); };
5620
+ case "<":
5621
+ return (fieldVal) => { return new Date(fieldVal) <= new Date(rhs); };
5622
+ case "~":
5623
+ return (fieldVal) => { return Array.isArray(fieldVal) && fieldVal.includes(rhs); };
5624
+ }
5625
+ };
5626
+ var peg$f9 = function (op) {
5627
+ switch (op) {
5628
+ case "?":
5629
+ return (fieldVal) => { return fieldVal != undefined; };
5630
+ }
5631
+ };
5632
+ var peg$f10 = function (val) {
5633
+ return val.join("").replaceAll("\\\\", "\\").replaceAll("\\'", "'");
5634
+ };
5635
+ var peg$f11 = function (val) {
5636
+ return val.join("").replaceAll("\\\\", "\\").replaceAll("\\'", "'");
5637
+ };
5638
+ var peg$currPos = 0;
5639
+ var peg$savedPos = 0;
5640
+ var peg$posDetailsCache = [{ line: 1, column: 1 }];
5641
+ var peg$maxFailPos = 0;
5642
+ var peg$maxFailExpected = [];
5643
+ var peg$silentFails = 0;
5644
+ var peg$result;
5645
+ if ("startRule" in options) {
5646
+ if (!(options.startRule in peg$startRuleFunctions)) {
5647
+ throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
5648
+ }
5649
+ peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
5650
+ }
5651
+ function text() {
5652
+ return input.substring(peg$savedPos, peg$currPos);
5653
+ }
5654
+ function offset() {
5655
+ return peg$savedPos;
5656
+ }
5657
+ function range() {
5658
+ return {
5659
+ source: peg$source,
5660
+ start: peg$savedPos,
5661
+ end: peg$currPos
5662
+ };
5663
+ }
5664
+ function location() {
5665
+ return peg$computeLocation(peg$savedPos, peg$currPos);
5666
+ }
5667
+ function expected(description, location) {
5668
+ location = location !== undefined
5669
+ ? location
5670
+ : peg$computeLocation(peg$savedPos, peg$currPos);
5671
+ throw peg$buildStructuredError([peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location);
5672
+ }
5673
+ function error(message, location) {
5674
+ location = location !== undefined
5675
+ ? location
5676
+ : peg$computeLocation(peg$savedPos, peg$currPos);
5677
+ throw peg$buildSimpleError(message, location);
5678
+ }
5679
+ function peg$literalExpectation(text, ignoreCase) {
5680
+ return { type: "literal", text: text, ignoreCase: ignoreCase };
5681
+ }
5682
+ function peg$classExpectation(parts, inverted, ignoreCase) {
5683
+ return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
5684
+ }
5685
+ function peg$anyExpectation() {
5686
+ return { type: "any" };
5687
+ }
5688
+ function peg$endExpectation() {
5689
+ return { type: "end" };
5690
+ }
5691
+ function peg$otherExpectation(description) {
5692
+ return { type: "other", description: description };
5693
+ }
5694
+ function peg$computePosDetails(pos) {
5695
+ var details = peg$posDetailsCache[pos];
5696
+ var p;
5697
+ if (details) {
5698
+ return details;
5699
+ }
5700
+ else {
5701
+ p = pos - 1;
5702
+ while (!peg$posDetailsCache[p]) {
5703
+ p--;
5704
+ }
5705
+ details = peg$posDetailsCache[p];
5706
+ details = {
5707
+ line: details.line,
5708
+ column: details.column
5709
+ };
5710
+ while (p < pos) {
5711
+ if (input.charCodeAt(p) === 10) {
5712
+ details.line++;
5713
+ details.column = 1;
5714
+ }
5715
+ else {
5716
+ details.column++;
5717
+ }
5718
+ p++;
5719
+ }
5720
+ peg$posDetailsCache[pos] = details;
5721
+ return details;
5722
+ }
5723
+ }
5724
+ function peg$computeLocation(startPos, endPos, offset) {
5725
+ var startPosDetails = peg$computePosDetails(startPos);
5726
+ var endPosDetails = peg$computePosDetails(endPos);
5727
+ var res = {
5728
+ source: peg$source,
5729
+ start: {
5730
+ offset: startPos,
5731
+ line: startPosDetails.line,
5732
+ column: startPosDetails.column
5733
+ },
5734
+ end: {
5735
+ offset: endPos,
5736
+ line: endPosDetails.line,
5737
+ column: endPosDetails.column
5738
+ }
5739
+ };
5740
+ if (offset && peg$source && (typeof peg$source.offset === "function")) {
5741
+ res.start = peg$source.offset(res.start);
5742
+ res.end = peg$source.offset(res.end);
5743
+ }
5744
+ return res;
5745
+ }
5746
+ function peg$fail(expected) {
5747
+ if (peg$currPos < peg$maxFailPos) {
5748
+ return;
5749
+ }
5750
+ if (peg$currPos > peg$maxFailPos) {
5751
+ peg$maxFailPos = peg$currPos;
5752
+ peg$maxFailExpected = [];
5753
+ }
5754
+ peg$maxFailExpected.push(expected);
5755
+ }
5756
+ function peg$buildSimpleError(message, location) {
5757
+ return new peg$SyntaxError(message, null, null, location);
5758
+ }
5759
+ function peg$buildStructuredError(expected, found, location) {
5760
+ return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location);
5761
+ }
5762
+ function peg$parseExpr() {
5763
+ var s0, s1, s2, s3, s4, s5, s6, s7;
5764
+ s0 = peg$currPos;
5765
+ s1 = peg$parseExpr0();
5766
+ if (s1 !== peg$FAILED) {
5767
+ s2 = [];
5768
+ s3 = peg$currPos;
5769
+ s4 = [];
5770
+ s5 = peg$parse_();
5771
+ if (s5 !== peg$FAILED) {
5772
+ while (s5 !== peg$FAILED) {
5773
+ s4.push(s5);
5774
+ s5 = peg$parse_();
5775
+ }
5776
+ }
5777
+ else {
5778
+ s4 = peg$FAILED;
5779
+ }
5780
+ if (s4 !== peg$FAILED) {
5781
+ if (input.substr(peg$currPos, 2) === peg$c0) {
5782
+ s5 = peg$c0;
5783
+ peg$currPos += 2;
5784
+ }
5785
+ else {
5786
+ s5 = peg$FAILED;
5787
+ if (peg$silentFails === 0) {
5788
+ peg$fail(peg$e0);
5789
+ }
5790
+ }
5791
+ if (s5 !== peg$FAILED) {
5792
+ s6 = [];
5793
+ s7 = peg$parse_();
5794
+ if (s7 !== peg$FAILED) {
5795
+ while (s7 !== peg$FAILED) {
5796
+ s6.push(s7);
5797
+ s7 = peg$parse_();
5798
+ }
5799
+ }
5800
+ else {
5801
+ s6 = peg$FAILED;
5802
+ }
5803
+ if (s6 !== peg$FAILED) {
5804
+ s7 = peg$parseExpr0();
5805
+ if (s7 !== peg$FAILED) {
5806
+ s3 = s7;
5807
+ }
5808
+ else {
5809
+ peg$currPos = s3;
5810
+ s3 = peg$FAILED;
5811
+ }
5812
+ }
5813
+ else {
5814
+ peg$currPos = s3;
5815
+ s3 = peg$FAILED;
5816
+ }
5817
+ }
5818
+ else {
5819
+ peg$currPos = s3;
5820
+ s3 = peg$FAILED;
5821
+ }
5822
+ }
5823
+ else {
5824
+ peg$currPos = s3;
5825
+ s3 = peg$FAILED;
5826
+ }
5827
+ while (s3 !== peg$FAILED) {
5828
+ s2.push(s3);
5829
+ s3 = peg$currPos;
5830
+ s4 = [];
5831
+ s5 = peg$parse_();
5832
+ if (s5 !== peg$FAILED) {
5833
+ while (s5 !== peg$FAILED) {
5834
+ s4.push(s5);
5835
+ s5 = peg$parse_();
5836
+ }
5837
+ }
5838
+ else {
5839
+ s4 = peg$FAILED;
5840
+ }
5841
+ if (s4 !== peg$FAILED) {
5842
+ if (input.substr(peg$currPos, 2) === peg$c0) {
5843
+ s5 = peg$c0;
5844
+ peg$currPos += 2;
5845
+ }
5846
+ else {
5847
+ s5 = peg$FAILED;
5848
+ if (peg$silentFails === 0) {
5849
+ peg$fail(peg$e0);
5850
+ }
5851
+ }
5852
+ if (s5 !== peg$FAILED) {
5853
+ s6 = [];
5854
+ s7 = peg$parse_();
5855
+ if (s7 !== peg$FAILED) {
5856
+ while (s7 !== peg$FAILED) {
5857
+ s6.push(s7);
5858
+ s7 = peg$parse_();
5859
+ }
5860
+ }
5861
+ else {
5862
+ s6 = peg$FAILED;
5863
+ }
5864
+ if (s6 !== peg$FAILED) {
5865
+ s7 = peg$parseExpr0();
5866
+ if (s7 !== peg$FAILED) {
5867
+ s3 = s7;
5868
+ }
5869
+ else {
5870
+ peg$currPos = s3;
5871
+ s3 = peg$FAILED;
5872
+ }
5873
+ }
5874
+ else {
5875
+ peg$currPos = s3;
5876
+ s3 = peg$FAILED;
5877
+ }
5878
+ }
5879
+ else {
5880
+ peg$currPos = s3;
5881
+ s3 = peg$FAILED;
5882
+ }
5883
+ }
5884
+ else {
5885
+ peg$currPos = s3;
5886
+ s3 = peg$FAILED;
5887
+ }
5888
+ }
5889
+ peg$savedPos = s0;
5890
+ s0 = peg$f0(s1, s2);
5891
+ }
5892
+ else {
5893
+ peg$currPos = s0;
5894
+ s0 = peg$FAILED;
5895
+ }
5896
+ return s0;
5897
+ }
5898
+ function peg$parseExpr0() {
5899
+ var s0, s1, s2, s3, s4, s5, s6, s7;
5900
+ s0 = peg$currPos;
5901
+ s1 = peg$parseExpr1();
5902
+ if (s1 !== peg$FAILED) {
5903
+ s2 = [];
5904
+ s3 = peg$currPos;
5905
+ s4 = [];
5906
+ s5 = peg$parse_();
5907
+ if (s5 !== peg$FAILED) {
5908
+ while (s5 !== peg$FAILED) {
5909
+ s4.push(s5);
5910
+ s5 = peg$parse_();
5911
+ }
5912
+ }
5913
+ else {
5914
+ s4 = peg$FAILED;
5915
+ }
5916
+ if (s4 !== peg$FAILED) {
5917
+ if (input.substr(peg$currPos, 2) === peg$c1) {
5918
+ s5 = peg$c1;
5919
+ peg$currPos += 2;
5920
+ }
5921
+ else {
5922
+ s5 = peg$FAILED;
5923
+ if (peg$silentFails === 0) {
5924
+ peg$fail(peg$e1);
5925
+ }
5926
+ }
5927
+ if (s5 !== peg$FAILED) {
5928
+ s6 = [];
5929
+ s7 = peg$parse_();
5930
+ if (s7 !== peg$FAILED) {
5931
+ while (s7 !== peg$FAILED) {
5932
+ s6.push(s7);
5933
+ s7 = peg$parse_();
5934
+ }
5935
+ }
5936
+ else {
5937
+ s6 = peg$FAILED;
5938
+ }
5939
+ if (s6 !== peg$FAILED) {
5940
+ s7 = peg$parseExpr1();
5941
+ if (s7 !== peg$FAILED) {
5942
+ s3 = s7;
5943
+ }
5944
+ else {
5945
+ peg$currPos = s3;
5946
+ s3 = peg$FAILED;
5947
+ }
5948
+ }
5949
+ else {
5950
+ peg$currPos = s3;
5951
+ s3 = peg$FAILED;
5952
+ }
5953
+ }
5954
+ else {
5955
+ peg$currPos = s3;
5956
+ s3 = peg$FAILED;
5957
+ }
5958
+ }
5959
+ else {
5960
+ peg$currPos = s3;
5961
+ s3 = peg$FAILED;
5962
+ }
5963
+ while (s3 !== peg$FAILED) {
5964
+ s2.push(s3);
5965
+ s3 = peg$currPos;
5966
+ s4 = [];
5967
+ s5 = peg$parse_();
5968
+ if (s5 !== peg$FAILED) {
5969
+ while (s5 !== peg$FAILED) {
5970
+ s4.push(s5);
5971
+ s5 = peg$parse_();
5972
+ }
5973
+ }
5974
+ else {
5975
+ s4 = peg$FAILED;
5976
+ }
5977
+ if (s4 !== peg$FAILED) {
5978
+ if (input.substr(peg$currPos, 2) === peg$c1) {
5979
+ s5 = peg$c1;
5980
+ peg$currPos += 2;
5981
+ }
5982
+ else {
5983
+ s5 = peg$FAILED;
5984
+ if (peg$silentFails === 0) {
5985
+ peg$fail(peg$e1);
5986
+ }
5987
+ }
5988
+ if (s5 !== peg$FAILED) {
5989
+ s6 = [];
5990
+ s7 = peg$parse_();
5991
+ if (s7 !== peg$FAILED) {
5992
+ while (s7 !== peg$FAILED) {
5993
+ s6.push(s7);
5994
+ s7 = peg$parse_();
5995
+ }
5996
+ }
5997
+ else {
5998
+ s6 = peg$FAILED;
5999
+ }
6000
+ if (s6 !== peg$FAILED) {
6001
+ s7 = peg$parseExpr1();
6002
+ if (s7 !== peg$FAILED) {
6003
+ s3 = s7;
6004
+ }
6005
+ else {
6006
+ peg$currPos = s3;
6007
+ s3 = peg$FAILED;
6008
+ }
6009
+ }
6010
+ else {
6011
+ peg$currPos = s3;
6012
+ s3 = peg$FAILED;
6013
+ }
6014
+ }
6015
+ else {
6016
+ peg$currPos = s3;
6017
+ s3 = peg$FAILED;
6018
+ }
6019
+ }
6020
+ else {
6021
+ peg$currPos = s3;
6022
+ s3 = peg$FAILED;
6023
+ }
6024
+ }
6025
+ peg$savedPos = s0;
6026
+ s0 = peg$f1(s1, s2);
6027
+ }
6028
+ else {
6029
+ peg$currPos = s0;
6030
+ s0 = peg$FAILED;
6031
+ }
6032
+ return s0;
6033
+ }
6034
+ function peg$parseExpr1() {
6035
+ var s0, s1, s2;
6036
+ s0 = peg$currPos;
6037
+ if (input.charCodeAt(peg$currPos) === 33) {
6038
+ s1 = peg$c2;
6039
+ peg$currPos++;
6040
+ }
6041
+ else {
6042
+ s1 = peg$FAILED;
6043
+ if (peg$silentFails === 0) {
6044
+ peg$fail(peg$e2);
6045
+ }
6046
+ }
6047
+ if (s1 !== peg$FAILED) {
6048
+ s2 = peg$parseExpr1();
6049
+ if (s2 !== peg$FAILED) {
6050
+ peg$savedPos = s0;
6051
+ s0 = peg$f2(s2);
6052
+ }
6053
+ else {
6054
+ peg$currPos = s0;
6055
+ s0 = peg$FAILED;
6056
+ }
6057
+ }
6058
+ else {
6059
+ peg$currPos = s0;
6060
+ s0 = peg$FAILED;
6061
+ }
6062
+ if (s0 === peg$FAILED) {
6063
+ s0 = peg$parseExpr2();
6064
+ }
6065
+ return s0;
6066
+ }
6067
+ function peg$parseExpr2() {
6068
+ var s0, s1, s2, s3, s4, s5;
6069
+ s0 = peg$currPos;
6070
+ if (input.charCodeAt(peg$currPos) === 40) {
6071
+ s1 = peg$c3;
6072
+ peg$currPos++;
6073
+ }
6074
+ else {
6075
+ s1 = peg$FAILED;
6076
+ if (peg$silentFails === 0) {
6077
+ peg$fail(peg$e3);
6078
+ }
6079
+ }
6080
+ if (s1 !== peg$FAILED) {
6081
+ s2 = [];
6082
+ s3 = peg$parse_();
6083
+ if (s3 !== peg$FAILED) {
6084
+ while (s3 !== peg$FAILED) {
6085
+ s2.push(s3);
6086
+ s3 = peg$parse_();
6087
+ }
6088
+ }
6089
+ else {
6090
+ s2 = peg$FAILED;
6091
+ }
6092
+ if (s2 !== peg$FAILED) {
6093
+ s3 = peg$parseExpr();
6094
+ if (s3 !== peg$FAILED) {
6095
+ s4 = [];
6096
+ s5 = peg$parse_();
6097
+ if (s5 !== peg$FAILED) {
6098
+ while (s5 !== peg$FAILED) {
6099
+ s4.push(s5);
6100
+ s5 = peg$parse_();
6101
+ }
6102
+ }
6103
+ else {
6104
+ s4 = peg$FAILED;
6105
+ }
6106
+ if (s4 !== peg$FAILED) {
6107
+ if (input.charCodeAt(peg$currPos) === 41) {
6108
+ s5 = peg$c4;
6109
+ peg$currPos++;
6110
+ }
6111
+ else {
6112
+ s5 = peg$FAILED;
6113
+ if (peg$silentFails === 0) {
6114
+ peg$fail(peg$e4);
6115
+ }
6116
+ }
6117
+ if (s5 !== peg$FAILED) {
6118
+ s0 = s3;
6119
+ }
6120
+ else {
6121
+ peg$currPos = s0;
6122
+ s0 = peg$FAILED;
6123
+ }
6124
+ }
6125
+ else {
6126
+ peg$currPos = s0;
6127
+ s0 = peg$FAILED;
6128
+ }
6129
+ }
6130
+ else {
6131
+ peg$currPos = s0;
6132
+ s0 = peg$FAILED;
6133
+ }
6134
+ }
6135
+ else {
6136
+ peg$currPos = s0;
6137
+ s0 = peg$FAILED;
6138
+ }
6139
+ }
6140
+ else {
6141
+ peg$currPos = s0;
6142
+ s0 = peg$FAILED;
6143
+ }
6144
+ if (s0 === peg$FAILED) {
6145
+ s0 = peg$parseTerm();
6146
+ }
6147
+ return s0;
6148
+ }
6149
+ function peg$parseTerm() {
6150
+ var s0;
6151
+ s0 = peg$parsePrimaryFieldTerm();
6152
+ if (s0 === peg$FAILED) {
6153
+ s0 = peg$parseMetadataFieldTerm();
6154
+ if (s0 === peg$FAILED) {
6155
+ s0 = peg$parseTagTerm();
6156
+ }
6157
+ }
6158
+ return s0;
6159
+ }
6160
+ function peg$parseMetadataFieldTerm() {
6161
+ var s0, s1, s2, s3, s4, s5;
6162
+ peg$silentFails++;
6163
+ s0 = peg$currPos;
6164
+ s1 = peg$parsePathSegment();
6165
+ if (s1 !== peg$FAILED) {
6166
+ s2 = [];
6167
+ s3 = peg$currPos;
6168
+ if (input.charCodeAt(peg$currPos) === 46) {
6169
+ s4 = peg$c5;
6170
+ peg$currPos++;
6171
+ }
6172
+ else {
6173
+ s4 = peg$FAILED;
6174
+ if (peg$silentFails === 0) {
6175
+ peg$fail(peg$e6);
6176
+ }
6177
+ }
6178
+ if (s4 !== peg$FAILED) {
6179
+ s5 = peg$parsePathSegment();
6180
+ if (s5 !== peg$FAILED) {
6181
+ s3 = s5;
6182
+ }
6183
+ else {
6184
+ peg$currPos = s3;
6185
+ s3 = peg$FAILED;
6186
+ }
6187
+ }
6188
+ else {
6189
+ peg$currPos = s3;
6190
+ s3 = peg$FAILED;
6191
+ }
6192
+ while (s3 !== peg$FAILED) {
6193
+ s2.push(s3);
6194
+ s3 = peg$currPos;
6195
+ if (input.charCodeAt(peg$currPos) === 46) {
6196
+ s4 = peg$c5;
6197
+ peg$currPos++;
6198
+ }
6199
+ else {
6200
+ s4 = peg$FAILED;
6201
+ if (peg$silentFails === 0) {
6202
+ peg$fail(peg$e6);
6203
+ }
6204
+ }
6205
+ if (s4 !== peg$FAILED) {
6206
+ s5 = peg$parsePathSegment();
6207
+ if (s5 !== peg$FAILED) {
6208
+ s3 = s5;
6209
+ }
6210
+ else {
6211
+ peg$currPos = s3;
6212
+ s3 = peg$FAILED;
6213
+ }
6214
+ }
6215
+ else {
6216
+ peg$currPos = s3;
6217
+ s3 = peg$FAILED;
6218
+ }
6219
+ }
6220
+ s3 = peg$parsePredicate();
6221
+ if (s3 !== peg$FAILED) {
6222
+ peg$savedPos = s0;
6223
+ s0 = peg$f3(s1, s2, s3);
6224
+ }
6225
+ else {
6226
+ peg$currPos = s0;
6227
+ s0 = peg$FAILED;
6228
+ }
6229
+ }
6230
+ else {
6231
+ peg$currPos = s0;
6232
+ s0 = peg$FAILED;
6233
+ }
6234
+ peg$silentFails--;
6235
+ if (s0 === peg$FAILED) {
6236
+ s1 = peg$FAILED;
6237
+ if (peg$silentFails === 0) {
6238
+ peg$fail(peg$e5);
6239
+ }
6240
+ }
6241
+ return s0;
6242
+ }
6243
+ function peg$parseTagTerm() {
6244
+ var s0, s1, s2;
6245
+ peg$silentFails++;
6246
+ s0 = peg$currPos;
6247
+ if (input.charCodeAt(peg$currPos) === 35) {
6248
+ s1 = peg$c6;
6249
+ peg$currPos++;
6250
+ }
6251
+ else {
6252
+ s1 = peg$FAILED;
6253
+ if (peg$silentFails === 0) {
6254
+ peg$fail(peg$e8);
6255
+ }
6256
+ }
6257
+ if (s1 !== peg$FAILED) {
6258
+ s2 = peg$parsePredicateRHS();
6259
+ if (s2 !== peg$FAILED) {
6260
+ peg$savedPos = s0;
6261
+ s0 = peg$f4(s2);
6262
+ }
6263
+ else {
6264
+ peg$currPos = s0;
6265
+ s0 = peg$FAILED;
6266
+ }
6267
+ }
6268
+ else {
6269
+ peg$currPos = s0;
6270
+ s0 = peg$FAILED;
6271
+ }
6272
+ peg$silentFails--;
6273
+ if (s0 === peg$FAILED) {
6274
+ s1 = peg$FAILED;
6275
+ if (peg$silentFails === 0) {
6276
+ peg$fail(peg$e7);
6277
+ }
6278
+ }
6279
+ return s0;
6280
+ }
6281
+ function peg$parsePrimaryFieldTerm() {
6282
+ var s0, s1, s2, s3, s4, s5;
6283
+ peg$silentFails++;
6284
+ s0 = peg$currPos;
6285
+ s1 = peg$parseAttributeType();
6286
+ if (s1 !== peg$FAILED) {
6287
+ s2 = [];
6288
+ s3 = peg$currPos;
6289
+ if (input.charCodeAt(peg$currPos) === 46) {
6290
+ s4 = peg$c5;
6291
+ peg$currPos++;
6292
+ }
6293
+ else {
6294
+ s4 = peg$FAILED;
6295
+ if (peg$silentFails === 0) {
6296
+ peg$fail(peg$e6);
6297
+ }
6298
+ }
6299
+ if (s4 !== peg$FAILED) {
6300
+ s5 = peg$parsePathSegment();
6301
+ if (s5 !== peg$FAILED) {
6302
+ s3 = s5;
6303
+ }
6304
+ else {
6305
+ peg$currPos = s3;
6306
+ s3 = peg$FAILED;
6307
+ }
6308
+ }
6309
+ else {
6310
+ peg$currPos = s3;
6311
+ s3 = peg$FAILED;
6312
+ }
6313
+ if (s3 !== peg$FAILED) {
6314
+ while (s3 !== peg$FAILED) {
6315
+ s2.push(s3);
6316
+ s3 = peg$currPos;
6317
+ if (input.charCodeAt(peg$currPos) === 46) {
6318
+ s4 = peg$c5;
6319
+ peg$currPos++;
6320
+ }
6321
+ else {
6322
+ s4 = peg$FAILED;
6323
+ if (peg$silentFails === 0) {
6324
+ peg$fail(peg$e6);
6325
+ }
6326
+ }
6327
+ if (s4 !== peg$FAILED) {
6328
+ s5 = peg$parsePathSegment();
6329
+ if (s5 !== peg$FAILED) {
6330
+ s3 = s5;
6331
+ }
6332
+ else {
6333
+ peg$currPos = s3;
6334
+ s3 = peg$FAILED;
6335
+ }
6336
+ }
6337
+ else {
6338
+ peg$currPos = s3;
6339
+ s3 = peg$FAILED;
6340
+ }
6341
+ }
6342
+ }
6343
+ else {
6344
+ s2 = peg$FAILED;
6345
+ }
6346
+ if (s2 !== peg$FAILED) {
6347
+ s3 = peg$parsePredicate();
6348
+ if (s3 !== peg$FAILED) {
6349
+ peg$savedPos = s0;
6350
+ s0 = peg$f5(s1, s2, s3);
6351
+ }
6352
+ else {
6353
+ peg$currPos = s0;
6354
+ s0 = peg$FAILED;
6355
+ }
6356
+ }
6357
+ else {
6358
+ peg$currPos = s0;
6359
+ s0 = peg$FAILED;
6360
+ }
6361
+ }
6362
+ else {
6363
+ peg$currPos = s0;
6364
+ s0 = peg$FAILED;
6365
+ }
6366
+ if (s0 === peg$FAILED) {
6367
+ s0 = peg$currPos;
6368
+ s1 = peg$parseAttributeType();
6369
+ if (s1 !== peg$FAILED) {
6370
+ s2 = peg$parsePredicate();
6371
+ if (s2 !== peg$FAILED) {
6372
+ peg$savedPos = s0;
6373
+ s0 = peg$f6(s1, s2);
6374
+ }
6375
+ else {
6376
+ peg$currPos = s0;
6377
+ s0 = peg$FAILED;
6378
+ }
6379
+ }
6380
+ else {
6381
+ peg$currPos = s0;
6382
+ s0 = peg$FAILED;
6383
+ }
6384
+ if (s0 === peg$FAILED) {
6385
+ s0 = peg$currPos;
6386
+ s1 = peg$parseAttributeType();
6387
+ if (s1 !== peg$FAILED) {
6388
+ peg$savedPos = s0;
6389
+ s1 = peg$f7(s1);
6390
+ }
6391
+ s0 = s1;
6392
+ }
6393
+ }
6394
+ peg$silentFails--;
6395
+ if (s0 === peg$FAILED) {
6396
+ s1 = peg$FAILED;
6397
+ if (peg$silentFails === 0) {
6398
+ peg$fail(peg$e9);
6399
+ }
6400
+ }
6401
+ return s0;
6402
+ }
6403
+ function peg$parsePredicate() {
6404
+ var s0, s1, s2;
6405
+ s0 = peg$currPos;
6406
+ if (peg$r0.test(input.charAt(peg$currPos))) {
6407
+ s1 = input.charAt(peg$currPos);
6408
+ peg$currPos++;
6409
+ }
6410
+ else {
6411
+ s1 = peg$FAILED;
6412
+ if (peg$silentFails === 0) {
6413
+ peg$fail(peg$e10);
6414
+ }
6415
+ }
6416
+ if (s1 !== peg$FAILED) {
6417
+ s2 = peg$parsePredicateRHS();
6418
+ if (s2 !== peg$FAILED) {
6419
+ peg$savedPos = s0;
6420
+ s0 = peg$f8(s1, s2);
6421
+ }
6422
+ else {
6423
+ peg$currPos = s0;
6424
+ s0 = peg$FAILED;
6425
+ }
6426
+ }
6427
+ else {
6428
+ peg$currPos = s0;
6429
+ s0 = peg$FAILED;
6430
+ }
6431
+ if (s0 === peg$FAILED) {
6432
+ s0 = peg$currPos;
6433
+ if (peg$r1.test(input.charAt(peg$currPos))) {
6434
+ s1 = input.charAt(peg$currPos);
6435
+ peg$currPos++;
6436
+ }
6437
+ else {
6438
+ s1 = peg$FAILED;
6439
+ if (peg$silentFails === 0) {
6440
+ peg$fail(peg$e11);
6441
+ }
6442
+ }
6443
+ if (s1 !== peg$FAILED) {
6444
+ peg$savedPos = s0;
6445
+ s1 = peg$f9(s1);
6446
+ }
6447
+ s0 = s1;
6448
+ }
6449
+ return s0;
6450
+ }
6451
+ function peg$parsePredicateRHS() {
6452
+ var s0, s1, s2, s3;
6453
+ s0 = peg$currPos;
6454
+ if (input.charCodeAt(peg$currPos) === 39) {
6455
+ s1 = peg$c7;
6456
+ peg$currPos++;
6457
+ }
6458
+ else {
6459
+ s1 = peg$FAILED;
6460
+ if (peg$silentFails === 0) {
6461
+ peg$fail(peg$e12);
6462
+ }
6463
+ }
6464
+ if (s1 !== peg$FAILED) {
6465
+ s2 = [];
6466
+ if (input.substr(peg$currPos, 2) === peg$c8) {
6467
+ s3 = peg$c8;
6468
+ peg$currPos += 2;
6469
+ }
6470
+ else {
6471
+ s3 = peg$FAILED;
6472
+ if (peg$silentFails === 0) {
6473
+ peg$fail(peg$e13);
6474
+ }
6475
+ }
6476
+ if (s3 === peg$FAILED) {
6477
+ if (input.substr(peg$currPos, 2) === peg$c9) {
6478
+ s3 = peg$c9;
6479
+ peg$currPos += 2;
6480
+ }
6481
+ else {
6482
+ s3 = peg$FAILED;
6483
+ if (peg$silentFails === 0) {
6484
+ peg$fail(peg$e14);
6485
+ }
6486
+ }
6487
+ if (s3 === peg$FAILED) {
6488
+ if (peg$r2.test(input.charAt(peg$currPos))) {
6489
+ s3 = input.charAt(peg$currPos);
6490
+ peg$currPos++;
6491
+ }
6492
+ else {
6493
+ s3 = peg$FAILED;
6494
+ if (peg$silentFails === 0) {
6495
+ peg$fail(peg$e15);
6496
+ }
6497
+ }
6498
+ }
6499
+ }
6500
+ while (s3 !== peg$FAILED) {
6501
+ s2.push(s3);
6502
+ if (input.substr(peg$currPos, 2) === peg$c8) {
6503
+ s3 = peg$c8;
6504
+ peg$currPos += 2;
6505
+ }
6506
+ else {
6507
+ s3 = peg$FAILED;
6508
+ if (peg$silentFails === 0) {
6509
+ peg$fail(peg$e13);
6510
+ }
6511
+ }
6512
+ if (s3 === peg$FAILED) {
6513
+ if (input.substr(peg$currPos, 2) === peg$c9) {
6514
+ s3 = peg$c9;
6515
+ peg$currPos += 2;
6516
+ }
6517
+ else {
6518
+ s3 = peg$FAILED;
6519
+ if (peg$silentFails === 0) {
6520
+ peg$fail(peg$e14);
6521
+ }
6522
+ }
6523
+ if (s3 === peg$FAILED) {
6524
+ if (peg$r2.test(input.charAt(peg$currPos))) {
6525
+ s3 = input.charAt(peg$currPos);
6526
+ peg$currPos++;
6527
+ }
6528
+ else {
6529
+ s3 = peg$FAILED;
6530
+ if (peg$silentFails === 0) {
6531
+ peg$fail(peg$e15);
6532
+ }
6533
+ }
6534
+ }
6535
+ }
6536
+ }
6537
+ if (input.charCodeAt(peg$currPos) === 39) {
6538
+ s3 = peg$c7;
6539
+ peg$currPos++;
6540
+ }
6541
+ else {
6542
+ s3 = peg$FAILED;
6543
+ if (peg$silentFails === 0) {
6544
+ peg$fail(peg$e12);
6545
+ }
6546
+ }
6547
+ if (s3 !== peg$FAILED) {
6548
+ peg$savedPos = s0;
6549
+ s0 = peg$f10(s2);
6550
+ }
6551
+ else {
6552
+ peg$currPos = s0;
6553
+ s0 = peg$FAILED;
6554
+ }
6555
+ }
6556
+ else {
6557
+ peg$currPos = s0;
6558
+ s0 = peg$FAILED;
6559
+ }
6560
+ if (s0 === peg$FAILED) {
6561
+ s0 = peg$currPos;
6562
+ s1 = [];
6563
+ if (input.substr(peg$currPos, 2) === peg$c8) {
6564
+ s2 = peg$c8;
6565
+ peg$currPos += 2;
6566
+ }
6567
+ else {
6568
+ s2 = peg$FAILED;
6569
+ if (peg$silentFails === 0) {
6570
+ peg$fail(peg$e13);
6571
+ }
6572
+ }
6573
+ if (s2 === peg$FAILED) {
6574
+ if (input.substr(peg$currPos, 2) === peg$c9) {
6575
+ s2 = peg$c9;
6576
+ peg$currPos += 2;
6577
+ }
6578
+ else {
6579
+ s2 = peg$FAILED;
6580
+ if (peg$silentFails === 0) {
6581
+ peg$fail(peg$e14);
6582
+ }
6583
+ }
6584
+ if (s2 === peg$FAILED) {
6585
+ if (peg$r3.test(input.charAt(peg$currPos))) {
6586
+ s2 = input.charAt(peg$currPos);
6587
+ peg$currPos++;
6588
+ }
6589
+ else {
6590
+ s2 = peg$FAILED;
6591
+ if (peg$silentFails === 0) {
6592
+ peg$fail(peg$e16);
6593
+ }
6594
+ }
6595
+ }
6596
+ }
6597
+ while (s2 !== peg$FAILED) {
6598
+ s1.push(s2);
6599
+ if (input.substr(peg$currPos, 2) === peg$c8) {
6600
+ s2 = peg$c8;
6601
+ peg$currPos += 2;
6602
+ }
6603
+ else {
6604
+ s2 = peg$FAILED;
6605
+ if (peg$silentFails === 0) {
6606
+ peg$fail(peg$e13);
6607
+ }
6608
+ }
6609
+ if (s2 === peg$FAILED) {
6610
+ if (input.substr(peg$currPos, 2) === peg$c9) {
6611
+ s2 = peg$c9;
6612
+ peg$currPos += 2;
6613
+ }
6614
+ else {
6615
+ s2 = peg$FAILED;
6616
+ if (peg$silentFails === 0) {
6617
+ peg$fail(peg$e14);
6618
+ }
6619
+ }
6620
+ if (s2 === peg$FAILED) {
6621
+ if (peg$r3.test(input.charAt(peg$currPos))) {
6622
+ s2 = input.charAt(peg$currPos);
6623
+ peg$currPos++;
6624
+ }
6625
+ else {
6626
+ s2 = peg$FAILED;
6627
+ if (peg$silentFails === 0) {
6628
+ peg$fail(peg$e16);
6629
+ }
6630
+ }
6631
+ }
6632
+ }
6633
+ }
6634
+ peg$savedPos = s0;
6635
+ s1 = peg$f11(s1);
6636
+ s0 = s1;
6637
+ }
6638
+ return s0;
6639
+ }
6640
+ function peg$parsePathSegment() {
6641
+ var s0, s1, s2, s3, s4;
6642
+ s0 = peg$currPos;
6643
+ s1 = peg$currPos;
6644
+ if (peg$r4.test(input.charAt(peg$currPos))) {
6645
+ s2 = input.charAt(peg$currPos);
6646
+ peg$currPos++;
6647
+ }
6648
+ else {
6649
+ s2 = peg$FAILED;
6650
+ if (peg$silentFails === 0) {
6651
+ peg$fail(peg$e17);
6652
+ }
6653
+ }
6654
+ if (s2 !== peg$FAILED) {
6655
+ s3 = [];
6656
+ if (peg$r5.test(input.charAt(peg$currPos))) {
6657
+ s4 = input.charAt(peg$currPos);
6658
+ peg$currPos++;
6659
+ }
6660
+ else {
6661
+ s4 = peg$FAILED;
6662
+ if (peg$silentFails === 0) {
6663
+ peg$fail(peg$e18);
6664
+ }
6665
+ }
6666
+ if (s4 !== peg$FAILED) {
6667
+ while (s4 !== peg$FAILED) {
6668
+ s3.push(s4);
6669
+ if (peg$r5.test(input.charAt(peg$currPos))) {
6670
+ s4 = input.charAt(peg$currPos);
6671
+ peg$currPos++;
6672
+ }
6673
+ else {
6674
+ s4 = peg$FAILED;
6675
+ if (peg$silentFails === 0) {
6676
+ peg$fail(peg$e18);
6677
+ }
6678
+ }
6679
+ }
6680
+ }
6681
+ else {
6682
+ s3 = peg$FAILED;
6683
+ }
6684
+ if (s3 !== peg$FAILED) {
6685
+ s2 = [s2, s3];
6686
+ s1 = s2;
6687
+ }
6688
+ else {
6689
+ peg$currPos = s1;
6690
+ s1 = peg$FAILED;
6691
+ }
6692
+ }
6693
+ else {
6694
+ peg$currPos = s1;
6695
+ s1 = peg$FAILED;
6696
+ }
6697
+ if (s1 !== peg$FAILED) {
6698
+ s0 = input.substring(s0, peg$currPos);
6699
+ }
6700
+ else {
6701
+ s0 = s1;
6702
+ }
6703
+ return s0;
6704
+ }
6705
+ function peg$parseAttributeType() {
6706
+ var s0, s1, s2, s3, s4;
6707
+ peg$silentFails++;
6708
+ s0 = peg$currPos;
6709
+ s1 = peg$currPos;
6710
+ if (peg$r6.test(input.charAt(peg$currPos))) {
6711
+ s2 = input.charAt(peg$currPos);
6712
+ peg$currPos++;
6713
+ }
6714
+ else {
6715
+ s2 = peg$FAILED;
6716
+ if (peg$silentFails === 0) {
6717
+ peg$fail(peg$e20);
6718
+ }
6719
+ }
6720
+ if (s2 !== peg$FAILED) {
6721
+ s3 = [];
6722
+ if (peg$r7.test(input.charAt(peg$currPos))) {
6723
+ s4 = input.charAt(peg$currPos);
6724
+ peg$currPos++;
6725
+ }
6726
+ else {
6727
+ s4 = peg$FAILED;
6728
+ if (peg$silentFails === 0) {
6729
+ peg$fail(peg$e21);
5048
6730
  }
5049
- const returnValue = method.apply(this, args);
5050
- if (params?.logReturnValue) {
5051
- thisT.log.trace(`Returning from ${propertyName} with: ${(0, json_stringify_safe_1.default)(returnValue)}`);
6731
+ }
6732
+ while (s4 !== peg$FAILED) {
6733
+ s3.push(s4);
6734
+ if (peg$r7.test(input.charAt(peg$currPos))) {
6735
+ s4 = input.charAt(peg$currPos);
6736
+ peg$currPos++;
5052
6737
  }
5053
6738
  else {
5054
- thisT.log.trace(`Returning from ${propertyName}`);
6739
+ s4 = peg$FAILED;
6740
+ if (peg$silentFails === 0) {
6741
+ peg$fail(peg$e21);
6742
+ }
5055
6743
  }
5056
- return returnValue;
5057
6744
  }
5058
- catch (error) {
5059
- if (error instanceof Error && error.stack) {
5060
- error.stack = error.stack
5061
- .split("\n")
5062
- .filter((s) => !s.includes(".propertyDescriptorDoNotChangeMyNamePlease.value"))
5063
- .join("\n");
5064
- }
5065
- thisT.log.error(`Error in ${propertyName}:`, error);
5066
- throw error;
6745
+ s2 = [s2, s3];
6746
+ s1 = s2;
6747
+ }
6748
+ else {
6749
+ peg$currPos = s1;
6750
+ s1 = peg$FAILED;
6751
+ }
6752
+ if (s1 !== peg$FAILED) {
6753
+ s0 = input.substring(s0, peg$currPos);
6754
+ }
6755
+ else {
6756
+ s0 = s1;
6757
+ }
6758
+ peg$silentFails--;
6759
+ if (s0 === peg$FAILED) {
6760
+ s1 = peg$FAILED;
6761
+ if (peg$silentFails === 0) {
6762
+ peg$fail(peg$e19);
5067
6763
  }
5068
- };
5069
- return propertyDescriptorDoNotChangeMyNamePlease;
5070
- };
5071
- }
5072
- exports.log = log;
5073
- //# sourceMappingURL=logDecorator.js.map
5074
-
5075
- /***/ }),
5076
-
5077
- /***/ "./node_modules/@js-soft/ts-utils/dist/measureExcecutionTime.js":
5078
- /*!**********************************************************************!*\
5079
- !*** ./node_modules/@js-soft/ts-utils/dist/measureExcecutionTime.js ***!
5080
- \**********************************************************************/
5081
- /***/ ((__unused_webpack_module, exports) => {
5082
-
5083
- "use strict";
5084
-
5085
- Object.defineProperty(exports, "__esModule", ({ value: true }));
5086
- exports.measureExcecutionTime = void 0;
5087
- /* eslint-disable no-console */
5088
- function measureExcecutionTime(_target, _propertyName, propertyDesciptor) {
5089
- const method = propertyDesciptor.value;
5090
- propertyDesciptor.value = async function (...args) {
5091
- const t0 = Date.now();
5092
- const result = await method.apply(this, args);
5093
- const t1 = Date.now();
5094
- console.info(`Execution time: ${t1 - t0}ms`);
5095
- return result;
5096
- };
5097
- return propertyDesciptor;
5098
- }
5099
- exports.measureExcecutionTime = measureExcecutionTime;
5100
- //# sourceMappingURL=measureExcecutionTime.js.map
5101
-
5102
- /***/ }),
5103
-
5104
- /***/ "./node_modules/@js-soft/ts-utils/dist/randomString.js":
5105
- /*!*************************************************************!*\
5106
- !*** ./node_modules/@js-soft/ts-utils/dist/randomString.js ***!
5107
- \*************************************************************/
5108
- /***/ ((__unused_webpack_module, exports) => {
5109
-
5110
- "use strict";
5111
-
5112
- Object.defineProperty(exports, "__esModule", ({ value: true }));
5113
- exports.randomString = void 0;
5114
- function randomString(length, characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") {
5115
- let result = "";
5116
- const charactersLength = characters.length;
5117
- for (let i = 0; i < length; i++) {
5118
- result += characters.charAt(Math.floor(Math.random() * charactersLength));
5119
- }
5120
- return result;
5121
- }
5122
- exports.randomString = randomString;
5123
- //# sourceMappingURL=randomString.js.map
5124
-
5125
- /***/ }),
5126
-
5127
- /***/ "./node_modules/@js-soft/ts-utils/dist/result/ApplicationError.js":
5128
- /*!************************************************************************!*\
5129
- !*** ./node_modules/@js-soft/ts-utils/dist/result/ApplicationError.js ***!
5130
- \************************************************************************/
5131
- /***/ ((__unused_webpack_module, exports) => {
5132
-
5133
- "use strict";
5134
-
5135
- Object.defineProperty(exports, "__esModule", ({ value: true }));
5136
- exports.ApplicationError = void 0;
5137
- class ApplicationError extends Error {
5138
- code;
5139
- data;
5140
- constructor(code, message, data) {
5141
- super(message);
5142
- this.code = code;
5143
- this.data = data;
5144
- }
5145
- equals(error) {
5146
- return this.code === error.code;
5147
- }
5148
- toString() {
5149
- return JSON.stringify({ code: this.code, message: this.message, data: this.data }, undefined, 2);
6764
+ }
6765
+ return s0;
5150
6766
  }
5151
- }
5152
- exports.ApplicationError = ApplicationError;
5153
- //# sourceMappingURL=ApplicationError.js.map
5154
-
5155
- /***/ }),
5156
-
5157
- /***/ "./node_modules/@js-soft/ts-utils/dist/result/Result.js":
5158
- /*!**************************************************************!*\
5159
- !*** ./node_modules/@js-soft/ts-utils/dist/result/Result.js ***!
5160
- \**************************************************************/
5161
- /***/ ((__unused_webpack_module, exports) => {
5162
-
5163
- "use strict";
5164
-
5165
- Object.defineProperty(exports, "__esModule", ({ value: true }));
5166
- exports.Result = void 0;
5167
- class Result {
5168
- _isSuccess;
5169
- _error;
5170
- _value;
5171
- constructor(isSuccess, value, error) {
5172
- if (isSuccess && error) {
5173
- throw new Error("InvalidOperation: A result cannot be successful and contain an error");
6767
+ function peg$parse_() {
6768
+ var s0, s1;
6769
+ peg$silentFails++;
6770
+ if (peg$r8.test(input.charAt(peg$currPos))) {
6771
+ s0 = input.charAt(peg$currPos);
6772
+ peg$currPos++;
5174
6773
  }
5175
- if (!isSuccess && !error) {
5176
- throw new Error("InvalidOperation: A failing result needs to contain an error");
6774
+ else {
6775
+ s0 = peg$FAILED;
6776
+ if (peg$silentFails === 0) {
6777
+ peg$fail(peg$e23);
6778
+ }
5177
6779
  }
5178
- if (value !== undefined && !isSuccess) {
5179
- throw new Error("InvalidOperation: A value is only useful in case of a success.");
6780
+ peg$silentFails--;
6781
+ if (s0 === peg$FAILED) {
6782
+ s1 = peg$FAILED;
6783
+ if (peg$silentFails === 0) {
6784
+ peg$fail(peg$e22);
6785
+ }
5180
6786
  }
5181
- this._value = value;
5182
- this._isSuccess = isSuccess;
5183
- this._error = error;
5184
- }
5185
- get isSuccess() {
5186
- return this._isSuccess;
6787
+ return s0;
5187
6788
  }
5188
- get isError() {
5189
- return !this._isSuccess;
5190
- }
5191
- get error() {
5192
- return this._error;
6789
+ peg$result = peg$startRuleFunction();
6790
+ if (peg$result !== peg$FAILED && peg$currPos === input.length) {
6791
+ return peg$result;
5193
6792
  }
5194
- get value() {
5195
- if (!this.isSuccess) {
5196
- throw new Error(`Can't get the value of an error result. Use 'error' instead. Root error: \r\n${this.error}`);
6793
+ else {
6794
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
6795
+ peg$fail(peg$endExpectation());
5197
6796
  }
5198
- return this._value;
5199
- }
5200
- static ok(value) {
5201
- return new Result(true, value);
5202
- }
5203
- static fail(error) {
5204
- return new Result(false, undefined, error);
6797
+ throw peg$buildStructuredError(peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length
6798
+ ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
6799
+ : peg$computeLocation(peg$maxFailPos, peg$maxFailPos));
5205
6800
  }
5206
6801
  }
5207
- exports.Result = Result;
5208
- //# sourceMappingURL=Result.js.map
5209
-
5210
- /***/ }),
5211
-
5212
- /***/ "./node_modules/@js-soft/ts-utils/dist/result/index.js":
5213
- /*!*************************************************************!*\
5214
- !*** ./node_modules/@js-soft/ts-utils/dist/result/index.js ***!
5215
- \*************************************************************/
5216
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
5217
-
5218
- "use strict";
5219
-
5220
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5221
- if (k2 === undefined) k2 = k;
5222
- var desc = Object.getOwnPropertyDescriptor(m, k);
5223
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5224
- desc = { enumerable: true, get: function() { return m[k]; } };
5225
- }
5226
- Object.defineProperty(o, k2, desc);
5227
- }) : (function(o, m, k, k2) {
5228
- if (k2 === undefined) k2 = k;
5229
- o[k2] = m[k];
5230
- }));
5231
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
5232
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
6802
+ module.exports = {
6803
+ SyntaxError: peg$SyntaxError,
6804
+ parse: peg$parse
5233
6805
  };
5234
- Object.defineProperty(exports, "__esModule", ({ value: true }));
5235
- __exportStar(__webpack_require__(/*! ./ApplicationError */ "./node_modules/@js-soft/ts-utils/dist/result/ApplicationError.js"), exports);
5236
- __exportStar(__webpack_require__(/*! ./Result */ "./node_modules/@js-soft/ts-utils/dist/result/Result.js"), exports);
5237
- //# sourceMappingURL=index.js.map
6806
+ //# sourceMappingURL=iql.js.map
5238
6807
 
5239
6808
  /***/ }),
5240
6809
 
5241
- /***/ "./node_modules/@js-soft/ts-utils/dist/sleep.js":
5242
- /*!******************************************************!*\
5243
- !*** ./node_modules/@js-soft/ts-utils/dist/sleep.js ***!
5244
- \******************************************************/
5245
- /***/ ((__unused_webpack_module, exports) => {
6810
+ /***/ "./node_modules/@nmshd/iql/dist/src/index.js":
6811
+ /*!***************************************************!*\
6812
+ !*** ./node_modules/@nmshd/iql/dist/src/index.js ***!
6813
+ \***************************************************/
6814
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5246
6815
 
5247
6816
  "use strict";
5248
6817
 
5249
6818
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5250
- exports.sleep = void 0;
5251
- function sleep(ms) {
5252
- return new Promise((resolve) => {
5253
- setTimeout(resolve, ms);
5254
- });
6819
+ exports.validate = exports.execute = void 0;
6820
+ const iql_js_1 = __webpack_require__(/*! ../generated/iql.js */ "./node_modules/@nmshd/iql/dist/generated/iql.js");
6821
+ /**
6822
+ * Executes IQL query, returning array of indicies of matched attributes in
6823
+ * attribute array.
6824
+ */
6825
+ function execute(iqlQuery, attributes) {
6826
+ return (0, iql_js_1.parse)(iqlQuery, { attributes });
5255
6827
  }
5256
- exports.sleep = sleep;
5257
- //# sourceMappingURL=sleep.js.map
6828
+ exports.execute = execute;
6829
+ function validate(iqlQuery) {
6830
+ try {
6831
+ (0, iql_js_1.parse)(iqlQuery, { attributes: [] });
6832
+ return { isValid: true };
6833
+ }
6834
+ catch (error) {
6835
+ // FIXME: Is there a cleaner way to catch IQL SyntaxErrors?
6836
+ // For the sake of backwards compatibility peggy compiles to old
6837
+ // js without the use of classes. Thus the static type inference
6838
+ // for the SyntaxError type is severely crippled.
6839
+ if (error instanceof iql_js_1.SyntaxError) {
6840
+ const err = error; // see FIXME above.
6841
+ return {
6842
+ isValid: false,
6843
+ error: {
6844
+ message: err.message,
6845
+ location: {
6846
+ start: err.location.start,
6847
+ end: err.location.end
6848
+ }
6849
+ }
6850
+ };
6851
+ }
6852
+ return {
6853
+ isValid: false,
6854
+ error: {
6855
+ message: JSON.stringify(error),
6856
+ location: {
6857
+ start: {
6858
+ column: 0,
6859
+ line: 0,
6860
+ offset: 0
6861
+ },
6862
+ end: {
6863
+ column: 0,
6864
+ line: 0,
6865
+ offset: 0
6866
+ }
6867
+ }
6868
+ }
6869
+ };
6870
+ }
6871
+ }
6872
+ exports.validate = validate;
6873
+ //# sourceMappingURL=index.js.map
5258
6874
 
5259
6875
  /***/ }),
5260
6876
 
@@ -24883,8 +26499,12 @@ class PolyNumberFormatter {
24883
26499
  class PolyDateFormatter {
24884
26500
  constructor(dt, intl, opts) {
24885
26501
  this.opts = opts;
26502
+ this.originalZone = undefined;
24886
26503
  let z = undefined;
24887
- if (dt.zone.isUniversal) {
26504
+ if (this.opts.timeZone) {
26505
+ // Don't apply any workarounds if a timeZone is explicitly provided in opts
26506
+ this.dt = dt;
26507
+ } else if (dt.zone.type === "fixed") {
24888
26508
  // UTC-8 or Etc/UTC-8 are not part of tzdata, only Etc/GMT+8 and the like.
24889
26509
  // That is why fixed-offset TZ is set to that unless it is:
24890
26510
  // 1. Representing offset 0 when UTC is used to maintain previous behavior and does not become GMT.
@@ -24897,25 +26517,27 @@ class PolyDateFormatter {
24897
26517
  z = offsetZ;
24898
26518
  this.dt = dt;
24899
26519
  } else {
24900
- // Not all fixed-offset zones like Etc/+4:30 are present in tzdata.
24901
- // So we have to make do. Two cases:
24902
- // 1. The format options tell us to show the zone. We can't do that, so the best
24903
- // we can do is format the date in UTC.
24904
- // 2. The format options don't tell us to show the zone. Then we can adjust them
24905
- // the time and tell the formatter to show it to us in UTC, so that the time is right
24906
- // and the bad zone doesn't show up.
26520
+ // Not all fixed-offset zones like Etc/+4:30 are present in tzdata so
26521
+ // we manually apply the offset and substitute the zone as needed.
24907
26522
  z = "UTC";
24908
- if (opts.timeZoneName) {
24909
- this.dt = dt;
24910
- } else {
24911
- this.dt = dt.offset === 0 ? dt : DateTime.fromMillis(dt.ts + dt.offset * 60 * 1000);
24912
- }
26523
+ this.dt = dt.offset === 0 ? dt : dt.setZone("UTC").plus({
26524
+ minutes: dt.offset
26525
+ });
26526
+ this.originalZone = dt.zone;
24913
26527
  }
24914
26528
  } else if (dt.zone.type === "system") {
24915
26529
  this.dt = dt;
24916
- } else {
26530
+ } else if (dt.zone.type === "iana") {
24917
26531
  this.dt = dt;
24918
26532
  z = dt.zone.name;
26533
+ } else {
26534
+ // Custom zones can have any offset / offsetName so we just manually
26535
+ // apply the offset and substitute the zone as needed.
26536
+ z = "UTC";
26537
+ this.dt = dt.setZone("UTC").plus({
26538
+ minutes: dt.offset
26539
+ });
26540
+ this.originalZone = dt.zone;
24919
26541
  }
24920
26542
  const intlOpts = {
24921
26543
  ...this.opts
@@ -24924,10 +26546,34 @@ class PolyDateFormatter {
24924
26546
  this.dtf = getCachedDTF(intl, intlOpts);
24925
26547
  }
24926
26548
  format() {
26549
+ if (this.originalZone) {
26550
+ // If we have to substitute in the actual zone name, we have to use
26551
+ // formatToParts so that the timezone can be replaced.
26552
+ return this.formatToParts().map(({
26553
+ value
26554
+ }) => value).join("");
26555
+ }
24927
26556
  return this.dtf.format(this.dt.toJSDate());
24928
26557
  }
24929
26558
  formatToParts() {
24930
- return this.dtf.formatToParts(this.dt.toJSDate());
26559
+ const parts = this.dtf.formatToParts(this.dt.toJSDate());
26560
+ if (this.originalZone) {
26561
+ return parts.map(part => {
26562
+ if (part.type === "timeZoneName") {
26563
+ const offsetName = this.originalZone.offsetName(this.dt.ts, {
26564
+ locale: this.dt.locale,
26565
+ format: this.opts.timeZoneName
26566
+ });
26567
+ return {
26568
+ ...part,
26569
+ value: offsetName
26570
+ };
26571
+ } else {
26572
+ return part;
26573
+ }
26574
+ });
26575
+ }
26576
+ return parts;
24931
26577
  }
24932
26578
  resolvedOptions() {
24933
26579
  return this.dtf.resolvedOptions();
@@ -25586,7 +27232,10 @@ function objToLocalTS(obj) {
25586
27232
  // for legacy reasons, years between 0 and 99 are interpreted as 19XX; revert that
25587
27233
  if (obj.year < 100 && obj.year >= 0) {
25588
27234
  d = new Date(d);
25589
- d.setUTCFullYear(d.getUTCFullYear() - 1900);
27235
+ // set the month and day again, this is necessary because year 2000 is a leap year, but year 100 is not
27236
+ // so if obj.year is in 99, but obj.day makes it roll over into year 100,
27237
+ // the calculations done by Date.UTC are using year 2000 - which is incorrect
27238
+ d.setUTCFullYear(obj.year, obj.month - 1, obj.day);
25590
27239
  }
25591
27240
  return +d;
25592
27241
  }
@@ -25818,6 +27467,9 @@ class Formatter {
25818
27467
  return new Formatter(locale, opts);
25819
27468
  }
25820
27469
  static parseFormat(fmt) {
27470
+ // white-space is always considered a literal in user-provided formats
27471
+ // the " " token has a special meaning (see unitForToken)
27472
+
25821
27473
  let current = null,
25822
27474
  currentFull = "",
25823
27475
  bracketed = false;
@@ -25827,7 +27479,7 @@ class Formatter {
25827
27479
  if (c === "'") {
25828
27480
  if (currentFull.length > 0) {
25829
27481
  splits.push({
25830
- literal: bracketed,
27482
+ literal: bracketed || /^\s+$/.test(currentFull),
25831
27483
  val: currentFull
25832
27484
  });
25833
27485
  }
@@ -25841,7 +27493,7 @@ class Formatter {
25841
27493
  } else {
25842
27494
  if (currentFull.length > 0) {
25843
27495
  splits.push({
25844
- literal: false,
27496
+ literal: /^\s+$/.test(currentFull),
25845
27497
  val: currentFull
25846
27498
  });
25847
27499
  }
@@ -25851,7 +27503,7 @@ class Formatter {
25851
27503
  }
25852
27504
  if (currentFull.length > 0) {
25853
27505
  splits.push({
25854
- literal: bracketed,
27506
+ literal: bracketed || /^\s+$/.test(currentFull),
25855
27507
  val: currentFull
25856
27508
  });
25857
27509
  }
@@ -27579,7 +29231,7 @@ class Interval {
27579
29231
  if (!this.isValid) return NaN;
27580
29232
  const start = this.start.startOf(unit),
27581
29233
  end = this.end.startOf(unit);
27582
- return Math.floor(end.diff(start, unit).get(unit)) + 1;
29234
+ return Math.floor(end.diff(start, unit).get(unit)) + (end.valueOf() !== this.end.valueOf());
27583
29235
  }
27584
29236
 
27585
29237
  /**
@@ -28445,6 +30097,10 @@ function unitForToken(token, loc) {
28445
30097
  // because we don't have any way to figure out what they are
28446
30098
  case "z":
28447
30099
  return simple(/[a-z_+-/]{1,256}?/i);
30100
+ // this special-case "token" represents a place where a macro-token expanded into a white-space literal
30101
+ // in this case we accept any non-newline white-space
30102
+ case " ":
30103
+ return simple(/[^\S\n\r]/);
28448
30104
  default:
28449
30105
  return literal(t);
28450
30106
  }
@@ -28499,9 +30155,10 @@ function tokenForPart(part, formatOpts) {
28499
30155
  value
28500
30156
  } = part;
28501
30157
  if (type === "literal") {
30158
+ const isSpace = /^\s+$/.test(value);
28502
30159
  return {
28503
- literal: true,
28504
- val: value
30160
+ literal: !isSpace,
30161
+ val: isSpace ? " " : value
28505
30162
  };
28506
30163
  }
28507
30164
  const style = formatOpts[type];
@@ -28976,7 +30633,7 @@ function parseDataToDateTime(parsed, parsedZone, opts, format, text, specificOff
28976
30633
  setZone,
28977
30634
  zone
28978
30635
  } = opts;
28979
- if (parsed && Object.keys(parsed).length !== 0) {
30636
+ if (parsed && Object.keys(parsed).length !== 0 || parsedZone) {
28980
30637
  const interpretationZone = parsedZone || zone,
28981
30638
  inst = DateTime.fromObject(parsed, {
28982
30639
  ...opts,
@@ -31023,7 +32680,7 @@ function friendlyDateTime(dateTimeish) {
31023
32680
  }
31024
32681
  }
31025
32682
 
31026
- const VERSION = "3.2.1";
32683
+ const VERSION = "3.3.0";
31027
32684
 
31028
32685
  exports.DateTime = DateTime;
31029
32686
  exports.Duration = Duration;