@dra2020/baseclient 1.0.13 → 1.0.14
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/LICENSE +21 -0
- package/README.md +37 -0
- package/dist/all/all.d.ts +36 -0
- package/dist/all/allclient.d.ts +18 -0
- package/dist/base.js +33010 -0
- package/dist/base.js.map +1 -0
- package/dist/baseclient.js +8991 -0
- package/dist/baseclient.js.map +1 -0
- package/dist/context/all.d.ts +1 -0
- package/dist/context/context.d.ts +13 -0
- package/dist/dbabstract/all.d.ts +1 -0
- package/dist/dbabstract/db.d.ts +83 -0
- package/dist/dbdynamo/all.d.ts +1 -0
- package/dist/dbdynamo/dbdynamo.d.ts +190 -0
- package/dist/filterexpr/all.d.ts +1 -0
- package/dist/filterexpr/filterexpr.d.ts +64 -0
- package/dist/fsm/all.d.ts +1 -0
- package/dist/fsm/fsm.d.ts +118 -0
- package/dist/fsmfile/all.d.ts +1 -0
- package/dist/fsmfile/fsmfile.d.ts +47 -0
- package/dist/jsonstream/all.d.ts +1 -0
- package/dist/jsonstream/jsonstream.d.ts +130 -0
- package/dist/lambda/all.d.ts +1 -0
- package/dist/lambda/env.d.ts +10 -0
- package/dist/lambda/lambda.d.ts +18 -0
- package/dist/logabstract/all.d.ts +1 -0
- package/dist/logabstract/log.d.ts +26 -0
- package/dist/logclient/all.d.ts +1 -0
- package/dist/logclient/log.d.ts +6 -0
- package/dist/logserver/all.d.ts +5 -0
- package/dist/logserver/log.d.ts +11 -0
- package/dist/logserver/logaccum.d.ts +154 -0
- package/dist/logserver/logblob.d.ts +24 -0
- package/dist/logserver/logconcat.d.ts +55 -0
- package/dist/logserver/logkey.d.ts +28 -0
- package/dist/memsqs/all.d.ts +4 -0
- package/dist/memsqs/client.d.ts +13 -0
- package/dist/memsqs/loopback.d.ts +11 -0
- package/dist/memsqs/orderedlist.d.ts +19 -0
- package/dist/memsqs/queue.d.ts +84 -0
- package/dist/memsqs/server.d.ts +37 -0
- package/dist/ot-editutil/all.d.ts +2 -0
- package/dist/ot-editutil/oteditutil.d.ts +14 -0
- package/dist/ot-editutil/otmaputil.d.ts +21 -0
- package/dist/ot-js/all.d.ts +9 -0
- package/dist/ot-js/otarray.d.ts +111 -0
- package/dist/ot-js/otclientengine.d.ts +38 -0
- package/dist/ot-js/otcomposite.d.ts +37 -0
- package/dist/ot-js/otcounter.d.ts +17 -0
- package/dist/ot-js/otengine.d.ts +22 -0
- package/dist/ot-js/otmap.d.ts +19 -0
- package/dist/ot-js/otserverengine.d.ts +38 -0
- package/dist/ot-js/otsession.d.ts +111 -0
- package/dist/ot-js/ottypes.d.ts +29 -0
- package/dist/poly/all.d.ts +15 -0
- package/dist/poly/blend.d.ts +1 -0
- package/dist/poly/boundbox.d.ts +16 -0
- package/dist/poly/cartesian.d.ts +5 -0
- package/dist/poly/graham-scan.d.ts +8 -0
- package/dist/poly/hash.d.ts +1 -0
- package/dist/poly/matrix.d.ts +24 -0
- package/dist/poly/minbound.d.ts +1 -0
- package/dist/poly/poly.d.ts +52 -0
- package/dist/poly/polybin.d.ts +5 -0
- package/dist/poly/polylabel.d.ts +7 -0
- package/dist/poly/polypack.d.ts +30 -0
- package/dist/poly/polyround.d.ts +1 -0
- package/dist/poly/polysimplify.d.ts +1 -0
- package/dist/poly/quad.d.ts +48 -0
- package/dist/poly/selfintersect.d.ts +1 -0
- package/dist/poly/shamos.d.ts +1 -0
- package/dist/poly/simplify.d.ts +2 -0
- package/dist/poly/topo.d.ts +46 -0
- package/dist/poly/union.d.ts +48 -0
- package/dist/storage/all.d.ts +4 -0
- package/dist/storage/datablob.d.ts +9 -0
- package/dist/storage/env.d.ts +10 -0
- package/dist/storage/splitsblob.d.ts +13 -0
- package/dist/storage/storage.d.ts +166 -0
- package/dist/storages3/all.d.ts +1 -0
- package/dist/storages3/s3.d.ts +62 -0
- package/dist/util/all.d.ts +5 -0
- package/dist/util/bintrie.d.ts +93 -0
- package/dist/util/countedhash.d.ts +19 -0
- package/dist/util/gradient.d.ts +15 -0
- package/dist/util/indexedarray.d.ts +15 -0
- package/dist/util/util.d.ts +68 -0
- package/docs/context.md +2 -0
- package/docs/dbabstract.md +2 -0
- package/docs/dbdynamo.md +2 -0
- package/docs/fsm.md +243 -0
- package/docs/fsmfile.md +2 -0
- package/docs/jsonstream.md +44 -0
- package/docs/lambda.md +2 -0
- package/docs/logabstract.md +2 -0
- package/docs/logclient.md +2 -0
- package/docs/logserver.md +2 -0
- package/docs/ot-editutil.md +2 -0
- package/docs/ot-js.md +95 -0
- package/docs/poly.md +103 -0
- package/docs/storage.md +2 -0
- package/docs/storages3.md +2 -0
- package/docs/util.md +2 -0
- package/lib/all/all.ts +41 -0
- package/lib/all/allclient.ts +19 -0
- package/lib/context/all.ts +1 -0
- package/lib/context/context.ts +82 -0
- package/lib/dbabstract/all.ts +1 -0
- package/lib/dbabstract/db.ts +246 -0
- package/lib/dbdynamo/all.ts +1 -0
- package/lib/dbdynamo/dbdynamo.ts +1551 -0
- package/lib/filterexpr/all.ts +1 -0
- package/lib/filterexpr/filterexpr.ts +625 -0
- package/lib/fsm/all.ts +1 -0
- package/lib/fsm/fsm.ts +549 -0
- package/lib/fsmfile/all.ts +1 -0
- package/lib/fsmfile/fsmfile.ts +236 -0
- package/lib/jsonstream/all.ts +1 -0
- package/lib/jsonstream/jsonstream.ts +940 -0
- package/lib/lambda/all.ts +1 -0
- package/lib/lambda/env.ts +13 -0
- package/lib/lambda/lambda.ts +120 -0
- package/lib/logabstract/all.ts +1 -0
- package/lib/logabstract/log.ts +55 -0
- package/lib/logclient/all.ts +1 -0
- package/lib/logclient/log.ts +105 -0
- package/lib/logserver/all.ts +5 -0
- package/lib/logserver/log.ts +565 -0
- package/lib/logserver/logaccum.ts +1445 -0
- package/lib/logserver/logblob.ts +84 -0
- package/lib/logserver/logconcat.ts +313 -0
- package/lib/logserver/logkey.ts +125 -0
- package/lib/memsqs/all.ts +4 -0
- package/lib/memsqs/client.ts +268 -0
- package/lib/memsqs/loopback.ts +64 -0
- package/lib/memsqs/orderedlist.ts +74 -0
- package/lib/memsqs/queue.ts +395 -0
- package/lib/memsqs/server.ts +262 -0
- package/lib/ot-editutil/all.ts +2 -0
- package/lib/ot-editutil/oteditutil.ts +180 -0
- package/lib/ot-editutil/otmaputil.ts +209 -0
- package/lib/ot-js/all.ts +9 -0
- package/lib/ot-js/otarray.ts +1168 -0
- package/lib/ot-js/otclientengine.ts +327 -0
- package/lib/ot-js/otcomposite.ts +247 -0
- package/lib/ot-js/otcounter.ts +145 -0
- package/lib/ot-js/otengine.ts +71 -0
- package/lib/ot-js/otmap.ts +144 -0
- package/lib/ot-js/otserverengine.ts +329 -0
- package/lib/ot-js/otsession.ts +199 -0
- package/lib/ot-js/ottypes.ts +98 -0
- package/lib/poly/all.ts +15 -0
- package/lib/poly/blend.ts +27 -0
- package/lib/poly/boundbox.ts +102 -0
- package/lib/poly/cartesian.ts +130 -0
- package/lib/poly/graham-scan.ts +401 -0
- package/lib/poly/hash.ts +15 -0
- package/lib/poly/matrix.ts +309 -0
- package/lib/poly/minbound.ts +211 -0
- package/lib/poly/poly.ts +767 -0
- package/lib/poly/polybin.ts +218 -0
- package/lib/poly/polylabel.ts +204 -0
- package/lib/poly/polypack.ts +458 -0
- package/lib/poly/polyround.ts +30 -0
- package/lib/poly/polysimplify.ts +24 -0
- package/lib/poly/quad.ts +272 -0
- package/lib/poly/selfintersect.ts +87 -0
- package/lib/poly/shamos.ts +297 -0
- package/lib/poly/simplify.ts +119 -0
- package/lib/poly/topo.ts +525 -0
- package/lib/poly/union.ts +371 -0
- package/lib/storage/all.ts +4 -0
- package/lib/storage/datablob.ts +36 -0
- package/lib/storage/env.ts +14 -0
- package/lib/storage/splitsblob.ts +63 -0
- package/lib/storage/storage.ts +604 -0
- package/lib/storages3/all.ts +1 -0
- package/lib/storages3/s3.ts +576 -0
- package/lib/util/all.ts +5 -0
- package/lib/util/bintrie.ts +603 -0
- package/lib/util/countedhash.ts +83 -0
- package/lib/util/gradient.ts +108 -0
- package/lib/util/indexedarray.ts +80 -0
- package/lib/util/util.ts +695 -0
- package/package.json +8 -8
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
// Shared libraries
|
|
2
|
+
import * as LogAbstract from '../logabstract/all';
|
|
3
|
+
import * as Context from '../context/all';
|
|
4
|
+
import * as Storage from '../storage/all';
|
|
5
|
+
import * as FSM from '../fsm/all';
|
|
6
|
+
|
|
7
|
+
// Custom DB state codes
|
|
8
|
+
export const FSM_CREATING: number = FSM.FSM_CUSTOM1;
|
|
9
|
+
export const FSM_NEEDRELEASE: number = FSM.FSM_CUSTOM2;
|
|
10
|
+
export const FSM_RELEASING: number = FSM.FSM_CUSTOM3;
|
|
11
|
+
export const FSM_READING: number = FSM.FSM_CUSTOM4;
|
|
12
|
+
|
|
13
|
+
type CollectionIndex = { [key: string]: DBCollection };
|
|
14
|
+
|
|
15
|
+
export interface DBEnvironment
|
|
16
|
+
{
|
|
17
|
+
context: Context.IContext;
|
|
18
|
+
log: LogAbstract.ILog;
|
|
19
|
+
fsmManager: FSM.FsmManager;
|
|
20
|
+
storageManager: Storage.StorageManager;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function fromCompactSchema(c: any): any
|
|
24
|
+
{
|
|
25
|
+
let s: any = [];
|
|
26
|
+
|
|
27
|
+
if (c && !Array.isArray(c))
|
|
28
|
+
{
|
|
29
|
+
for (let p in c) if (c.hasOwnProperty(p))
|
|
30
|
+
s.push({ AttributeName: p, AttributeType: c[p] });
|
|
31
|
+
}
|
|
32
|
+
else
|
|
33
|
+
s = c;
|
|
34
|
+
return s;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function fromCompactKey(c: any): any
|
|
38
|
+
{
|
|
39
|
+
let s: any = [];
|
|
40
|
+
|
|
41
|
+
if (c && !Array.isArray(c))
|
|
42
|
+
{
|
|
43
|
+
for (let p in c) if (c.hasOwnProperty(p))
|
|
44
|
+
s.push({ AttributeName: p, KeyType: c[p] });
|
|
45
|
+
}
|
|
46
|
+
else
|
|
47
|
+
s = c;
|
|
48
|
+
return s;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function findHash(c: any): string
|
|
52
|
+
{
|
|
53
|
+
let h: string = null;
|
|
54
|
+
|
|
55
|
+
Object.keys(c).forEach((k: string) => { if (c[k] === 'HASH') h = k } );
|
|
56
|
+
while (h && h.length < 3)
|
|
57
|
+
h = `_${h}`;
|
|
58
|
+
return h;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function fromCompactIndex(c: any): any
|
|
62
|
+
{
|
|
63
|
+
return { KeySchema: fromCompactKey(c), IndexName: findHash(c) };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function toCompactSchema(s: any): any
|
|
67
|
+
{
|
|
68
|
+
let c: any = {};
|
|
69
|
+
|
|
70
|
+
if (s && Array.isArray(s))
|
|
71
|
+
{
|
|
72
|
+
for (let i: number = 0; i < s.length; i++)
|
|
73
|
+
c[s[i].AttributeName] = s[i].AttributeType;
|
|
74
|
+
}
|
|
75
|
+
else
|
|
76
|
+
c = s;
|
|
77
|
+
|
|
78
|
+
return c;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export class DBClient extends FSM.Fsm
|
|
82
|
+
{
|
|
83
|
+
constructor(env: DBEnvironment)
|
|
84
|
+
{
|
|
85
|
+
super(env);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get env(): DBEnvironment { return this._env as DBEnvironment; }
|
|
89
|
+
|
|
90
|
+
createCollection(name: string, options: any): DBCollection { return new DBCollection(this.env, this, name, options); }
|
|
91
|
+
createStream(col: DBCollection): FSM.FsmArray { return null; }
|
|
92
|
+
closeStream(col: DBCollection): void {}
|
|
93
|
+
createUpdate(col: DBCollection, query: any, values: any): DBUpdate { return new DBUpdate(this.env, col, query, values); }
|
|
94
|
+
createUnset(col: DBCollection, query: any, values: any): DBUnset { return new DBUnset(this.env, col, query, values); }
|
|
95
|
+
createDelete(col: DBCollection, query: any): DBDelete { return new DBDelete(this.env, col, query); }
|
|
96
|
+
createFind(col: DBCollection, filter: any): DBFind { return new DBFind(this.env, col, filter); }
|
|
97
|
+
createQuery(col: DBCollection, filter: any): DBQuery { return new DBQuery(this.env, col, filter); }
|
|
98
|
+
createIndex(col: DBCollection, uid: string): DBIndex { return new DBIndex(this.env, col, uid); }
|
|
99
|
+
createClose(): DBClose { return new DBClose(this.env, this); }
|
|
100
|
+
|
|
101
|
+
close(): void
|
|
102
|
+
{
|
|
103
|
+
if (this.state == FSM.FSM_DONE)
|
|
104
|
+
this.setState(FSM_NEEDRELEASE);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export class DBCollection extends FSM.Fsm
|
|
109
|
+
{
|
|
110
|
+
name: string;
|
|
111
|
+
options: any;
|
|
112
|
+
col: any;
|
|
113
|
+
client: DBClient;
|
|
114
|
+
|
|
115
|
+
constructor(env: DBEnvironment, client: DBClient, name: string, options: any)
|
|
116
|
+
{
|
|
117
|
+
super(env);
|
|
118
|
+
this.waitOn(client);
|
|
119
|
+
this.client = client;
|
|
120
|
+
this.name = name;
|
|
121
|
+
this.options = options;
|
|
122
|
+
this.col = null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export class DBUpdate extends FSM.Fsm
|
|
127
|
+
{
|
|
128
|
+
col: DBCollection;
|
|
129
|
+
query: any;
|
|
130
|
+
values: any;
|
|
131
|
+
result: any;
|
|
132
|
+
|
|
133
|
+
constructor(env: DBEnvironment, col: DBCollection, query: any, values: any)
|
|
134
|
+
{
|
|
135
|
+
super(env);
|
|
136
|
+
this.waitOn(col);
|
|
137
|
+
this.col = col;
|
|
138
|
+
this.query = query;
|
|
139
|
+
this.values = values;
|
|
140
|
+
this.result = undefined;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export class DBUnset extends FSM.Fsm
|
|
145
|
+
{
|
|
146
|
+
col: DBCollection;
|
|
147
|
+
query: any;
|
|
148
|
+
values: any;
|
|
149
|
+
result: any;
|
|
150
|
+
|
|
151
|
+
constructor(env: DBEnvironment, col: DBCollection, query: any, values: any)
|
|
152
|
+
{
|
|
153
|
+
super(env);
|
|
154
|
+
this.waitOn(col);
|
|
155
|
+
this.col = col;
|
|
156
|
+
this.query = query;
|
|
157
|
+
this.values = values;
|
|
158
|
+
this.result = undefined;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export class DBDelete extends FSM.Fsm
|
|
163
|
+
{
|
|
164
|
+
col: DBCollection;
|
|
165
|
+
query: any;
|
|
166
|
+
result: any;
|
|
167
|
+
|
|
168
|
+
constructor(env: DBEnvironment, col: DBCollection, query: any)
|
|
169
|
+
{
|
|
170
|
+
super(env);
|
|
171
|
+
this.waitOn(col);
|
|
172
|
+
this.col = col;
|
|
173
|
+
this.query = query;
|
|
174
|
+
this.result = null;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export class DBFind extends FSM.Fsm
|
|
179
|
+
{
|
|
180
|
+
col: DBCollection;
|
|
181
|
+
filter: any;
|
|
182
|
+
result: any;
|
|
183
|
+
|
|
184
|
+
constructor(env: DBEnvironment, col: DBCollection, filter: any)
|
|
185
|
+
{
|
|
186
|
+
super(env);
|
|
187
|
+
this.waitOn(col);
|
|
188
|
+
this.col = col;
|
|
189
|
+
this.filter = filter;
|
|
190
|
+
this.result = null;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export class DBQuery extends FSM.Fsm
|
|
195
|
+
{
|
|
196
|
+
col: DBCollection;
|
|
197
|
+
filter: any;
|
|
198
|
+
fsmResult: FSM.FsmArray;
|
|
199
|
+
|
|
200
|
+
constructor(env: DBEnvironment, col: DBCollection, filter: any)
|
|
201
|
+
{
|
|
202
|
+
super(env);
|
|
203
|
+
this.waitOn(col);
|
|
204
|
+
this.col = col;
|
|
205
|
+
this.filter = filter;
|
|
206
|
+
this.fsmResult = new FSM.FsmArray(env);;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
get result(): any[] { return this.fsmResult.a }
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export class DBIndex extends FSM.Fsm
|
|
213
|
+
{
|
|
214
|
+
col: DBCollection;
|
|
215
|
+
uid: string;
|
|
216
|
+
|
|
217
|
+
constructor(env: DBEnvironment, col: DBCollection, uid: string)
|
|
218
|
+
{
|
|
219
|
+
super(env);
|
|
220
|
+
this.waitOn(col);
|
|
221
|
+
this.col = col;
|
|
222
|
+
this.uid = uid;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export class DBClose extends FSM.Fsm
|
|
227
|
+
{
|
|
228
|
+
client: DBClient;
|
|
229
|
+
|
|
230
|
+
constructor(env: DBEnvironment, client: DBClient)
|
|
231
|
+
{
|
|
232
|
+
super(env);
|
|
233
|
+
this.client = client;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
tick(): void
|
|
237
|
+
{
|
|
238
|
+
if (this.ready && this.isDependentError)
|
|
239
|
+
this.setState(FSM.FSM_ERROR);
|
|
240
|
+
else if (this.ready && this.state == FSM.FSM_STARTING)
|
|
241
|
+
{
|
|
242
|
+
this.client.close();
|
|
243
|
+
this.setState(FSM.FSM_DONE);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dbdynamo';
|