@guardian/bridget 2.9.0 → 4.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.
@@ -0,0 +1,26 @@
1
+ import * as thrift from "@creditkarma/thrift-server-core";
2
+ export interface IDiscussionApiResponse {
3
+ status: string;
4
+ statusCode: number;
5
+ message: string;
6
+ errorCode?: string;
7
+ }
8
+ export interface IDiscussionApiResponseArgs {
9
+ status: string;
10
+ statusCode: number;
11
+ message: string;
12
+ errorCode?: string;
13
+ }
14
+ export declare const DiscussionApiResponseCodec: thrift.IStructCodec<IDiscussionApiResponseArgs, IDiscussionApiResponse>;
15
+ export declare class DiscussionApiResponse extends thrift.StructLike implements IDiscussionApiResponse {
16
+ status: string;
17
+ statusCode: number;
18
+ message: string;
19
+ errorCode?: string;
20
+ readonly _annotations: thrift.IThriftAnnotations;
21
+ readonly _fieldAnnotations: thrift.IFieldAnnotations;
22
+ constructor(args: IDiscussionApiResponseArgs);
23
+ static read(input: thrift.TProtocol): DiscussionApiResponse;
24
+ static write(args: IDiscussionApiResponseArgs, output: thrift.TProtocol): void;
25
+ write(output: thrift.TProtocol): void;
26
+ }
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.CommentResponse = exports.CommentResponseCodec = void 0;
26
+ exports.DiscussionApiResponse = exports.DiscussionApiResponseCodec = void 0;
27
27
  /* tslint:disable */
28
28
  /* eslint-disable */
29
29
  /*
@@ -31,7 +31,7 @@ exports.CommentResponse = exports.CommentResponseCodec = void 0;
31
31
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
32
32
  */
33
33
  const thrift = __importStar(require("@creditkarma/thrift-server-core"));
