@dra2020/baseclient 1.0.14 → 1.0.17

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.
Files changed (97) hide show
  1. package/README.md +5 -16
  2. package/dist/all/all.d.ts +2 -18
  3. package/dist/baseclient.js +1309 -173
  4. package/dist/baseclient.js.map +1 -1
  5. package/dist/filterexpr/filterexpr.d.ts +3 -0
  6. package/dist/fsm/fsm.d.ts +1 -0
  7. package/dist/geo/all.d.ts +2 -0
  8. package/dist/geo/geo.d.ts +67 -0
  9. package/dist/geo/vfeature.d.ts +4 -0
  10. package/dist/ot-js/otsession.d.ts +3 -0
  11. package/dist/poly/union.d.ts +1 -0
  12. package/docs/filterexpr.md +22 -0
  13. package/lib/all/all.ts +2 -22
  14. package/lib/filterexpr/filterexpr.ts +79 -5
  15. package/lib/fsm/fsm.ts +12 -2
  16. package/lib/geo/all.ts +2 -0
  17. package/lib/geo/geo.ts +452 -0
  18. package/lib/geo/vfeature.ts +34 -0
  19. package/lib/ot-js/otsession.ts +4 -1
  20. package/lib/poly/hash.ts +1 -1
  21. package/lib/poly/polybin.ts +5 -4
  22. package/lib/poly/polypack.ts +16 -4
  23. package/lib/poly/topo.ts +26 -41
  24. package/lib/poly/union.ts +17 -0
  25. package/package.json +9 -10
  26. package/dist/all/allclient.d.ts +0 -18
  27. package/dist/base.js +0 -33010
  28. package/dist/base.js.map +0 -1
  29. package/dist/dbabstract/all.d.ts +0 -1
  30. package/dist/dbabstract/db.d.ts +0 -83
  31. package/dist/dbdynamo/all.d.ts +0 -1
  32. package/dist/dbdynamo/dbdynamo.d.ts +0 -190
  33. package/dist/fsmfile/all.d.ts +0 -1
  34. package/dist/fsmfile/fsmfile.d.ts +0 -47
  35. package/dist/jsonstream/all.d.ts +0 -1
  36. package/dist/jsonstream/jsonstream.d.ts +0 -130
  37. package/dist/lambda/all.d.ts +0 -1
  38. package/dist/lambda/env.d.ts +0 -10
  39. package/dist/lambda/lambda.d.ts +0 -18
  40. package/dist/logserver/all.d.ts +0 -5
  41. package/dist/logserver/log.d.ts +0 -11
  42. package/dist/logserver/logaccum.d.ts +0 -154
  43. package/dist/logserver/logblob.d.ts +0 -24
  44. package/dist/logserver/logconcat.d.ts +0 -55
  45. package/dist/logserver/logkey.d.ts +0 -28
  46. package/dist/memsqs/all.d.ts +0 -4
  47. package/dist/memsqs/client.d.ts +0 -13
  48. package/dist/memsqs/loopback.d.ts +0 -11
  49. package/dist/memsqs/orderedlist.d.ts +0 -19
  50. package/dist/memsqs/queue.d.ts +0 -84
  51. package/dist/memsqs/server.d.ts +0 -37
  52. package/dist/storage/all.d.ts +0 -4
  53. package/dist/storage/datablob.d.ts +0 -9
  54. package/dist/storage/env.d.ts +0 -10
  55. package/dist/storage/splitsblob.d.ts +0 -13
  56. package/dist/storage/storage.d.ts +0 -166
  57. package/dist/storages3/all.d.ts +0 -1
  58. package/dist/storages3/s3.d.ts +0 -62
  59. package/docs/dbabstract.md +0 -2
  60. package/docs/dbdynamo.md +0 -2
  61. package/docs/fsmfile.md +0 -2
  62. package/docs/jsonstream.md +0 -44
  63. package/docs/lambda.md +0 -2
  64. package/docs/logserver.md +0 -2
  65. package/docs/storage.md +0 -2
  66. package/docs/storages3.md +0 -2
  67. package/lib/all/allclient.ts +0 -19
  68. package/lib/dbabstract/all.ts +0 -1
  69. package/lib/dbabstract/db.ts +0 -246
  70. package/lib/dbdynamo/all.ts +0 -1
  71. package/lib/dbdynamo/dbdynamo.ts +0 -1551
  72. package/lib/fsmfile/all.ts +0 -1
  73. package/lib/fsmfile/fsmfile.ts +0 -236
  74. package/lib/jsonstream/all.ts +0 -1
  75. package/lib/jsonstream/jsonstream.ts +0 -940
  76. package/lib/lambda/all.ts +0 -1
  77. package/lib/lambda/env.ts +0 -13
  78. package/lib/lambda/lambda.ts +0 -120
  79. package/lib/logserver/all.ts +0 -5
  80. package/lib/logserver/log.ts +0 -565
  81. package/lib/logserver/logaccum.ts +0 -1445
  82. package/lib/logserver/logblob.ts +0 -84
  83. package/lib/logserver/logconcat.ts +0 -313
  84. package/lib/logserver/logkey.ts +0 -125
  85. package/lib/memsqs/all.ts +0 -4
  86. package/lib/memsqs/client.ts +0 -268
  87. package/lib/memsqs/loopback.ts +0 -64
  88. package/lib/memsqs/orderedlist.ts +0 -74
  89. package/lib/memsqs/queue.ts +0 -395
  90. package/lib/memsqs/server.ts +0 -262
  91. package/lib/storage/all.ts +0 -4
  92. package/lib/storage/datablob.ts +0 -36
  93. package/lib/storage/env.ts +0 -14
  94. package/lib/storage/splitsblob.ts +0 -63
  95. package/lib/storage/storage.ts +0 -604
  96. package/lib/storages3/all.ts +0 -1
  97. package/lib/storages3/s3.ts +0 -576
