@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,962 +1,962 @@
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 communication_ttypes = require('./communication_types');
13
- const services_ttypes = require('./services_types');
14
- const structure_ttypes = require('./structure_types');
15
- const uuid_ttypes = require('./uuid_types');
16
- const metadata_ttypes = require('./metadata_types');
17
- const entities_ttypes = require('./entities_types');
18
-
19
-
20
- const Service = require('./Service');
21
- const ServiceClient = Service.Client;
22
- const ServiceProcessor = Service.Processor;
23
- const ttypes = require('./search_types');
24
- //HELPER FUNCTIONS AND STRUCTURES
25
-
26
- const SearchProxyService_search_args = class {
27
- constructor(args) {
28
- this.query = null;
29
- this.provider = null;
30
- if (args) {
31
- if (args.query !== undefined && args.query !== null) {
32
- this.query = new ttypes.SearchQuery(args.query);
33
- }
34
- if (args.provider !== undefined && args.provider !== null) {
35
- this.provider = args.provider;
36
- }
37
- }
38
- }
39
-
40
- read (input) {
41
- input.readStructBegin();
42
- while (true) {
43
- const ret = input.readFieldBegin();
44
- const ftype = ret.ftype;
45
- const fid = ret.fid;
46
- if (ftype == Thrift.Type.STOP) {
47
- break;
48
- }
49
- switch (fid) {
50
- case 1:
51
- if (ftype == Thrift.Type.STRUCT) {
52
- this.query = new ttypes.SearchQuery();
53
- this.query.read(input);
54
- } else {
55
- input.skip(ftype);
56
- }
57
- break;
58
- case 2:
59
- if (ftype == Thrift.Type.STRING) {
60
- this.provider = input.readString();
61
- } else {
62
- input.skip(ftype);
63
- }
64
- break;
65
- default:
66
- input.skip(ftype);
67
- }
68
- input.readFieldEnd();
69
- }
70
- input.readStructEnd();
71
- return;
72
- }
73
-
74
- write (output) {
75
- output.writeStructBegin('SearchProxyService_search_args');
76
- if (this.query !== null && this.query !== undefined) {
77
- output.writeFieldBegin('query', Thrift.Type.STRUCT, 1);
78
- this.query.write(output);
79
- output.writeFieldEnd();
80
- }
81
- if (this.provider !== null && this.provider !== undefined) {
82
- output.writeFieldBegin('provider', Thrift.Type.STRING, 2);
83
- output.writeString(this.provider);
84
- output.writeFieldEnd();
85
- }
86
- output.writeFieldStop();
87
- output.writeStructEnd();
88
- return;
89
- }
90
-
91
- };
92
- const SearchProxyService_search_result = class {
93
- constructor(args) {
94
- this.success = null;
95
- this.ex = null;
96
- if (args instanceof services_ttypes.ServicesException) {
97
- this.ex = args;
98
- return;
99
- }
100
- if (args) {
101
- if (args.success !== undefined && args.success !== null) {
102
- this.success = new ttypes.SearchResult(args.success);
103
- }
104
- if (args.ex !== undefined && args.ex !== null) {
105
- this.ex = args.ex;
106
- }
107
- }
108
- }
109
-
110
- read (input) {
111
- input.readStructBegin();
112
- while (true) {
113
- const ret = input.readFieldBegin();
114
- const ftype = ret.ftype;
115
- const fid = ret.fid;
116
- if (ftype == Thrift.Type.STOP) {
117
- break;
118
- }
119
- switch (fid) {
120
- case 0:
121
- if (ftype == Thrift.Type.STRUCT) {
122
- this.success = new ttypes.SearchResult();
123
- this.success.read(input);
124
- } else {
125
- input.skip(ftype);
126
- }
127
- break;
128
- case 1:
129
- if (ftype == Thrift.Type.STRUCT) {
130
- this.ex = new services_ttypes.ServicesException();
131
- this.ex.read(input);
132
- } else {
133
- input.skip(ftype);
134
- }
135
- break;
136
- default:
137
- input.skip(ftype);
138
- }
139
- input.readFieldEnd();
140
- }
141
- input.readStructEnd();
142
- return;
143
- }
144
-
145
- write (output) {
146
- output.writeStructBegin('SearchProxyService_search_result');
147
- if (this.success !== null && this.success !== undefined) {
148
- output.writeFieldBegin('success', Thrift.Type.STRUCT, 0);
149
- this.success.write(output);
150
- output.writeFieldEnd();
151
- }
152
- if (this.ex !== null && this.ex !== undefined) {
153
- output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
154
- this.ex.write(output);
155
- output.writeFieldEnd();
156
- }
157
- output.writeFieldStop();
158
- output.writeStructEnd();
159
- return;
160
- }
161
-
162
- };
163
- const SearchProxyService_getProviders_args = class {
164
- constructor(args) {
165
- }
166
-
167
- read (input) {
168
- input.readStructBegin();
169
- while (true) {
170
- const ret = input.readFieldBegin();
171
- const ftype = ret.ftype;
172
- if (ftype == Thrift.Type.STOP) {
173
- break;
174
- }
175
- input.skip(ftype);
176
- input.readFieldEnd();
177
- }
178
- input.readStructEnd();
179
- return;
180
- }
181
-
182
- write (output) {
183
- output.writeStructBegin('SearchProxyService_getProviders_args');
184
- output.writeFieldStop();
185
- output.writeStructEnd();
186
- return;
187
- }
188
-
189
- };
190
- const SearchProxyService_getProviders_result = class {
191
- constructor(args) {
192
- this.success = null;
193
- this.ex = null;
194
- if (args instanceof services_ttypes.ServicesException) {
195
- this.ex = args;
196
- return;
197
- }
198
- if (args) {
199
- if (args.success !== undefined && args.success !== null) {
200
- this.success = Thrift.copyList(args.success, [null]);
201
- }
202
- if (args.ex !== undefined && args.ex !== null) {
203
- this.ex = args.ex;
204
- }
205
- }
206
- }
207
-
208
- read (input) {
209
- input.readStructBegin();
210
- while (true) {
211
- const ret = input.readFieldBegin();
212
- const ftype = ret.ftype;
213
- const fid = ret.fid;
214
- if (ftype == Thrift.Type.STOP) {
215
- break;
216
- }
217
- switch (fid) {
218
- case 0:
219
- if (ftype == Thrift.Type.LIST) {
220
- this.success = [];
221
- const _rtmp331 = input.readListBegin();
222
- const _size30 = _rtmp331.size || 0;
223
- for (let _i32 = 0; _i32 < _size30; ++_i32) {
224
- let elem33 = null;
225
- elem33 = input.readString();
226
- this.success.push(elem33);
227
- }
228
- input.readListEnd();
229
- } else {
230
- input.skip(ftype);
231
- }
232
- break;
233
- case 1:
234
- if (ftype == Thrift.Type.STRUCT) {
235
- this.ex = new services_ttypes.ServicesException();
236
- this.ex.read(input);
237
- } else {
238
- input.skip(ftype);
239
- }
240
- break;
241
- default:
242
- input.skip(ftype);
243
- }
244
- input.readFieldEnd();
245
- }
246
- input.readStructEnd();
247
- return;
248
- }
249
-
250
- write (output) {
251
- output.writeStructBegin('SearchProxyService_getProviders_result');
252
- if (this.success !== null && this.success !== undefined) {
253
- output.writeFieldBegin('success', Thrift.Type.LIST, 0);
254
- output.writeListBegin(Thrift.Type.STRING, this.success.length);
255
- for (let iter34 in this.success) {
256
- if (this.success.hasOwnProperty(iter34)) {
257
- iter34 = this.success[iter34];
258
- output.writeString(iter34);
259
- }
260
- }
261
- output.writeListEnd();
262
- output.writeFieldEnd();
263
- }
264
- if (this.ex !== null && this.ex !== undefined) {
265
- output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
266
- this.ex.write(output);
267
- output.writeFieldEnd();
268
- }
269
- output.writeFieldStop();
270
- output.writeStructEnd();
271
- return;
272
- }
273
-
274
- };
275
- const SearchProxyService_getCapabilities_args = class {
276
- constructor(args) {
277
- this.provider = null;
278
- if (args) {
279
- if (args.provider !== undefined && args.provider !== null) {
280
- this.provider = args.provider;
281
- }
282
- }
283
- }
284
-
285
- read (input) {
286
- input.readStructBegin();
287
- while (true) {
288
- const ret = input.readFieldBegin();
289
- const ftype = ret.ftype;
290
- const fid = ret.fid;
291
- if (ftype == Thrift.Type.STOP) {
292
- break;
293
- }
294
- switch (fid) {
295
- case 1:
296
- if (ftype == Thrift.Type.STRING) {
297
- this.provider = input.readString();
298
- } else {
299
- input.skip(ftype);
300
- }
301
- break;
302
- case 0:
303
- input.skip(ftype);
304
- break;
305
- default:
306
- input.skip(ftype);
307
- }
308
- input.readFieldEnd();
309
- }
310
- input.readStructEnd();
311
- return;
312
- }
313
-
314
- write (output) {
315
- output.writeStructBegin('SearchProxyService_getCapabilities_args');
316
- if (this.provider !== null && this.provider !== undefined) {
317
- output.writeFieldBegin('provider', Thrift.Type.STRING, 1);
318
- output.writeString(this.provider);
319
- output.writeFieldEnd();
320
- }
321
- output.writeFieldStop();
322
- output.writeStructEnd();
323
- return;
324
- }
325
-
326
- };
327
- const SearchProxyService_getCapabilities_result = class {
328
- constructor(args) {
329
- this.success = null;
330
- this.ex = null;
331
- if (args instanceof services_ttypes.ServicesException) {
332
- this.ex = args;
333
- return;
334
- }
335
- if (args) {
336
- if (args.success !== undefined && args.success !== null) {
337
- this.success = Thrift.copyList(args.success, [ttypes.SearchCapability]);
338
- }
339
- if (args.ex !== undefined && args.ex !== null) {
340
- this.ex = args.ex;
341
- }
342
- }
343
- }
344
-
345
- read (input) {
346
- input.readStructBegin();
347
- while (true) {
348
- const ret = input.readFieldBegin();
349
- const ftype = ret.ftype;
350
- const fid = ret.fid;
351
- if (ftype == Thrift.Type.STOP) {
352
- break;
353
- }
354
- switch (fid) {
355
- case 0:
356
- if (ftype == Thrift.Type.LIST) {
357
- this.success = [];
358
- const _rtmp336 = input.readListBegin();
359
- const _size35 = _rtmp336.size || 0;
360
- for (let _i37 = 0; _i37 < _size35; ++_i37) {
361
- let elem38 = null;
362
- elem38 = new ttypes.SearchCapability();
363
- elem38.read(input);
364
- this.success.push(elem38);
365
- }
366
- input.readListEnd();
367
- } else {
368
- input.skip(ftype);
369
- }
370
- break;
371
- case 1:
372
- if (ftype == Thrift.Type.STRUCT) {
373
- this.ex = new services_ttypes.ServicesException();
374
- this.ex.read(input);
375
- } else {
376
- input.skip(ftype);
377
- }
378
- break;
379
- default:
380
- input.skip(ftype);
381
- }
382
- input.readFieldEnd();
383
- }
384
- input.readStructEnd();
385
- return;
386
- }
387
-
388
- write (output) {
389
- output.writeStructBegin('SearchProxyService_getCapabilities_result');
390
- if (this.success !== null && this.success !== undefined) {
391
- output.writeFieldBegin('success', Thrift.Type.LIST, 0);
392
- output.writeListBegin(Thrift.Type.STRUCT, this.success.length);
393
- for (let iter39 in this.success) {
394
- if (this.success.hasOwnProperty(iter39)) {
395
- iter39 = this.success[iter39];
396
- iter39.write(output);
397
- }
398
- }
399
- output.writeListEnd();
400
- output.writeFieldEnd();
401
- }
402
- if (this.ex !== null && this.ex !== undefined) {
403
- output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
404
- this.ex.write(output);
405
- output.writeFieldEnd();
406
- }
407
- output.writeFieldStop();
408
- output.writeStructEnd();
409
- return;
410
- }
411
-
412
- };
413
- const SearchProxyService_getCorpora_args = class {
414
- constructor(args) {
415
- this.provider = null;
416
- if (args) {
417
- if (args.provider !== undefined && args.provider !== null) {
418
- this.provider = args.provider;
419
- }
420
- }
421
- }
422
-
423
- read (input) {
424
- input.readStructBegin();
425
- while (true) {
426
- const ret = input.readFieldBegin();
427
- const ftype = ret.ftype;
428
- const fid = ret.fid;
429
- if (ftype == Thrift.Type.STOP) {
430
- break;
431
- }
432
- switch (fid) {
433
- case 1:
434
- if (ftype == Thrift.Type.STRING) {
435
- this.provider = input.readString();
436
- } else {
437
- input.skip(ftype);
438
- }
439
- break;
440
- case 0:
441
- input.skip(ftype);
442
- break;
443
- default:
444
- input.skip(ftype);
445
- }
446
- input.readFieldEnd();
447
- }
448
- input.readStructEnd();
449
- return;
450
- }
451
-
452
- write (output) {
453
- output.writeStructBegin('SearchProxyService_getCorpora_args');
454
- if (this.provider !== null && this.provider !== undefined) {
455
- output.writeFieldBegin('provider', Thrift.Type.STRING, 1);
456
- output.writeString(this.provider);
457
- output.writeFieldEnd();
458
- }
459
- output.writeFieldStop();
460
- output.writeStructEnd();
461
- return;
462
- }
463
-
464
- };
465
- const SearchProxyService_getCorpora_result = class {
466
- constructor(args) {
467
- this.success = null;
468
- this.ex = null;
469
- if (args instanceof services_ttypes.ServicesException) {
470
- this.ex = args;
471
- return;
472
- }
473
- if (args) {
474
- if (args.success !== undefined && args.success !== null) {
475
- this.success = Thrift.copyList(args.success, [null]);
476
- }
477
- if (args.ex !== undefined && args.ex !== null) {
478
- this.ex = args.ex;
479
- }
480
- }
481
- }
482
-
483
- read (input) {
484
- input.readStructBegin();
485
- while (true) {
486
- const ret = input.readFieldBegin();
487
- const ftype = ret.ftype;
488
- const fid = ret.fid;
489
- if (ftype == Thrift.Type.STOP) {
490
- break;
491
- }
492
- switch (fid) {
493
- case 0:
494
- if (ftype == Thrift.Type.LIST) {
495
- this.success = [];
496
- const _rtmp341 = input.readListBegin();
497
- const _size40 = _rtmp341.size || 0;
498
- for (let _i42 = 0; _i42 < _size40; ++_i42) {
499
- let elem43 = null;
500
- elem43 = input.readString();
501
- this.success.push(elem43);
502
- }
503
- input.readListEnd();
504
- } else {
505
- input.skip(ftype);
506
- }
507
- break;
508
- case 1:
509
- if (ftype == Thrift.Type.STRUCT) {
510
- this.ex = new services_ttypes.ServicesException();
511
- this.ex.read(input);
512
- } else {
513
- input.skip(ftype);
514
- }
515
- break;
516
- default:
517
- input.skip(ftype);
518
- }
519
- input.readFieldEnd();
520
- }
521
- input.readStructEnd();
522
- return;
523
- }
524
-
525
- write (output) {
526
- output.writeStructBegin('SearchProxyService_getCorpora_result');
527
- if (this.success !== null && this.success !== undefined) {
528
- output.writeFieldBegin('success', Thrift.Type.LIST, 0);
529
- output.writeListBegin(Thrift.Type.STRING, this.success.length);
530
- for (let iter44 in this.success) {
531
- if (this.success.hasOwnProperty(iter44)) {
532
- iter44 = this.success[iter44];
533
- output.writeString(iter44);
534
- }
535
- }
536
- output.writeListEnd();
537
- output.writeFieldEnd();
538
- }
539
- if (this.ex !== null && this.ex !== undefined) {
540
- output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
541
- this.ex.write(output);
542
- output.writeFieldEnd();
543
- }
544
- output.writeFieldStop();
545
- output.writeStructEnd();
546
- return;
547
- }
548
-
549
- };
550
- const SearchProxyServiceClient = exports.Client = class SearchProxyServiceClient extends ServiceClient {
551
- constructor(output, pClass) {
552
- super(output, pClass);
553
- this.output = output;
554
- this.pClass = pClass;
555
- this._seqid = 0;
556
- this._reqs = {};
557
- }
558
- seqid () { return this._seqid; }
559
- new_seqid () { return this._seqid += 1; }
560
-
561
- search (query, provider) {
562
- this._seqid = this.new_seqid();
563
- const self = this;
564
- return new Promise((resolve, reject) => {
565
- self._reqs[self.seqid()] = (error, result) => {
566
- return error ? reject(error) : resolve(result);
567
- };
568
- self.send_search(query, provider);
569
- });
570
- }
571
-
572
- send_search (query, provider) {
573
- const output = new this.pClass(this.output);
574
- const params = {
575
- query: query,
576
- provider: provider
577
- };
578
- const args = new SearchProxyService_search_args(params);
579
- try {
580
- output.writeMessageBegin('search', Thrift.MessageType.CALL, this.seqid());
581
- args.write(output);
582
- output.writeMessageEnd();
583
- return this.output.flush();
584
- }
585
- catch (e) {
586
- delete this._reqs[this.seqid()];
587
- if (typeof output.reset === 'function') {
588
- output.reset();
589
- }
590
- throw e;
591
- }
592
- }
593
-
594
- recv_search (input, mtype, rseqid) {
595
- const callback = this._reqs[rseqid] || function() {};
596
- delete this._reqs[rseqid];
597
- if (mtype == Thrift.MessageType.EXCEPTION) {
598
- const x = new Thrift.TApplicationException();
599
- x.read(input);
600
- input.readMessageEnd();
601
- return callback(x);
602
- }
603
- const result = new SearchProxyService_search_result();
604
- result.read(input);
605
- input.readMessageEnd();
606
-
607
- if (null !== result.ex) {
608
- return callback(result.ex);
609
- }
610
- if (null !== result.success) {
611
- return callback(null, result.success);
612
- }
613
- return callback('search failed: unknown result');
614
- }
615
-
616
- getProviders () {
617
- this._seqid = this.new_seqid();
618
- const self = this;
619
- return new Promise((resolve, reject) => {
620
- self._reqs[self.seqid()] = (error, result) => {
621
- return error ? reject(error) : resolve(result);
622
- };
623
- self.send_getProviders();
624
- });
625
- }
626
-
627
- send_getProviders () {
628
- const output = new this.pClass(this.output);
629
- const args = new SearchProxyService_getProviders_args();
630
- try {
631
- output.writeMessageBegin('getProviders', Thrift.MessageType.CALL, this.seqid());
632
- args.write(output);
633
- output.writeMessageEnd();
634
- return this.output.flush();
635
- }
636
- catch (e) {
637
- delete this._reqs[this.seqid()];
638
- if (typeof output.reset === 'function') {
639
- output.reset();
640
- }
641
- throw e;
642
- }
643
- }
644
-
645
- recv_getProviders (input, mtype, rseqid) {
646
- const callback = this._reqs[rseqid] || function() {};
647
- delete this._reqs[rseqid];
648
- if (mtype == Thrift.MessageType.EXCEPTION) {
649
- const x = new Thrift.TApplicationException();
650
- x.read(input);
651
- input.readMessageEnd();
652
- return callback(x);
653
- }
654
- const result = new SearchProxyService_getProviders_result();
655
- result.read(input);
656
- input.readMessageEnd();
657
-
658
- if (null !== result.ex) {
659
- return callback(result.ex);
660
- }
661
- if (null !== result.success) {
662
- return callback(null, result.success);
663
- }
664
- return callback('getProviders failed: unknown result');
665
- }
666
-
667
- getCapabilities (provider) {
668
- this._seqid = this.new_seqid();
669
- const self = this;
670
- return new Promise((resolve, reject) => {
671
- self._reqs[self.seqid()] = (error, result) => {
672
- return error ? reject(error) : resolve(result);
673
- };
674
- self.send_getCapabilities(provider);
675
- });
676
- }
677
-
678
- send_getCapabilities (provider) {
679
- const output = new this.pClass(this.output);
680
- const params = {
681
- provider: provider
682
- };
683
- const args = new SearchProxyService_getCapabilities_args(params);
684
- try {
685
- output.writeMessageBegin('getCapabilities', Thrift.MessageType.CALL, this.seqid());
686
- args.write(output);
687
- output.writeMessageEnd();
688
- return this.output.flush();
689
- }
690
- catch (e) {
691
- delete this._reqs[this.seqid()];
692
- if (typeof output.reset === 'function') {
693
- output.reset();
694
- }
695
- throw e;
696
- }
697
- }
698
-
699
- recv_getCapabilities (input, mtype, rseqid) {
700
- const callback = this._reqs[rseqid] || function() {};
701
- delete this._reqs[rseqid];
702
- if (mtype == Thrift.MessageType.EXCEPTION) {
703
- const x = new Thrift.TApplicationException();
704
- x.read(input);
705
- input.readMessageEnd();
706
- return callback(x);
707
- }
708
- const result = new SearchProxyService_getCapabilities_result();
709
- result.read(input);
710
- input.readMessageEnd();
711
-
712
- if (null !== result.ex) {
713
- return callback(result.ex);
714
- }
715
- if (null !== result.success) {
716
- return callback(null, result.success);
717
- }
718
- return callback('getCapabilities failed: unknown result');
719
- }
720
-
721
- getCorpora (provider) {
722
- this._seqid = this.new_seqid();
723
- const self = this;
724
- return new Promise((resolve, reject) => {
725
- self._reqs[self.seqid()] = (error, result) => {
726
- return error ? reject(error) : resolve(result);
727
- };
728
- self.send_getCorpora(provider);
729
- });
730
- }
731
-
732
- send_getCorpora (provider) {
733
- const output = new this.pClass(this.output);
734
- const params = {
735
- provider: provider
736
- };
737
- const args = new SearchProxyService_getCorpora_args(params);
738
- try {
739
- output.writeMessageBegin('getCorpora', Thrift.MessageType.CALL, this.seqid());
740
- args.write(output);
741
- output.writeMessageEnd();
742
- return this.output.flush();
743
- }
744
- catch (e) {
745
- delete this._reqs[this.seqid()];
746
- if (typeof output.reset === 'function') {
747
- output.reset();
748
- }
749
- throw e;
750
- }
751
- }
752
-
753
- recv_getCorpora (input, mtype, rseqid) {
754
- const callback = this._reqs[rseqid] || function() {};
755
- delete this._reqs[rseqid];
756
- if (mtype == Thrift.MessageType.EXCEPTION) {
757
- const x = new Thrift.TApplicationException();
758
- x.read(input);
759
- input.readMessageEnd();
760
- return callback(x);
761
- }
762
- const result = new SearchProxyService_getCorpora_result();
763
- result.read(input);
764
- input.readMessageEnd();
765
-
766
- if (null !== result.ex) {
767
- return callback(result.ex);
768
- }
769
- if (null !== result.success) {
770
- return callback(null, result.success);
771
- }
772
- return callback('getCorpora failed: unknown result');
773
- }
774
- };
775
- const SearchProxyServiceProcessor = exports.Processor = class SearchProxyServiceProcessor extends ServiceProcessor {
776
- constructor(handler) {
777
- super(handler);
778
- this._handler = handler;
779
- }
780
- process (input, output) {
781
- const r = input.readMessageBegin();
782
- if (this['process_' + r.fname]) {
783
- return this['process_' + r.fname].call(this, r.rseqid, input, output);
784
- } else {
785
- input.skip(Thrift.Type.STRUCT);
786
- input.readMessageEnd();
787
- const x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname);
788
- output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid);
789
- x.write(output);
790
- output.writeMessageEnd();
791
- output.flush();
792
- }
793
- }
794
- process_search (seqid, input, output) {
795
- const args = new SearchProxyService_search_args();
796
- args.read(input);
797
- input.readMessageEnd();
798
- if (this._handler.search.length === 2) {
799
- Promise.resolve(this._handler.search.bind(this._handler)(
800
- args.query,
801
- args.provider
802
- )).then(result => {
803
- const result_obj = new SearchProxyService_search_result({success: result});
804
- output.writeMessageBegin("search", Thrift.MessageType.REPLY, seqid);
805
- result_obj.write(output);
806
- output.writeMessageEnd();
807
- output.flush();
808
- }).catch(err => {
809
- let result;
810
- if (err instanceof services_ttypes.ServicesException) {
811
- result = new SearchProxyService_search_result(err);
812
- output.writeMessageBegin("search", Thrift.MessageType.REPLY, seqid);
813
- } else {
814
- result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
815
- output.writeMessageBegin("search", Thrift.MessageType.EXCEPTION, seqid);
816
- }
817
- result.write(output);
818
- output.writeMessageEnd();
819
- output.flush();
820
- });
821
- } else {
822
- this._handler.search(args.query, args.provider, (err, result) => {
823
- let result_obj;
824
- if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
825
- result_obj = new SearchProxyService_search_result((err !== null || typeof err === 'undefined') ? err : {success: result});
826
- output.writeMessageBegin("search", Thrift.MessageType.REPLY, seqid);
827
- } else {
828
- result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
829
- output.writeMessageBegin("search", Thrift.MessageType.EXCEPTION, seqid);
830
- }
831
- result_obj.write(output);
832
- output.writeMessageEnd();
833
- output.flush();
834
- });
835
- }
836
- }
837
- process_getProviders (seqid, input, output) {
838
- const args = new SearchProxyService_getProviders_args();
839
- args.read(input);
840
- input.readMessageEnd();
841
- if (this._handler.getProviders.length === 0) {
842
- Promise.resolve(this._handler.getProviders.bind(this._handler)(
843
- )).then(result => {
844
- const result_obj = new SearchProxyService_getProviders_result({success: result});
845
- output.writeMessageBegin("getProviders", Thrift.MessageType.REPLY, seqid);
846
- result_obj.write(output);
847
- output.writeMessageEnd();
848
- output.flush();
849
- }).catch(err => {
850
- let result;
851
- if (err instanceof services_ttypes.ServicesException) {
852
- result = new SearchProxyService_getProviders_result(err);
853
- output.writeMessageBegin("getProviders", Thrift.MessageType.REPLY, seqid);
854
- } else {
855
- result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
856
- output.writeMessageBegin("getProviders", Thrift.MessageType.EXCEPTION, seqid);
857
- }
858
- result.write(output);
859
- output.writeMessageEnd();
860
- output.flush();
861
- });
862
- } else {
863
- this._handler.getProviders((err, result) => {
864
- let result_obj;
865
- if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
866
- result_obj = new SearchProxyService_getProviders_result((err !== null || typeof err === 'undefined') ? err : {success: result});
867
- output.writeMessageBegin("getProviders", Thrift.MessageType.REPLY, seqid);
868
- } else {
869
- result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
870
- output.writeMessageBegin("getProviders", Thrift.MessageType.EXCEPTION, seqid);
871
- }
872
- result_obj.write(output);
873
- output.writeMessageEnd();
874
- output.flush();
875
- });
876
- }
877
- }
878
- process_getCapabilities (seqid, input, output) {
879
- const args = new SearchProxyService_getCapabilities_args();
880
- args.read(input);
881
- input.readMessageEnd();
882
- if (this._handler.getCapabilities.length === 1) {
883
- Promise.resolve(this._handler.getCapabilities.bind(this._handler)(
884
- args.provider
885
- )).then(result => {
886
- const result_obj = new SearchProxyService_getCapabilities_result({success: result});
887
- output.writeMessageBegin("getCapabilities", Thrift.MessageType.REPLY, seqid);
888
- result_obj.write(output);
889
- output.writeMessageEnd();
890
- output.flush();
891
- }).catch(err => {
892
- let result;
893
- if (err instanceof services_ttypes.ServicesException) {
894
- result = new SearchProxyService_getCapabilities_result(err);
895
- output.writeMessageBegin("getCapabilities", Thrift.MessageType.REPLY, seqid);
896
- } else {
897
- result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
898
- output.writeMessageBegin("getCapabilities", Thrift.MessageType.EXCEPTION, seqid);
899
- }
900
- result.write(output);
901
- output.writeMessageEnd();
902
- output.flush();
903
- });
904
- } else {
905
- this._handler.getCapabilities(args.provider, (err, result) => {
906
- let result_obj;
907
- if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
908
- result_obj = new SearchProxyService_getCapabilities_result((err !== null || typeof err === 'undefined') ? err : {success: result});
909
- output.writeMessageBegin("getCapabilities", Thrift.MessageType.REPLY, seqid);
910
- } else {
911
- result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
912
- output.writeMessageBegin("getCapabilities", Thrift.MessageType.EXCEPTION, seqid);
913
- }
914
- result_obj.write(output);
915
- output.writeMessageEnd();
916
- output.flush();
917
- });
918
- }
919
- }
920
- process_getCorpora (seqid, input, output) {
921
- const args = new SearchProxyService_getCorpora_args();
922
- args.read(input);
923
- input.readMessageEnd();
924
- if (this._handler.getCorpora.length === 1) {
925
- Promise.resolve(this._handler.getCorpora.bind(this._handler)(
926
- args.provider
927
- )).then(result => {
928
- const result_obj = new SearchProxyService_getCorpora_result({success: result});
929
- output.writeMessageBegin("getCorpora", Thrift.MessageType.REPLY, seqid);
930
- result_obj.write(output);
931
- output.writeMessageEnd();
932
- output.flush();
933
- }).catch(err => {
934
- let result;
935
- if (err instanceof services_ttypes.ServicesException) {
936
- result = new SearchProxyService_getCorpora_result(err);
937
- output.writeMessageBegin("getCorpora", Thrift.MessageType.REPLY, seqid);
938
- } else {
939
- result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
940
- output.writeMessageBegin("getCorpora", Thrift.MessageType.EXCEPTION, seqid);
941
- }
942
- result.write(output);
943
- output.writeMessageEnd();
944
- output.flush();
945
- });
946
- } else {
947
- this._handler.getCorpora(args.provider, (err, result) => {
948
- let result_obj;
949
- if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
950
- result_obj = new SearchProxyService_getCorpora_result((err !== null || typeof err === 'undefined') ? err : {success: result});
951
- output.writeMessageBegin("getCorpora", Thrift.MessageType.REPLY, seqid);
952
- } else {
953
- result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
954
- output.writeMessageBegin("getCorpora", Thrift.MessageType.EXCEPTION, seqid);
955
- }
956
- result_obj.write(output);
957
- output.writeMessageEnd();
958
- output.flush();
959
- });
960
- }
961
- }
962
- };
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 communication_ttypes = require('./communication_types');
13
+ const services_ttypes = require('./services_types');
14
+ const structure_ttypes = require('./structure_types');
15
+ const uuid_ttypes = require('./uuid_types');
16
+ const metadata_ttypes = require('./metadata_types');
17
+ const entities_ttypes = require('./entities_types');
18
+
19
+
20
+ const Service = require('./Service');
21
+ const ServiceClient = Service.Client;
22
+ const ServiceProcessor = Service.Processor;
23
+ const ttypes = require('./search_types');
24
+ //HELPER FUNCTIONS AND STRUCTURES
25
+
26
+ const SearchProxyService_search_args = class {
27
+ constructor(args) {
28
+ this.query = null;
29
+ this.provider = null;
30
+ if (args) {
31
+ if (args.query !== undefined && args.query !== null) {
32
+ this.query = new ttypes.SearchQuery(args.query);
33
+ }
34
+ if (args.provider !== undefined && args.provider !== null) {
35
+ this.provider = args.provider;
36
+ }
37
+ }
38
+ }
39
+
40
+ read (input) {
41
+ input.readStructBegin();
42
+ while (true) {
43
+ const ret = input.readFieldBegin();
44
+ const ftype = ret.ftype;
45
+ const fid = ret.fid;
46
+ if (ftype == Thrift.Type.STOP) {
47
+ break;
48
+ }
49
+ switch (fid) {
50
+ case 1:
51
+ if (ftype == Thrift.Type.STRUCT) {
52
+ this.query = new ttypes.SearchQuery();
53
+ this.query.read(input);
54
+ } else {
55
+ input.skip(ftype);
56
+ }
57
+ break;
58
+ case 2:
59
+ if (ftype == Thrift.Type.STRING) {
60
+ this.provider = input.readString();
61
+ } else {
62
+ input.skip(ftype);
63
+ }
64
+ break;
65
+ default:
66
+ input.skip(ftype);
67
+ }
68
+ input.readFieldEnd();
69
+ }
70
+ input.readStructEnd();
71
+ return;
72
+ }
73
+
74
+ write (output) {
75
+ output.writeStructBegin('SearchProxyService_search_args');
76
+ if (this.query !== null && this.query !== undefined) {
77
+ output.writeFieldBegin('query', Thrift.Type.STRUCT, 1);
78
+ this.query.write(output);
79
+ output.writeFieldEnd();
80
+ }
81
+ if (this.provider !== null && this.provider !== undefined) {
82
+ output.writeFieldBegin('provider', Thrift.Type.STRING, 2);
83
+ output.writeString(this.provider);
84
+ output.writeFieldEnd();
85
+ }
86
+ output.writeFieldStop();
87
+ output.writeStructEnd();
88
+ return;
89
+ }
90
+
91
+ };
92
+ const SearchProxyService_search_result = class {
93
+ constructor(args) {
94
+ this.success = null;
95
+ this.ex = null;
96
+ if (args instanceof services_ttypes.ServicesException) {
97
+ this.ex = args;
98
+ return;
99
+ }
100
+ if (args) {
101
+ if (args.success !== undefined && args.success !== null) {
102
+ this.success = new ttypes.SearchResult(args.success);
103
+ }
104
+ if (args.ex !== undefined && args.ex !== null) {
105
+ this.ex = args.ex;
106
+ }
107
+ }
108
+ }
109
+
110
+ read (input) {
111
+ input.readStructBegin();
112
+ while (true) {
113
+ const ret = input.readFieldBegin();
114
+ const ftype = ret.ftype;
115
+ const fid = ret.fid;
116
+ if (ftype == Thrift.Type.STOP) {
117
+ break;
118
+ }
119
+ switch (fid) {
120
+ case 0:
121
+ if (ftype == Thrift.Type.STRUCT) {
122
+ this.success = new ttypes.SearchResult();
123
+ this.success.read(input);
124
+ } else {
125
+ input.skip(ftype);
126
+ }
127
+ break;
128
+ case 1:
129
+ if (ftype == Thrift.Type.STRUCT) {
130
+ this.ex = new services_ttypes.ServicesException();
131
+ this.ex.read(input);
132
+ } else {
133
+ input.skip(ftype);
134
+ }
135
+ break;
136
+ default:
137
+ input.skip(ftype);
138
+ }
139
+ input.readFieldEnd();
140
+ }
141
+ input.readStructEnd();
142
+ return;
143
+ }
144
+
145
+ write (output) {
146
+ output.writeStructBegin('SearchProxyService_search_result');
147
+ if (this.success !== null && this.success !== undefined) {
148
+ output.writeFieldBegin('success', Thrift.Type.STRUCT, 0);
149
+ this.success.write(output);
150
+ output.writeFieldEnd();
151
+ }
152
+ if (this.ex !== null && this.ex !== undefined) {
153
+ output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
154
+ this.ex.write(output);
155
+ output.writeFieldEnd();
156
+ }
157
+ output.writeFieldStop();
158
+ output.writeStructEnd();
159
+ return;
160
+ }
161
+
162
+ };
163
+ const SearchProxyService_getProviders_args = class {
164
+ constructor(args) {
165
+ }
166
+
167
+ read (input) {
168
+ input.readStructBegin();
169
+ while (true) {
170
+ const ret = input.readFieldBegin();
171
+ const ftype = ret.ftype;
172
+ if (ftype == Thrift.Type.STOP) {
173
+ break;
174
+ }
175
+ input.skip(ftype);
176
+ input.readFieldEnd();
177
+ }
178
+ input.readStructEnd();
179
+ return;
180
+ }
181
+
182
+ write (output) {
183
+ output.writeStructBegin('SearchProxyService_getProviders_args');
184
+ output.writeFieldStop();
185
+ output.writeStructEnd();
186
+ return;
187
+ }
188
+
189
+ };
190
+ const SearchProxyService_getProviders_result = class {
191
+ constructor(args) {
192
+ this.success = null;
193
+ this.ex = null;
194
+ if (args instanceof services_ttypes.ServicesException) {
195
+ this.ex = args;
196
+ return;
197
+ }
198
+ if (args) {
199
+ if (args.success !== undefined && args.success !== null) {
200
+ this.success = Thrift.copyList(args.success, [null]);
201
+ }
202
+ if (args.ex !== undefined && args.ex !== null) {
203
+ this.ex = args.ex;
204
+ }
205
+ }
206
+ }
207
+
208
+ read (input) {
209
+ input.readStructBegin();
210
+ while (true) {
211
+ const ret = input.readFieldBegin();
212
+ const ftype = ret.ftype;
213
+ const fid = ret.fid;
214
+ if (ftype == Thrift.Type.STOP) {
215
+ break;
216
+ }
217
+ switch (fid) {
218
+ case 0:
219
+ if (ftype == Thrift.Type.LIST) {
220
+ this.success = [];
221
+ const _rtmp331 = input.readListBegin();
222
+ const _size30 = _rtmp331.size || 0;
223
+ for (let _i32 = 0; _i32 < _size30; ++_i32) {
224
+ let elem33 = null;
225
+ elem33 = input.readString();
226
+ this.success.push(elem33);
227
+ }
228
+ input.readListEnd();
229
+ } else {
230
+ input.skip(ftype);
231
+ }
232
+ break;
233
+ case 1:
234
+ if (ftype == Thrift.Type.STRUCT) {
235
+ this.ex = new services_ttypes.ServicesException();
236
+ this.ex.read(input);
237
+ } else {
238
+ input.skip(ftype);
239
+ }
240
+ break;
241
+ default:
242
+ input.skip(ftype);
243
+ }
244
+ input.readFieldEnd();
245
+ }
246
+ input.readStructEnd();
247
+ return;
248
+ }
249
+
250
+ write (output) {
251
+ output.writeStructBegin('SearchProxyService_getProviders_result');
252
+ if (this.success !== null && this.success !== undefined) {
253
+ output.writeFieldBegin('success', Thrift.Type.LIST, 0);
254
+ output.writeListBegin(Thrift.Type.STRING, this.success.length);
255
+ for (let iter34 in this.success) {
256
+ if (this.success.hasOwnProperty(iter34)) {
257
+ iter34 = this.success[iter34];
258
+ output.writeString(iter34);
259
+ }
260
+ }
261
+ output.writeListEnd();
262
+ output.writeFieldEnd();
263
+ }
264
+ if (this.ex !== null && this.ex !== undefined) {
265
+ output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
266
+ this.ex.write(output);
267
+ output.writeFieldEnd();
268
+ }
269
+ output.writeFieldStop();
270
+ output.writeStructEnd();
271
+ return;
272
+ }
273
+
274
+ };
275
+ const SearchProxyService_getCapabilities_args = class {
276
+ constructor(args) {
277
+ this.provider = null;
278
+ if (args) {
279
+ if (args.provider !== undefined && args.provider !== null) {
280
+ this.provider = args.provider;
281
+ }
282
+ }
283
+ }
284
+
285
+ read (input) {
286
+ input.readStructBegin();
287
+ while (true) {
288
+ const ret = input.readFieldBegin();
289
+ const ftype = ret.ftype;
290
+ const fid = ret.fid;
291
+ if (ftype == Thrift.Type.STOP) {
292
+ break;
293
+ }
294
+ switch (fid) {
295
+ case 1:
296
+ if (ftype == Thrift.Type.STRING) {
297
+ this.provider = input.readString();
298
+ } else {
299
+ input.skip(ftype);
300
+ }
301
+ break;
302
+ case 0:
303
+ input.skip(ftype);
304
+ break;
305
+ default:
306
+ input.skip(ftype);
307
+ }
308
+ input.readFieldEnd();
309
+ }
310
+ input.readStructEnd();
311
+ return;
312
+ }
313
+
314
+ write (output) {
315
+ output.writeStructBegin('SearchProxyService_getCapabilities_args');
316
+ if (this.provider !== null && this.provider !== undefined) {
317
+ output.writeFieldBegin('provider', Thrift.Type.STRING, 1);
318
+ output.writeString(this.provider);
319
+ output.writeFieldEnd();
320
+ }
321
+ output.writeFieldStop();
322
+ output.writeStructEnd();
323
+ return;
324
+ }
325
+
326
+ };
327
+ const SearchProxyService_getCapabilities_result = class {
328
+ constructor(args) {
329
+ this.success = null;
330
+ this.ex = null;
331
+ if (args instanceof services_ttypes.ServicesException) {
332
+ this.ex = args;
333
+ return;
334
+ }
335
+ if (args) {
336
+ if (args.success !== undefined && args.success !== null) {
337
+ this.success = Thrift.copyList(args.success, [ttypes.SearchCapability]);
338
+ }
339
+ if (args.ex !== undefined && args.ex !== null) {
340
+ this.ex = args.ex;
341
+ }
342
+ }
343
+ }
344
+
345
+ read (input) {
346
+ input.readStructBegin();
347
+ while (true) {
348
+ const ret = input.readFieldBegin();
349
+ const ftype = ret.ftype;
350
+ const fid = ret.fid;
351
+ if (ftype == Thrift.Type.STOP) {
352
+ break;
353
+ }
354
+ switch (fid) {
355
+ case 0:
356
+ if (ftype == Thrift.Type.LIST) {
357
+ this.success = [];
358
+ const _rtmp336 = input.readListBegin();
359
+ const _size35 = _rtmp336.size || 0;
360
+ for (let _i37 = 0; _i37 < _size35; ++_i37) {
361
+ let elem38 = null;
362
+ elem38 = new ttypes.SearchCapability();
363
+ elem38.read(input);
364
+ this.success.push(elem38);
365
+ }
366
+ input.readListEnd();
367
+ } else {
368
+ input.skip(ftype);
369
+ }
370
+ break;
371
+ case 1:
372
+ if (ftype == Thrift.Type.STRUCT) {
373
+ this.ex = new services_ttypes.ServicesException();
374
+ this.ex.read(input);
375
+ } else {
376
+ input.skip(ftype);
377
+ }
378
+ break;
379
+ default:
380
+ input.skip(ftype);
381
+ }
382
+ input.readFieldEnd();
383
+ }
384
+ input.readStructEnd();
385
+ return;
386
+ }
387
+
388
+ write (output) {
389
+ output.writeStructBegin('SearchProxyService_getCapabilities_result');
390
+ if (this.success !== null && this.success !== undefined) {
391
+ output.writeFieldBegin('success', Thrift.Type.LIST, 0);
392
+ output.writeListBegin(Thrift.Type.STRUCT, this.success.length);
393
+ for (let iter39 in this.success) {
394
+ if (this.success.hasOwnProperty(iter39)) {
395
+ iter39 = this.success[iter39];
396
+ iter39.write(output);
397
+ }
398
+ }
399
+ output.writeListEnd();
400
+ output.writeFieldEnd();
401
+ }
402
+ if (this.ex !== null && this.ex !== undefined) {
403
+ output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
404
+ this.ex.write(output);
405
+ output.writeFieldEnd();
406
+ }
407
+ output.writeFieldStop();
408
+ output.writeStructEnd();
409
+ return;
410
+ }
411
+
412
+ };
413
+ const SearchProxyService_getCorpora_args = class {
414
+ constructor(args) {
415
+ this.provider = null;
416
+ if (args) {
417
+ if (args.provider !== undefined && args.provider !== null) {
418
+ this.provider = args.provider;
419
+ }
420
+ }
421
+ }
422
+
423
+ read (input) {
424
+ input.readStructBegin();
425
+ while (true) {
426
+ const ret = input.readFieldBegin();
427
+ const ftype = ret.ftype;
428
+ const fid = ret.fid;
429
+ if (ftype == Thrift.Type.STOP) {
430
+ break;
431
+ }
432
+ switch (fid) {
433
+ case 1:
434
+ if (ftype == Thrift.Type.STRING) {
435
+ this.provider = input.readString();
436
+ } else {
437
+ input.skip(ftype);
438
+ }
439
+ break;
440
+ case 0:
441
+ input.skip(ftype);
442
+ break;
443
+ default:
444
+ input.skip(ftype);
445
+ }
446
+ input.readFieldEnd();
447
+ }
448
+ input.readStructEnd();
449
+ return;
450
+ }
451
+
452
+ write (output) {
453
+ output.writeStructBegin('SearchProxyService_getCorpora_args');
454
+ if (this.provider !== null && this.provider !== undefined) {
455
+ output.writeFieldBegin('provider', Thrift.Type.STRING, 1);
456
+ output.writeString(this.provider);
457
+ output.writeFieldEnd();
458
+ }
459
+ output.writeFieldStop();
460
+ output.writeStructEnd();
461
+ return;
462
+ }
463
+
464
+ };
465
+ const SearchProxyService_getCorpora_result = class {
466
+ constructor(args) {
467
+ this.success = null;
468
+ this.ex = null;
469
+ if (args instanceof services_ttypes.ServicesException) {
470
+ this.ex = args;
471
+ return;
472
+ }
473
+ if (args) {
474
+ if (args.success !== undefined && args.success !== null) {
475
+ this.success = Thrift.copyList(args.success, [null]);
476
+ }
477
+ if (args.ex !== undefined && args.ex !== null) {
478
+ this.ex = args.ex;
479
+ }
480
+ }
481
+ }
482
+
483
+ read (input) {
484
+ input.readStructBegin();
485
+ while (true) {
486
+ const ret = input.readFieldBegin();
487
+ const ftype = ret.ftype;
488
+ const fid = ret.fid;
489
+ if (ftype == Thrift.Type.STOP) {
490
+ break;
491
+ }
492
+ switch (fid) {
493
+ case 0:
494
+ if (ftype == Thrift.Type.LIST) {
495
+ this.success = [];
496
+ const _rtmp341 = input.readListBegin();
497
+ const _size40 = _rtmp341.size || 0;
498
+ for (let _i42 = 0; _i42 < _size40; ++_i42) {
499
+ let elem43 = null;
500
+ elem43 = input.readString();
501
+ this.success.push(elem43);
502
+ }
503
+ input.readListEnd();
504
+ } else {
505
+ input.skip(ftype);
506
+ }
507
+ break;
508
+ case 1:
509
+ if (ftype == Thrift.Type.STRUCT) {
510
+ this.ex = new services_ttypes.ServicesException();
511
+ this.ex.read(input);
512
+ } else {
513
+ input.skip(ftype);
514
+ }
515
+ break;
516
+ default:
517
+ input.skip(ftype);
518
+ }
519
+ input.readFieldEnd();
520
+ }
521
+ input.readStructEnd();
522
+ return;
523
+ }
524
+
525
+ write (output) {
526
+ output.writeStructBegin('SearchProxyService_getCorpora_result');
527
+ if (this.success !== null && this.success !== undefined) {
528
+ output.writeFieldBegin('success', Thrift.Type.LIST, 0);
529
+ output.writeListBegin(Thrift.Type.STRING, this.success.length);
530
+ for (let iter44 in this.success) {
531
+ if (this.success.hasOwnProperty(iter44)) {
532
+ iter44 = this.success[iter44];
533
+ output.writeString(iter44);
534
+ }
535
+ }
536
+ output.writeListEnd();
537
+ output.writeFieldEnd();
538
+ }
539
+ if (this.ex !== null && this.ex !== undefined) {
540
+ output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
541
+ this.ex.write(output);
542
+ output.writeFieldEnd();
543
+ }
544
+ output.writeFieldStop();
545
+ output.writeStructEnd();
546
+ return;
547
+ }
548
+
549
+ };
550
+ const SearchProxyServiceClient = exports.Client = class SearchProxyServiceClient extends ServiceClient {
551
+ constructor(output, pClass) {
552
+ super(output, pClass);
553
+ this.output = output;
554
+ this.pClass = pClass;
555
+ this._seqid = 0;
556
+ this._reqs = {};
557
+ }
558
+ seqid () { return this._seqid; }
559
+ new_seqid () { return this._seqid += 1; }
560
+
561
+ search (query, provider) {
562
+ this._seqid = this.new_seqid();
563
+ const self = this;
564
+ return new Promise((resolve, reject) => {
565
+ self._reqs[self.seqid()] = (error, result) => {
566
+ return error ? reject(error) : resolve(result);
567
+ };
568
+ self.send_search(query, provider);
569
+ });
570
+ }
571
+
572
+ send_search (query, provider) {
573
+ const output = new this.pClass(this.output);
574
+ const params = {
575
+ query: query,
576
+ provider: provider
577
+ };
578
+ const args = new SearchProxyService_search_args(params);
579
+ try {
580
+ output.writeMessageBegin('search', Thrift.MessageType.CALL, this.seqid());
581
+ args.write(output);
582
+ output.writeMessageEnd();
583
+ return this.output.flush();
584
+ }
585
+ catch (e) {
586
+ delete this._reqs[this.seqid()];
587
+ if (typeof output.reset === 'function') {
588
+ output.reset();
589
+ }
590
+ throw e;
591
+ }
592
+ }
593
+
594
+ recv_search (input, mtype, rseqid) {
595
+ const callback = this._reqs[rseqid] || function() {};
596
+ delete this._reqs[rseqid];
597
+ if (mtype == Thrift.MessageType.EXCEPTION) {
598
+ const x = new Thrift.TApplicationException();
599
+ x.read(input);
600
+ input.readMessageEnd();
601
+ return callback(x);
602
+ }
603
+ const result = new SearchProxyService_search_result();
604
+ result.read(input);
605
+ input.readMessageEnd();
606
+
607
+ if (null !== result.ex) {
608
+ return callback(result.ex);
609
+ }
610
+ if (null !== result.success) {
611
+ return callback(null, result.success);
612
+ }
613
+ return callback('search failed: unknown result');
614
+ }
615
+
616
+ getProviders () {
617
+ this._seqid = this.new_seqid();
618
+ const self = this;
619
+ return new Promise((resolve, reject) => {
620
+ self._reqs[self.seqid()] = (error, result) => {
621
+ return error ? reject(error) : resolve(result);
622
+ };
623
+ self.send_getProviders();
624
+ });
625
+ }
626
+
627
+ send_getProviders () {
628
+ const output = new this.pClass(this.output);
629
+ const args = new SearchProxyService_getProviders_args();
630
+ try {
631
+ output.writeMessageBegin('getProviders', Thrift.MessageType.CALL, this.seqid());
632
+ args.write(output);
633
+ output.writeMessageEnd();
634
+ return this.output.flush();
635
+ }
636
+ catch (e) {
637
+ delete this._reqs[this.seqid()];
638
+ if (typeof output.reset === 'function') {
639
+ output.reset();
640
+ }
641
+ throw e;
642
+ }
643
+ }
644
+
645
+ recv_getProviders (input, mtype, rseqid) {
646
+ const callback = this._reqs[rseqid] || function() {};
647
+ delete this._reqs[rseqid];
648
+ if (mtype == Thrift.MessageType.EXCEPTION) {
649
+ const x = new Thrift.TApplicationException();
650
+ x.read(input);
651
+ input.readMessageEnd();
652
+ return callback(x);
653
+ }
654
+ const result = new SearchProxyService_getProviders_result();
655
+ result.read(input);
656
+ input.readMessageEnd();
657
+
658
+ if (null !== result.ex) {
659
+ return callback(result.ex);
660
+ }
661
+ if (null !== result.success) {
662
+ return callback(null, result.success);
663
+ }
664
+ return callback('getProviders failed: unknown result');
665
+ }
666
+
667
+ getCapabilities (provider) {
668
+ this._seqid = this.new_seqid();
669
+ const self = this;
670
+ return new Promise((resolve, reject) => {
671
+ self._reqs[self.seqid()] = (error, result) => {
672
+ return error ? reject(error) : resolve(result);
673
+ };
674
+ self.send_getCapabilities(provider);
675
+ });
676
+ }
677
+
678
+ send_getCapabilities (provider) {
679
+ const output = new this.pClass(this.output);
680
+ const params = {
681
+ provider: provider
682
+ };
683
+ const args = new SearchProxyService_getCapabilities_args(params);
684
+ try {
685
+ output.writeMessageBegin('getCapabilities', Thrift.MessageType.CALL, this.seqid());
686
+ args.write(output);
687
+ output.writeMessageEnd();
688
+ return this.output.flush();
689
+ }
690
+ catch (e) {
691
+ delete this._reqs[this.seqid()];
692
+ if (typeof output.reset === 'function') {
693
+ output.reset();
694
+ }
695
+ throw e;
696
+ }
697
+ }
698
+
699
+ recv_getCapabilities (input, mtype, rseqid) {
700
+ const callback = this._reqs[rseqid] || function() {};
701
+ delete this._reqs[rseqid];
702
+ if (mtype == Thrift.MessageType.EXCEPTION) {
703
+ const x = new Thrift.TApplicationException();
704
+ x.read(input);
705
+ input.readMessageEnd();
706
+ return callback(x);
707
+ }
708
+ const result = new SearchProxyService_getCapabilities_result();
709
+ result.read(input);
710
+ input.readMessageEnd();
711
+
712
+ if (null !== result.ex) {
713
+ return callback(result.ex);
714
+ }
715
+ if (null !== result.success) {
716
+ return callback(null, result.success);
717
+ }
718
+ return callback('getCapabilities failed: unknown result');
719
+ }
720
+
721
+ getCorpora (provider) {
722
+ this._seqid = this.new_seqid();
723
+ const self = this;
724
+ return new Promise((resolve, reject) => {
725
+ self._reqs[self.seqid()] = (error, result) => {
726
+ return error ? reject(error) : resolve(result);
727
+ };
728
+ self.send_getCorpora(provider);
729
+ });
730
+ }
731
+
732
+ send_getCorpora (provider) {
733
+ const output = new this.pClass(this.output);
734
+ const params = {
735
+ provider: provider
736
+ };
737
+ const args = new SearchProxyService_getCorpora_args(params);
738
+ try {
739
+ output.writeMessageBegin('getCorpora', Thrift.MessageType.CALL, this.seqid());
740
+ args.write(output);
741
+ output.writeMessageEnd();
742
+ return this.output.flush();
743
+ }
744
+ catch (e) {
745
+ delete this._reqs[this.seqid()];
746
+ if (typeof output.reset === 'function') {
747
+ output.reset();
748
+ }
749
+ throw e;
750
+ }
751
+ }
752
+
753
+ recv_getCorpora (input, mtype, rseqid) {
754
+ const callback = this._reqs[rseqid] || function() {};
755
+ delete this._reqs[rseqid];
756
+ if (mtype == Thrift.MessageType.EXCEPTION) {
757
+ const x = new Thrift.TApplicationException();
758
+ x.read(input);
759
+ input.readMessageEnd();
760
+ return callback(x);
761
+ }
762
+ const result = new SearchProxyService_getCorpora_result();
763
+ result.read(input);
764
+ input.readMessageEnd();
765
+
766
+ if (null !== result.ex) {
767
+ return callback(result.ex);
768
+ }
769
+ if (null !== result.success) {
770
+ return callback(null, result.success);
771
+ }
772
+ return callback('getCorpora failed: unknown result');
773
+ }
774
+ };
775
+ const SearchProxyServiceProcessor = exports.Processor = class SearchProxyServiceProcessor extends ServiceProcessor {
776
+ constructor(handler) {
777
+ super(handler);
778
+ this._handler = handler;
779
+ }
780
+ process (input, output) {
781
+ const r = input.readMessageBegin();
782
+ if (this['process_' + r.fname]) {
783
+ return this['process_' + r.fname].call(this, r.rseqid, input, output);
784
+ } else {
785
+ input.skip(Thrift.Type.STRUCT);
786
+ input.readMessageEnd();
787
+ const x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname);
788
+ output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid);
789
+ x.write(output);
790
+ output.writeMessageEnd();
791
+ output.flush();
792
+ }
793
+ }
794
+ process_search (seqid, input, output) {
795
+ const args = new SearchProxyService_search_args();
796
+ args.read(input);
797
+ input.readMessageEnd();
798
+ if (this._handler.search.length === 2) {
799
+ Promise.resolve(this._handler.search.bind(this._handler)(
800
+ args.query,
801
+ args.provider
802
+ )).then(result => {
803
+ const result_obj = new SearchProxyService_search_result({success: result});
804
+ output.writeMessageBegin("search", Thrift.MessageType.REPLY, seqid);
805
+ result_obj.write(output);
806
+ output.writeMessageEnd();
807
+ output.flush();
808
+ }).catch(err => {
809
+ let result;
810
+ if (err instanceof services_ttypes.ServicesException) {
811
+ result = new SearchProxyService_search_result(err);
812
+ output.writeMessageBegin("search", Thrift.MessageType.REPLY, seqid);
813
+ } else {
814
+ result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
815
+ output.writeMessageBegin("search", Thrift.MessageType.EXCEPTION, seqid);
816
+ }
817
+ result.write(output);
818
+ output.writeMessageEnd();
819
+ output.flush();
820
+ });
821
+ } else {
822
+ this._handler.search(args.query, args.provider, (err, result) => {
823
+ let result_obj;
824
+ if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
825
+ result_obj = new SearchProxyService_search_result((err !== null || typeof err === 'undefined') ? err : {success: result});
826
+ output.writeMessageBegin("search", Thrift.MessageType.REPLY, seqid);
827
+ } else {
828
+ result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
829
+ output.writeMessageBegin("search", Thrift.MessageType.EXCEPTION, seqid);
830
+ }
831
+ result_obj.write(output);
832
+ output.writeMessageEnd();
833
+ output.flush();
834
+ });
835
+ }
836
+ }
837
+ process_getProviders (seqid, input, output) {
838
+ const args = new SearchProxyService_getProviders_args();
839
+ args.read(input);
840
+ input.readMessageEnd();
841
+ if (this._handler.getProviders.length === 0) {
842
+ Promise.resolve(this._handler.getProviders.bind(this._handler)(
843
+ )).then(result => {
844
+ const result_obj = new SearchProxyService_getProviders_result({success: result});
845
+ output.writeMessageBegin("getProviders", Thrift.MessageType.REPLY, seqid);
846
+ result_obj.write(output);
847
+ output.writeMessageEnd();
848
+ output.flush();
849
+ }).catch(err => {
850
+ let result;
851
+ if (err instanceof services_ttypes.ServicesException) {
852
+ result = new SearchProxyService_getProviders_result(err);
853
+ output.writeMessageBegin("getProviders", Thrift.MessageType.REPLY, seqid);
854
+ } else {
855
+ result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
856
+ output.writeMessageBegin("getProviders", Thrift.MessageType.EXCEPTION, seqid);
857
+ }
858
+ result.write(output);
859
+ output.writeMessageEnd();
860
+ output.flush();
861
+ });
862
+ } else {
863
+ this._handler.getProviders((err, result) => {
864
+ let result_obj;
865
+ if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
866
+ result_obj = new SearchProxyService_getProviders_result((err !== null || typeof err === 'undefined') ? err : {success: result});
867
+ output.writeMessageBegin("getProviders", Thrift.MessageType.REPLY, seqid);
868
+ } else {
869
+ result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
870
+ output.writeMessageBegin("getProviders", Thrift.MessageType.EXCEPTION, seqid);
871
+ }
872
+ result_obj.write(output);
873
+ output.writeMessageEnd();
874
+ output.flush();
875
+ });
876
+ }
877
+ }
878
+ process_getCapabilities (seqid, input, output) {
879
+ const args = new SearchProxyService_getCapabilities_args();
880
+ args.read(input);
881
+ input.readMessageEnd();
882
+ if (this._handler.getCapabilities.length === 1) {
883
+ Promise.resolve(this._handler.getCapabilities.bind(this._handler)(
884
+ args.provider
885
+ )).then(result => {
886
+ const result_obj = new SearchProxyService_getCapabilities_result({success: result});
887
+ output.writeMessageBegin("getCapabilities", Thrift.MessageType.REPLY, seqid);
888
+ result_obj.write(output);
889
+ output.writeMessageEnd();
890
+ output.flush();
891
+ }).catch(err => {
892
+ let result;
893
+ if (err instanceof services_ttypes.ServicesException) {
894
+ result = new SearchProxyService_getCapabilities_result(err);
895
+ output.writeMessageBegin("getCapabilities", Thrift.MessageType.REPLY, seqid);
896
+ } else {
897
+ result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
898
+ output.writeMessageBegin("getCapabilities", Thrift.MessageType.EXCEPTION, seqid);
899
+ }
900
+ result.write(output);
901
+ output.writeMessageEnd();
902
+ output.flush();
903
+ });
904
+ } else {
905
+ this._handler.getCapabilities(args.provider, (err, result) => {
906
+ let result_obj;
907
+ if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
908
+ result_obj = new SearchProxyService_getCapabilities_result((err !== null || typeof err === 'undefined') ? err : {success: result});
909
+ output.writeMessageBegin("getCapabilities", Thrift.MessageType.REPLY, seqid);
910
+ } else {
911
+ result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
912
+ output.writeMessageBegin("getCapabilities", Thrift.MessageType.EXCEPTION, seqid);
913
+ }
914
+ result_obj.write(output);
915
+ output.writeMessageEnd();
916
+ output.flush();
917
+ });
918
+ }
919
+ }
920
+ process_getCorpora (seqid, input, output) {
921
+ const args = new SearchProxyService_getCorpora_args();
922
+ args.read(input);
923
+ input.readMessageEnd();
924
+ if (this._handler.getCorpora.length === 1) {
925
+ Promise.resolve(this._handler.getCorpora.bind(this._handler)(
926
+ args.provider
927
+ )).then(result => {
928
+ const result_obj = new SearchProxyService_getCorpora_result({success: result});
929
+ output.writeMessageBegin("getCorpora", Thrift.MessageType.REPLY, seqid);
930
+ result_obj.write(output);
931
+ output.writeMessageEnd();
932
+ output.flush();
933
+ }).catch(err => {
934
+ let result;
935
+ if (err instanceof services_ttypes.ServicesException) {
936
+ result = new SearchProxyService_getCorpora_result(err);
937
+ output.writeMessageBegin("getCorpora", Thrift.MessageType.REPLY, seqid);
938
+ } else {
939
+ result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
940
+ output.writeMessageBegin("getCorpora", Thrift.MessageType.EXCEPTION, seqid);
941
+ }
942
+ result.write(output);
943
+ output.writeMessageEnd();
944
+ output.flush();
945
+ });
946
+ } else {
947
+ this._handler.getCorpora(args.provider, (err, result) => {
948
+ let result_obj;
949
+ if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
950
+ result_obj = new SearchProxyService_getCorpora_result((err !== null || typeof err === 'undefined') ? err : {success: result});
951
+ output.writeMessageBegin("getCorpora", Thrift.MessageType.REPLY, seqid);
952
+ } else {
953
+ result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
954
+ output.writeMessageBegin("getCorpora", Thrift.MessageType.EXCEPTION, seqid);
955
+ }
956
+ result_obj.write(output);
957
+ output.writeMessageEnd();
958
+ output.flush();
959
+ });
960
+ }
961
+ }
962
+ };