@guardian/bridget 8.3.3 → 8.5.0

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