@@ -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
  }
package/dist/fsm/fsm.d.ts CHANGED
@@ -63,6 +63,7 @@ export declare class FsmOnDone extends Fsm {
63
63
  }
64
64
  export declare class FsmSleep extends Fsm {
65
65
  delay: number;
66
+ timeoutHandle: any;
66
67
  constructor(env: FsmEnvironment, delay: number);
67
68
  tick(): void;
68
69
  }
@@ -0,0 +1,2 @@
1
+ export * from './geo';
2
+ export * from './vfeature';
@@ -0,0 +1,67 @@
1
+ import * as geojson from 'geojson';
2
+ import * as Poly from '../poly/all';
3
+ export declare type GeoProperties = geojson.GeoJsonProperties;
4
+ export declare type GeoFeature = geojson.Feature;
5
+ export declare type GeoFeatureArray = GeoFeature[];
6
+ export declare type GeoFeatureCollection = geojson.FeatureCollection;
7
+ export declare function geoCollectionToMap(col: GeoFeatureCollection): GeoFeatureMap;
8
+ export declare function geoMapToCollection(map: GeoFeatureMap): GeoFeatureCollection;
9
+ export declare function geoCollectionToTopo(col: GeoFeatureCollection): Poly.Topo;
10
+ export declare function geoTopoToCollection(topo: Poly.Topo): GeoFeatureCollection;
11
+ export interface GeoFeatureMap {
12
+ [id: string]: GeoFeature;
13
+ }
14
+ export declare type FeatureFunc = (f: GeoFeature) => void;
15
+ interface GeoEntry {
16
+ tag: string;
17
+ col?: GeoFeatureCollection;
18
+ map?: GeoFeatureMap;
19
+ topo?: Poly.Topo;
20
+ }
21
+ declare type GeoEntryMap = {
22
+ [tag: string]: GeoEntry;
23
+ };
24
+ export declare function geoEqual(m1: GeoMultiCollection, m2: GeoMultiCollection): boolean;
25
+ export declare function geoMapEqual(m1: GeoFeatureMap, m2: GeoFeatureMap): boolean;
26
+ export declare class GeoMultiCollection {
27
+ entries: GeoEntryMap;
28
+ all: GeoEntry;
29
+ hidden: any;
30
+ stamp: number;
31
+ constructor(tag?: string, topo?: Poly.Topo, col?: GeoFeatureCollection, map?: GeoFeatureMap);
32
+ empty(): void;
33
+ get nEntries(): number;
34
+ nthEntry(n: number): GeoEntry;
35
+ add(tag: string, topo: Poly.Topo, col: GeoFeatureCollection, map: GeoFeatureMap): void;
36
+ addMulti(multi: GeoMultiCollection): void;
37
+ remove(tag: string): void;
38
+ _onChange(): void;
39
+ _col(e: GeoEntry): GeoFeatureCollection;
40
+ _map(e: GeoEntry): GeoFeatureMap;
41
+ _topo(e: GeoEntry): Poly.Topo;
42
+ colOf(tag: string): GeoFeatureCollection;
43
+ mapOf(tag: string): GeoFeatureMap;
44
+ topoOf(tag: string): Poly.Topo;
45
+ forEachEntry(cb: (e: GeoEntry) => void): void;
46
+ allCol(): GeoFeatureCollection;
47
+ allMap(): GeoFeatureMap;
48
+ allTopo(): Poly.Topo;
49
+ hide(id: any): void;
50
+ show(id: any): void;
51
+ showAll(): void;
52
+ get length(): number;
53
+ nthFeature(n: number): GeoFeature;
54
+ nthFilteredFeature(n: number, cb: (f: GeoFeature) => boolean): GeoFeature;
55
+ forEach(cb: FeatureFunc): void;
56
+ map(cb: (f: GeoFeature) => GeoFeature): GeoFeature[];
57
+ isHidden(id: string): boolean;
58
+ find(id: string): GeoFeature;
59
+ filter(test: (f: GeoFeature) => boolean): GeoMultiCollection;
60
+ }
61
+ export declare enum geoIntersectOptions {
62
+ Intersects = 0,
63
+ Bounds = 1,
64
+ BoundsCenter = 2
65
+ }
66
+ export declare function geoIntersect(multi: GeoMultiCollection, bbox: Poly.BoundBox, opt: geoIntersectOptions): GeoMultiCollection;
67
+ export {};
@@ -0,0 +1,4 @@
1
+ import * as Util from '../util/all';
2
+ import * as Poly from '../poly/all';
3
+ import * as G from './geo';
4
+ export declare function computeVFeature(topoPrecinct: Poly.Topo, bintrie: Util.BinTrie, blocks: string[]): G.GeoFeature;
@@ -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
  };