34
- exports.CommentResponseCodec = {
34
+ exports.DiscussionApiResponseCodec = {
35
35
  encode(args, output) {
36
36
  const obj = {
37
37
  status: args.status,
@@ -39,7 +39,7 @@ exports.CommentResponseCodec = {
39
39
  message: args.message,
40
40
  errorCode: args.errorCode
41
41
  };
42
- output.writeStructBegin("CommentResponse");
42
+ output.writeStructBegin("DiscussionApiResponse");
43
43
  if (obj.status != null) {
44
44
  output.writeFieldBegin("status", thrift.TType.STRING, 1);
45
45
  output.writeString(obj.status);
@@ -136,11 +136,11 @@ exports.CommentResponseCodec = {
136
136
  };
137
137
  }
138
138
  else {
139
- throw new thrift.TProtocolException(thrift.TProtocolExceptionType.UNKNOWN, "Unable to read CommentResponse from input");
139
+ throw new thrift.TProtocolException(thrift.TProtocolExceptionType.UNKNOWN, "Unable to read DiscussionApiResponse from input");
140
140
  }
141
141
  }
142
142
  };
143
- class CommentResponse extends thrift.StructLike {
143
+ class DiscussionApiResponse extends thrift.StructLike {
144
144
  constructor(args) {
145
145
  super();
146
146
  this._annotations = {};
@@ -172,13 +172,13 @@ class CommentResponse extends thrift.StructLike {
172
172
  }
173
173
  }
174
174
  static read(input) {
175
- return new CommentResponse(exports.CommentResponseCodec.decode(input));
175
+ return new DiscussionApiResponse(exports.DiscussionApiResponseCodec.decode(input));
176
176
  }
177
177
  static write(args, output) {
178
- return exports.CommentResponseCodec.encode(args, output);
178
+ return exports.DiscussionApiResponseCodec.encode(args, output);
179
179
  }
180
180
  write(output) {
181
- return exports.CommentResponseCodec.encode(this, output);
181
+ return exports.DiscussionApiResponseCodec.encode(this, output);
182
182
  }
183
183
  }
184
- exports.CommentResponse = CommentResponse;
184
+ exports.DiscussionApiResponse = DiscussionApiResponse;
@@ -0,0 +1,3 @@
1
+ export declare enum DiscussionNativeError {
2
+ UNKNOWN_ERROR = 0
3
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DiscussionNativeError = void 0;
4
+ /* tslint:disable */
5
+ /* eslint-disable */
6
+ /*
7
+ * Autogenerated by @creditkarma/thrift-typescript v3.7.6
8
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
9
+ */
10
+ var DiscussionNativeError;
11
+ (function (DiscussionNativeError) {
12
+ DiscussionNativeError[DiscussionNativeError["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
13
+ })(DiscussionNativeError || (exports.DiscussionNativeError = DiscussionNativeError = {}));
@@ -0,0 +1,28 @@
1
+ import * as thrift from "@creditkarma/thrift-server-core";
2
+ import * as DiscussionApiResponse from "./DiscussionApiResponse";
3
+ import * as DiscussionNativeError from "./DiscussionNativeError";
4
+ export declare enum DiscussionResponseType {
5
+ DiscussionResponseWithResponse = "response",
6
+ DiscussionResponseWithError = "error"
7
+ }
8
+ export type DiscussionResponse = IDiscussionResponseWithResponse | IDiscussionResponseWithError;
9
+ export interface IDiscussionResponseWithResponse {
10
+ __type: DiscussionResponseType.DiscussionResponseWithResponse;
11
+ response: DiscussionApiResponse.IDiscussionApiResponse;
12
+ error?: undefined;
13
+ }
14
+ export interface IDiscussionResponseWithError {
15
+ __type: DiscussionResponseType.DiscussionResponseWithError;
16
+ response?: undefined;
17
+ error: DiscussionNativeError.DiscussionNativeError;
18
+ }
19
+ export type DiscussionResponseArgs = IDiscussionResponseWithResponseArgs | IDiscussionResponseWithErrorArgs;
20
+ export interface IDiscussionResponseWithResponseArgs {
21
+ response: DiscussionApiResponse.IDiscussionApiResponseArgs;
22
+ error?: undefined;
23
+ }
24
+ export interface IDiscussionResponseWithErrorArgs {
25
+ response?: undefined;
26
+ error: DiscussionNativeError.DiscussionNativeError;
27
+ }
28
+ export declare const DiscussionResponseCodec: thrift.IStructToolkit<DiscussionResponseArgs, DiscussionResponse>;
@@ -0,0 +1,170 @@
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.DiscussionResponseCodec = exports.DiscussionResponseType = 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
+ const DiscussionApiResponse = __importStar(require("./DiscussionApiResponse"));
35
+ var DiscussionResponseType;
36
+ (function (DiscussionResponseType) {
37
+ DiscussionResponseType["DiscussionResponseWithResponse"] = "response";
38
+ DiscussionResponseType["DiscussionResponseWithError"] = "error";
39
+ })(DiscussionResponseType || (exports.DiscussionResponseType = DiscussionResponseType = {}));
40
+ exports.DiscussionResponseCodec = {
41
+ create(args) {
42
+ let _fieldsSet = 0;
43
+ let _returnValue = null;
44
+ if (args.response != null) {
45
+ _fieldsSet++;
46
+ const value_1 = new DiscussionApiResponse.DiscussionApiResponse(args.response);
47
+ _returnValue = { response: value_1 };
48
+ }
49
+ if (args.error != null) {
50
+ _fieldsSet++;
51
+ const value_2 = args.error;
52
+ _returnValue = { error: value_2 };
53
+ }
54
+ if (_fieldsSet > 1) {
55
+ throw new thrift.TProtocolException(thrift.TProtocolExceptionType.INVALID_DATA, "TUnion cannot have more than one value");
56
+ }
57
+ else if (_fieldsSet < 1) {
58
+ throw new thrift.TProtocolException(thrift.TProtocolExceptionType.INVALID_DATA, "TUnion must have one value set");
59
+ }
60
+ if (_returnValue !== null) {
61
+ if (_returnValue.response !== undefined) {
62
+ return {
63
+ __type: DiscussionResponseType.DiscussionResponseWithResponse,
64
+ response: _returnValue.response
65
+ };
66
+ }
67
+ else {
68
+ return {
69
+ __type: DiscussionResponseType.DiscussionResponseWithError,
70
+ error: _returnValue.error
71
+ };
72
+ }
73
+ }
74
+ else {
75
+ throw new thrift.TProtocolException(thrift.TProtocolExceptionType.UNKNOWN, "Unable to read data for TUnion");
76
+ }
77
+ },
78
+ encode(args, output) {
79
+ let _fieldsSet = 0;
80
+ const obj = {
81
+ response: args.response,
82
+ error: args.error
83
+ };
84
+ output.writeStructBegin("DiscussionResponse");
85
+ if (obj.response != null) {
86
+ _fieldsSet++;
87
+ output.writeFieldBegin("response", thrift.TType.STRUCT, 1);
88
+ DiscussionApiResponse.DiscussionApiResponseCodec.encode(obj.response, output);
89
+ output.writeFieldEnd();
90
+ }
91
+ if (obj.error != null) {
92
+ _fieldsSet++;
93
+ output.writeFieldBegin("error", thrift.TType.I32, 2);
94
+ output.writeI32(obj.error);
95
+ output.writeFieldEnd();
96
+ }
97
+ output.writeFieldStop();
98
+ output.writeStructEnd();
99
+ if (_fieldsSet > 1) {
100
+ throw new thrift.TProtocolException(thrift.TProtocolExceptionType.INVALID_DATA, "TUnion cannot have more than one value");
101
+ }
102
+ else if (_fieldsSet < 1) {
103
+ throw new thrift.TProtocolException(thrift.TProtocolExceptionType.INVALID_DATA, "TUnion must have one value set");
104
+ }
105
+ return;
106
+ },
107
+ decode(input) {
108
+ let _fieldsSet = 0;
109
+ let _returnValue = null;
110
+ input.readStructBegin();
111
+ while (true) {
112
+ const ret = input.readFieldBegin();
113
+ const fieldType = ret.fieldType;
114
+ const fieldId = ret.fieldId;
115
+ if (fieldType === thrift.TType.STOP) {
116
+ break;
117
+ }
118
+ switch (fieldId) {
119
+ case 1:
120
+ if (fieldType === thrift.TType.STRUCT) {
121
+ _fieldsSet++;
122
+ const value_3 = DiscussionApiResponse.DiscussionApiResponseCodec.decode(input);
123
+ _returnValue = { response: value_3 };
124
+ }
125
+ else {
126
+ input.skip(fieldType);
127
+ }
128
+ break;
129
+ case 2:
130
+ if (fieldType === thrift.TType.I32) {
131
+ _fieldsSet++;
132
+ const value_4 = input.readI32();
133
+ _returnValue = { error: value_4 };
134
+ }
135
+ else {
136
+ input.skip(fieldType);
137
+ }
138
+ break;
139
+ default: {
140
+ input.skip(fieldType);
141
+ }
142
+ }
143
+ input.readFieldEnd();
144
+ }
145
+ input.readStructEnd();
146
+ if (_fieldsSet > 1) {
147
+ throw new thrift.TProtocolException(thrift.TProtocolExceptionType.INVALID_DATA, "TUnion cannot have more than one value");
148
+ }
149
+ else if (_fieldsSet < 1) {
150
+ throw new thrift.TProtocolException(thrift.TProtocolExceptionType.INVALID_DATA, "TUnion must have one value set");
151
+ }
152
+ if (_returnValue !== null) {
153
+ if (_returnValue.response !== undefined) {
154
+ return {
155
+ __type: DiscussionResponseType.DiscussionResponseWithResponse,
156
+ response: _returnValue.response
157
+ };
158
+ }
159
+ else {
160
+ return {
161
+ __type: DiscussionResponseType.DiscussionResponseWithError,
162
+ error: _returnValue.error
163
+ };
164
+ }
165
+ }
166
+ else {
167
+ throw new thrift.TProtocolException(thrift.TProtocolExceptionType.UNKNOWN, "Unable to read data for TUnion");
168
+ }
169
+ }
170
+ };
package/User.d.ts CHANGED
@@ -178,14 +178,14 @@ export declare class IsSignedIn__Result extends thrift.StructLike implements IIs
178
178
  write(output: thrift.TProtocol): void;
179
179
  }
180
180
  export interface ISignIn__Result {
181
- success?: void;
181
+ success?: boolean;
182
182
  }
183
183
  export interface ISignIn__ResultArgs {
184
- success?: void;
184
+ success?: boolean;
185
185
  }
186
186
  export declare const SignIn__ResultCodec: thrift.IStructCodec<ISignIn__ResultArgs, ISignIn__Result>;
187
187
  export declare class SignIn__Result extends thrift.StructLike implements ISignIn__Result {
188
- success?: void;
188
+ success?: boolean;
189
189
  readonly _annotations: thrift.IThriftAnnotations;
190
190
  readonly _fieldAnnotations: thrift.IFieldAnnotations;
191
191
  constructor(args?: ISignIn__ResultArgs);
@@ -210,7 +210,7 @@ export declare class Client<Context = any> extends thrift.ThriftClient<Context>
210
210
  discussionId(context?: Context): Promise<string>;
211
211
  doesCcpaApply(context?: Context): Promise<boolean>;
212
212
  isSignedIn(context?: Context): Promise<boolean>;
213
- signIn(reason: SignInScreenReason.SignInScreenReason, referrer: SignInScreenReferrer.SignInScreenReferrer, context?: Context): Promise<void>;
213
+ signIn(reason: SignInScreenReason.SignInScreenReason, referrer: SignInScreenReferrer.SignInScreenReferrer, context?: Context): Promise<boolean>;
214
214
  }
215
215
  export interface IHandler<Context = any> {
216
216
  isPremium(context?: Context): boolean | Promise<boolean>;
@@ -218,7 +218,7 @@ export interface IHandler<Context = any> {
218
218
  discussionId(context?: Context): string | Promise<string>;
219
219
  doesCcpaApply(context?: Context): boolean | Promise<boolean>;
220
220
  isSignedIn(context?: Context): boolean | Promise<boolean>;
221
- signIn(reason: SignInScreenReason.SignInScreenReason, referrer: SignInScreenReferrer.SignInScreenReferrer, context?: Context): void | Promise<void>;
221
+ signIn(reason: SignInScreenReason.SignInScreenReason, referrer: SignInScreenReferrer.SignInScreenReferrer, context?: Context): boolean | Promise<boolean>;
222
222
  }
223
223
  export declare class Processor<Context = any> extends thrift.ThriftProcessor<Context, IHandler<Context>> {
224
224
  protected readonly _handler: IHandler<Context>;
package/User.js CHANGED
@@ -800,7 +800,15 @@ class IsSignedIn__Result extends thrift.StructLike {
800
800
  exports.IsSignedIn__Result = IsSignedIn__Result;
801
801
  exports.SignIn__ResultCodec = {
802
802
  encode(args, output) {
803
+ const obj = {
804
+ success: args.success
805
+ };
803
806
  output.writeStructBegin("SignIn__Result");
807
+ if (obj.success != null) {
808
+ output.writeFieldBegin("success", thrift.TType.BOOL, 0);
809
+ output.writeBool(obj.success);
810
+ output.writeFieldEnd();
811
+ }
804
812
  output.writeFieldStop();
805
813
  output.writeStructEnd();
806
814
  return;
@@ -817,8 +825,9 @@ exports.SignIn__ResultCodec = {
817
825
  }
818
826
  switch (fieldId) {
819
827
  case 0:
820
- if (fieldType === thrift.TType.VOID) {
821
- input.skip(fieldType);
828
+ if (fieldType === thrift.TType.BOOL) {
829
+ const value_25 = input.readBool();
830
+ _args.success = value_25;
822
831
  }
823
832
  else {
824
833
  input.skip(fieldType);
@@ -842,8 +851,8 @@ class SignIn__Result extends thrift.StructLike {
842
851
  this._annotations = {};
843
852
  this._fieldAnnotations = {};
844
853
  if (args.success != null) {
845
- const value_25 = undefined;
846
- this.success = value_25;
854
+ const value_26 = args.success;
855
+ this.success = value_26;
847
856
  }
848
857
  }
849
858
  static read(input) {
@@ -1077,7 +1086,12 @@ class Client extends thrift.ThriftClient {
1077
1086
  else {
1078
1087
  const result = exports.SignIn__ResultCodec.decode(input);
1079
1088
  input.readMessageEnd();
1080
- return Promise.resolve(result.success);
1089
+ if (result.success != null) {
1090
+ return Promise.resolve(result.success);
1091
+ }
1092
+ else {
1093
+ return Promise.reject(new thrift.TApplicationException(thrift.TApplicationExceptionType.UNKNOWN, "signIn failed: unknown result"));
1094
+ }
1081
1095
  }
1082
1096
  }
1083
1097
  else {
package/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from "./PurchaseScreenReason";
2
2
  export * from "./SignInScreenReason";
3
3
  export * from "./SignInScreenReferrer";
4
+ export * from "./DiscussionNativeError";
4
5
  export * from "./Rect";
5
6
  export * from "./AdSlot";
6
7
  export * from "./Topic";
@@ -10,8 +11,9 @@ export * from "./MaybeEpic";
10
11
  export * from "./VideoSlot";
11
12
  export * from "./MetricPaint";
12
13
  export * from "./MetricFont";
13
- export * from "./CommentResponse";
14
+ export * from "./DiscussionApiResponse";
14
15
  export * from "./Metric";
16
+ export * from "./DiscussionResponse";
15
17
  import * as Environment from "./Environment";
16
18
  export { Environment as Environment };
17
19
  import * as Commercial from "./Commercial";
package/index.js CHANGED
@@ -36,6 +36,7 @@ exports.Newsletters = exports.Navigation = exports.Analytics = exports.Discussio
36
36
  __exportStar(require("./PurchaseScreenReason"), exports);
37
37
  __exportStar(require("./SignInScreenReason"), exports);
38
38
  __exportStar(require("./SignInScreenReferrer"), exports);
39
+ __exportStar(require("./DiscussionNativeError"), exports);
39
40
  __exportStar(require("./Rect"), exports);
40
41
  __exportStar(require("./AdSlot"), exports);
41
42
  __exportStar(require("./Topic"), exports);
@@ -45,8 +46,9 @@ __exportStar(require("./MaybeEpic"), exports);
45
46
  __exportStar(require("./VideoSlot"), exports);
46
47
  __exportStar(require("./MetricPaint"), exports);
47
48
  __exportStar(require("./MetricFont"), exports);
48
- __exportStar(require("./CommentResponse"), exports);
49
+ __exportStar(require("./DiscussionApiResponse"), exports);
49
50
  __exportStar(require("./Metric"), exports);
51
+ __exportStar(require("./DiscussionResponse"), exports);
50
52
  const Environment = __importStar(require("./Environment"));
51
53
  exports.Environment = Environment;
52
54
  const Commercial = __importStar(require("./Commercial"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/bridget",
3
- "version": "2.9.0",
3
+ "version": "4.0.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,26 +0,0 @@
1
- import * as thrift from "@creditkarma/thrift-server-core";
2
- export interface ICommentResponse {
3
- status: string;
4
- statusCode: number;
5
- message: string;
6
- errorCode?: string;
7
- }
8
- export interface ICommentResponseArgs {
9
- status: string;
10
- statusCode: number;
11
- message: string;
12
- errorCode?: string;
13
- }
14
- export declare const CommentResponseCodec: thrift.IStructCodec<ICommentResponseArgs, ICommentResponse>;
15
- export declare class CommentResponse extends thrift.StructLike implements ICommentResponse {
16
- status: string;
17
- statusCode: number;
18
- message: string;
19
- errorCode?: string;
20
- readonly _annotations: thrift.IThriftAnnotations;
21
- readonly _fieldAnnotations: thrift.IFieldAnnotations;
22
- constructor(args: ICommentResponseArgs);
23
- static read(input: thrift.TProtocol): CommentResponse;
24
- static write(args: ICommentResponseArgs, output: thrift.TProtocol): void;
25
- write(output: thrift.TProtocol): void;
26
- }