@dra2020/baseclient 1.0.9 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/baseclient.js +79 -10
- package/dist/baseclient.js.map +1 -1
- package/dist/filterexpr/filterexpr.d.ts +3 -0
- package/dist/ot-js/otsession.d.ts +1 -0
- package/lib/filterexpr/filterexpr.ts +79 -5
- package/lib/ot-js/otsession.ts +2 -1
- package/lib/poly/polypack.ts +12 -2
- package/package.json +1 -1
package/dist/baseclient.js
CHANGED
|
@@ -597,6 +597,40 @@ function wordyDate(s) {
|
|
|
597
597
|
// But this is close enough to match what gets displayed by "prettyDate" while also letting selection by month year
|
|
598
598
|
return s;
|
|
599
599
|
}
|
|
600
|
+
function clauseEqual(c1, c2) {
|
|
601
|
+
if (c1 == null && c2 == null)
|
|
602
|
+
return true;
|
|
603
|
+
if (c1 == null || c2 == null)
|
|
604
|
+
return false;
|
|
605
|
+
if (c1.op.tt === c2.op.tt) {
|
|
606
|
+
if (c1.op.tt === TokType.Text)
|
|
607
|
+
return c1.op.text === c2.op.text;
|
|
608
|
+
else
|
|
609
|
+
return clauseEqual(c1.operand1, c2.operand1) && clauseEqual(c1.operand2, c2.operand2);
|
|
610
|
+
}
|
|
611
|
+
else
|
|
612
|
+
return false;
|
|
613
|
+
}
|
|
614
|
+
function containsClause(c, s) {
|
|
615
|
+
if (clauseEqual(c, s))
|
|
616
|
+
return true;
|
|
617
|
+
if (c == null || s == null)
|
|
618
|
+
return false;
|
|
619
|
+
return containsClause(c.operand1, s) || containsClause(c.operand2, s);
|
|
620
|
+
}
|
|
621
|
+
function removeClause(c, s) {
|
|
622
|
+
if (c == null || (c.op.tt === TokType.Text && c.op.tt !== s.op.tt))
|
|
623
|
+
return c;
|
|
624
|
+
else if (clauseEqual(c, s))
|
|
625
|
+
return null;
|
|
626
|
+
else {
|
|
627
|
+
c.operand1 = removeClause(c.operand1, s);
|
|
628
|
+
c.operand2 = removeClause(c.operand2, s);
|
|
629
|
+
if ((c.op.tt === TokType.And || c.op.tt === TokType.Or) && (c.operand1 == null || c.operand2 == null))
|
|
630
|
+
return c.operand1 || c.operand2;
|
|
631
|
+
return c;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
600
634
|
class FilterExpr {
|
|
601
635
|
constructor(coder, expr) {
|
|
602
636
|
this.lexer = new Lexer(coder);
|
|
@@ -614,13 +648,38 @@ class FilterExpr {
|
|
|
614
648
|
asString() {
|
|
615
649
|
return this.asStringClause(this.parser.clause);
|
|
616
650
|
}
|
|
651
|
+
containsClause(expr) {
|
|
652
|
+
let sub = new FilterExpr(this.lexer.coder, expr);
|
|
653
|
+
return containsClause(this.parser.clause, sub.parser.clause);
|
|
654
|
+
}
|
|
655
|
+
addClause(expr) {
|
|
656
|
+
let sub = new FilterExpr(this.lexer.coder, expr);
|
|
657
|
+
if (!containsClause(this.parser.clause, sub.parser.clause)) {
|
|
658
|
+
if (this.parser.clause)
|
|
659
|
+
this.parser.clauses = [{ op: { tt: TokType.And }, operand1: this.parser.clause, operand2: sub.parser.clause }];
|
|
660
|
+
else
|
|
661
|
+
this.parser.clauses = [sub.parser.clause];
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
removeClause(expr) {
|
|
665
|
+
if (this.containsClause(expr)) {
|
|
666
|
+
let sub = new FilterExpr(this.lexer.coder, expr);
|
|
667
|
+
this.parser.clauses = [removeClause(this.parser.clause, sub.parser.clause)];
|
|
668
|
+
}
|
|
669
|
+
}
|
|
617
670
|
asStringClause(clause) {
|
|
618
671
|
if (clause == null)
|
|
619
672
|
return '';
|
|
620
|
-
if (clause.op.tt == TokType.Text)
|
|
621
|
-
|
|
673
|
+
if (clause.op.tt == TokType.Text) {
|
|
674
|
+
this.lexer.set(clause.op.text);
|
|
675
|
+
if (this.lexer.tokens.length == 1 && this.lexer.tokens[0].tt === TokType.Text)
|
|
676
|
+
return clause.op.text;
|
|
677
|
+
else
|
|
678
|
+
return `'${clause.op.text}'`;
|
|
679
|
+
}
|
|
622
680
|
let a = [];
|
|
623
|
-
|
|
681
|
+
if (clause !== this.parser.clause)
|
|
682
|
+
a.push('(');
|
|
624
683
|
switch (clause.op.tt) {
|
|
625
684
|
case TokType.And:
|
|
626
685
|
a.push(this.asStringClause(clause.operand1));
|
|
@@ -637,8 +696,7 @@ class FilterExpr {
|
|
|
637
696
|
a.push(this.asStringClause(clause.operand1));
|
|
638
697
|
break;
|
|
639
698
|
case TokType.Colon:
|
|
640
|
-
a.push(this.asStringClause(clause.operand1));
|
|
641
|
-
a.push(':');
|
|
699
|
+
a.push(`${this.asStringClause(clause.operand1)}:`);
|
|
642
700
|
a.push(this.asStringClause(clause.operand2));
|
|
643
701
|
break;
|
|
644
702
|
case TokType.Equal:
|
|
@@ -653,7 +711,8 @@ class FilterExpr {
|
|
|
653
711
|
default:
|
|
654
712
|
throw 'Unexpected token in asString';
|
|
655
713
|
}
|
|
656
|
-
|
|
714
|
+
if (clause !== this.parser.clause)
|
|
715
|
+
a.push(')');
|
|
657
716
|
return a.join(' ');
|
|
658
717
|
}
|
|
659
718
|
testClause(o, types, clause, prop, relation) {
|
|
@@ -4328,7 +4387,7 @@ exports.OTServerEngine = OTServerEngine;
|
|
|
4328
4387
|
|
|
4329
4388
|
|
|
4330
4389
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4331
|
-
exports.SessionFilterFunction = exports.accessMapFindUser = exports.accessFindUser = exports.ServerStateMaintenance = exports.ServerStateRunning = exports.PermAll = exports.PermEdit = exports.PermAdmin = exports.PermOwner = exports.PermWrite = exports.PermRead = exports.PermNone = exports.FilterCount = exports.FilterOfficial = exports.FilterPublic = exports.FilterTrash = exports.FilterRecent = exports.FilterMyPublic = exports.FilterSharedWithMe = exports.FilterMyMaps = exports.EClockAnomaly = exports.EMaintenance = exports.ENoAccess = exports.ENoPerm = exports.ELoadFailed = exports.EBadRequest = exports.ENoUser = exports.EClockReset = exports.EClockFailure = exports.EClockSeen = exports.ENoSession = exports.ERetry = exports.EFull = exports.EFail = exports.ESuccess = void 0;
|
|
4390
|
+
exports.SessionFilterFunction = exports.accessMapFindUser = exports.accessFindUser = exports.ServerStateMaintenance = exports.ServerStateRunning = exports.PermAll = exports.PermEdit = exports.PermAdmin = exports.PermOwner = exports.PermWrite = exports.PermRead = exports.PermNone = exports.FilterCount = exports.FilterCOI = exports.FilterOfficial = exports.FilterPublic = exports.FilterTrash = exports.FilterRecent = exports.FilterMyPublic = exports.FilterSharedWithMe = exports.FilterMyMaps = exports.EClockAnomaly = exports.EMaintenance = exports.ENoAccess = exports.ENoPerm = exports.ELoadFailed = exports.EBadRequest = exports.ENoUser = exports.EClockReset = exports.EClockFailure = exports.EClockSeen = exports.ENoSession = exports.ERetry = exports.EFull = exports.EFail = exports.ESuccess = void 0;
|
|
4332
4391
|
// Errors
|
|
4333
4392
|
exports.ESuccess = 0; // Generic success
|
|
4334
4393
|
exports.EFail = 1; // Generic failure
|
|
@@ -4353,7 +4412,8 @@ exports.FilterRecent = 3;
|
|
|
4353
4412
|
exports.FilterTrash = 4;
|
|
4354
4413
|
exports.FilterPublic = 5;
|
|
4355
4414
|
exports.FilterOfficial = 6;
|
|
4356
|
-
exports.
|
|
4415
|
+
exports.FilterCOI = 7;
|
|
4416
|
+
exports.FilterCount = 8;
|
|
4357
4417
|
// Permissions
|
|
4358
4418
|
exports.PermNone = 0; // No permissions
|
|
4359
4419
|
exports.PermRead = 1; // Can view
|
|
@@ -6879,7 +6939,9 @@ function polyPack(coords, prepack) {
|
|
|
6879
6939
|
coords = coords.geometry.coordinates;
|
|
6880
6940
|
// Transparently handle polygon or multi-polygon
|
|
6881
6941
|
let depth = Util.depthof(coords);
|
|
6882
|
-
if (depth ==
|
|
6942
|
+
if (depth == 2)
|
|
6943
|
+
coords = [[[coords]]];
|
|
6944
|
+
else if (depth == 3)
|
|
6883
6945
|
coords = [[coords]];
|
|
6884
6946
|
else if (depth == 4)
|
|
6885
6947
|
coords = [coords];
|
|
@@ -7006,9 +7068,16 @@ exports.featurePack = featurePack;
|
|
|
7006
7068
|
function featureUnpack(f) {
|
|
7007
7069
|
if (f && f.geometry && f.geometry.packed !== undefined) {
|
|
7008
7070
|
f.geometry.coordinates = polyUnpack(f.geometry.packed);
|
|
7071
|
+
let depth = Util.depthof(f.geometry.coordinates);
|
|
7009
7072
|
// Check for oops, optimized away the multipolygon in polyUnpack
|
|
7010
|
-
if (f.geometry.type === 'MultiPolygon' &&
|
|
7073
|
+
if (f.geometry.type === 'MultiPolygon' && depth === 4)
|
|
7011
7074
|
f.geometry.coordinates = [f.geometry.coordinates];
|
|
7075
|
+
else if (f.geometry.type === 'Point' && depth != 2) {
|
|
7076
|
+
while (depth > 2) {
|
|
7077
|
+
f.geometry.coordinates = f.geometry.coordinates[0];
|
|
7078
|
+
depth = Util.depthof(f.geometry.coordinates);
|
|
7079
|
+
}
|
|
7080
|
+
}
|
|
7012
7081
|
delete f.geometry.packed;
|
|
7013
7082
|
}
|
|
7014
7083
|
else if (f.type && f.type === 'FeatureCollection' && f.features) {
|