Skip to content

Commit b179da5

Browse files
authored
refactor(ts): partial-result-stream types/refactor (#488)
1 parent 63d63d3 commit b179da5

8 files changed

Lines changed: 614 additions & 1146 deletions

File tree

handwritten/spanner/src/codec.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,25 @@ import {common as p} from 'protobufjs';
2222
import {SpannerClient as s} from './v1';
2323

2424
// tslint:disable-next-line no-any
25-
type Value = any;
25+
export type Value = any;
2626

27-
interface Field {
27+
export interface Field {
2828
name: string;
2929
value: Value;
3030
}
3131

32-
interface Json {
32+
export interface Json {
3333
[field: string]: Value;
3434
}
3535

3636
/**
37-
* @typedef JsonOptions
37+
* @typedef JSONOptions
3838
* @property {boolean} [wrapNumbers=false] Indicates if the numbers should be
3939
* wrapped in Int/Float wrappers.
4040
* @property {boolean} [wrapStructs=false] Indicates if the structs should be
4141
* wrapped in Struct wrapper.
4242
*/
43-
interface JsonOptions {
43+
export interface JSONOptions {
4444
wrapNumbers?: boolean;
4545
wrapStructs?: boolean;
4646
}
@@ -117,10 +117,10 @@ export class Struct extends Array<Field> {
117117
/**
118118
* Converts struct into a pojo (plain old JavaScript object).
119119
*
120-
* @param {JsonOptions} [options] JSON options.
120+
* @param {JSONOptions} [options] JSON options.
121121
* @returns {object}
122122
*/
123-
toJSON(options?: JsonOptions): Json {
123+
toJSON(options?: JSONOptions): Json {
124124
return codec.convertFieldsToJson(this, options);
125125
}
126126
/**
@@ -158,10 +158,10 @@ export class Struct extends Array<Field> {
158158
* @private
159159
*
160160
* @param {array} row The row to generate JSON for.
161-
* @param {JsonOptions} [options] JSON options.
161+
* @param {JSONOptions} [options] JSON options.
162162
* @returns {object}
163163
*/
164-
function convertFieldsToJson(fields: Field[], options?: JsonOptions): Json {
164+
function convertFieldsToJson(fields: Field[], options?: JSONOptions): Json {
165165
const json: Json = {};
166166

167167
const defaultOptions = {wrapNumbers: false, wrapStructs: false};
@@ -193,10 +193,10 @@ function convertFieldsToJson(fields: Field[], options?: JsonOptions): Json {
193193
* @private
194194
*
195195
* @param {*} value The value to convert.
196-
* @param {JsonOptions} options JSON options.
196+
* @param {JSONOptions} options JSON options.
197197
* @return {*}
198198
*/
199-
function convertValueToJson(value: Value, options: JsonOptions): Value {
199+
function convertValueToJson(value: Value, options: JSONOptions): Value {
200200
if (!options.wrapNumbers && value instanceof WrappedNumber) {
201201
return value.valueOf();
202202
}
@@ -433,7 +433,7 @@ function getType(value: Value): Type {
433433
*/
434434
interface RequestOptions {
435435
json?: boolean;
436-
jsonOptions?: JsonOptions;
436+
jsonOptions?: JSONOptions;
437437
gaxOptions?: CallOptions;
438438
}
439439

@@ -450,7 +450,7 @@ interface RequestOptions {
450450
* client will attempt to guess for all non-null values.
451451
* @property {boolean} [json=false] Receive the rows as serialized objects. This
452452
* is the equivalent of calling `toJSON()` on each row.
453-
* @property {JsonOptions} [jsonOptions] Configuration options for the
453+
* @property {JSONOptions} [jsonOptions] Configuration options for the
454454
* serialized objects.
455455
*/
456456
export interface ExecuteSqlRequest extends s.ExecuteSqlRequest, RequestOptions {
@@ -553,7 +553,7 @@ interface KeyRange {
553553
* be used to define a range of keys to be yielded.
554554
* @property {boolean} [json=false] Receive the rows as serialized objects. This
555555
* is the equivalent of calling `toJSON()` on each row.
556-
* @property {JsonOptions} [jsonOptions] Configuration options for the
556+
* @property {JSONOptions} [jsonOptions] Configuration options for the
557557
* serialized objects.
558558
*/
559559
export interface ReadRequest extends s.ReadRequest, RequestOptions {

0 commit comments

Comments
 (0)