@ccmaymay/concrete 4.15.0 → 4.15.1

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 (42) hide show
  1. package/ActiveLearnerClientService.js +249 -249
  2. package/ActiveLearnerServerService.js +642 -642
  3. package/AnnotateCommunicationService.js +696 -696
  4. package/AnnotateWithContextService.js +298 -298
  5. package/FeedbackService.js +750 -750
  6. package/FetchCommunicationService.js +709 -709
  7. package/README.md +125 -0
  8. package/ResultsServerService.js +2138 -2138
  9. package/SearchProxyService.js +962 -962
  10. package/SearchService.js +685 -685
  11. package/Service.js +373 -373
  12. package/StoreCommunicationService.js +255 -255
  13. package/SummarizationService.js +479 -479
  14. package/access_types.js +168 -168
  15. package/annotate_types.js +26 -26
  16. package/audio_types.js +110 -110
  17. package/cluster_types.js +398 -398
  18. package/communication_fu.js +432 -432
  19. package/communication_types.js +845 -845
  20. package/concrete.js +64 -64
  21. package/context_types.js +65 -65
  22. package/email_types.js +477 -477
  23. package/entities_types.js +658 -658
  24. package/ex_types.js +82 -82
  25. package/language_types.js +123 -123
  26. package/learn_types.js +207 -207
  27. package/linking_types.js +286 -286
  28. package/metadata_types.js +926 -926
  29. package/nitf_types.js +1005 -1005
  30. package/package.json +26 -5
  31. package/results_types.js +18 -18
  32. package/search_types.js +661 -661
  33. package/services_types.js +384 -384
  34. package/situations_types.js +1268 -1268
  35. package/spans_types.js +151 -151
  36. package/structure_types.js +2311 -2311
  37. package/summarization_types.js +433 -433
  38. package/tokenization_fu.js +33 -33
  39. package/tokentagging_fu.js +241 -241
  40. package/twitter_types.js +1553 -1553
  41. package/util.js +117 -117
  42. package/uuid_types.js +67 -67
