From bdefb1d8903fdc4434671bffaa21d2d84408c578 Mon Sep 17 00:00:00 2001 From: Jonathan Lui Date: Thu, 6 Dec 2018 14:32:50 -0800 Subject: [PATCH] fix(docs): move comments above last overload --- src/dataset.ts | 18 +-- src/index.ts | 306 +++++++++++++++++++++++++------------------------ src/job.ts | 43 +++---- src/table.ts | 138 +++++++++++----------- 4 files changed, 259 insertions(+), 246 deletions(-) diff --git a/src/dataset.ts b/src/dataset.ts index a385640b..777d8e22 100644 --- a/src/dataset.ts +++ b/src/dataset.ts @@ -301,6 +301,8 @@ class Dataset extends ServiceObject { this.getTablesStream = paginator.streamify('getTables'); } + createQueryJob(options: string|Query): Promise; + createQueryJob(options: string|Query, callback: JobCallback): void; /** * Run a query as a job. No results are immediately returned. Instead, your * callback will be executed with a {@link Job} object that you must @@ -313,8 +315,6 @@ class Dataset extends ServiceObject { * @param {function} [callback] See {@link BigQuery#createQueryJob} for full documentation of this method. * @returns {Promise} See {@link BigQuery#createQueryJob} for full documentation of this method. */ - createQueryJob(options: string|Query): Promise; - createQueryJob(options: string|Query, callback: JobCallback): void; createQueryJob(options: string|Query, callback?: JobCallback): void|Promise { if (typeof options === 'string') { @@ -359,6 +359,10 @@ class Dataset extends ServiceObject { return this.bigQuery.createQueryStream(options); } + createTable(id: string, options: TableMetadata): Promise; + createTable(id: string, options: TableMetadata, callback: TableCallback): + void; + createTable(id: string, callback: TableCallback): void; /** * Create a table given a tableId or configuration object. * @@ -402,10 +406,6 @@ class Dataset extends ServiceObject { * const apiResponse = data[1]; * }); */ - createTable(id: string, options: TableMetadata): Promise; - createTable(id: string, options: TableMetadata, callback: TableCallback): - void; - createTable(id: string, callback: TableCallback): void; createTable( id: string, optionsOrCallback?: TableMetadata|TableCallback, cb?: TableCallback): void|Promise { @@ -442,6 +442,9 @@ class Dataset extends ServiceObject { }); } + delete(options?: DatasetDeleteOptions): Promise<[r.Response]>; + delete(options: DatasetDeleteOptions, callback: DeleteCallback): void; + delete(callback: DeleteCallback): void; /** * Delete the dataset. * @@ -476,9 +479,6 @@ class Dataset extends ServiceObject { * const apiResponse = data[0]; * }); */ - delete(options?: DatasetDeleteOptions): Promise<[r.Response]>; - delete(options: DatasetDeleteOptions, callback: DeleteCallback): void; - delete(callback: DeleteCallback): void; delete( optionsOrCallback?: DeleteCallback|DatasetDeleteOptions, callback?: DeleteCallback): void|Promise<[r.Response]> { diff --git a/src/index.ts b/src/index.ts index 6fef06cb..103469b4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -164,14 +164,8 @@ export interface QueryParameter { parameterValue: {arrayValues?: Array<{}>; structValues?: {}; value?: {}}; } -export interface BigQueryOptions extends common.GoogleAuthOptions { - autoRetry?: boolean; - maxRetries?: number; - location?: string; -} - /** - * @typedef {object} ClientConfig + * @typedef {object} BigQueryOptions * @property {string} [projectId] The project ID from the Google Developer's * Console, e.g. 'grape-spaceship-123'. We will also check the environment * variable `GCLOUD_PROJECT` for your project ID. If your app is running in @@ -203,6 +197,11 @@ export interface BigQueryOptions extends common.GoogleAuthOptions { * example, to access an external data source, you may need the * `https://www.googleapis.com/auth/drive.readonly` scope. */ +export interface BigQueryOptions extends common.GoogleAuthOptions { + autoRetry?: boolean; + maxRetries?: number; + location?: string; +} /** * In the following examples from this page and the other modules (`Dataset`, @@ -216,7 +215,7 @@ export interface BigQueryOptions extends common.GoogleAuthOptions { * * @see [What is BigQuery?]{@link https://cloud.google.com/bigquery/what-is-bigquery} * - * @param {ClientConfig} options Configuration options. + * @param {BigQueryOptions} options Constructor options. * * @example Install the client library with npm: npm install --save @@ -241,8 +240,109 @@ export interface BigQueryOptions extends common.GoogleAuthOptions { */ export class BigQuery extends common.Service { location?: string; + + /** + * @method BigQuery#createQueryStream + * Run a query scoped to your project as a readable object stream. + * + * @param {object} query Configuration object. See {@link Query} for a complete + * list of options. + * @returns {stream} + * + * @example + * const {BigQuery} = require('@google-cloud/bigquery'); + * const bigquery = new BigQuery(); + * + * const query = 'SELECT url FROM `publicdata.samples.github_nested` LIMIT + * 100'; + * + * bigquery.createQueryStream(query) + * .on('error', console.error) + * .on('data', function(row) { + * // row is a result from your query. + * }) + * .on('end', function() { + * // All rows retrieved. + * }); + * + * //- + * // If you anticipate many results, you can end a stream early to prevent + * // unnecessary processing and API requests. + * //- + * bigquery.createQueryStream(query) + * .on('data', function(row) { + * this.end(); + * }); + */ createQueryStream: (options?: Query|string) => Duplex; + + /** + * @method BigQuery#getDatasetsStream + * + * List all or some of the {@link Dataset} objects in your project as + * a readable object stream. + * + * @param {object} [options] Configuration object. See + * {@link BigQuery#getDatasets} for a complete list of options. + * @returns {stream} + * + * @example + * const {BigQuery} = require('@google-cloud/bigquery'); + * const bigquery = new BigQuery(); + * + * bigquery.getDatasetsStream() + * .on('error', console.error) + * .on('data', function(dataset) { + * // dataset is a Dataset object. + * }) + * .on('end', function() { + * // All datasets retrieved. + * }); + * + * //- + * // If you anticipate many results, you can end a stream early to prevent + * // unnecessary processing and API requests. + * //- + * bigquery.getDatasetsStream() + * .on('data', function(dataset) { + * this.end(); + * }); + */ getDatasetsStream: () => Readable; + + /** + * @method BigQuery#getJobsStream + * + * List all or some of the {@link Job} objects in your project as a + * readable object stream. + * + * @param {object} [options] Configuration object. See + * {@link BigQuery#getJobs} for a complete list of options. + * @returns {stream} + * + * @example + * const {BigQuery} = require('@google-cloud/bigquery'); + * const bigquery = new BigQuery(); + * + * bigquery.getJobsStream() + * .on('error', console.error) + * .on('data', function(job) { + * // job is a Job object. + * }) + * .on('end', function() { + * // All jobs retrieved. + * }); + * + * //- + * // If you anticipate many results, you can end a stream early to prevent + * // unnecessary processing and API requests. + * //- + * bigquery.getJobsStream() + * .on('data', function(job) { + * this.end(); + * }); + */ + getJobsStream: () => Readable; constructor(options?: BigQueryOptions) { @@ -279,7 +379,6 @@ export class BigQuery extends common.Service { * @param {array} rows * @returns {array} Fields using their matching names from the table's schema. */ - static mergeSchemaWithRows_( schema: TableSchema|TableField, rows: TableRow[]) { return arrify(rows).map(mergeSchema).map(flattenRows); @@ -369,7 +468,12 @@ export class BigQuery extends common.Service { } /** - * @method BigQuery.date + * The `DATE` type represents a logical calendar date, independent of time + * zone. It does not represent a specific 24-hour time period. Rather, a given + * DATE value represents a different 24-hour period when interpreted in + * different time zones, and may represent a shorter or longer day during + * Daylight Savings Time transitions. + * * @param {object|string} value The date. If a string, this should be in the * format the API describes: `YYYY-[M]M-[D]D`. * Otherwise, provide an object. @@ -379,26 +483,23 @@ export class BigQuery extends common.Service { * * @example * const {BigQuery} = require('@google-cloud/bigquery'); - * const date = BigQuery.date('2017-01-01'); + * const bigquery = new BigQuery(); + * const date = bigquery.date('2017-01-01'); * * //- * // Alternatively, provide an object. * //- - * const date2 = BigQuery.date({ + * const date2 = bigquery.date({ * year: 2017, * month: 1, * day: 1 * }); */ + static date(value: BigQueryDateOptions|string) { + return new BigQueryDate(value); + } /** - * The `DATE` type represents a logical calendar date, independent of time - * zone. It does not represent a specific 24-hour time period. Rather, a given - * DATE value represents a different 24-hour period when interpreted in - * different time zones, and may represent a shorter or longer day during - * Daylight Savings Time transitions. - * - * @method BigQuery#date * @param {object|string} value The date. If a string, this should be in the * format the API describes: `YYYY-[M]M-[D]D`. * Otherwise, provide an object. @@ -408,21 +509,17 @@ export class BigQuery extends common.Service { * * @example * const {BigQuery} = require('@google-cloud/bigquery'); - * const bigquery = new BigQuery(); - * const date = bigquery.date('2017-01-01'); + * const date = BigQuery.date('2017-01-01'); * * //- * // Alternatively, provide an object. * //- - * const date2 = bigquery.date({ + * const date2 = BigQuery.date({ * year: 2017, * month: 1, * day: 1 * }); */ - static date(value: BigQueryDateOptions|string) { - return new BigQueryDate(value); - } date(value: BigQueryDateOptions|string) { return BigQuery.date(value); @@ -713,6 +810,11 @@ export class BigQuery extends common.Service { return queryParameter; } + createDataset(id: string, options?: DatasetResource): + Promise; + createDataset( + id: string, options: DatasetResource, callback: DatasetCallback): void; + createDataset(id: string, callback: DatasetCallback): void; /** * Create a dataset. * @@ -743,11 +845,6 @@ export class BigQuery extends common.Service { * const apiResponse = data[1]; * }); */ - createDataset(id: string, options?: DatasetResource): - Promise; - createDataset( - id: string, options: DatasetResource, callback: DatasetCallback): void; - createDataset(id: string, callback: DatasetCallback): void; createDataset( id: string, optionsOrCallback?: DatasetResource|DatasetCallback, cb?: DatasetCallback): void|Promise { @@ -783,6 +880,8 @@ export class BigQuery extends common.Service { }); } + createQueryJob(options: Query|string): Promise; + createQueryJob(options: Query|string, callback: JobCallback): void; /** * Run a query as a job. No results are immediately returned. Instead, your * callback will be executed with a {@link Job} object that you must @@ -861,8 +960,6 @@ export class BigQuery extends common.Service { * return job.getQueryResults(); * }); */ - createQueryJob(options: Query|string): Promise; - createQueryJob(options: Query|string, callback: JobCallback): void; createQueryJob(opts: Query|string, callback?: JobCallback): void|Promise { const options = typeof opts === 'object' ? opts : {query: opts}; @@ -942,40 +1039,8 @@ export class BigQuery extends common.Service { this.createJob(reqOpts, callback!); } - /** - * Run a query scoped to your project as a readable object stream. - * - * @param {object} query Configuration object. See {@link Query} for a complete - * list of options. - * @returns {stream} - * - * @example - * const {BigQuery} = require('@google-cloud/bigquery'); - * const bigquery = new BigQuery(); - * - * const query = 'SELECT url FROM `publicdata.samples.github_nested` LIMIT - * 100'; - * - * bigquery.createQueryStream(query) - * .on('error', console.error) - * .on('data', function(row) { - * // row is a result from your query. - * }) - * .on('end', function() { - * // All rows retrieved. - * }); - * - * //- - * // If you anticipate many results, you can end a stream early to prevent - * // unnecessary processing and API requests. - * //- - * bigquery.createQueryStream(query) - * .on('data', function(row) { - * this.end(); - * }); - */ - - + createJob(options: JobOptions): Promise; + createJob(options: JobOptions, callback: JobCallback): void; /** * Creates a job. Typically when creating a job you'll have a very specific * task in mind. For this we recommend one of the following methods: @@ -1034,8 +1099,6 @@ export class BigQuery extends common.Service { * return job.getQueryResults(); * }); */ - createJob(options: JobOptions): Promise; - createJob(options: JobOptions, callback: JobCallback): void; createJob(options: JobOptions, callback?: JobCallback): void|Promise { // tslint:disable-next-line no-any @@ -1111,6 +1174,9 @@ export class BigQuery extends common.Service { return new Dataset(this, id, options); } + getDatasets(options?: GetDatasetsOptions): Promise; + getDatasets(options: GetDatasetsOptions, callback: DatasetsCallback): void; + getDatasets(callback: DatasetsCallback): void; /** * List all or some of the datasets in your project. * @@ -1159,9 +1225,6 @@ export class BigQuery extends common.Service { * //- * bigquery.getDatasets().then(function(datasets) {}); */ - getDatasets(options?: GetDatasetsOptions): Promise; - getDatasets(options: GetDatasetsOptions, callback: DatasetsCallback): void; - getDatasets(callback: DatasetsCallback): void; getDatasets( optionsOrCallback?: GetDatasetsOptions|DatasetsCallback, cb?: DatasetsCallback): void|Promise { @@ -1203,38 +1266,9 @@ export class BigQuery extends common.Service { }); } - /** - * List all or some of the {@link Dataset} objects in your project as - * a readable object stream. - * - * @param {object} [options] Configuration object. See - * {@link BigQuery#getDatasets} for a complete list of options. - * @returns {stream} - * - * @example - * const {BigQuery} = require('@google-cloud/bigquery'); - * const bigquery = new BigQuery(); - * - * bigquery.getDatasetsStream() - * .on('error', console.error) - * .on('data', function(dataset) { - * // dataset is a Dataset object. - * }) - * .on('end', function() { - * // All datasets retrieved. - * }); - * - * //- - * // If you anticipate many results, you can end a stream early to prevent - * // unnecessary processing and API requests. - * //- - * bigquery.getDatasetsStream() - * .on('data', function(dataset) { - * this.end(); - * }); - */ - - + getJobs(options?: GetJobsOptions): Promise; + getJobs(options: GetJobsOptions, callback: GetJobsCallback): void; + getJobs(callback: GetJobsCallback): void; /** * Get all of the jobs from your project. * @@ -1293,9 +1327,6 @@ export class BigQuery extends common.Service { * const jobs = data[0]; * }); */ - getJobs(options?: GetJobsOptions): Promise; - getJobs(options: GetJobsOptions, callback: GetJobsCallback): void; - getJobs(callback: GetJobsCallback): void; getJobs( optionsOrCallback?: GetJobsOptions|GetJobsCallback, cb?: GetJobsCallback): void|Promise { @@ -1338,37 +1369,6 @@ export class BigQuery extends common.Service { }); } - /** - * List all or some of the {@link Job} objects in your project as a - * readable object stream. - * - * @param {object} [options] Configuration object. See - * {@link BigQuery#getJobs} for a complete list of options. - * @returns {stream} - * - * @example - * const {BigQuery} = require('@google-cloud/bigquery'); - * const bigquery = new BigQuery(); - * - * bigquery.getJobsStream() - * .on('error', console.error) - * .on('data', function(job) { - * // job is a Job object. - * }) - * .on('end', function() { - * // All jobs retrieved. - * }); - * - * //- - * // If you anticipate many results, you can end a stream early to prevent - * // unnecessary processing and API requests. - * //- - * bigquery.getJobsStream() - * .on('data', function(job) { - * this.end(); - * }); - */ - /** * Create a reference to an existing job. * @@ -1391,6 +1391,15 @@ export class BigQuery extends common.Service { return new Job(this, id, options); } + query(query: string, options?: QueryOptions): Promise; + query(query: Query, options?: QueryOptions): Promise; + query(query: string, options: QueryOptions, callback?: QueryRowsCallback): + void; + query( + query: Query, options: QueryOptions, + callback?: SimpleQueryRowsCallback): void; + query(query: string, callback?: QueryRowsCallback): void; + query(query: Query, callback?: SimpleQueryRowsCallback): void; /** * Run a query scoped to your project. For manual pagination please refer to * {@link BigQuery#createQueryJob}. @@ -1480,15 +1489,6 @@ export class BigQuery extends common.Service { * const rows = data[0]; * }); */ - query(query: string, options?: QueryOptions): Promise; - query(query: Query, options?: QueryOptions): Promise; - query(query: string, options: QueryOptions, callback?: QueryRowsCallback): - void; - query( - query: Query, options: QueryOptions, - callback?: SimpleQueryRowsCallback): void; - query(query: string, callback?: QueryRowsCallback): void; - query(query: Query, callback?: SimpleQueryRowsCallback): void; query( query: string|Query, optionsOrCallback?: QueryOptions|SimpleQueryRowsCallback| @@ -1538,6 +1538,9 @@ promisifyAll(BigQuery, { exclude: ['dataset', 'date', 'datetime', 'job', 'time', 'timestamp'], }); +/** + * Date class for BigQuery. + */ export class BigQueryDate { value: string; constructor(value: BigQueryDateOptions|string) { @@ -1548,6 +1551,9 @@ export class BigQueryDate { } } +/** + * Timestamp class for BigQuery. + */ export class BigQueryTimestamp { value: string; constructor(value: Date|string) { @@ -1555,6 +1561,9 @@ export class BigQueryTimestamp { } } +/** + * Datetime class for BigQuery. + */ export class BigQueryDatetime { value: string; constructor(value: BigQueryDatetimeOptions|string) { @@ -1576,6 +1585,9 @@ export class BigQueryDatetime { } } +/** + * Time class for BigQuery. + */ export class BigQueryTime { value: string; constructor(value: BigQueryTimeOptions|string) { @@ -1622,7 +1634,7 @@ export {Table}; * The default export of the `@google-cloud/bigquery` package is the {@link * BigQuery} class. * - * See {@link BigQuery} and {@link ClientConfig} for client methods and + * See {@link BigQuery} and {@link BigQueryOptions} for client methods and * configuration options. * * @module {constructor} @google-cloud/bigquery diff --git a/src/job.ts b/src/job.ts index 697b54a4..221b3fb5 100644 --- a/src/job.ts +++ b/src/job.ts @@ -50,6 +50,22 @@ export interface QueryResultsOptions { timeoutMs?: number; } +/** + * @callback QueryResultsCallback + * @param {?Error} err An error returned while making this request. + * @param {array} rows The results of the job. + */ +/** + * @callback ManualQueryResultsCallback + * @param {?Error} err An error returned while making this request. + * @param {array} rows The results of the job. + * @param {?object} nextQuery A pre-made configuration object for your next + * request. This will be `null` if no additional results are available. + * If the query is not yet complete, you may get empty `rows` and + * non-`null` `nextQuery` that you should use for your next request. + * @param {object} apiResponse The full API response. + */ + /** * Job objects are returned from various places in the BigQuery API: * @@ -286,6 +302,8 @@ class Job extends Operation { paginator.streamify('getQueryResultsAsStream_'); } + cancel(): Promise; + cancel(callback: CancelCallback): void; /** * Cancel a job. Use {@link Job#getMetadata} to see if the cancel * completes successfully. See an example implementation below. @@ -316,8 +334,6 @@ class Job extends Operation { * const apiResponse = data[0]; * }); */ - cancel(): Promise; - cancel(callback: CancelCallback): void; cancel(callback?: CancelCallback): void|Promise { let qs; @@ -334,21 +350,10 @@ class Job extends Operation { callback!); } - /** - * @callback QueryResultsCallback - * @param {?Error} err An error returned while making this request. - * @param {array} rows The results of the job. - */ - /** - * @callback ManualQueryResultsCallback - * @param {?Error} err An error returned while making this request. - * @param {array} rows The results of the job. - * @param {?object} nextQuery A pre-made configuration object for your next - * request. This will be `null` if no additional results are available. - * If the query is not yet complete, you may get empty `rows` and - * non-`null` `nextQuery` that you should use for your next request. - * @param {object} apiResponse The full API response. - */ + getQueryResults(options?: QueryResultsOptions): Promise; + getQueryResults(options: QueryResultsOptions, callback: QueryRowsCallback): + void; + getQueryResults(callback: QueryRowsCallback): void; /** * Get the results of a job. * @@ -416,10 +421,6 @@ class Job extends Operation { * const rows = data[0]; * }); */ - getQueryResults(options?: QueryResultsOptions): Promise; - getQueryResults(options: QueryResultsOptions, callback: QueryRowsCallback): - void; - getQueryResults(callback: QueryRowsCallback): void; getQueryResults( optionsOrCallback?: QueryResultsOptions|QueryRowsCallback, cb?: QueryRowsCallback): void|Promise { diff --git a/src/table.ts b/src/table.ts index 3e5e2c49..c9ece2a7 100644 --- a/src/table.ts +++ b/src/table.ts @@ -575,6 +575,12 @@ class Table extends common.ServiceObject { return body; } + copy(destination: Table, metadata?: CopyTableMetadata): + Promise; + copy( + destination: Table, metadata: CopyTableMetadata, + callback: JobMetadataCallback): void; + copy(destination: Table, callback: JobMetadataCallback): void; /** * Copy data from one table to another, optionally creating that table. * @@ -622,12 +628,6 @@ class Table extends common.ServiceObject { * const apiResponse = data[0]; * }); */ - copy(destination: Table, metadata?: CopyTableMetadata): - Promise; - copy( - destination: Table, metadata: CopyTableMetadata, - callback: JobMetadataCallback): void; - copy(destination: Table, callback: JobMetadataCallback): void; copy( destination: Table, metadataOrCallback?: CopyTableMetadata|JobMetadataCallback, @@ -650,6 +650,12 @@ class Table extends common.ServiceObject { }); } + copyFrom(sourceTables: Table|Table[], metadata?: CopyTableMetadata): + Promise; + copyFrom( + sourceTables: Table|Table[], metadata: CopyTableMetadata, + callback: JobMetadataCallback): void; + copyFrom(sourceTables: Table|Table[], callback: JobMetadataCallback): void; /** * Copy data from multiple tables into this table. * @@ -701,12 +707,6 @@ class Table extends common.ServiceObject { * const apiResponse = data[0]; * }); */ - copyFrom(sourceTables: Table|Table[], metadata?: CopyTableMetadata): - Promise; - copyFrom( - sourceTables: Table|Table[], metadata: CopyTableMetadata, - callback: JobMetadataCallback): void; - copyFrom(sourceTables: Table|Table[], callback: JobMetadataCallback): void; copyFrom( sourceTables: Table|Table[], metadataOrCallback?: CopyTableMetadata|JobMetadataCallback, @@ -726,6 +726,12 @@ class Table extends common.ServiceObject { }); } + createCopyJob(destination: Table, metadata?: CreateCopyJobMetadata): + Promise; + createCopyJob( + destination: Table, metadata: CreateCopyJobMetadata, + callback: JobCallback): void; + createCopyJob(destination: Table, callback: JobCallback): void; /** * Copy data from one table to another, optionally creating that table. * @@ -778,12 +784,6 @@ class Table extends common.ServiceObject { * const apiResponse = data[1]; * }); */ - createCopyJob(destination: Table, metadata?: CreateCopyJobMetadata): - Promise; - createCopyJob( - destination: Table, metadata: CreateCopyJobMetadata, - callback: JobCallback): void; - createCopyJob(destination: Table, callback: JobCallback): void; createCopyJob( destination: Table, metadataOrCallback?: CreateCopyJobMetadata|JobCallback, @@ -832,6 +832,12 @@ class Table extends common.ServiceObject { this.bigQuery.createJob(body, callback!); } + createCopyFromJob(source: Table|Table[], metadata?: CopyTableMetadata): + Promise; + createCopyFromJob( + source: Table|Table[], metadata: CopyTableMetadata, + callback: JobCallback): void; + createCopyFromJob(source: Table|Table[], callback: JobCallback): void; /** * Copy data from multiple tables into this table. * @@ -891,12 +897,6 @@ class Table extends common.ServiceObject { * const apiResponse = data[1]; * }); */ - createCopyFromJob(source: Table|Table[], metadata?: CopyTableMetadata): - Promise; - createCopyFromJob( - source: Table|Table[], metadata: CopyTableMetadata, - callback: JobCallback): void; - createCopyFromJob(source: Table|Table[], callback: JobCallback): void; createCopyFromJob( source: Table|Table[], metadataOrCallback?: CopyTableMetadata|JobCallback, cb?: JobCallback): void|Promise { @@ -950,6 +950,12 @@ class Table extends common.ServiceObject { this.bigQuery.createJob(body, callback!); } + createExtractJob(destination: File, options?: CreateExtractJobOptions): + Promise; + createExtractJob( + destination: File, options: CreateExtractJobOptions, + callback: JobCallback): void; + createExtractJob(destination: File, callback: JobCallback): void; /** * Export table to Cloud Storage. * @@ -1028,12 +1034,6 @@ class Table extends common.ServiceObject { * const apiResponse = data[1]; * }); */ - createExtractJob(destination: File, options?: CreateExtractJobOptions): - Promise; - createExtractJob( - destination: File, options: CreateExtractJobOptions, - callback: JobCallback): void; - createExtractJob(destination: File, callback: JobCallback): void; createExtractJob( destination: File, optionsOrCallback?: CreateExtractJobOptions|JobCallback, @@ -1107,6 +1107,15 @@ class Table extends common.ServiceObject { this.bigQuery.createJob(body, callback!); } + createLoadJob(source: string, metadata?: JobLoadMetadata): Writable; + createLoadJob(source: File, metadata?: JobLoadMetadata): Promise; + createLoadJob( + source: string, metadata: JobLoadMetadata, + callback: JobCallback): Writable; + createLoadJob(source: File, metadata: JobLoadMetadata, callback: JobCallback): + void; + createLoadJob(source: string, callback: JobCallback): Writable; + createLoadJob(source: File, callback: JobCallback): void; /** * Load data from a local file or Storage {@link * https://cloud.google.com/nodejs/docs/reference/storage/latest/File File}. @@ -1193,15 +1202,6 @@ class Table extends common.ServiceObject { * const apiResponse = data[1]; * }); */ - createLoadJob(source: string, metadata?: JobLoadMetadata): Writable; - createLoadJob(source: File, metadata?: JobLoadMetadata): Promise; - createLoadJob( - source: string, metadata: JobLoadMetadata, - callback: JobCallback): Writable; - createLoadJob(source: File, metadata: JobLoadMetadata, callback: JobCallback): - void; - createLoadJob(source: string, callback: JobCallback): Writable; - createLoadJob(source: File, callback: JobCallback): void; createLoadJob( source: string|File, metadataOrCallback?: JobLoadMetadata|JobCallback, cb?: JobCallback): void|Promise|Writable { @@ -1286,6 +1286,8 @@ class Table extends common.ServiceObject { this.bigQuery.createJob(body, callback); } + createQueryJob(options: Query): Promise; + createQueryJob(options: Query, callback: JobCallback): void; /** * Run a query as a job. No results are immediately returned. Instead, your * callback will be executed with a {@link Job} object that you must @@ -1294,8 +1296,6 @@ class Table extends common.ServiceObject { * * See {@link BigQuery#createQueryJob} for full documentation of this method. */ - createQueryJob(options: Query): Promise; - createQueryJob(options: Query, callback: JobCallback): void; createQueryJob(options: Query, callback?: JobCallback): void|Promise { return this.dataset.createQueryJob(options, callback!); @@ -1481,6 +1481,12 @@ class Table extends common.ServiceObject { return stream; } + extract(destination: File, options?: CreateExtractJobOptions): + Promise; + extract( + destination: File, options: CreateExtractJobOptions, + callback?: JobMetadataCallback): void; + extract(destination: File, callback?: JobMetadataCallback): void; /** * Export table to Cloud Storage. * @@ -1550,12 +1556,6 @@ class Table extends common.ServiceObject { * const apiResponse = data[0]; * }); */ - extract(destination: File, options?: CreateExtractJobOptions): - Promise; - extract( - destination: File, options: CreateExtractJobOptions, - callback?: JobMetadataCallback): void; - extract(destination: File, callback?: JobMetadataCallback): void; extract( destination: File, optionsOrCallback?: CreateExtractJobOptions|JobMetadataCallback, @@ -1575,6 +1575,9 @@ class Table extends common.ServiceObject { }); } + getRows(options?: GetRowsOptions): Promise; + getRows(options: GetRowsOptions, callback: RowsCallback): void; + getRows(callback: RowsCallback): void; /** * Retrieves table data from a specified set of rows. The rows are returned to * your callback as an array of objects matching your table's schema. @@ -1625,9 +1628,6 @@ class Table extends common.ServiceObject { * const rows = data[0]; * }); */ - getRows(options?: GetRowsOptions): Promise; - getRows(options: GetRowsOptions, callback: RowsCallback): void; - getRows(callback: RowsCallback): void; getRows(optionsOrCallback?: GetRowsOptions|RowsCallback, cb?: RowsCallback): void|Promise { const options = @@ -1679,6 +1679,12 @@ class Table extends common.ServiceObject { }); } + insert(rows: RowMetadata|RowMetadata[], options?: InsertRowsOptions): + Promise; + insert( + rows: RowMetadata|RowMetadata[], options: InsertRowsOptions, + callback: ApiResponseCallback): void; + insert(rows: RowMetadata|RowMetadata[], callback: ApiResponseCallback): void; /** * Stream data into BigQuery one record at a time without running a load job. * @@ -1812,12 +1818,6 @@ class Table extends common.ServiceObject { * } * }); */ - insert(rows: RowMetadata|RowMetadata[], options?: InsertRowsOptions): - Promise; - insert( - rows: RowMetadata|RowMetadata[], options: InsertRowsOptions, - callback: ApiResponseCallback): void; - insert(rows: RowMetadata|RowMetadata[], callback: ApiResponseCallback): void; insert( rows: RowMetadata|RowMetadata[], optionsOrCallback?: InsertRowsOptions|ApiResponseCallback, @@ -1921,6 +1921,12 @@ class Table extends common.ServiceObject { }); } + load(source: string|File, metadata?: JobLoadMetadata): + Promise; + load( + source: string|File, metadata: JobLoadMetadata, + callback: JobMetadataCallback): void; + load(source: string|File, callback: JobMetadataCallback): void; /** * Load data from a local file or Storage {@link * https://cloud.google.com/nodejs/docs/reference/storage/latest/File File}. @@ -1998,12 +2004,6 @@ class Table extends common.ServiceObject { * const apiResponse = data[0]; * }); */ - load(source: string|File, metadata?: JobLoadMetadata): - Promise; - load( - source: string|File, metadata: JobLoadMetadata, - callback: JobMetadataCallback): void; - load(source: string|File, callback: JobMetadataCallback): void; load( source: string|File, metadataOrCallback?: JobLoadMetadata|JobMetadataCallback, @@ -2025,6 +2025,8 @@ class Table extends common.ServiceObject { }); } + query(query: Query): Promise; + query(query: Query, callback: SimpleQueryRowsCallback): void; /** * Run a query scoped to your dataset. * @@ -2033,13 +2035,16 @@ class Table extends common.ServiceObject { * @param {function} [callback] See {@link BigQuery#query} for full documentation of this method. * @returns {Promise} */ - query(query: Query): Promise; - query(query: Query, callback: SimpleQueryRowsCallback): void; query(query: Query, callback?: SimpleQueryRowsCallback): void|Promise { this.dataset.query(query, callback!); } + setMetadata(metadata: SetTableMetadataOptions): + Promise; + setMetadata( + metadata: SetTableMetadataOptions, + callback: common.ResponseCallback): void; /** * Set the metadata on the table. * @@ -2083,11 +2088,6 @@ class Table extends common.ServiceObject { * const apiResponse = data[1]; * }); */ - setMetadata(metadata: SetTableMetadataOptions): - Promise; - setMetadata( - metadata: SetTableMetadataOptions, - callback: common.ResponseCallback): void; setMetadata( metadata: SetTableMetadataOptions, callback?: common.ResponseCallback): void|Promise {