@guardian/bridget
Advanced tools
Comparing version 0.66.0 to 0.67.0
{ | ||
"name": "@guardian/bridget", | ||
"version": "0.66.0", | ||
"version": "0.67.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -23,2 +23,18 @@ /// <reference types="node" /> | ||
} | ||
export interface IFilterSeenArticles__Args { | ||
articleIds: Array<string>; | ||
} | ||
export interface IFilterSeenArticles__ArgsArgs { | ||
articleIds: Array<string>; | ||
} | ||
export declare const FilterSeenArticles__ArgsCodec: thrift.IStructCodec<IFilterSeenArticles__ArgsArgs, IFilterSeenArticles__Args>; | ||
export declare class FilterSeenArticles__Args extends thrift.StructLike implements IFilterSeenArticles__Args { | ||
articleIds: Array<string>; | ||
readonly _annotations: thrift.IThriftAnnotations; | ||
readonly _fieldAnnotations: thrift.IFieldAnnotations; | ||
constructor(args: IFilterSeenArticles__ArgsArgs); | ||
static read(input: thrift.TProtocol): FilterSeenArticles__Args; | ||
static write(args: IFilterSeenArticles__ArgsArgs, output: thrift.TProtocol): void; | ||
write(output: thrift.TProtocol): void; | ||
} | ||
export interface IIsPremium__Result { | ||
@@ -40,2 +56,18 @@ success?: boolean; | ||
} | ||
export interface IFilterSeenArticles__Result { | ||
success?: Array<string>; | ||
} | ||
export interface IFilterSeenArticles__ResultArgs { | ||
success?: Array<string>; | ||
} | ||
export declare const FilterSeenArticles__ResultCodec: thrift.IStructCodec<IFilterSeenArticles__ResultArgs, IFilterSeenArticles__Result>; | ||
export declare class FilterSeenArticles__Result extends thrift.StructLike implements IFilterSeenArticles__Result { | ||
success?: Array<string>; | ||
readonly _annotations: thrift.IThriftAnnotations; | ||
readonly _fieldAnnotations: thrift.IFieldAnnotations; | ||
constructor(args?: IFilterSeenArticles__ResultArgs); | ||
static read(input: thrift.TProtocol): FilterSeenArticles__Result; | ||
static write(args: IFilterSeenArticles__ResultArgs, output: thrift.TProtocol): void; | ||
write(output: thrift.TProtocol): void; | ||
} | ||
export declare class Client<Context = any> extends thrift.ThriftClient<Context> { | ||
@@ -54,5 +86,7 @@ static readonly serviceName: string; | ||
isPremium(context?: Context): Promise<boolean>; | ||
filterSeenArticles(articleIds: Array<string>, context?: Context): Promise<Array<string>>; | ||
} | ||
export interface IHandler<Context = any> { | ||
isPremium(context?: Context): boolean | Promise<boolean>; | ||
filterSeenArticles(articleIds: Array<string>, context?: Context): Array<string> | Promise<Array<string>>; | ||
} | ||
@@ -72,2 +106,3 @@ export declare class Processor<Context = any> extends thrift.ThriftProcessor<Context, IHandler<Context>> { | ||
process_isPremium(requestId: number, input: thrift.TProtocol, output: thrift.TProtocol, context: Context): Promise<Buffer>; | ||
process_filterSeenArticles(requestId: number, input: thrift.TProtocol, output: thrift.TProtocol, context: Context): Promise<Buffer>; | ||
} |
260
User.js
@@ -23,7 +23,12 @@ "use strict"; | ||
fieldAnnotations: {} | ||
}, | ||
filterSeenArticles: { | ||
annotations: {}, | ||
fieldAnnotations: {} | ||
} | ||
}; | ||
exports.methodNames = ["isPremium"]; | ||
exports.methodNames = ["isPremium", "filterSeenArticles"]; | ||
exports.methodParameters = { | ||
isPremium: 1 | ||
isPremium: 1, | ||
filterSeenArticles: 2 | ||
}; | ||
@@ -74,2 +79,96 @@ exports.IsPremium__ArgsCodec = { | ||
exports.IsPremium__Args = IsPremium__Args; | ||
exports.FilterSeenArticles__ArgsCodec = { | ||
encode(args, output) { | ||
const obj = { | ||
articleIds: args.articleIds | ||
}; | ||
output.writeStructBegin("FilterSeenArticles__Args"); | ||
if (obj.articleIds != null) { | ||
output.writeFieldBegin("articleIds", thrift.TType.LIST, 1); | ||
output.writeListBegin(thrift.TType.STRING, obj.articleIds.length); | ||
obj.articleIds.forEach((value_1) => { | ||
output.writeString(value_1); | ||
}); | ||
output.writeListEnd(); | ||
output.writeFieldEnd(); | ||
} | ||
else { | ||
throw new thrift.TProtocolException(thrift.TProtocolExceptionType.UNKNOWN, "Required field[articleIds] is unset!"); | ||
} | ||
output.writeFieldStop(); | ||
output.writeStructEnd(); | ||
return; | ||
}, | ||
decode(input) { | ||
let _args = {}; | ||
input.readStructBegin(); | ||
while (true) { | ||
const ret = input.readFieldBegin(); | ||
const fieldType = ret.fieldType; | ||
const fieldId = ret.fieldId; | ||
if (fieldType === thrift.TType.STOP) { | ||
break; | ||
} | ||
switch (fieldId) { | ||
case 1: | ||
if (fieldType === thrift.TType.LIST) { | ||
const value_2 = new Array(); | ||
const metadata_1 = input.readListBegin(); | ||
const size_1 = metadata_1.size; | ||
for (let i_1 = 0; i_1 < size_1; i_1++) { | ||
const value_3 = input.readString(); | ||
value_2.push(value_3); | ||
} | ||
input.readListEnd(); | ||
_args.articleIds = value_2; | ||
} | ||
else { | ||
input.skip(fieldType); | ||
} | ||
break; | ||
default: { | ||
input.skip(fieldType); | ||
} | ||
} | ||
input.readFieldEnd(); | ||
} | ||
input.readStructEnd(); | ||
if (_args.articleIds !== undefined) { | ||
return { | ||
articleIds: _args.articleIds | ||
}; | ||
} | ||
else { | ||
throw new thrift.TProtocolException(thrift.TProtocolExceptionType.UNKNOWN, "Unable to read FilterSeenArticles__Args from input"); | ||
} | ||
} | ||
}; | ||
class FilterSeenArticles__Args extends thrift.StructLike { | ||
constructor(args) { | ||
super(); | ||
this._annotations = {}; | ||
this._fieldAnnotations = {}; | ||
if (args.articleIds != null) { | ||
const value_4 = new Array(); | ||
args.articleIds.forEach((value_5) => { | ||
const value_6 = value_5; | ||
value_4.push(value_6); | ||
}); | ||
this.articleIds = value_4; | ||
} | ||
else { | ||
throw new thrift.TProtocolException(thrift.TProtocolExceptionType.UNKNOWN, "Required field[articleIds] is unset!"); | ||
} | ||
} | ||
static read(input) { | ||
return new FilterSeenArticles__Args(exports.FilterSeenArticles__ArgsCodec.decode(input)); | ||
} | ||
static write(args, output) { | ||
return exports.FilterSeenArticles__ArgsCodec.encode(args, output); | ||
} | ||
write(output) { | ||
return exports.FilterSeenArticles__ArgsCodec.encode(this, output); | ||
} | ||
} | ||
exports.FilterSeenArticles__Args = FilterSeenArticles__Args; | ||
exports.IsPremium__ResultCodec = { | ||
@@ -103,4 +202,4 @@ encode(args, output) { | ||
if (fieldType === thrift.TType.BOOL) { | ||
const value_1 = input.readBool(); | ||
_args.success = value_1; | ||
const value_7 = input.readBool(); | ||
_args.success = value_7; | ||
} | ||
@@ -129,4 +228,4 @@ else { | ||
if (args.success != null) { | ||
const value_2 = args.success; | ||
this.success = value_2; | ||
const value_8 = args.success; | ||
this.success = value_8; | ||
} | ||
@@ -145,2 +244,85 @@ } | ||
exports.IsPremium__Result = IsPremium__Result; | ||
exports.FilterSeenArticles__ResultCodec = { | ||
encode(args, output) { | ||
const obj = { | ||
success: args.success | ||
}; | ||
output.writeStructBegin("FilterSeenArticles__Result"); | ||
if (obj.success != null) { | ||
output.writeFieldBegin("success", thrift.TType.LIST, 0); | ||
output.writeListBegin(thrift.TType.STRING, obj.success.length); | ||
obj.success.forEach((value_9) => { | ||
output.writeString(value_9); | ||
}); | ||
output.writeListEnd(); | ||
output.writeFieldEnd(); | ||
} | ||
output.writeFieldStop(); | ||
output.writeStructEnd(); | ||
return; | ||
}, | ||
decode(input) { | ||
let _args = {}; | ||
input.readStructBegin(); | ||
while (true) { | ||
const ret = input.readFieldBegin(); | ||
const fieldType = ret.fieldType; | ||
const fieldId = ret.fieldId; | ||
if (fieldType === thrift.TType.STOP) { | ||
break; | ||
} | ||
switch (fieldId) { | ||
case 0: | ||
if (fieldType === thrift.TType.LIST) { | ||
const value_10 = new Array(); | ||
const metadata_2 = input.readListBegin(); | ||
const size_2 = metadata_2.size; | ||
for (let i_2 = 0; i_2 < size_2; i_2++) { | ||
const value_11 = input.readString(); | ||
value_10.push(value_11); | ||
} | ||
input.readListEnd(); | ||
_args.success = value_10; | ||
} | ||
else { | ||
input.skip(fieldType); | ||
} | ||
break; | ||
default: { | ||
input.skip(fieldType); | ||
} | ||
} | ||
input.readFieldEnd(); | ||
} | ||
input.readStructEnd(); | ||
return { | ||
success: _args.success | ||
}; | ||
} | ||
}; | ||
class FilterSeenArticles__Result extends thrift.StructLike { | ||
constructor(args = {}) { | ||
super(); | ||
this._annotations = {}; | ||
this._fieldAnnotations = {}; | ||
if (args.success != null) { | ||
const value_12 = new Array(); | ||
args.success.forEach((value_13) => { | ||
const value_14 = value_13; | ||
value_12.push(value_14); | ||
}); | ||
this.success = value_12; | ||
} | ||
} | ||
static read(input) { | ||
return new FilterSeenArticles__Result(exports.FilterSeenArticles__ResultCodec.decode(input)); | ||
} | ||
static write(args, output) { | ||
return exports.FilterSeenArticles__ResultCodec.encode(args, output); | ||
} | ||
write(output) { | ||
return exports.FilterSeenArticles__ResultCodec.encode(this, output); | ||
} | ||
} | ||
exports.FilterSeenArticles__Result = FilterSeenArticles__Result; | ||
class Client extends thrift.ThriftClient { | ||
@@ -193,2 +375,40 @@ constructor() { | ||
} | ||
filterSeenArticles(articleIds, context) { | ||
const writer = new this.transport(); | ||
const output = new this.protocol(writer); | ||
output.writeMessageBegin("filterSeenArticles", thrift.MessageType.CALL, this.incrementRequestId()); | ||
const args = { articleIds }; | ||
exports.FilterSeenArticles__ArgsCodec.encode(args, output); | ||
output.writeMessageEnd(); | ||
return this.connection.send(writer.flush(), context).then((data) => { | ||
const reader = this.transport.receiver(data); | ||
const input = new this.protocol(reader); | ||
try { | ||
const { fieldName: fieldName, messageType: messageType } = input.readMessageBegin(); | ||
if (fieldName === "filterSeenArticles") { | ||
if (messageType === thrift.MessageType.EXCEPTION) { | ||
const err = thrift.TApplicationExceptionCodec.decode(input); | ||
input.readMessageEnd(); | ||
return Promise.reject(err); | ||
} | ||
else { | ||
const result = exports.FilterSeenArticles__ResultCodec.decode(input); | ||
input.readMessageEnd(); | ||
if (result.success != null) { | ||
return Promise.resolve(result.success); | ||
} | ||
else { | ||
return Promise.reject(new thrift.TApplicationException(thrift.TApplicationExceptionType.UNKNOWN, "filterSeenArticles failed: unknown result")); | ||
} | ||
} | ||
} | ||
else { | ||
return Promise.reject(new thrift.TApplicationException(thrift.TApplicationExceptionType.WRONG_METHOD_NAME, "Received a response to an unknown RPC function: " + fieldName)); | ||
} | ||
} | ||
catch (err) { | ||
return Promise.reject(err); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -220,2 +440,6 @@ exports.Client = Client; | ||
} | ||
case "process_filterSeenArticles": { | ||
resolve(this.process_filterSeenArticles(requestId, input, output, context)); | ||
break; | ||
} | ||
default: { | ||
@@ -258,2 +482,26 @@ input.skip(thrift.TType.STRUCT); | ||
} | ||
process_filterSeenArticles(requestId, input, output, context) { | ||
return new Promise((resolve, reject) => { | ||
try { | ||
const args = exports.FilterSeenArticles__ArgsCodec.decode(input); | ||
input.readMessageEnd(); | ||
resolve(this._handler.filterSeenArticles(args.articleIds, context)); | ||
} | ||
catch (err) { | ||
reject(err); | ||
} | ||
}).then((data) => { | ||
const result = { success: data }; | ||
output.writeMessageBegin("filterSeenArticles", thrift.MessageType.REPLY, requestId); | ||
exports.FilterSeenArticles__ResultCodec.encode(result, output); | ||
output.writeMessageEnd(); | ||
return output.flush(); | ||
}).catch((err) => { | ||
const result = new thrift.TApplicationException(thrift.TApplicationExceptionType.UNKNOWN, err.message); | ||
output.writeMessageBegin("filterSeenArticles", thrift.MessageType.EXCEPTION, requestId); | ||
thrift.TApplicationExceptionCodec.encode(result, output); | ||
output.writeMessageEnd(); | ||
return output.flush(); | ||
}); | ||
} | ||
} | ||
@@ -260,0 +508,0 @@ exports.Processor = Processor; |
251118
6434