@dra2020/baseclient 1.0.8 → 1.0.11
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.
|
@@ -58,6 +58,9 @@ export declare class FilterExpr {
|
|
|
58
58
|
set(expr: string): void;
|
|
59
59
|
test(o: any, types?: any): boolean;
|
|
60
60
|
asString(): string;
|
|
61
|
+
containsClause(expr: string): boolean;
|
|
62
|
+
addClause(expr: string): void;
|
|
63
|
+
removeClause(expr: string): void;
|
|
61
64
|
asStringClause(clause: Clause): string;
|
|
62
65
|
testClause(o: any, types: any, clause: Clause, prop?: string, relation?: TokType): boolean;
|
|
63
66
|
}
|
|
@@ -20,6 +20,7 @@ export declare const FilterRecent: number;
|
|
|
20
20
|
export declare const FilterTrash: number;
|
|
21
21
|
export declare const FilterPublic: number;
|
|
22
22
|
export declare const FilterOfficial: number;
|
|
23
|
+
export declare const FilterCOI: number;
|
|
23
24
|
export declare const FilterCount: number;
|
|
24
25
|
export declare type Filter = number;
|
|
25
26
|
export declare const PermNone: number;
|
|
@@ -83,6 +84,8 @@ export interface SessionProps {
|
|
|
83
84
|
loadFailed: boolean;
|
|
84
85
|
accessMap: AccessMap;
|
|
85
86
|
revisions: RevisionList;
|
|
87
|
+
expunged?: boolean;
|
|
88
|
+
expungeDate?: string;
|
|
86
89
|
xprops?: {
|
|
87
90
|
[prop: string]: string;
|
|
88
91
|
};
|
|
@@ -484,6 +484,45 @@ function wordyDate(s: string): string
|
|
|
484
484
|
return s;
|
|
485
485
|
}
|
|
486
486
|
|
|
487
|
+
function clauseEqual(c1: Clause, c2: Clause): boolean
|
|
488
|
+
{
|
|
489
|
+
if (c1 == null && c2 == null) return true;
|
|
490
|
+
if (c1 == null || c2 == null) return false;
|
|
491
|
+
if (c1.op.tt === c2.op.tt)
|
|
492
|
+
{
|
|
493
|
+
if (c1.op.tt === TokType.Text)
|
|
494
|
+
return c1.op.text === c2.op.text;
|
|
495
|
+
else
|
|
496
|
+
return clauseEqual(c1.operand1, c2.operand1) && clauseEqual(c1.operand2, c2.operand2);
|
|
497
|
+
}
|
|
498
|
+
else
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function containsClause(c: Clause, s: Clause): boolean
|
|
503
|
+
{
|
|
504
|
+
if (clauseEqual(c, s))
|
|
505
|
+
return true;
|
|
506
|
+
if (c == null || s == null) return false;
|
|
507
|
+
return containsClause(c.operand1, s) || containsClause(c.operand2, s);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function removeClause(c: Clause, s: Clause): Clause
|
|
511
|
+
{
|
|
512
|
+
if (c == null || (c.op.tt === TokType.Text && c.op.tt !== s.op.tt))
|
|
513
|
+
return c;
|
|
514
|
+
else if (clauseEqual(c, s))
|
|
515
|
+
return null;
|
|
516
|
+
else
|
|
517
|
+
{
|
|
518
|
+
c.operand1 = removeClause(c.operand1, s);
|
|
519
|
+
c.operand2 = removeClause(c.operand2, s);
|
|
520
|
+
if ((c.op.tt === TokType.And || c.op.tt === TokType.Or) && (c.operand1 == null || c.operand2 == null))
|
|
521
|
+
return c.operand1 || c.operand2;
|
|
522
|
+
return c;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
487
526
|
export class FilterExpr
|
|
488
527
|
{
|
|
489
528
|
lexer: Lexer;
|
|
@@ -512,12 +551,47 @@ export class FilterExpr
|
|
|
512
551
|
return this.asStringClause(this.parser.clause);
|
|
513
552
|
}
|
|
514
553
|
|
|
554
|
+
containsClause(expr: string): boolean
|
|
555
|
+
{
|
|
556
|
+
let sub = new FilterExpr(this.lexer.coder, expr);
|
|
557
|
+
return containsClause(this.parser.clause, sub.parser.clause);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
addClause(expr: string): void
|
|
561
|
+
{
|
|
562
|
+
let sub = new FilterExpr(this.lexer.coder, expr);
|
|
563
|
+
if (! containsClause(this.parser.clause, sub.parser.clause))
|
|
564
|
+
{
|
|
565
|
+
if (this.parser.clause)
|
|
566
|
+
this.parser.clauses = [ { op: { tt: TokType.And }, operand1: this.parser.clause, operand2: sub.parser.clause } ];
|
|
567
|
+
else
|
|
568
|
+
this.parser.clauses = [ sub.parser.clause ];
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
removeClause(expr: string): void
|
|
573
|
+
{
|
|
574
|
+
if (this.containsClause(expr))
|
|
575
|
+
{
|
|
576
|
+
let sub = new FilterExpr(this.lexer.coder, expr);
|
|
577
|
+
this.parser.clauses = [ removeClause(this.parser.clause, sub.parser.clause) ];
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
515
581
|
asStringClause(clause: Clause): string
|
|
516
582
|
{
|
|
517
583
|
if (clause == null) return '';
|
|
518
|
-
if (clause.op.tt == TokType.Text)
|
|
584
|
+
if (clause.op.tt == TokType.Text)
|
|
585
|
+
{
|
|
586
|
+
this.lexer.set(clause.op.text);
|
|
587
|
+
if (this.lexer.tokens.length == 1 && this.lexer.tokens[0].tt === TokType.Text)
|
|
588
|
+
return clause.op.text;
|
|
589
|
+
else
|
|
590
|
+
return `'${clause.op.text}'`;
|
|
591
|
+
}
|
|
519
592
|
let a: string[] = [];
|
|
520
|
-
|
|
593
|
+
if (clause !== this.parser.clause)
|
|
594
|
+
a.push('(');
|
|
521
595
|
switch (clause.op.tt)
|
|
522
596
|
{
|
|
523
597
|
case TokType.And:
|
|
@@ -535,8 +609,7 @@ export class FilterExpr
|
|
|
535
609
|
a.push(this.asStringClause(clause.operand1));
|
|
536
610
|
break;
|
|
537
611
|
case TokType.Colon:
|
|
538
|
-
a.push(this.asStringClause(clause.operand1));
|
|
539
|
-
a.push(':');
|
|
612
|
+
a.push(`${this.asStringClause(clause.operand1)}:`);
|
|
540
613
|
a.push(this.asStringClause(clause.operand2));
|
|
541
614
|
break;
|
|
542
615
|
case TokType.Equal:
|
|
@@ -551,7 +624,8 @@ export class FilterExpr
|
|
|
551
624
|
default:
|
|
552
625
|
throw 'Unexpected token in asString';
|
|
553
626
|
}
|
|
554
|
-
|
|
627
|
+
if (clause !== this.parser.clause)
|
|
628
|
+
a.push(')');
|
|
555
629
|
return a.join(' ');
|
|
556
630
|
}
|
|
557
631
|
|
package/lib/ot-js/otsession.ts
CHANGED
|
@@ -23,7 +23,8 @@ export const FilterRecent: number = 3;
|
|
|
23
23
|
export const FilterTrash: number = 4;
|
|
24
24
|
export const FilterPublic: number = 5;
|
|
25
25
|
export const FilterOfficial: number = 6;
|
|
26
|
-
export const
|
|
26
|
+
export const FilterCOI: number = 7;
|
|
27
|
+
export const FilterCount: number = 8;
|
|
27
28
|
export type Filter = number;
|
|
28
29
|
|
|
29
30
|
// Permissions
|
|
@@ -111,6 +112,8 @@ export interface SessionProps
|
|
|
111
112
|
loadFailed: boolean;
|
|
112
113
|
accessMap: AccessMap;
|
|
113
114
|
revisions: RevisionList;
|
|
115
|
+
expunged?: boolean;
|
|
116
|
+
expungeDate?: string;
|
|
114
117
|
xprops?: { [prop: string]: string };
|
|
115
118
|
}
|
|
116
119
|
|