@hmcts/ccd-case-ui-toolkit 7.3.68-exui-4216-2 → 7.3.68-exui-4666-rc-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.
@@ -17,6 +17,7 @@ import moment from 'moment';
17
17
  import { __decorate, __metadata } from 'tslib';
18
18
  import * as _ from 'underscore';
19
19
  import 'reflect-metadata';
20
+ import { generate } from 'pegjs';
20
21
  import { StateMachine } from '@edium/fsm';
21
22
  import * as i1$3 from '@angular/material/legacy-dialog';
22
23
  import { MAT_LEGACY_DIALOG_DATA, MatLegacyDialogModule } from '@angular/material/legacy-dialog';
@@ -4797,1031 +4798,105 @@ class FieldsUtils {
4797
4798
  type: Injectable
4798
4799
  }], null, null); })();
4799
4800
 
4800
- /* eslint-disable */
4801
- // @ts-nocheck
4802
- // This file is generated by scripts/generate-condition-parser.mjs. Do not edit by hand.
4803
- // @generated by Peggy 5.1.0.
4804
- //
4805
- // https://peggyjs.org/
4806
- class peg$SyntaxError extends SyntaxError {
4807
- constructor(message, expected, found, location) {
4808
- super(message);
4809
- this.expected = expected;
4810
- this.found = found;
4811
- this.location = location;
4812
- this.name = "SyntaxError";
4813
- }
4814
- format(sources) {
4815
- let str = "Error: " + this.message;
4816
- if (this.location) {
4817
- let src = null;
4818
- const st = sources.find(s => s.source === this.location.source);
4819
- if (st) {
4820
- src = st.text.split(/\r\n|\n|\r/g);
4821
- }
4822
- const s = this.location.start;
4823
- const offset_s = (this.location.source && (typeof this.location.source.offset === "function"))
4824
- ? this.location.source.offset(s)
4825
- : s;
4826
- const loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
4827
- if (src) {
4828
- const e = this.location.end;
4829
- const filler = "".padEnd(offset_s.line.toString().length, " ");
4830
- const line = src[s.line - 1];
4831
- const last = s.line === e.line ? e.column : line.length + 1;
4832
- const hatLen = (last - s.column) || 1;
4833
- str += "\n --> " + loc + "\n"
4834
- + filler + " |\n"
4835
- + offset_s.line + " | " + line + "\n"
4836
- + filler + " | " + "".padEnd(s.column - 1, " ")
4837
- + "".padEnd(hatLen, "^");
4838
- }
4839
- else {
4840
- str += "\n at " + loc;
4841
- }
4842
- }
4843
- return str;
4844
- }
4845
- static buildMessage(expected, found) {
4846
- function hex(ch) {
4847
- return ch.codePointAt(0).toString(16).toUpperCase();
4848
- }
4849
- const nonPrintable = Object.prototype.hasOwnProperty.call(RegExp.prototype, "unicode")
4850
- ? new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]", "gu")
4851
- : null;
4852
- function unicodeEscape(s) {
4853
- if (nonPrintable) {
4854
- return s.replace(nonPrintable, ch => "\\u{" + hex(ch) + "}");
4855
- }
4856
- return s;
4857
- }
4858
- function literalEscape(s) {
4859
- return unicodeEscape(s
4860
- .replace(/\\/g, "\\\\")
4861
- .replace(/"/g, "\\\"")
4862
- .replace(/\0/g, "\\0")
4863
- .replace(/\t/g, "\\t")
4864
- .replace(/\n/g, "\\n")
4865
- .replace(/\r/g, "\\r")
4866
- .replace(/[\x00-\x0F]/g, ch => "\\x0" + hex(ch))
4867
- .replace(/[\x10-\x1F\x7F-\x9F]/g, ch => "\\x" + hex(ch)));
4868
- }
4869
- function classEscape(s) {
4870
- return unicodeEscape(s
4871
- .replace(/\\/g, "\\\\")
4872
- .replace(/\]/g, "\\]")
4873
- .replace(/\^/g, "\\^")
4874
- .replace(/-/g, "\\-")
4875
- .replace(/\0/g, "\\0")
4876
- .replace(/\t/g, "\\t")
4877
- .replace(/\n/g, "\\n")
4878
- .replace(/\r/g, "\\r")
4879
- .replace(/[\x00-\x0F]/g, ch => "\\x0" + hex(ch))
4880
- .replace(/[\x10-\x1F\x7F-\x9F]/g, ch => "\\x" + hex(ch)));
4881
- }
4882
- const DESCRIBE_EXPECTATION_FNS = {
4883
- literal(expectation) {
4884
- return "\"" + literalEscape(expectation.text) + "\"";
4885
- },
4886
- class(expectation) {
4887
- const escapedParts = expectation.parts.map(part => (Array.isArray(part)
4888
- ? classEscape(part[0]) + "-" + classEscape(part[1])
4889
- : classEscape(part)));
4890
- return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]" + (expectation.unicode ? "u" : "");
4891
- },
4892
- any() {
4893
- return "any character";
4894
- },
4895
- end() {
4896
- return "end of input";
4897
- },
4898
- other(expectation) {
4899
- return expectation.description;
4900
- },
4901
- };
4902
- function describeExpectation(expectation) {
4903
- return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
4904
- }
4905
- function describeExpected(expected) {
4906
- const descriptions = expected.map(describeExpectation);
4907
- descriptions.sort();
4908
- if (descriptions.length > 0) {
4909
- let j = 1;
4910
- for (let i = 1; i < descriptions.length; i++) {
4911
- if (descriptions[i - 1] !== descriptions[i]) {
4912
- descriptions[j] = descriptions[i];
4913
- j++;
4914
- }
4915
- }
4916
- descriptions.length = j;
4917
- }
4918
- switch (descriptions.length) {
4919
- case 1:
4920
- return descriptions[0];
4921
- case 2:
4922
- return descriptions[0] + " or " + descriptions[1];
4923
- default:
4924
- return descriptions.slice(0, -1).join(", ")
4925
- + ", or "
4926
- + descriptions[descriptions.length - 1];
4927
- }
4928
- }
4929
- function describeFound(found) {
4930
- return found ? "\"" + literalEscape(found) + "\"" : "end of input";
4931
- }
4932
- return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
4933
- }
4934
- }
4935
- function peg$parse(input, options) {
4936
- options = options !== undefined ? options : {};
4937
- const peg$FAILED = {};
4938
- const peg$source = options.grammarSource;
4939
- const peg$startRuleFunctions = {
4940
- Start: peg$parseStart,
4941
- };
4942
- let peg$startRuleFunction = peg$parseStart;
4943
- const peg$c0 = "AND";
4944
- const peg$c1 = "OR";
4945
- const peg$c2 = "[";
4946
- const peg$c3 = "]";
4947
- const peg$c4 = "\"";
4948
- const peg$c5 = "(";
4949
- const peg$c6 = ")";
4950
- const peg$c7 = "=";
4951
- const peg$c8 = "!=";
4952
- const peg$c9 = "CONTAINS";
4953
- const peg$r0 = /^[a-zA-Z]/;
4954
- const peg$r1 = /^[A-Za-z0-9._\-]/;
4955
- const peg$r2 = /^[0-9]/;
4956
- const peg$r3 = /^[A-Za-z0-9.,* _&()\/\-]/;
4957
- const peg$r4 = /^[ \t]/;
4958
- const peg$e0 = peg$literalExpectation("AND", false);
4959
- const peg$e1 = peg$literalExpectation("OR", false);
4960
- const peg$e2 = peg$classExpectation([["a", "z"], ["A", "Z"]], false, false, false);
4961
- const peg$e3 = peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"], ".", "_", "-"], false, false, false);
4962
- const peg$e4 = peg$literalExpectation("[", false);
4963
- const peg$e5 = peg$literalExpectation("]", false);
4964
- const peg$e6 = peg$classExpectation([["0", "9"]], false, false, false);
4965
- const peg$e7 = peg$literalExpectation("\"", false);
4966
- const peg$e8 = peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"], ".", ",", "*", " ", "_", "&", "(", ")", "/", "-"], false, false, false);
4967
- const peg$e9 = peg$literalExpectation("(", false);
4968
- const peg$e10 = peg$literalExpectation(")", false);
4969
- const peg$e11 = peg$literalExpectation("=", false);
4970
- const peg$e12 = peg$literalExpectation("!=", false);
4971
- const peg$e13 = peg$literalExpectation("CONTAINS", false);
4972
- const peg$e14 = peg$otherExpectation("Whitespace");
4973
- const peg$e15 = peg$classExpectation([" ", "\t"], false, false, false);
4974
- const peg$e16 = peg$otherExpectation("One or more whitespaces");
4975
- function peg$f0(formula, join) { return flat([[formula], join[0]], 1); }
4976
- function peg$f1(eq, joins) { return flat([eq, flat(joins)]); }
4977
- function peg$f2(comp, eq) { return [comp, eq]; }
4978
- function peg$f3(comp, f) { return [comp, f]; }
4979
- function peg$f4(fr, op, val) { return { fieldReference: fr, comparator: op, value: val }; }
4980
- function peg$f5(c) { return c; }
4981
- function peg$f6(c) { return c; }
4982
- function peg$f7(l) { return l.join(""); }
4983
- function peg$f8(v) { return v.join(""); }
4984
- function peg$f9(v) { return parseInt(v.join("")); }
4985
- function peg$f10(s1, fr, s2) { return s1 + fr + s2; }
4986
- function peg$f11(characters) { return characters.join(""); }
4987
- function peg$f12(val) { return val.join(""); }
4988
- let peg$currPos = options.peg$currPos | 0;
4989
- let peg$savedPos = peg$currPos;
4990
- const peg$posDetailsCache = [{ line: 1, column: 1 }];
4991
- let peg$maxFailPos = peg$currPos;
4992
- let peg$maxFailExpected = options.peg$maxFailExpected || [];
4993
- let peg$silentFails = options.peg$silentFails | 0;
4994
- let peg$result;
4995
- if (options.startRule) {
4996
- if (!(options.startRule in peg$startRuleFunctions)) {
4997
- throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
4998
- }
4999
- peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
5000
- }
5001
- function text() {
5002
- return input.substring(peg$savedPos, peg$currPos);
5003
- }
5004
- function offset() {
5005
- return peg$savedPos;
5006
- }
5007
- function range() {
5008
- return {
5009
- source: peg$source,
5010
- start: peg$savedPos,
5011
- end: peg$currPos,
5012
- };
5013
- }
5014
- function location() {
5015
- return peg$computeLocation(peg$savedPos, peg$currPos);
5016
- }
5017
- function expected(description, location) {
5018
- location = location !== undefined
5019
- ? location
5020
- : peg$computeLocation(peg$savedPos, peg$currPos);
5021
- throw peg$buildStructuredError([peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location);
5022
- }
5023
- function error(message, location) {
5024
- location = location !== undefined
5025
- ? location
5026
- : peg$computeLocation(peg$savedPos, peg$currPos);
5027
- throw peg$buildSimpleError(message, location);
5028
- }
5029
- function peg$getUnicode(pos = peg$currPos) {
5030
- const cp = input.codePointAt(pos);
5031
- if (cp === undefined) {
5032
- return "";
5033
- }
5034
- return String.fromCodePoint(cp);
5035
- }
5036
- function peg$literalExpectation(text, ignoreCase) {
5037
- return { type: "literal", text, ignoreCase };
5038
- }
5039
- function peg$classExpectation(parts, inverted, ignoreCase, unicode) {
5040
- return { type: "class", parts, inverted, ignoreCase, unicode };
5041
- }
5042
- function peg$anyExpectation() {
5043
- return { type: "any" };
5044
- }
5045
- function peg$endExpectation() {
5046
- return { type: "end" };
5047
- }
5048
- function peg$otherExpectation(description) {
5049
- return { type: "other", description };
5050
- }
5051
- function peg$computePosDetails(pos) {
5052
- let details = peg$posDetailsCache[pos];
5053
- let p;
5054
- if (details) {
5055
- return details;
5056
- }
5057
- else {
5058
- if (pos >= peg$posDetailsCache.length) {
5059
- p = peg$posDetailsCache.length - 1;
5060
- }
5061
- else {
5062
- p = pos;
5063
- while (!peg$posDetailsCache[--p]) { }
5064
- }
5065
- details = peg$posDetailsCache[p];
5066
- details = {
5067
- line: details.line,
5068
- column: details.column,
5069
- };
5070
- while (p < pos) {
5071
- if (input.charCodeAt(p) === 10) {
5072
- details.line++;
5073
- details.column = 1;
5074
- }
5075
- else {
5076
- details.column++;
5077
- }
5078
- p++;
5079
- }
5080
- peg$posDetailsCache[pos] = details;
5081
- return details;
5082
- }
5083
- }
5084
- function peg$computeLocation(startPos, endPos, offset) {
5085
- const startPosDetails = peg$computePosDetails(startPos);
5086
- const endPosDetails = peg$computePosDetails(endPos);
5087
- const res = {
5088
- source: peg$source,
5089
- start: {
5090
- offset: startPos,
5091
- line: startPosDetails.line,
5092
- column: startPosDetails.column,
5093
- },
5094
- end: {
5095
- offset: endPos,
5096
- line: endPosDetails.line,
5097
- column: endPosDetails.column,
5098
- },
5099
- };
5100
- if (offset && peg$source && (typeof peg$source.offset === "function")) {
5101
- res.start = peg$source.offset(res.start);
5102
- res.end = peg$source.offset(res.end);
5103
- }
5104
- return res;
5105
- }
5106
- function peg$fail(expected) {
5107
- if (peg$currPos < peg$maxFailPos) {
5108
- return;
5109
- }
5110
- if (peg$currPos > peg$maxFailPos) {
5111
- peg$maxFailPos = peg$currPos;
5112
- peg$maxFailExpected = [];
5113
- }
5114
- peg$maxFailExpected.push(expected);
5115
- }
5116
- function peg$buildSimpleError(message, location) {
5117
- return new peg$SyntaxError(message, null, null, location);
5118
- }
5119
- function peg$buildStructuredError(expected, found, location) {
5120
- return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location);
5121
- }
5122
- function peg$parseStart() {
5123
- let s0;
5124
- s0 = peg$parseFormula();
5125
- return s0;
5126
- }
5127
- function peg$parseFormula() {
5128
- let s0;
5129
- s0 = peg$parseEnclosedFormula();
5130
- if (s0 === peg$FAILED) {
5131
- s0 = peg$parseOpenFormula();
5132
- }
5133
- return s0;
5134
- }
5135
- function peg$parseEnclosedFormula() {
5136
- let s0, s1, s2, s3, s4, s5;
5137
- s0 = peg$currPos;
5138
- s1 = peg$parsebracket();
5139
- if (s1 !== peg$FAILED) {
5140
- s2 = peg$parseOpenFormula();
5141
- if (s2 !== peg$FAILED) {
5142
- s3 = peg$parsebracket();
5143
- if (s3 !== peg$FAILED) {
5144
- s4 = [];
5145
- s5 = peg$parseJoinComparator();
5146
- while (s5 !== peg$FAILED) {
5147
- s4.push(s5);
5148
- s5 = peg$parseJoinComparator();
5149
- }
5150
- peg$savedPos = s0;
5151
- s0 = peg$f0(s2, s4);
5152
- }
5153
- else {
5154
- peg$currPos = s0;
5155
- s0 = peg$FAILED;
5156
- }
5157
- }
5158
- else {
5159
- peg$currPos = s0;
5160
- s0 = peg$FAILED;
5161
- }
5162
- }
5163
- else {
5164
- peg$currPos = s0;
5165
- s0 = peg$FAILED;
5166
- }
5167
- return s0;
5168
- }
5169
- function peg$parseOpenFormula() {
5170
- let s0, s1, s2, s3;
5171
- s0 = peg$currPos;
5172
- s1 = peg$parseOpenEqualityCheck();
5173
- if (s1 !== peg$FAILED) {
5174
- s2 = [];
5175
- s3 = peg$parseJoinComparator();
5176
- while (s3 !== peg$FAILED) {
5177
- s2.push(s3);
5178
- s3 = peg$parseJoinComparator();
5179
- }
5180
- peg$savedPos = s0;
5181
- s0 = peg$f1(s1, s2);
5182
- }
5183
- else {
5184
- peg$currPos = s0;
5185
- s0 = peg$FAILED;
5186
- }
5187
- return s0;
5188
- }
5189
- function peg$parseJoinComparator() {
5190
- let s0, s1, s2;
5191
- s0 = peg$currPos;
5192
- s1 = peg$parseComparator();
5193
- if (s1 !== peg$FAILED) {
5194
- s2 = peg$parseOpenEqualityCheck();
5195
- if (s2 !== peg$FAILED) {
5196
- peg$savedPos = s0;
5197
- s0 = peg$f2(s1, s2);
5198
- }
5199
- else {
5200
- peg$currPos = s0;
5201
- s0 = peg$FAILED;
5202
- }
5203
- }
5204
- else {
5205
- peg$currPos = s0;
5206
- s0 = peg$FAILED;
5207
- }
5208
- if (s0 === peg$FAILED) {
5209
- s0 = peg$parseCompoundJoinComparator();
5210
- }
5211
- return s0;
5212
- }
5213
- function peg$parseCompoundJoinComparator() {
5214
- let s0, s1, s2, s3, s4;
5215
- s0 = peg$currPos;
5216
- s1 = peg$parseComparator();
5217
- if (s1 !== peg$FAILED) {
5218
- s2 = peg$parsebracket();
5219
- if (s2 !== peg$FAILED) {
5220
- s3 = peg$parseOpenFormula();
5221
- if (s3 !== peg$FAILED) {
5222
- s4 = peg$parsebracket();
5223
- if (s4 !== peg$FAILED) {
5224
- peg$savedPos = s0;
5225
- s0 = peg$f3(s1, s3);
5226
- }
5227
- else {
5228
- peg$currPos = s0;
5229
- s0 = peg$FAILED;
5230
- }
5231
- }
5232
- else {
5233
- peg$currPos = s0;
5234
- s0 = peg$FAILED;
5235
- }
5236
- }
5237
- else {
5238
- peg$currPos = s0;
5239
- s0 = peg$FAILED;
5240
- }
5241
- }
5242
- else {
5243
- peg$currPos = s0;
5244
- s0 = peg$FAILED;
5245
- }
5246
- return s0;
5247
- }
5248
- function peg$parseOpenEqualityCheck() {
5249
- let s0, s1, s2, s3, s4, s5;
5250
- s0 = peg$currPos;
5251
- s1 = peg$parseFieldRef();
5252
- if (s1 !== peg$FAILED) {
5253
- s2 = peg$parse_();
5254
- if (s2 === peg$FAILED) {
5255
- s2 = null;
5256
- }
5257
- s3 = peg$parseoperator();
5258
- if (s3 !== peg$FAILED) {
5259
- s4 = peg$parse_();
5260
- if (s4 === peg$FAILED) {
5261
- s4 = null;
5262
- }
5263
- s5 = peg$parseValue();
5264
- if (s5 !== peg$FAILED) {
5265
- peg$savedPos = s0;
5266
- s0 = peg$f4(s1, s3, s5);
5267
- }
5268
- else {
5269
- peg$currPos = s0;
5270
- s0 = peg$FAILED;
5271
- }
5272
- }
5273
- else {
5274
- peg$currPos = s0;
5275
- s0 = peg$FAILED;
5276
- }
5277
- }
5278
- else {
5279
- peg$currPos = s0;
5280
- s0 = peg$FAILED;
5281
- }
5282
- return s0;
5283
- }
5284
- function peg$parseComparator() {
5285
- let s0, s1, s2, s3;
5286
- s0 = peg$currPos;
5287
- s1 = peg$parse_();
5288
- if (s1 === peg$FAILED) {
5289
- s1 = null;
5290
- }
5291
- if (input.substr(peg$currPos, 3) === peg$c0) {
5292
- s2 = peg$c0;
5293
- peg$currPos += 3;
5294
- }
5295
- else {
5296
- s2 = peg$FAILED;
5297
- if (peg$silentFails === 0) {
5298
- peg$fail(peg$e0);
5299
- }
5300
- }
5301
- if (s2 !== peg$FAILED) {
5302
- s3 = peg$parse_();
5303
- if (s3 === peg$FAILED) {
5304
- s3 = null;
5305
- }
5306
- peg$savedPos = s0;
5307
- s0 = peg$f5(s2);
5308
- }
5309
- else {
5310
- peg$currPos = s0;
5311
- s0 = peg$FAILED;
5312
- }
5313
- if (s0 === peg$FAILED) {
5314
- s0 = peg$currPos;
5315
- s1 = peg$parse_();
5316
- if (s1 === peg$FAILED) {
5317
- s1 = null;
5318
- }
5319
- if (input.substr(peg$currPos, 2) === peg$c1) {
5320
- s2 = peg$c1;
5321
- peg$currPos += 2;
5322
- }
5323
- else {
5324
- s2 = peg$FAILED;
5325
- if (peg$silentFails === 0) {
5326
- peg$fail(peg$e1);
5327
- }
5328
- }
5329
- if (s2 !== peg$FAILED) {
5330
- s3 = peg$parse_();
5331
- if (s3 === peg$FAILED) {
5332
- s3 = null;
5333
- }
5334
- peg$savedPos = s0;
5335
- s0 = peg$f6(s2);
5336
- }
5337
- else {
5338
- peg$currPos = s0;
5339
- s0 = peg$FAILED;
5340
- }
5341
- }
5342
- return s0;
5343
- }
5344
- function peg$parseWord() {
5345
- let s0, s1, s2;
5346
- s0 = peg$currPos;
5347
- s1 = [];
5348
- s2 = peg$parseLetter();
5349
- if (s2 !== peg$FAILED) {
5350
- while (s2 !== peg$FAILED) {
5351
- s1.push(s2);
5352
- s2 = peg$parseLetter();
5353
- }
5354
- }
5355
- else {
5356
- s1 = peg$FAILED;
5357
- }
5358
- if (s1 !== peg$FAILED) {
5359
- peg$savedPos = s0;
5360
- s1 = peg$f7(s1);
5361
- }
5362
- s0 = s1;
5363
- return s0;
5364
- }
5365
- function peg$parseLetter() {
5366
- let s0;
5367
- s0 = input.charAt(peg$currPos);
5368
- if (peg$r0.test(s0)) {
5369
- peg$currPos++;
5370
- }
5371
- else {
5372
- s0 = peg$FAILED;
5373
- if (peg$silentFails === 0) {
5374
- peg$fail(peg$e2);
5375
- }
5376
- }
5377
- return s0;
5378
- }
5379
- function peg$parseValue() {
5380
- let s0, s1;
5381
- s0 = peg$parsequotedValue();
5382
- if (s0 === peg$FAILED) {
5383
- s0 = peg$currPos;
5384
- s1 = peg$parseWord();
5385
- if (s1 !== peg$FAILED) {
5386
- peg$savedPos = s0;
5387
- s1 = peg$f8(s1);
5388
- }
5389
- s0 = s1;
5390
- if (s0 === peg$FAILED) {
5391
- s0 = peg$currPos;
5392
- s1 = peg$parsenumber();
5393
- if (s1 !== peg$FAILED) {
5394
- peg$savedPos = s0;
5395
- s1 = peg$f9(s1);
5396
- }
5397
- s0 = s1;
5398
- }
5399
- }
5400
- return s0;
5401
- }
5402
- function peg$parseFieldRef() {
5403
- let s0;
5404
- s0 = peg$parseFieldReference();
5405
- if (s0 === peg$FAILED) {
5406
- s0 = peg$parseMetadataFieldReference();
5407
- }
5408
- return s0;
5409
- }
5410
- function peg$parseMetadataFieldReference() {
5411
- let s0, s1, s2, s3;
5412
- s0 = peg$currPos;
5413
- s1 = peg$parseopenSquare();
5414
- if (s1 !== peg$FAILED) {
5415
- s2 = peg$parseFieldReference();
5416
- if (s2 !== peg$FAILED) {
5417
- s3 = peg$parsecloseSquare();
5418
- if (s3 !== peg$FAILED) {
5419
- peg$savedPos = s0;
5420
- s0 = peg$f10(s1, s2, s3);
5421
- }
5422
- else {
5423
- peg$currPos = s0;
5424
- s0 = peg$FAILED;
5425
- }
5426
- }
5427
- else {
5428
- peg$currPos = s0;
5429
- s0 = peg$FAILED;
5430
- }
5431
- }
5432
- else {
5433
- peg$currPos = s0;
5434
- s0 = peg$FAILED;
5435
- }
5436
- return s0;
5437
- }
5438
- function peg$parseFieldReference() {
5439
- let s0, s1, s2;
5440
- s0 = peg$currPos;
5441
- s1 = [];
5442
- s2 = input.charAt(peg$currPos);
5443
- if (peg$r1.test(s2)) {
5444
- peg$currPos++;
5445
- }
5446
- else {
5447
- s2 = peg$FAILED;
5448
- if (peg$silentFails === 0) {
5449
- peg$fail(peg$e3);
5450
- }
5451
- }
5452
- if (s2 !== peg$FAILED) {
5453
- while (s2 !== peg$FAILED) {
5454
- s1.push(s2);
5455
- s2 = input.charAt(peg$currPos);
5456
- if (peg$r1.test(s2)) {
5457
- peg$currPos++;
5458
- }
5459
- else {
5460
- s2 = peg$FAILED;
5461
- if (peg$silentFails === 0) {
5462
- peg$fail(peg$e3);
5463
- }
5464
- }
5465
- }
5466
- }
5467
- else {
5468
- s1 = peg$FAILED;
5469
- }
5470
- if (s1 !== peg$FAILED) {
5471
- peg$savedPos = s0;
5472
- s1 = peg$f11(s1);
5473
- }
5474
- s0 = s1;
5475
- return s0;
5476
- }
5477
- function peg$parseopenSquare() {
5478
- let s0;
5479
- if (input.charCodeAt(peg$currPos) === 91) {
5480
- s0 = peg$c2;
5481
- peg$currPos++;
5482
- }
5483
- else {
5484
- s0 = peg$FAILED;
5485
- if (peg$silentFails === 0) {
5486
- peg$fail(peg$e4);
5487
- }
5488
- }
5489
- return s0;
5490
- }
5491
- function peg$parsecloseSquare() {
5492
- let s0;
5493
- if (input.charCodeAt(peg$currPos) === 93) {
5494
- s0 = peg$c3;
5495
- peg$currPos++;
5496
- }
5497
- else {
5498
- s0 = peg$FAILED;
5499
- if (peg$silentFails === 0) {
5500
- peg$fail(peg$e5);
5501
- }
5502
- }
5503
- return s0;
5504
- }
5505
- function peg$parsenumber() {
5506
- let s0, s1;
5507
- s0 = [];
5508
- s1 = input.charAt(peg$currPos);
5509
- if (peg$r2.test(s1)) {
5510
- peg$currPos++;
5511
- }
5512
- else {
5513
- s1 = peg$FAILED;
5514
- if (peg$silentFails === 0) {
5515
- peg$fail(peg$e6);
5516
- }
5517
- }
5518
- if (s1 !== peg$FAILED) {
5519
- while (s1 !== peg$FAILED) {
5520
- s0.push(s1);
5521
- s1 = input.charAt(peg$currPos);
5522
- if (peg$r2.test(s1)) {
5523
- peg$currPos++;
5524
- }
5525
- else {
5526
- s1 = peg$FAILED;
5527
- if (peg$silentFails === 0) {
5528
- peg$fail(peg$e6);
5529
- }
5530
- }
5531
- }
5532
- }
5533
- else {
5534
- s0 = peg$FAILED;
5535
- }
5536
- return s0;
5537
- }
5538
- function peg$parsequotedValue() {
5539
- let s0, s1, s2, s3;
5540
- s0 = peg$currPos;
5541
- if (input.charCodeAt(peg$currPos) === 34) {
5542
- s1 = peg$c4;
5543
- peg$currPos++;
5544
- }
5545
- else {
5546
- s1 = peg$FAILED;
5547
- if (peg$silentFails === 0) {
5548
- peg$fail(peg$e7);
5549
- }
5550
- }
5551
- if (s1 !== peg$FAILED) {
5552
- s2 = [];
5553
- s3 = input.charAt(peg$currPos);
5554
- if (peg$r3.test(s3)) {
5555
- peg$currPos++;
5556
- }
5557
- else {
5558
- s3 = peg$FAILED;
5559
- if (peg$silentFails === 0) {
5560
- peg$fail(peg$e8);
5561
- }
5562
- }
5563
- while (s3 !== peg$FAILED) {
5564
- s2.push(s3);
5565
- s3 = input.charAt(peg$currPos);
5566
- if (peg$r3.test(s3)) {
5567
- peg$currPos++;
5568
- }
5569
- else {
5570
- s3 = peg$FAILED;
5571
- if (peg$silentFails === 0) {
5572
- peg$fail(peg$e8);
5573
- }
5574
- }
5575
- }
5576
- if (input.charCodeAt(peg$currPos) === 34) {
5577
- s3 = peg$c4;
5578
- peg$currPos++;
5579
- }
5580
- else {
5581
- s3 = peg$FAILED;
5582
- if (peg$silentFails === 0) {
5583
- peg$fail(peg$e7);
5584
- }
5585
- }
5586
- if (s3 !== peg$FAILED) {
5587
- peg$savedPos = s0;
5588
- s0 = peg$f12(s2);
5589
- }
5590
- else {
5591
- peg$currPos = s0;
5592
- s0 = peg$FAILED;
5593
- }
5594
- }
5595
- else {
5596
- peg$currPos = s0;
5597
- s0 = peg$FAILED;
5598
- }
5599
- return s0;
5600
- }
5601
- function peg$parsebracket() {
5602
- let s0, s1, s2, s3;
5603
- s0 = peg$currPos;
5604
- s1 = peg$parse_();
5605
- if (s1 === peg$FAILED) {
5606
- s1 = null;
5607
- }
5608
- s2 = [];
5609
- if (input.charCodeAt(peg$currPos) === 40) {
5610
- s3 = peg$c5;
5611
- peg$currPos++;
5612
- }
5613
- else {
5614
- s3 = peg$FAILED;
5615
- if (peg$silentFails === 0) {
5616
- peg$fail(peg$e9);
5617
- }
5618
- }
5619
- if (s3 !== peg$FAILED) {
5620
- while (s3 !== peg$FAILED) {
5621
- s2.push(s3);
5622
- if (input.charCodeAt(peg$currPos) === 40) {
5623
- s3 = peg$c5;
5624
- peg$currPos++;
5625
- }
5626
- else {
5627
- s3 = peg$FAILED;
5628
- if (peg$silentFails === 0) {
5629
- peg$fail(peg$e9);
5630
- }
5631
- }
5632
- }
5633
- }
5634
- else {
5635
- s2 = peg$FAILED;
5636
- }
5637
- if (s2 !== peg$FAILED) {
5638
- s3 = peg$parse_();
5639
- if (s3 === peg$FAILED) {
5640
- s3 = null;
5641
- }
5642
- s1 = [s1, s2, s3];
5643
- s0 = s1;
5644
- }
5645
- else {
5646
- peg$currPos = s0;
5647
- s0 = peg$FAILED;
5648
- }
5649
- if (s0 === peg$FAILED) {
5650
- s0 = peg$currPos;
5651
- s1 = peg$parse_();
5652
- if (s1 === peg$FAILED) {
5653
- s1 = null;
5654
- }
5655
- s2 = [];
5656
- if (input.charCodeAt(peg$currPos) === 41) {
5657
- s3 = peg$c6;
5658
- peg$currPos++;
5659
- }
5660
- else {
5661
- s3 = peg$FAILED;
5662
- if (peg$silentFails === 0) {
5663
- peg$fail(peg$e10);
5664
- }
5665
- }
5666
- if (s3 !== peg$FAILED) {
5667
- while (s3 !== peg$FAILED) {
5668
- s2.push(s3);
5669
- if (input.charCodeAt(peg$currPos) === 41) {
5670
- s3 = peg$c6;
5671
- peg$currPos++;
5672
- }
5673
- else {
5674
- s3 = peg$FAILED;
5675
- if (peg$silentFails === 0) {
5676
- peg$fail(peg$e10);
5677
- }
5678
- }
5679
- }
5680
- }
5681
- else {
5682
- s2 = peg$FAILED;
5683
- }
5684
- if (s2 !== peg$FAILED) {
5685
- s3 = peg$parse_();
5686
- if (s3 === peg$FAILED) {
5687
- s3 = null;
5688
- }
5689
- s1 = [s1, s2, s3];
5690
- s0 = s1;
5691
- }
5692
- else {
5693
- peg$currPos = s0;
5694
- s0 = peg$FAILED;
5695
- }
5696
- }
5697
- return s0;
5698
- }
5699
- function peg$parseoperator() {
5700
- let s0;
5701
- if (input.charCodeAt(peg$currPos) === 61) {
5702
- s0 = peg$c7;
5703
- peg$currPos++;
5704
- }
5705
- else {
5706
- s0 = peg$FAILED;
5707
- if (peg$silentFails === 0) {
5708
- peg$fail(peg$e11);
5709
- }
5710
- }
5711
- if (s0 === peg$FAILED) {
5712
- if (input.substr(peg$currPos, 2) === peg$c8) {
5713
- s0 = peg$c8;
5714
- peg$currPos += 2;
5715
- }
5716
- else {
5717
- s0 = peg$FAILED;
5718
- if (peg$silentFails === 0) {
5719
- peg$fail(peg$e12);
5720
- }
5721
- }
5722
- if (s0 === peg$FAILED) {
5723
- if (input.substr(peg$currPos, 8) === peg$c9) {
5724
- s0 = peg$c9;
5725
- peg$currPos += 8;
5726
- }
5727
- else {
5728
- s0 = peg$FAILED;
5729
- if (peg$silentFails === 0) {
5730
- peg$fail(peg$e13);
5731
- }
5732
- }
5733
- }
5734
- }
5735
- return s0;
5736
- }
5737
- function peg$parsews() {
5738
- let s0, s1;
5739
- peg$silentFails++;
5740
- s0 = input.charAt(peg$currPos);
5741
- if (peg$r4.test(s0)) {
5742
- peg$currPos++;
5743
- }
5744
- else {
5745
- s0 = peg$FAILED;
5746
- if (peg$silentFails === 0) {
5747
- peg$fail(peg$e15);
5748
- }
5749
- }
5750
- peg$silentFails--;
5751
- if (s0 === peg$FAILED) {
5752
- s1 = peg$FAILED;
5753
- if (peg$silentFails === 0) {
5754
- peg$fail(peg$e14);
5755
- }
5756
- }
5757
- return s0;
5758
- }
5759
- function peg$parse_() {
5760
- let s0, s1;
5761
- peg$silentFails++;
5762
- s0 = [];
5763
- s1 = peg$parsews();
5764
- if (s1 !== peg$FAILED) {
5765
- while (s1 !== peg$FAILED) {
5766
- s0.push(s1);
5767
- s1 = peg$parsews();
5768
- }
5769
- }
5770
- else {
5771
- s0 = peg$FAILED;
5772
- }
5773
- peg$silentFails--;
5774
- if (s0 === peg$FAILED) {
5775
- s1 = peg$FAILED;
5776
- if (peg$silentFails === 0) {
5777
- peg$fail(peg$e16);
5778
- }
5779
- }
5780
- return s0;
5781
- }
4801
+ const conditionSource = `{
5782
4802
  function flat(arr, depth = 1) {
5783
- var flatten = function (arr, depth = 1) {
5784
- if (depth)
5785
- return arr;
5786
- // Otherwise, concatenate into the parent array
5787
- return arr.reduce(function (acc, val) {
5788
- return acc.concat(Array.isArray(val) ? flatten(val, depth - 1) : val);
5789
- }, []);
5790
- };
5791
- return flatten(arr, depth - 1);
5792
- }
5793
- peg$result = peg$startRuleFunction();
5794
- const peg$success = (peg$result !== peg$FAILED && peg$currPos === input.length);
5795
- function peg$throw() {
5796
- if (peg$result !== peg$FAILED && peg$currPos < input.length) {
5797
- peg$fail(peg$endExpectation());
5798
- }
5799
- throw peg$buildStructuredError(peg$maxFailExpected, peg$maxFailPos < input.length ? peg$getUnicode(peg$maxFailPos) : null, peg$maxFailPos < input.length
5800
- ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
5801
- : peg$computeLocation(peg$maxFailPos, peg$maxFailPos));
5802
- }
5803
- if (options.peg$library) {
5804
- return /** @type {any} */ ({
5805
- peg$result,
5806
- peg$currPos,
5807
- peg$FAILED,
5808
- peg$maxFailExpected,
5809
- peg$maxFailPos,
5810
- peg$success,
5811
- peg$throw: peg$success ? undefined : peg$throw,
5812
- });
5813
- }
5814
- if (peg$success) {
5815
- return peg$result;
5816
- }
5817
- else {
5818
- peg$throw();
4803
+ var flatten = function (arr, depth = 1) {
4804
+ if (depth) return arr;
4805
+
4806
+ // Otherwise, concatenate into the parent array
4807
+ return arr.reduce(function (acc, val) {
4808
+ return acc.concat(Array.isArray(val) ? flatten(val, depth - 1) : val);
4809
+ }, []);
4810
+
4811
+ };
4812
+
4813
+ return flatten(arr, depth - 1);
5819
4814
  }
5820
- }
5821
- const peg$allowedStartRules = [
5822
- "Start"
5823
- ];
5824
- const parser = { SyntaxError: peg$SyntaxError, parse: peg$parse };
4815
+ }
4816
+
4817
+ Start
4818
+ = Formula
4819
+
4820
+ Formula
4821
+ = term:FormulaTerm joins:(JoinComparator)*
4822
+ { return [term].concat(flat(joins)); }
4823
+
4824
+ FormulaTerm
4825
+ = EnclosedFormula
4826
+ / OpenEqualityCheck
4827
+
4828
+ EnclosedFormula
4829
+ = openBracket formula:Formula closeBracket
4830
+ { return formula.length === 1 ? formula[0] : formula; }
4831
+
4832
+ JoinComparator
4833
+ = comp:Comparator term:FormulaTerm
4834
+ { return [comp, term]; }
4835
+
4836
+ OpenEqualityCheck
4837
+ = fr:FieldRef _? op:operator _? val:Value
4838
+ { return { fieldReference: fr, comparator: op, value: val } }
4839
+
4840
+ Comparator
4841
+ = _? c:'AND' _?
4842
+ { return c; }
4843
+ / _? c:'OR' _?
4844
+ { return c; }
4845
+
4846
+ Word
4847
+ = l:Letter+
4848
+ { return l.join(""); }
4849
+
4850
+ Letter
4851
+ = [a-zA-Z]
4852
+
4853
+ Value
4854
+ = v:quotedValue / v:Word
4855
+ { return v.join("") }
4856
+ / v:number
4857
+ { return parseInt(v.join("")) }
4858
+
4859
+ FieldRef
4860
+ = FieldReference / MetadataFieldReference
4861
+
4862
+ MetadataFieldReference
4863
+ = s1:openSquare fr:FieldReference s2:closeSquare
4864
+ { return s1 + fr + s2 }
4865
+
4866
+ FieldReference
4867
+ = characters:[A-Za-z0-9._-]+ { return characters.join(""); }
4868
+
4869
+ openSquare
4870
+ = "["
4871
+
4872
+ closeSquare
4873
+ = "]"
4874
+
4875
+ number
4876
+ = [0-9]+
4877
+
4878
+ quotedValue
4879
+ = '"'val:[A-Za-z0-9.,* _&()/-]*'"'
4880
+ { return val.join(""); }
4881
+
4882
+ openBracket
4883
+ = _? "(" _?
4884
+
4885
+ closeBracket
4886
+ = _? ")" _?
4887
+
4888
+ operator
4889
+ = "=" / "!=" / "CONTAINS"
4890
+
4891
+ ws "Whitespace"
4892
+ = [ \t]
4893
+
4894
+ _ "One or more whitespaces"
4895
+ = ws+
4896
+
4897
+ nl "New line"
4898
+ = "\\n"`;
4899
+ var peg = generate(conditionSource);
5825
4900
 
5826
4901
  class ConditionParser {
5827
4902
  static logger = new StructuredLoggerService();
@@ -5835,7 +4910,7 @@ class ConditionParser {
5835
4910
  return null;
5836
4911
  }
5837
4912
  condition = condition.replace(/CONTAINS/g, ' CONTAINS');
5838
- return parser.parse(condition.trim(), {});
4913
+ return peg.parse(condition.trim(), {});
5839
4914
  }
5840
4915
  /**
5841
4916
  * Evaluate the current fields against the conditions