@@ -1,642 +1,642 @@
1
- //
2
- // Autogenerated by Thrift Compiler (0.15.0)
3
- //
4
- // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
- //
6
- "use strict";
7
-
8
- const thrift = require('thrift');
9
- const Thrift = thrift.Thrift;
10
- const Int64 = require('node-int64');
11
-
12
- const services_ttypes = require('./services_types');
13
- const uuid_ttypes = require('./uuid_types');
14
- const communication_ttypes = require('./communication_types');
15
-
16
-
17
- const Service = require('./Service');
18
- const ServiceClient = Service.Client;
19
- const ServiceProcessor = Service.Processor;
20
- const ttypes = require('./learn_types');
21
- //HELPER FUNCTIONS AND STRUCTURES
22
-
23
- const ActiveLearnerServerService_start_args = class {
24
- constructor(args) {
25
- this.sessionId = null;
26
- this.task = null;
27
- this.contact = null;
28
- if (args) {
29
- if (args.sessionId !== undefined && args.sessionId !== null) {
30
- this.sessionId = new uuid_ttypes.UUID(args.sessionId);
31
- }
32
- if (args.task !== undefined && args.task !== null) {
33
- this.task = new ttypes.AnnotationTask(args.task);
34
- }
35
- if (args.contact !== undefined && args.contact !== null) {
36
- this.contact = new services_ttypes.AsyncContactInfo(args.contact);
37
- }
38
- }
39
- }
40
-
41
- read (input) {
42
- input.readStructBegin();
43
- while (true) {
44
- const ret = input.readFieldBegin();
45
- const ftype = ret.ftype;
46
- const fid = ret.fid;
47
- if (ftype == Thrift.Type.STOP) {
48
- break;
49
- }
50
- switch (fid) {
51
- case 1:
52
- if (ftype == Thrift.Type.STRUCT) {
53
- this.sessionId = new uuid_ttypes.UUID();
54
- this.sessionId.read(input);
55
- } else {
56
- input.skip(ftype);
57
- }
58
- break;
59
- case 2:
60
- if (ftype == Thrift.Type.STRUCT) {
61
- this.task = new ttypes.AnnotationTask();
62
- this.task.read(input);
63
- } else {
64
- input.skip(ftype);
65
- }
66
- break;
67
- case 3:
68
- if (ftype == Thrift.Type.STRUCT) {
69
- this.contact = new services_ttypes.AsyncContactInfo();
70
- this.contact.read(input);
71
- } else {
72
- input.skip(ftype);
73
- }
74
- break;
75
- default:
76
- input.skip(ftype);
77
- }
78
- input.readFieldEnd();
79
- }
80
- input.readStructEnd();
81
- return;
82
- }
83
-
84
- write (output) {
85
- output.writeStructBegin('ActiveLearnerServerService_start_args');
86
- if (this.sessionId !== null && this.sessionId !== undefined) {
87
- output.writeFieldBegin('sessionId', Thrift.Type.STRUCT, 1);
88
- this.sessionId.write(output);
89
- output.writeFieldEnd();
90
- }
91
- if (this.task !== null && this.task !== undefined) {
92
- output.writeFieldBegin('task', Thrift.Type.STRUCT, 2);
93
- this.task.write(output);
94
- output.writeFieldEnd();
95
- }
96
- if (this.contact !== null && this.contact !== undefined) {
97
- output.writeFieldBegin('contact', Thrift.Type.STRUCT, 3);
98
- this.contact.write(output);
99
- output.writeFieldEnd();
100
- }
101
- output.writeFieldStop();
102
- output.writeStructEnd();
103
- return;
104
- }
105
-
106
- };
107
- const ActiveLearnerServerService_start_result = class {
108
- constructor(args) {
109
- this.success = null;
110
- if (args) {
111
- if (args.success !== undefined && args.success !== null) {
112
- this.success = args.success;
113
- }
114
- }
115
- }
116
-
117
- read (input) {
118
- input.readStructBegin();
119
- while (true) {
120
- const ret = input.readFieldBegin();
121
- const ftype = ret.ftype;
122
- const fid = ret.fid;
123
- if (ftype == Thrift.Type.STOP) {
124
- break;
125
- }
126
- switch (fid) {
127
- case 0:
128
- if (ftype == Thrift.Type.BOOL) {
129
- this.success = input.readBool();
130
- } else {
131
- input.skip(ftype);
132
- }
133
- break;
134
- case 0:
135
- input.skip(ftype);
136
- break;
137
- default:
138
- input.skip(ftype);
139
- }
140
- input.readFieldEnd();
141
- }
142
- input.readStructEnd();
143
- return;
144
- }
145
-
146
- write (output) {
147
- output.writeStructBegin('ActiveLearnerServerService_start_result');
148
- if (this.success !== null && this.success !== undefined) {
149
- output.writeFieldBegin('success', Thrift.Type.BOOL, 0);
150
- output.writeBool(this.success);
151
- output.writeFieldEnd();
152
- }
153
- output.writeFieldStop();
154
- output.writeStructEnd();
155
- return;
156
- }
157
-
158
- };
159
- const ActiveLearnerServerService_stop_args = class {
160
- constructor(args) {
161
- this.sessionId = null;
162
- if (args) {
163
- if (args.sessionId !== undefined && args.sessionId !== null) {
164
- this.sessionId = new uuid_ttypes.UUID(args.sessionId);
165
- }
166
- }
167
- }
168
-
169
- read (input) {
170
- input.readStructBegin();
171
- while (true) {
172
- const ret = input.readFieldBegin();
173
- const ftype = ret.ftype;
174
- const fid = ret.fid;
175
- if (ftype == Thrift.Type.STOP) {
176
- break;
177
- }
178
- switch (fid) {
179
- case 1:
180
- if (ftype == Thrift.Type.STRUCT) {
181
- this.sessionId = new uuid_ttypes.UUID();
182
- this.sessionId.read(input);
183
- } else {
184
- input.skip(ftype);
185
- }
186
- break;
187
- case 0:
188
- input.skip(ftype);
189
- break;
190
- default:
191
- input.skip(ftype);
192
- }
193
- input.readFieldEnd();
194
- }
195
- input.readStructEnd();
196
- return;
197
- }
198
-
199
- write (output) {
200
- output.writeStructBegin('ActiveLearnerServerService_stop_args');
201
- if (this.sessionId !== null && this.sessionId !== undefined) {
202
- output.writeFieldBegin('sessionId', Thrift.Type.STRUCT, 1);
203
- this.sessionId.write(output);
204
- output.writeFieldEnd();
205
- }
206
- output.writeFieldStop();
207
- output.writeStructEnd();
208
- return;
209
- }
210
-
211
- };
212
- const ActiveLearnerServerService_stop_result = class {
213
- constructor(args) {
214
- }
215
-
216
- read (input) {
217
- input.readStructBegin();
218
- while (true) {
219
- const ret = input.readFieldBegin();
220
- const ftype = ret.ftype;
221
- if (ftype == Thrift.Type.STOP) {
222
- break;
223
- }
224
- input.skip(ftype);
225
- input.readFieldEnd();
226
- }
227
- input.readStructEnd();
228
- return;
229
- }
230
-
231
- write (output) {
232
- output.writeStructBegin('ActiveLearnerServerService_stop_result');
233
- output.writeFieldStop();
234
- output.writeStructEnd();
235
- return;
236
- }
237
-
238
- };
239
- const ActiveLearnerServerService_addAnnotations_args = class {
240
- constructor(args) {
241
- this.sessionId = null;
242
- this.annotations = null;
243
- if (args) {
244
- if (args.sessionId !== undefined && args.sessionId !== null) {
245
- this.sessionId = new uuid_ttypes.UUID(args.sessionId);
246
- }
247
- if (args.annotations !== undefined && args.annotations !== null) {
248
- this.annotations = Thrift.copyList(args.annotations, [ttypes.Annotation]);
249
- }
250
- }
251
- }
252
-
253
- read (input) {
254
- input.readStructBegin();
255
- while (true) {
256
- const ret = input.readFieldBegin();
257
- const ftype = ret.ftype;
258
- const fid = ret.fid;
259
- if (ftype == Thrift.Type.STOP) {
260
- break;
261
- }
262
- switch (fid) {
263
- case 1:
264
- if (ftype == Thrift.Type.STRUCT) {
265
- this.sessionId = new uuid_ttypes.UUID();
266
- this.sessionId.read(input);
267
- } else {
268
- input.skip(ftype);
269
- }
270
- break;
271
- case 2:
272
- if (ftype == Thrift.Type.LIST) {
273
- this.annotations = [];
274
- const _rtmp36 = input.readListBegin();
275
- const _size5 = _rtmp36.size || 0;
276
- for (let _i7 = 0; _i7 < _size5; ++_i7) {
277
- let elem8 = null;
278
- elem8 = new ttypes.Annotation();
279
- elem8.read(input);
280
- this.annotations.push(elem8);
281
- }
282
- input.readListEnd();
283
- } else {
284
- input.skip(ftype);
285
- }
286
- break;
287
- default:
288
- input.skip(ftype);
289
- }
290
- input.readFieldEnd();
291
- }
292
- input.readStructEnd();
293
- return;
294
- }
295
-
296
- write (output) {
297
- output.writeStructBegin('ActiveLearnerServerService_addAnnotations_args');
298
- if (this.sessionId !== null && this.sessionId !== undefined) {
299
- output.writeFieldBegin('sessionId', Thrift.Type.STRUCT, 1);
300
- this.sessionId.write(output);
301
- output.writeFieldEnd();
302
- }
303
- if (this.annotations !== null && this.annotations !== undefined) {
304
- output.writeFieldBegin('annotations', Thrift.Type.LIST, 2);
305
- output.writeListBegin(Thrift.Type.STRUCT, this.annotations.length);
306
- for (let iter9 in this.annotations) {
307
- if (this.annotations.hasOwnProperty(iter9)) {
308
- iter9 = this.annotations[iter9];
309
- iter9.write(output);
310
- }
311
- }
312
- output.writeListEnd();
313
- output.writeFieldEnd();
314
- }
315
- output.writeFieldStop();
316
- output.writeStructEnd();
317
- return;
318
- }
319
-
320
- };
321
- const ActiveLearnerServerService_addAnnotations_result = class {
322
- constructor(args) {
323
- }
324
-
325
- read (input) {
326
- input.readStructBegin();
327
- while (true) {
328
- const ret = input.readFieldBegin();
329
- const ftype = ret.ftype;
330
- if (ftype == Thrift.Type.STOP) {
331
- break;
332
- }
333
- input.skip(ftype);
334
- input.readFieldEnd();
335
- }
336
- input.readStructEnd();
337
- return;
338
- }
339
-
340
- write (output) {
341
- output.writeStructBegin('ActiveLearnerServerService_addAnnotations_result');
342
- output.writeFieldStop();
343
- output.writeStructEnd();
344
- return;
345
- }
346
-
347
- };
348
- const ActiveLearnerServerServiceClient = exports.Client = class ActiveLearnerServerServiceClient extends ServiceClient {
349
- constructor(output, pClass) {
350
- super(output, pClass);
351
- this.output = output;
352
- this.pClass = pClass;
353
- this._seqid = 0;
354
- this._reqs = {};
355
- }
356
- seqid () { return this._seqid; }
357
- new_seqid () { return this._seqid += 1; }
358
-
359
- start (sessionId, task, contact) {
360
- this._seqid = this.new_seqid();
361
- const self = this;
362
- return new Promise((resolve, reject) => {
363
- self._reqs[self.seqid()] = (error, result) => {
364
- return error ? reject(error) : resolve(result);
365
- };
366
- self.send_start(sessionId, task, contact);
367
- });
368
- }
369
-
370
- send_start (sessionId, task, contact) {
371
- const output = new this.pClass(this.output);
372
- const params = {
373
- sessionId: sessionId,
374
- task: task,
375
- contact: contact
376
- };
377
- const args = new ActiveLearnerServerService_start_args(params);
378
- try {
379
- output.writeMessageBegin('start', Thrift.MessageType.CALL, this.seqid());
380
- args.write(output);
381
- output.writeMessageEnd();
382
- return this.output.flush();
383
- }
384
- catch (e) {
385
- delete this._reqs[this.seqid()];
386
- if (typeof output.reset === 'function') {
387
- output.reset();
388
- }
389
- throw e;
390
- }
391
- }
392
-
393
- recv_start (input, mtype, rseqid) {
394
- const callback = this._reqs[rseqid] || function() {};
395
- delete this._reqs[rseqid];
396
- if (mtype == Thrift.MessageType.EXCEPTION) {
397
- const x = new Thrift.TApplicationException();
398
- x.read(input);
399
- input.readMessageEnd();
400
- return callback(x);
401
- }
402
- const result = new ActiveLearnerServerService_start_result();
403
- result.read(input);
404
- input.readMessageEnd();
405
-
406
- if (null !== result.success) {
407
- return callback(null, result.success);
408
- }
409
- return callback('start failed: unknown result');
410
- }
411
-
412
- stop (sessionId) {
413
- this._seqid = this.new_seqid();
414
- const self = this;
415
- return new Promise((resolve, reject) => {
416
- self._reqs[self.seqid()] = (error, result) => {
417
- return error ? reject(error) : resolve(result);
418
- };
419
- self.send_stop(sessionId);
420
- });
421
- }
422
-
423
- send_stop (sessionId) {
424
- const output = new this.pClass(this.output);
425
- const params = {
426
- sessionId: sessionId
427
- };
428
- const args = new ActiveLearnerServerService_stop_args(params);
429
- try {
430
- output.writeMessageBegin('stop', Thrift.MessageType.CALL, this.seqid());
431
- args.write(output);
432
- output.writeMessageEnd();
433
- return this.output.flush();
434
- }
435
- catch (e) {
436
- delete this._reqs[this.seqid()];
437
- if (typeof output.reset === 'function') {
438
- output.reset();
439
- }
440
- throw e;
441
- }
442
- }
443
-
444
- recv_stop (input, mtype, rseqid) {
445
- const callback = this._reqs[rseqid] || function() {};
446
- delete this._reqs[rseqid];
447
- if (mtype == Thrift.MessageType.EXCEPTION) {
448
- const x = new Thrift.TApplicationException();
449
- x.read(input);
450
- input.readMessageEnd();
451
- return callback(x);
452
- }
453
- const result = new ActiveLearnerServerService_stop_result();
454
- result.read(input);
455
- input.readMessageEnd();
456
-
457
- callback(null);
458
- }
459
-
460
- addAnnotations (sessionId, annotations) {
461
- this._seqid = this.new_seqid();
462
- const self = this;
463
- return new Promise((resolve, reject) => {
464
- self._reqs[self.seqid()] = (error, result) => {
465
- return error ? reject(error) : resolve(result);
466
- };
467
- self.send_addAnnotations(sessionId, annotations);
468
- });
469
- }
470
-
471
- send_addAnnotations (sessionId, annotations) {
472
- const output = new this.pClass(this.output);
473
- const params = {
474
- sessionId: sessionId,
475
- annotations: annotations
476
- };
477
- const args = new ActiveLearnerServerService_addAnnotations_args(params);
478
- try {
479
- output.writeMessageBegin('addAnnotations', Thrift.MessageType.CALL, this.seqid());
480
- args.write(output);
481
- output.writeMessageEnd();
482
- return this.output.flush();
483
- }
484
- catch (e) {
485
- delete this._reqs[this.seqid()];
486
- if (typeof output.reset === 'function') {
487
- output.reset();
488
- }
489
- throw e;
490
- }
491
- }
492
-
493
- recv_addAnnotations (input, mtype, rseqid) {
494
- const callback = this._reqs[rseqid] || function() {};
495
- delete this._reqs[rseqid];
496
- if (mtype == Thrift.MessageType.EXCEPTION) {
497
- const x = new Thrift.TApplicationException();
498
- x.read(input);
499
- input.readMessageEnd();
500
- return callback(x);
501
- }
502
- const result = new ActiveLearnerServerService_addAnnotations_result();
503
- result.read(input);
504
- input.readMessageEnd();
505
-
506
- callback(null);
507
- }
508
- };
509
- const ActiveLearnerServerServiceProcessor = exports.Processor = class ActiveLearnerServerServiceProcessor extends ServiceProcessor {
510
- constructor(handler) {
511
- super(handler);
512
- this._handler = handler;
513
- }
514
- process (input, output) {
515
- const r = input.readMessageBegin();
516
- if (this['process_' + r.fname]) {
517
- return this['process_' + r.fname].call(this, r.rseqid, input, output);
518
- } else {
519
- input.skip(Thrift.Type.STRUCT);
520
- input.readMessageEnd();
521
- const x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname);
522
- output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid);
523
- x.write(output);
524
- output.writeMessageEnd();
525
- output.flush();
526
- }
527
- }
528
- process_start (seqid, input, output) {
529
- const args = new ActiveLearnerServerService_start_args();
530
- args.read(input);
531
- input.readMessageEnd();
532
- if (this._handler.start.length === 3) {
533
- Promise.resolve(this._handler.start.bind(this._handler)(
534
- args.sessionId,
535
- args.task,
536
- args.contact
537
- )).then(result => {
538
- const result_obj = new ActiveLearnerServerService_start_result({success: result});
539
- output.writeMessageBegin("start", Thrift.MessageType.REPLY, seqid);
540
- result_obj.write(output);
541
- output.writeMessageEnd();
542
- output.flush();
543
- }).catch(err => {
544
- let result;
545
- result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
546
- output.writeMessageBegin("start", Thrift.MessageType.EXCEPTION, seqid);
547
- result.write(output);
548
- output.writeMessageEnd();
549
- output.flush();
550
- });
551
- } else {
552
- this._handler.start(args.sessionId, args.task, args.contact, (err, result) => {
553
- let result_obj;
554
- if ((err === null || typeof err === 'undefined')) {
555
- result_obj = new ActiveLearnerServerService_start_result((err !== null || typeof err === 'undefined') ? err : {success: result});
556
- output.writeMessageBegin("start", Thrift.MessageType.REPLY, seqid);
557
- } else {
558
- result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
559
- output.writeMessageBegin("start", Thrift.MessageType.EXCEPTION, seqid);
560
- }
561
- result_obj.write(output);
562
- output.writeMessageEnd();
563
- output.flush();
564
- });
565
- }
566
- }
567
- process_stop (seqid, input, output) {
568
- const args = new ActiveLearnerServerService_stop_args();
569
- args.read(input);
570
- input.readMessageEnd();
571
- if (this._handler.stop.length === 1) {
572
- Promise.resolve(this._handler.stop.bind(this._handler)(
573
- args.sessionId
574
- )).then(result => {
575
- const result_obj = new ActiveLearnerServerService_stop_result({success: result});
576
- output.writeMessageBegin("stop", Thrift.MessageType.REPLY, seqid);
577
- result_obj.write(output);
578
- output.writeMessageEnd();
579
- output.flush();
580
- }).catch(err => {
581
- let result;
582
- result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
583
- output.writeMessageBegin("stop", Thrift.MessageType.EXCEPTION, seqid);
584
- result.write(output);
585
- output.writeMessageEnd();
586
- output.flush();
587
- });
588
- } else {
589
- this._handler.stop(args.sessionId, (err, result) => {
590
- let result_obj;
591
- if ((err === null || typeof err === 'undefined')) {
592
- result_obj = new ActiveLearnerServerService_stop_result((err !== null || typeof err === 'undefined') ? err : {success: result});
593
- output.writeMessageBegin("stop", Thrift.MessageType.REPLY, seqid);
594
- } else {
595
- result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
596
- output.writeMessageBegin("stop", Thrift.MessageType.EXCEPTION, seqid);
597
- }
598
- result_obj.write(output);
599
- output.writeMessageEnd();
600
- output.flush();
601
- });
602
- }
603
- }
604
- process_addAnnotations (seqid, input, output) {
605
- const args = new ActiveLearnerServerService_addAnnotations_args();
606
- args.read(input);
607
- input.readMessageEnd();
608
- if (this._handler.addAnnotations.length === 2) {
609
- Promise.resolve(this._handler.addAnnotations.bind(this._handler)(
610
- args.sessionId,
611
- args.annotations
612
- )).then(result => {
613
- const result_obj = new ActiveLearnerServerService_addAnnotations_result({success: result});
614
- output.writeMessageBegin("addAnnotations", Thrift.MessageType.REPLY, seqid);
615
- result_obj.write(output);
616
- output.writeMessageEnd();
617
- output.flush();
618
- }).catch(err => {
619
- let result;
620
- result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
621
- output.writeMessageBegin("addAnnotations", Thrift.MessageType.EXCEPTION, seqid);
622
- result.write(output);
623
- output.writeMessageEnd();
624
- output.flush();
625
- });
626
- } else {
627
- this._handler.addAnnotations(args.sessionId, args.annotations, (err, result) => {
628
- let result_obj;
629
- if ((err === null || typeof err === 'undefined')) {
630
- result_obj = new ActiveLearnerServerService_addAnnotations_result((err !== null || typeof err === 'undefined') ? err : {success: result});
631
- output.writeMessageBegin("addAnnotations", Thrift.MessageType.REPLY, seqid);
632
- } else {
633
- result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
634
- output.writeMessageBegin("addAnnotations", Thrift.MessageType.EXCEPTION, seqid);
635
- }
636
- result_obj.write(output);
637
- output.writeMessageEnd();
638
- output.flush();
639
- });
640
- }
641
- }
642
- };
1
+ //
2
+ // Autogenerated by Thrift Compiler (0.15.0)
3
+ //
4
+ // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ //
6
+ "use strict";
7
+
8
+ const thrift = require('thrift');
9
+ const Thrift = thrift.Thrift;
10
+ const Int64 = require('node-int64');
11
+
12
+ const services_ttypes = require('./services_types');
13
+ const uuid_ttypes = require('./uuid_types');
14
+ const communication_ttypes = require('./communication_types');
15
+
16
+
17
+ const Service = require('./Service');
18
+ const ServiceClient = Service.Client;
19
+ const ServiceProcessor = Service.Processor;
20
+ const ttypes = require('./learn_types');
21
+ //HELPER FUNCTIONS AND STRUCTURES
22
+
23
+ const ActiveLearnerServerService_start_args = class {
24
+ constructor(args) {
25
+ this.sessionId = null;
26
+ this.task = null;
27
+ this.contact = null;
28
+ if (args) {
29
+ if (args.sessionId !== undefined && args.sessionId !== null) {
30
+ this.sessionId = new uuid_ttypes.UUID(args.sessionId);
31
+ }
32
+ if (args.task !== undefined && args.task !== null) {
33
+ this.task = new ttypes.AnnotationTask(args.task);
34
+ }
35
+ if (args.contact !== undefined && args.contact !== null) {
36
+ this.contact = new services_ttypes.AsyncContactInfo(args.contact);
37
+ }
38
+ }
39
+ }
40
+
41
+ read (input) {
42
+ input.readStructBegin();
43
+ while (true) {
44
+ const ret = input.readFieldBegin();
45
+ const ftype = ret.ftype;
46
+ const fid = ret.fid;
47
+ if (ftype == Thrift.Type.STOP) {
48
+ break;
49
+ }
50
+ switch (fid) {
51
+ case 1:
52
+ if (ftype == Thrift.Type.STRUCT) {
53
+ this.sessionId = new uuid_ttypes.UUID();
54
+ this.sessionId.read(input);
55
+ } else {
56
+ input.skip(ftype);
57
+ }
58
+ break;
59
+ case 2:
60
+ if (ftype == Thrift.Type.STRUCT) {
61
+ this.task = new ttypes.AnnotationTask();
62
+ this.task.read(input);
63
+ } else {
64
+ input.skip(ftype);
65
+ }
66
+ break;
67
+ case 3:
68
+ if (ftype == Thrift.Type.STRUCT) {
69
+ this.contact = new services_ttypes.AsyncContactInfo();
70
+ this.contact.read(input);
71
+ } else {
72
+ input.skip(ftype);
73
+ }
74
+ break;
75
+ default:
76
+ input.skip(ftype);
77
+ }
78
+ input.readFieldEnd();
79
+ }
80
+ input.readStructEnd();
81
+ return;
82
+ }
83
+
84
+ write (output) {
85
+ output.writeStructBegin('ActiveLearnerServerService_start_args');
86
+ if (this.sessionId !== null && this.sessionId !== undefined) {
87
+ output.writeFieldBegin('sessionId', Thrift.Type.STRUCT, 1);
88
+ this.sessionId.write(output);
89
+ output.writeFieldEnd();
90
+ }
91
+ if (this.task !== null && this.task !== undefined) {
92
+ output.writeFieldBegin('task', Thrift.Type.STRUCT, 2);
93
+ this.task.write(output);
94
+ output.writeFieldEnd();
95
+ }
96
+ if (this.contact !== null && this.contact !== undefined) {
97
+ output.writeFieldBegin('contact', Thrift.Type.STRUCT, 3);
98
+ this.contact.write(output);
99
+ output.writeFieldEnd();
100
+ }
101
+ output.writeFieldStop();
102
+ output.writeStructEnd();
103
+ return;
104
+ }
105
+
106
+ };
107
+ const ActiveLearnerServerService_start_result = class {
108
+ constructor(args) {
109
+ this.success = null;
110
+ if (args) {
111
+ if (args.success !== undefined && args.success !== null) {
112
+ this.success = args.success;
113
+ }
114
+ }
115
+ }
116
+
117
+ read (input) {
118
+ input.readStructBegin();
119
+ while (true) {
120
+ const ret = input.readFieldBegin();
121
+ const ftype = ret.ftype;
122
+ const fid = ret.fid;
123
+ if (ftype == Thrift.Type.STOP) {
124
+ break;
125
+ }
126
+ switch (fid) {
127
+ case 0:
128
+ if (ftype == Thrift.Type.BOOL) {
129
+ this.success = input.readBool();
130
+ } else {
131
+ input.skip(ftype);
132
+ }
133
+ break;
134
+ case 0:
135
+ input.skip(ftype);
136
+ break;
137
+ default:
138
+ input.skip(ftype);
139
+ }
140
+ input.readFieldEnd();
141
+ }
142
+ input.readStructEnd();
143
+ return;
144
+ }
145
+
146
+ write (output) {
147
+ output.writeStructBegin('ActiveLearnerServerService_start_result');
148
+ if (this.success !== null && this.success !== undefined) {
149
+ output.writeFieldBegin('success', Thrift.Type.BOOL, 0);
150
+ output.writeBool(this.success);
151
+ output.writeFieldEnd();
152
+ }
153
+ output.writeFieldStop();
154
+ output.writeStructEnd();
155
+ return;
156
+ }
157
+
158
+ };
159
+ const ActiveLearnerServerService_stop_args = class {
160
+ constructor(args) {
161
+ this.sessionId = null;
162
+ if (args) {
163
+ if (args.sessionId !== undefined && args.sessionId !== null) {
164
+ this.sessionId = new uuid_ttypes.UUID(args.sessionId);
165
+ }
166
+ }
167
+ }
168
+
169
+ read (input) {
170
+ input.readStructBegin();
171
+ while (true) {
172
+ const ret = input.readFieldBegin();
173
+ const ftype = ret.ftype;
174
+ const fid = ret.fid;
175
+ if (ftype == Thrift.Type.STOP) {
176
+ break;
177
+ }
178
+ switch (fid) {
179
+ case 1:
180
+ if (ftype == Thrift.Type.STRUCT) {
181
+ this.sessionId = new uuid_ttypes.UUID();
182
+ this.sessionId.read(input);
183
+ } else {
184
+ input.skip(ftype);
185
+ }
186
+ break;
187
+ case 0:
188
+ input.skip(ftype);
189
+ break;
190
+ default:
191
+ input.skip(ftype);
192
+ }
193
+ input.readFieldEnd();
194
+ }
195
+ input.readStructEnd();
196
+ return;
197
+ }
198
+
199
+ write (output) {
200
+ output.writeStructBegin('ActiveLearnerServerService_stop_args');
201
+ if (this.sessionId !== null && this.sessionId !== undefined) {
202
+ output.writeFieldBegin('sessionId', Thrift.Type.STRUCT, 1);
203
+ this.sessionId.write(output);
204
+ output.writeFieldEnd();
205
+ }
206
+ output.writeFieldStop();
207
+ output.writeStructEnd();
208
+ return;
209
+ }
210
+
211
+ };
212
+ const ActiveLearnerServerService_stop_result = class {
213
+ constructor(args) {
214
+ }
215
+
216
+ read (input) {
217
+ input.readStructBegin();
218
+ while (true) {
219
+ const ret = input.readFieldBegin();
220
+ const ftype = ret.ftype;
221
+ if (ftype == Thrift.Type.STOP) {
222
+ break;
223
+ }
224
+ input.skip(ftype);
225
+ input.readFieldEnd();
226
+ }
227
+ input.readStructEnd();
228
+ return;
229
+ }
230
+
231
+ write (output) {
232
+ output.writeStructBegin('ActiveLearnerServerService_stop_result');
233
+ output.writeFieldStop();
234
+ output.writeStructEnd();
235
+ return;
236
+ }
237
+
238
+ };
239
+ const ActiveLearnerServerService_addAnnotations_args = class {
240
+ constructor(args) {
241
+ this.sessionId = null;
242
+ this.annotations = null;
243
+ if (args) {
244
+ if (args.sessionId !== undefined && args.sessionId !== null) {
245
+ this.sessionId = new uuid_ttypes.UUID(args.sessionId);
246
+ }
247
+ if (args.annotations !== undefined && args.annotations !== null) {
248
+ this.annotations = Thrift.copyList(args.annotations, [ttypes.Annotation]);
249
+ }
250
+ }
251
+ }
252
+
253
+ read (input) {
254
+ input.readStructBegin();
255
+ while (true) {
256
+ const ret = input.readFieldBegin();
257
+ const ftype = ret.ftype;
258
+ const fid = ret.fid;
259
+ if (ftype == Thrift.Type.STOP) {
260
+ break;
261
+ }
262
+ switch (fid) {
263
+ case 1:
264
+ if (ftype == Thrift.Type.STRUCT) {
265
+ this.sessionId = new uuid_ttypes.UUID();
266
+ this.sessionId.read(input);
267
+ } else {
268
+ input.skip(ftype);
269
+ }
270
+ break;
271
+ case 2:
272
+ if (ftype == Thrift.Type.LIST) {
273
+ this.annotations = [];
274
+ const _rtmp36 = input.readListBegin();
275
+ const _size5 = _rtmp36.size || 0;
276
+ for (let _i7 = 0; _i7 < _size5; ++_i7) {
277
+ let elem8 = null;
278
+ elem8 = new ttypes.Annotation();
279
+ elem8.read(input);
280
+ this.annotations.push(elem8);
281
+ }
282
+ input.readListEnd();
283
+ } else {
284
+ input.skip(ftype);
285
+ }
286
+ break;
287
+ default:
288
+ input.skip(ftype);
289
+ }
290
+ input.readFieldEnd();
291
+ }
292
+ input.readStructEnd();
293
+ return;
294
+ }
295
+
296
+ write (output) {
297
+ output.writeStructBegin('ActiveLearnerServerService_addAnnotations_args');
298
+ if (this.sessionId !== null && this.sessionId !== undefined) {
299
+ output.writeFieldBegin('sessionId', Thrift.Type.STRUCT, 1);
300
+ this.sessionId.write(output);
301
+ output.writeFieldEnd();
302
+ }
303
+ if (this.annotations !== null && this.annotations !== undefined) {
304
+ output.writeFieldBegin('annotations', Thrift.Type.LIST, 2);
305
+ output.writeListBegin(Thrift.Type.STRUCT, this.annotations.length);
306
+ for (let iter9 in this.annotations) {
307
+ if (this.annotations.hasOwnProperty(iter9)) {
308
+ iter9 = this.annotations[iter9];
309
+ iter9.write(output);
310
+ }
311
+ }
312
+ output.writeListEnd();
313
+ output.writeFieldEnd();
314
+ }
315
+ output.writeFieldStop();
316
+ output.writeStructEnd();
317
+ return;
318
+ }
319
+
320
+ };
321
+ const ActiveLearnerServerService_addAnnotations_result = class {
322
+ constructor(args) {
323
+ }
324
+
325
+ read (input) {
326
+ input.readStructBegin();
327
+ while (true) {
328
+ const ret = input.readFieldBegin();
329
+ const ftype = ret.ftype;
330
+ if (ftype == Thrift.Type.STOP) {
331
+ break;
332
+ }
333
+ input.skip(ftype);
334
+ input.readFieldEnd();
335
+ }
336
+ input.readStructEnd();
337
+ return;
338
+ }
339
+
340
+ write (output) {
341
+ output.writeStructBegin('ActiveLearnerServerService_addAnnotations_result');
342
+ output.writeFieldStop();
343
+ output.writeStructEnd();
344
+ return;
345
+ }
346
+
347
+ };
348
+ const ActiveLearnerServerServiceClient = exports.Client = class ActiveLearnerServerServiceClient extends ServiceClient {
349
+ constructor(output, pClass) {
350
+ super(output, pClass);
351
+ this.output = output;
352
+ this.pClass = pClass;
353
+ this._seqid = 0;
354
+ this._reqs = {};
355
+ }
356
+ seqid () { return this._seqid; }
357
+ new_seqid () { return this._seqid += 1; }
358
+
359
+ start (sessionId, task, contact) {
360
+ this._seqid = this.new_seqid();
361
+ const self = this;
362
+ return new Promise((resolve, reject) => {
363
+ self._reqs[self.seqid()] = (error, result) => {
364
+ return error ? reject(error) : resolve(result);
365
+ };
366
+ self.send_start(sessionId, task, contact);
367
+ });
368
+ }
369
+
370
+ send_start (sessionId, task, contact) {
371
+ const output = new this.pClass(this.output);
372
+ const params = {
373
+ sessionId: sessionId,
374
+ task: task,
375
+ contact: contact
376
+ };
377
+ const args = new ActiveLearnerServerService_start_args(params);
378
+ try {
379
+ output.writeMessageBegin('start', Thrift.MessageType.CALL, this.seqid());
380
+ args.write(output);
381
+ output.writeMessageEnd();
382
+ return this.output.flush();
383
+ }
384
+ catch (e) {
385
+ delete this._reqs[this.seqid()];
386
+ if (typeof output.reset === 'function') {
387
+ output.reset();
388
+ }
389
+ throw e;
390
+ }
391
+ }
392
+
393
+ recv_start (input, mtype, rseqid) {
394
+ const callback = this._reqs[rseqid] || function() {};
395
+ delete this._reqs[rseqid];
396
+ if (mtype == Thrift.MessageType.EXCEPTION) {
397
+ const x = new Thrift.TApplicationException();
398
+ x.read(input);
399
+ input.readMessageEnd();
400
+ return callback(x);
401
+ }
402
+ const result = new ActiveLearnerServerService_start_result();
403
+ result.read(input);
404
+ input.readMessageEnd();
405
+
406
+ if (null !== result.success) {
407
+ return callback(null, result.success);
408
+ }
409
+ return callback('start failed: unknown result');
410
+ }
411
+
412
+ stop (sessionId) {
413
+ this._seqid = this.new_seqid();
414
+ const self = this;
415
+ return new Promise((resolve, reject) => {
416
+ self._reqs[self.seqid()] = (error, result) => {
417
+ return error ? reject(error) : resolve(result);
418
+ };
419
+ self.send_stop(sessionId);
420
+ });
421
+ }
422
+
423
+ send_stop (sessionId) {
424
+ const output = new this.pClass(this.output);
425
+ const params = {
426
+ sessionId: sessionId
427
+ };
428
+ const args = new ActiveLearnerServerService_stop_args(params);
429
+ try {
430
+ output.writeMessageBegin('stop', Thrift.MessageType.CALL, this.seqid());
431
+ args.write(output);
432
+ output.writeMessageEnd();
433
+ return this.output.flush();
434
+ }
435
+ catch (e) {
436
+ delete this._reqs[this.seqid()];
437
+ if (typeof output.reset === 'function') {
438
+ output.reset();
439
+ }
440
+ throw e;
441
+ }
442
+ }
443
+
444
+ recv_stop (input, mtype, rseqid) {
445
+ const callback = this._reqs[rseqid] || function() {};
446
+ delete this._reqs[rseqid];
447
+ if (mtype == Thrift.MessageType.EXCEPTION) {
448
+ const x = new Thrift.TApplicationException();
449
+ x.read(input);
450
+ input.readMessageEnd();
451
+ return callback(x);
452
+ }
453
+ const result = new ActiveLearnerServerService_stop_result();
454
+ result.read(input);
455
+ input.readMessageEnd();
456
+
457
+ callback(null);
458
+ }
459
+
460
+ addAnnotations (sessionId, annotations) {
461
+ this._seqid = this.new_seqid();
462
+ const self = this;
463
+ return new Promise((resolve, reject) => {
464
+ self._reqs[self.seqid()] = (error, result) => {
465
+ return error ? reject(error) : resolve(result);
466
+ };
467
+ self.send_addAnnotations(sessionId, annotations);
468
+ });
469
+ }
470
+
471
+ send_addAnnotations (sessionId, annotations) {
472
+ const output = new this.pClass(this.output);
473
+ const params = {
474
+ sessionId: sessionId,
475
+ annotations: annotations
476
+ };
477
+ const args = new ActiveLearnerServerService_addAnnotations_args(params);
478
+ try {
479
+ output.writeMessageBegin('addAnnotations', Thrift.MessageType.CALL, this.seqid());
480
+ args.write(output);
481
+ output.writeMessageEnd();
482
+ return this.output.flush();
483
+ }
484
+ catch (e) {
485
+ delete this._reqs[this.seqid()];
486
+ if (typeof output.reset === 'function') {
487
+ output.reset();
488
+ }
489
+ throw e;
490
+ }
491
+ }
492
+
493
+ recv_addAnnotations (input, mtype, rseqid) {
494
+ const callback = this._reqs[rseqid] || function() {};
495
+ delete this._reqs[rseqid];
496
+ if (mtype == Thrift.MessageType.EXCEPTION) {
497
+ const x = new Thrift.TApplicationException();
498
+ x.read(input);
499
+ input.readMessageEnd();
500
+ return callback(x);
501
+ }
502
+ const result = new ActiveLearnerServerService_addAnnotations_result();
503
+ result.read(input);
504
+ input.readMessageEnd();
505
+
506
+ callback(null);
507
+ }
508
+ };
509
+ const ActiveLearnerServerServiceProcessor = exports.Processor = class ActiveLearnerServerServiceProcessor extends ServiceProcessor {
510
+ constructor(handler) {
511
+ super(handler);
512
+ this._handler = handler;
513
+ }
514
+ process (input, output) {
515
+ const r = input.readMessageBegin();
516
+ if (this['process_' + r.fname]) {
517
+ return this['process_' + r.fname].call(this, r.rseqid, input, output);
518
+ } else {
519
+ input.skip(Thrift.Type.STRUCT);
520
+ input.readMessageEnd();
521
+ const x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname);
522
+ output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid);
523
+ x.write(output);
524
+ output.writeMessageEnd();
525
+ output.flush();
526
+ }
527
+ }
528
+ process_start (seqid, input, output) {
529
+ const args = new ActiveLearnerServerService_start_args();
530
+ args.read(input);
531
+ input.readMessageEnd();
532
+ if (this._handler.start.length === 3) {
533
+ Promise.resolve(this._handler.start.bind(this._handler)(
534
+ args.sessionId,
535
+ args.task,
536
+ args.contact
537
+ )).then(result => {
538
+ const result_obj = new ActiveLearnerServerService_start_result({success: result});
539
+ output.writeMessageBegin("start", Thrift.MessageType.REPLY, seqid);
540
+ result_obj.write(output);
541
+ output.writeMessageEnd();
542
+ output.flush();
543
+ }).catch(err => {
544
+ let result;
545
+ result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
546
+ output.writeMessageBegin("start", Thrift.MessageType.EXCEPTION, seqid);
547
+ result.write(output);
548
+ output.writeMessageEnd();
549
+ output.flush();
550
+ });
551
+ } else {
552
+ this._handler.start(args.sessionId, args.task, args.contact, (err, result) => {
553
+ let result_obj;
554
+ if ((err === null || typeof err === 'undefined')) {
555
+ result_obj = new ActiveLearnerServerService_start_result((err !== null || typeof err === 'undefined') ? err : {success: result});
556
+ output.writeMessageBegin("start", Thrift.MessageType.REPLY, seqid);
557
+ } else {
558
+ result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
559
+ output.writeMessageBegin("start", Thrift.MessageType.EXCEPTION, seqid);
560
+ }
561
+ result_obj.write(output);
562
+ output.writeMessageEnd();
563
+ output.flush();
564
+ });
565
+ }
566
+ }
567
+ process_stop (seqid, input, output) {
568
+ const args = new ActiveLearnerServerService_stop_args();
569
+ args.read(input);
570
+ input.readMessageEnd();
571
+ if (this._handler.stop.length === 1) {
572
+ Promise.resolve(this._handler.stop.bind(this._handler)(
573
+ args.sessionId
574
+ )).then(result => {
575
+ const result_obj = new ActiveLearnerServerService_stop_result({success: result});
576
+ output.writeMessageBegin("stop", Thrift.MessageType.REPLY, seqid);
577
+ result_obj.write(output);
578
+ output.writeMessageEnd();
579
+ output.flush();
580
+ }).catch(err => {
581
+ let result;
582
+ result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
583
+ output.writeMessageBegin("stop", Thrift.MessageType.EXCEPTION, seqid);
584
+ result.write(output);
585
+ output.writeMessageEnd();
586
+ output.flush();
587
+ });
588
+ } else {
589
+ this._handler.stop(args.sessionId, (err, result) => {
590
+ let result_obj;
591
+ if ((err === null || typeof err === 'undefined')) {
592
+ result_obj = new ActiveLearnerServerService_stop_result((err !== null || typeof err === 'undefined') ? err : {success: result});
593
+ output.writeMessageBegin("stop", Thrift.MessageType.REPLY, seqid);
594
+ } else {
595
+ result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
596
+ output.writeMessageBegin("stop", Thrift.MessageType.EXCEPTION, seqid);
597
+ }
598
+ result_obj.write(output);
599
+ output.writeMessageEnd();
600
+ output.flush();
601
+ });
602
+ }
603
+ }
604
+ process_addAnnotations (seqid, input, output) {
605
+ const args = new ActiveLearnerServerService_addAnnotations_args();
606
+ args.read(input);
607
+ input.readMessageEnd();
608
+ if (this._handler.addAnnotations.length === 2) {
609
+ Promise.resolve(this._handler.addAnnotations.bind(this._handler)(
610
+ args.sessionId,
611
+ args.annotations
612
+ )).then(result => {
613
+ const result_obj = new ActiveLearnerServerService_addAnnotations_result({success: result});
614
+ output.writeMessageBegin("addAnnotations", Thrift.MessageType.REPLY, seqid);
615
+ result_obj.write(output);
616
+ output.writeMessageEnd();
617
+ output.flush();
618
+ }).catch(err => {
619
+ let result;
620
+ result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
621
+ output.writeMessageBegin("addAnnotations", Thrift.MessageType.EXCEPTION, seqid);
622
+ result.write(output);
623
+ output.writeMessageEnd();
624
+ output.flush();
625
+ });
626
+ } else {
627
+ this._handler.addAnnotations(args.sessionId, args.annotations, (err, result) => {
628
+ let result_obj;
629
+ if ((err === null || typeof err === 'undefined')) {
630
+ result_obj = new ActiveLearnerServerService_addAnnotations_result((err !== null || typeof err === 'undefined') ? err : {success: result});
631
+ output.writeMessageBegin("addAnnotations", Thrift.MessageType.REPLY, seqid);
632
+ } else {
633
+ result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
634
+ output.writeMessageBegin("addAnnotations", Thrift.MessageType.EXCEPTION, seqid);
635
+ }
636
+ result_obj.write(output);
637
+ output.writeMessageEnd();
638
+ output.flush();
639
+ });
640
+ }
641
+ }
642
+ };