@@ -2,6 +2,7 @@ import * as FSM from '../fsm/all';
2
2
  import * as Poly from './poly';
3
3
  import * as Q from './quad';
4
4
  export declare function polyIntersects(p1: any, p2: any): boolean;
5
+ export declare function polyDifference(main: any, parts: any[]): any;
5
6
  declare class FsmDifference extends FSM.Fsm {
6
7
  accum: any;
7
8
  polys: any[];
@@ -0,0 +1,22 @@
1
+ # filterexpr
2
+ Simple utility class for applying a user-provided filtering expression against an object.
3
+
4
+ ## FilterExpr
5
+
6
+ Optionally initialize with expression to test against.
7
+ Or call `set(expr: string)` to set the expression.
8
+ The function `test(o: any)` will test the object against the expression.
9
+
10
+ ## Expression syntax
11
+
12
+ The simplest expression is just a string of text. If any field in the object contains the string, the pattern matches.
13
+ All comparisons are case-insensitive.
14
+
15
+ A quoted string can be used to hide special characters. Single or double quotes are allowed.
16
+
17
+ Expressions can be combined with `not`, `and`, and `or`. Precedence is in that order.
18
+
19
+ Expressions can be surrounded by parens to force a precedence interpretation.
20
+
21
+ A field name can be specified to limit the comparison to a specific field. An example is `state: ma`. Field names are case-insensitive.
22
+ Field name is lowest precedence, so `state: ma or tx` would constrain both strings to the `state` property.
package/lib/all/all.ts CHANGED
@@ -17,25 +17,5 @@ import * as OTE from '../ot-editutil/all';
17
17
  export { OTE };
18
18
  import { FilterExpr } from '../filterexpr/all';
19
19
  export { FilterExpr }
20
-
21
- // Server Only
22
- import * as DB from '../dbabstract/all';
23
- export { DB };
24
- import * as Storage from '../storage/all';
25
- export { Storage };
26
- import * as JS from '../jsonstream/all';
27
- export { JS };
28
- import * as FsmFile from '../fsmfile/all';
29
- export { FsmFile };
30
-
31
- import * as LogServer from '../logserver/all';
32
- export { LogServer };
33
-
34
- import * as S3 from '../storages3/all';
35
- export { S3 };
36
- import * as DBDynamo from '../dbdynamo/all';
37
- export { DBDynamo };
38
- import * as Lambda from '../lambda/all';
39
- export { Lambda };
40
- import * as Memsqs from '../memsqs/all';
41
- export { Memsqs };
20
+ import * as G from '../geo/all';
21
+ export { G };
@@ -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) return `'${clause.op.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
- a.push('(');
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
- a.push(')');
627
+ if (clause !== this.parser.clause)
628
+ a.push(')');
555
629
  return a.join(' ');
556
630
  }
557
631
 
package/lib/fsm/fsm.ts CHANGED
@@ -291,6 +291,7 @@ export class FsmOnDone extends Fsm
291
291
  export class FsmSleep extends Fsm
292
292
  {
293
293
  delay: number;
294
+ timeoutHandle: any;
294
295
 
295
296
  constructor(env: FsmEnvironment, delay: number)
296
297
  {
@@ -300,10 +301,19 @@ export class FsmSleep extends Fsm
300
301
 
301
302
  tick(): void
302
303
  {
303
- if (this.ready && this.state === FSM_STARTING)
304
+ // This allows canceling by simply setting state to done
305
+ if (this.done && this.timeoutHandle !== undefined)
306
+ {
307
+ clearTimeout(this.timeoutHandle);
308
+ delete this.timeoutHandle;
309
+ }
310
+ else if (this.ready && this.state === FSM_STARTING)
304
311
  {
305
312
  this.setState(FSM_PENDING);
306
- setTimeout(() => { this.setState(FSM_DONE); }, this.delay);
313
+ this.timeoutHandle = setTimeout(() => {
314
+ delete this.timeoutHandle;
315
+ this.setState(FSM_DONE)
316
+ }, this.delay);
307
317
  }
308
318
  }
309
319
  }
package/lib/geo/all.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './geo';
2
+ export * from './vfeature';