@guardian/bridget 1.12.0 → 2.0.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.
- package/Newsletters.d.ts +75 -0
- package/Newsletters.js +318 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +1 -1
package/Newsletters.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as thrift from "@creditkarma/thrift-server-core";
|
|
3
|
+
export declare const serviceName: string;
|
|
4
|
+
export declare const annotations: thrift.IThriftAnnotations;
|
|
5
|
+
export declare const methodAnnotations: thrift.IMethodAnnotations;
|
|
6
|
+
export declare const methodNames: Array<string>;
|
|
7
|
+
export declare const methodParameters: {
|
|
8
|
+
[methodName: string]: number;
|
|
9
|
+
};
|
|
10
|
+
export interface IRequestSignUp__Args {
|
|
11
|
+
emailAddress: string;
|
|
12
|
+
newsletterIdentityName: string;
|
|
13
|
+
}
|
|
14
|
+
export interface IRequestSignUp__ArgsArgs {
|
|
15
|
+
emailAddress: string;
|
|
16
|
+
newsletterIdentityName: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const RequestSignUp__ArgsCodec: thrift.IStructCodec<IRequestSignUp__ArgsArgs, IRequestSignUp__Args>;
|
|
19
|
+
export declare class RequestSignUp__Args extends thrift.StructLike implements IRequestSignUp__Args {
|
|
20
|
+
emailAddress: string;
|
|
21
|
+
newsletterIdentityName: string;
|
|
22
|
+
readonly _annotations: thrift.IThriftAnnotations;
|
|
23
|
+
readonly _fieldAnnotations: thrift.IFieldAnnotations;
|
|
24
|
+
constructor(args: IRequestSignUp__ArgsArgs);
|
|
25
|
+
static read(input: thrift.TProtocol): RequestSignUp__Args;
|
|
26
|
+
static write(args: IRequestSignUp__ArgsArgs, output: thrift.TProtocol): void;
|
|
27
|
+
write(output: thrift.TProtocol): void;
|
|
28
|
+
}
|
|
29
|
+
export interface IRequestSignUp__Result {
|
|
30
|
+
success?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface IRequestSignUp__ResultArgs {
|
|
33
|
+
success?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare const RequestSignUp__ResultCodec: thrift.IStructCodec<IRequestSignUp__ResultArgs, IRequestSignUp__Result>;
|
|
36
|
+
export declare class RequestSignUp__Result extends thrift.StructLike implements IRequestSignUp__Result {
|
|
37
|
+
success?: boolean;
|
|
38
|
+
readonly _annotations: thrift.IThriftAnnotations;
|
|
39
|
+
readonly _fieldAnnotations: thrift.IFieldAnnotations;
|
|
40
|
+
constructor(args?: IRequestSignUp__ResultArgs);
|
|
41
|
+
static read(input: thrift.TProtocol): RequestSignUp__Result;
|
|
42
|
+
static write(args: IRequestSignUp__ResultArgs, output: thrift.TProtocol): void;
|
|
43
|
+
write(output: thrift.TProtocol): void;
|
|
44
|
+
}
|
|
45
|
+
export declare class Client<Context = any> extends thrift.ThriftClient<Context> {
|
|
46
|
+
static readonly serviceName: string;
|
|
47
|
+
static readonly annotations: thrift.IThriftAnnotations;
|
|
48
|
+
static readonly methodAnnotations: thrift.IMethodAnnotations;
|
|
49
|
+
static readonly methodNames: Array<string>;
|
|
50
|
+
readonly _serviceName: string;
|
|
51
|
+
readonly _annotations: thrift.IThriftAnnotations;
|
|
52
|
+
readonly _methodAnnotations: thrift.IMethodAnnotations;
|
|
53
|
+
readonly _methodNames: Array<string>;
|
|
54
|
+
readonly _methodParameters?: {
|
|
55
|
+
[methodName: string]: number;
|
|
56
|
+
};
|
|
57
|
+
requestSignUp(emailAddress: string, newsletterIdentityName: string, context?: Context): Promise<boolean>;
|
|
58
|
+
}
|
|
59
|
+
export interface IHandler<Context = any> {
|
|
60
|
+
requestSignUp(emailAddress: string, newsletterIdentityName: string, context?: Context): boolean | Promise<boolean>;
|
|
61
|
+
}
|
|
62
|
+
export declare class Processor<Context = any> extends thrift.ThriftProcessor<Context, IHandler<Context>> {
|
|
63
|
+
protected readonly _handler: IHandler<Context>;
|
|
64
|
+
static readonly serviceName: string;
|
|
65
|
+
static readonly annotations: thrift.IThriftAnnotations;
|
|
66
|
+
static readonly methodAnnotations: thrift.IMethodAnnotations;
|
|
67
|
+
static readonly methodNames: Array<string>;
|
|
68
|
+
readonly _serviceName: string;
|
|
69
|
+
readonly _annotations: thrift.IThriftAnnotations;
|
|
70
|
+
readonly _methodAnnotations: thrift.IMethodAnnotations;
|
|
71
|
+
readonly _methodNames: Array<string>;
|
|
72
|
+
constructor(handler: IHandler<Context>);
|
|
73
|
+
process(input: thrift.TProtocol, output: thrift.TProtocol, context: Context): Promise<Buffer>;
|
|
74
|
+
process_requestSignUp(requestId: number, input: thrift.TProtocol, output: thrift.TProtocol, context: Context): Promise<Buffer>;
|
|
75
|
+
}
|
package/Newsletters.js
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
3
|
+
if (mod && mod.__esModule) return mod;
|
|
4
|
+
var result = {};
|
|
5
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
6
|
+
result["default"] = mod;
|
|
7
|
+
return result;
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
/* tslint:disable */
|
|
11
|
+
/* eslint-disable */
|
|
12
|
+
/*
|
|
13
|
+
* Autogenerated by @creditkarma/thrift-typescript v3.7.6
|
|
14
|
+
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
|
15
|
+
*/
|
|
16
|
+
const thrift = __importStar(require("@creditkarma/thrift-server-core"));
|
|
17
|
+
exports.serviceName = "Newsletters";
|
|
18
|
+
exports.annotations = {};
|
|
19
|
+
exports.methodAnnotations = {
|
|
20
|
+
requestSignUp: {
|
|
21
|
+
annotations: {},
|
|
22
|
+
fieldAnnotations: {}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.methodNames = ["requestSignUp"];
|
|
26
|
+
exports.methodParameters = {
|
|
27
|
+
requestSignUp: 3
|
|
28
|
+
};
|
|
29
|
+
exports.RequestSignUp__ArgsCodec = {
|
|
30
|
+
encode(args, output) {
|
|
31
|
+
const obj = {
|
|
32
|
+
emailAddress: args.emailAddress,
|
|
33
|
+
newsletterIdentityName: args.newsletterIdentityName
|
|
34
|
+
};
|
|
35
|
+
output.writeStructBegin("RequestSignUp__Args");
|
|
36
|
+
if (obj.emailAddress != null) {
|
|
37
|
+
output.writeFieldBegin("emailAddress", thrift.TType.STRING, 1);
|
|
38
|
+
output.writeString(obj.emailAddress);
|
|
39
|
+
output.writeFieldEnd();
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
throw new thrift.TProtocolException(thrift.TProtocolExceptionType.UNKNOWN, "Required field[emailAddress] is unset!");
|
|
43
|
+
}
|
|
44
|
+
if (obj.newsletterIdentityName != null) {
|
|
45
|
+
output.writeFieldBegin("newsletterIdentityName", thrift.TType.STRING, 2);
|
|
46
|
+
output.writeString(obj.newsletterIdentityName);
|
|
47
|
+
output.writeFieldEnd();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
throw new thrift.TProtocolException(thrift.TProtocolExceptionType.UNKNOWN, "Required field[newsletterIdentityName] is unset!");
|
|
51
|
+
}
|
|
52
|
+
output.writeFieldStop();
|
|
53
|
+
output.writeStructEnd();
|
|
54
|
+
return;
|
|
55
|
+
},
|
|
56
|
+
decode(input) {
|
|
57
|
+
let _args = {};
|
|
58
|
+
input.readStructBegin();
|
|
59
|
+
while (true) {
|
|
60
|
+
const ret = input.readFieldBegin();
|
|
61
|
+
const fieldType = ret.fieldType;
|
|
62
|
+
const fieldId = ret.fieldId;
|
|
63
|
+
if (fieldType === thrift.TType.STOP) {
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
switch (fieldId) {
|
|
67
|
+
case 1:
|
|
68
|
+
if (fieldType === thrift.TType.STRING) {
|
|
69
|
+
const value_1 = input.readString();
|
|
70
|
+
_args.emailAddress = value_1;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
input.skip(fieldType);
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
case 2:
|
|
77
|
+
if (fieldType === thrift.TType.STRING) {
|
|
78
|
+
const value_2 = input.readString();
|
|
79
|
+
_args.newsletterIdentityName = value_2;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
input.skip(fieldType);
|
|
83
|
+
}
|
|
84
|
+
break;
|
|
85
|
+
default: {
|
|
86
|
+
input.skip(fieldType);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
input.readFieldEnd();
|
|
90
|
+
}
|
|
91
|
+
input.readStructEnd();
|
|
92
|
+
if (_args.emailAddress !== undefined && _args.newsletterIdentityName !== undefined) {
|
|
93
|
+
return {
|
|
94
|
+
emailAddress: _args.emailAddress,
|
|
95
|
+
newsletterIdentityName: _args.newsletterIdentityName
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
throw new thrift.TProtocolException(thrift.TProtocolExceptionType.UNKNOWN, "Unable to read RequestSignUp__Args from input");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
class RequestSignUp__Args extends thrift.StructLike {
|
|
104
|
+
constructor(args) {
|
|
105
|
+
super();
|
|
106
|
+
this._annotations = {};
|
|
107
|
+
this._fieldAnnotations = {};
|
|
108
|
+
if (args.emailAddress != null) {
|
|
109
|
+
const value_3 = args.emailAddress;
|
|
110
|
+
this.emailAddress = value_3;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
throw new thrift.TProtocolException(thrift.TProtocolExceptionType.UNKNOWN, "Required field[emailAddress] is unset!");
|
|
114
|
+
}
|
|
115
|
+
if (args.newsletterIdentityName != null) {
|
|
116
|
+
const value_4 = args.newsletterIdentityName;
|
|
117
|
+
this.newsletterIdentityName = value_4;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
throw new thrift.TProtocolException(thrift.TProtocolExceptionType.UNKNOWN, "Required field[newsletterIdentityName] is unset!");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
static read(input) {
|
|
124
|
+
return new RequestSignUp__Args(exports.RequestSignUp__ArgsCodec.decode(input));
|
|
125
|
+
}
|
|
126
|
+
static write(args, output) {
|
|
127
|
+
return exports.RequestSignUp__ArgsCodec.encode(args, output);
|
|
128
|
+
}
|
|
129
|
+
write(output) {
|
|
130
|
+
return exports.RequestSignUp__ArgsCodec.encode(this, output);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.RequestSignUp__Args = RequestSignUp__Args;
|
|
134
|
+
exports.RequestSignUp__ResultCodec = {
|
|
135
|
+
encode(args, output) {
|
|
136
|
+
const obj = {
|
|
137
|
+
success: args.success
|
|
138
|
+
};
|
|
139
|
+
output.writeStructBegin("RequestSignUp__Result");
|
|
140
|
+
if (obj.success != null) {
|
|
141
|
+
output.writeFieldBegin("success", thrift.TType.BOOL, 0);
|
|
142
|
+
output.writeBool(obj.success);
|
|
143
|
+
output.writeFieldEnd();
|
|
144
|
+
}
|
|
145
|
+
output.writeFieldStop();
|
|
146
|
+
output.writeStructEnd();
|
|
147
|
+
return;
|
|
148
|
+
},
|
|
149
|
+
decode(input) {
|
|
150
|
+
let _args = {};
|
|
151
|
+
input.readStructBegin();
|
|
152
|
+
while (true) {
|
|
153
|
+
const ret = input.readFieldBegin();
|
|
154
|
+
const fieldType = ret.fieldType;
|
|
155
|
+
const fieldId = ret.fieldId;
|
|
156
|
+
if (fieldType === thrift.TType.STOP) {
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
switch (fieldId) {
|
|
160
|
+
case 0:
|
|
161
|
+
if (fieldType === thrift.TType.BOOL) {
|
|
162
|
+
const value_5 = input.readBool();
|
|
163
|
+
_args.success = value_5;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
input.skip(fieldType);
|
|
167
|
+
}
|
|
168
|
+
break;
|
|
169
|
+
default: {
|
|
170
|
+
input.skip(fieldType);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
input.readFieldEnd();
|
|
174
|
+
}
|
|
175
|
+
input.readStructEnd();
|
|
176
|
+
return {
|
|
177
|
+
success: _args.success
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
class RequestSignUp__Result extends thrift.StructLike {
|
|
182
|
+
constructor(args = {}) {
|
|
183
|
+
super();
|
|
184
|
+
this._annotations = {};
|
|
185
|
+
this._fieldAnnotations = {};
|
|
186
|
+
if (args.success != null) {
|
|
187
|
+
const value_6 = args.success;
|
|
188
|
+
this.success = value_6;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
static read(input) {
|
|
192
|
+
return new RequestSignUp__Result(exports.RequestSignUp__ResultCodec.decode(input));
|
|
193
|
+
}
|
|
194
|
+
static write(args, output) {
|
|
195
|
+
return exports.RequestSignUp__ResultCodec.encode(args, output);
|
|
196
|
+
}
|
|
197
|
+
write(output) {
|
|
198
|
+
return exports.RequestSignUp__ResultCodec.encode(this, output);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
exports.RequestSignUp__Result = RequestSignUp__Result;
|
|
202
|
+
class Client extends thrift.ThriftClient {
|
|
203
|
+
constructor() {
|
|
204
|
+
super(...arguments);
|
|
205
|
+
this._serviceName = exports.serviceName;
|
|
206
|
+
this._annotations = exports.annotations;
|
|
207
|
+
this._methodAnnotations = exports.methodAnnotations;
|
|
208
|
+
this._methodNames = exports.methodNames;
|
|
209
|
+
this._methodParameters = exports.methodParameters;
|
|
210
|
+
}
|
|
211
|
+
requestSignUp(emailAddress, newsletterIdentityName, context) {
|
|
212
|
+
const writer = new this.transport();
|
|
213
|
+
const output = new this.protocol(writer);
|
|
214
|
+
output.writeMessageBegin("requestSignUp", thrift.MessageType.CALL, this.incrementRequestId());
|
|
215
|
+
const args = { emailAddress, newsletterIdentityName };
|
|
216
|
+
exports.RequestSignUp__ArgsCodec.encode(args, output);
|
|
217
|
+
output.writeMessageEnd();
|
|
218
|
+
return this.connection.send(writer.flush(), context).then((data) => {
|
|
219
|
+
const reader = this.transport.receiver(data);
|
|
220
|
+
const input = new this.protocol(reader);
|
|
221
|
+
try {
|
|
222
|
+
const { fieldName: fieldName, messageType: messageType } = input.readMessageBegin();
|
|
223
|
+
if (fieldName === "requestSignUp") {
|
|
224
|
+
if (messageType === thrift.MessageType.EXCEPTION) {
|
|
225
|
+
const err = thrift.TApplicationExceptionCodec.decode(input);
|
|
226
|
+
input.readMessageEnd();
|
|
227
|
+
return Promise.reject(err);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
const result = exports.RequestSignUp__ResultCodec.decode(input);
|
|
231
|
+
input.readMessageEnd();
|
|
232
|
+
if (result.success != null) {
|
|
233
|
+
return Promise.resolve(result.success);
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
return Promise.reject(new thrift.TApplicationException(thrift.TApplicationExceptionType.UNKNOWN, "requestSignUp failed: unknown result"));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
return Promise.reject(new thrift.TApplicationException(thrift.TApplicationExceptionType.WRONG_METHOD_NAME, "Received a response to an unknown RPC function: " + fieldName));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
catch (err) {
|
|
245
|
+
return Promise.reject(err);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
exports.Client = Client;
|
|
251
|
+
Client.serviceName = exports.serviceName;
|
|
252
|
+
Client.annotations = exports.annotations;
|
|
253
|
+
Client.methodAnnotations = exports.methodAnnotations;
|
|
254
|
+
Client.methodNames = exports.methodNames;
|
|
255
|
+
class Processor extends thrift.ThriftProcessor {
|
|
256
|
+
constructor(handler) {
|
|
257
|
+
super();
|
|
258
|
+
this._serviceName = exports.serviceName;
|
|
259
|
+
this._annotations = exports.annotations;
|
|
260
|
+
this._methodAnnotations = exports.methodAnnotations;
|
|
261
|
+
this._methodNames = exports.methodNames;
|
|
262
|
+
this._handler = handler;
|
|
263
|
+
}
|
|
264
|
+
process(input, output, context) {
|
|
265
|
+
return new Promise((resolve, reject) => {
|
|
266
|
+
const metadata = input.readMessageBegin();
|
|
267
|
+
const fieldName = metadata.fieldName;
|
|
268
|
+
const requestId = metadata.requestId;
|
|
269
|
+
const methodName = "process_" + fieldName;
|
|
270
|
+
switch (methodName) {
|
|
271
|
+
case "process_requestSignUp": {
|
|
272
|
+
resolve(this.process_requestSignUp(requestId, input, output, context));
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
default: {
|
|
276
|
+
input.skip(thrift.TType.STRUCT);
|
|
277
|
+
input.readMessageEnd();
|
|
278
|
+
const errMessage = "Unknown function " + fieldName;
|
|
279
|
+
const err = new thrift.TApplicationException(thrift.TApplicationExceptionType.UNKNOWN_METHOD, errMessage);
|
|
280
|
+
output.writeMessageBegin(fieldName, thrift.MessageType.EXCEPTION, requestId);
|
|
281
|
+
thrift.TApplicationExceptionCodec.encode(err, output);
|
|
282
|
+
output.writeMessageEnd();
|
|
283
|
+
resolve(output.flush());
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
process_requestSignUp(requestId, input, output, context) {
|
|
290
|
+
return new Promise((resolve, reject) => {
|
|
291
|
+
try {
|
|
292
|
+
const args = exports.RequestSignUp__ArgsCodec.decode(input);
|
|
293
|
+
input.readMessageEnd();
|
|
294
|
+
resolve(this._handler.requestSignUp(args.emailAddress, args.newsletterIdentityName, context));
|
|
295
|
+
}
|
|
296
|
+
catch (err) {
|
|
297
|
+
reject(err);
|
|
298
|
+
}
|
|
299
|
+
}).then((data) => {
|
|
300
|
+
const result = { success: data };
|
|
301
|
+
output.writeMessageBegin("requestSignUp", thrift.MessageType.REPLY, requestId);
|
|
302
|
+
exports.RequestSignUp__ResultCodec.encode(result, output);
|
|
303
|
+
output.writeMessageEnd();
|
|
304
|
+
return output.flush();
|
|
305
|
+
}).catch((err) => {
|
|
306
|
+
const result = new thrift.TApplicationException(thrift.TApplicationExceptionType.UNKNOWN, err.message);
|
|
307
|
+
output.writeMessageBegin("requestSignUp", thrift.MessageType.EXCEPTION, requestId);
|
|
308
|
+
thrift.TApplicationExceptionCodec.encode(result, output);
|
|
309
|
+
output.writeMessageEnd();
|
|
310
|
+
return output.flush();
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
exports.Processor = Processor;
|
|
315
|
+
Processor.serviceName = exports.serviceName;
|
|
316
|
+
Processor.annotations = exports.annotations;
|
|
317
|
+
Processor.methodAnnotations = exports.methodAnnotations;
|
|
318
|
+
Processor.methodNames = exports.methodNames;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -50,3 +50,5 @@ const Analytics = __importStar(require("./Analytics"));
|
|
|
50
50
|
exports.Analytics = Analytics;
|
|
51
51
|
const Navigation = __importStar(require("./Navigation"));
|
|
52
52
|
exports.Navigation = Navigation;
|
|
53
|
+
const Newsletters = __importStar(require("./Newsletters"));
|
|
54
|
+
exports.Newsletters = Newsletters;
|