Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix the broken link and improve jsdocs #1402

Merged
merged 4 commits into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,26 +124,26 @@ class Backup {
* expireTime The expire time of the backup.
* @property {string|number|google.protobuf.Timestamp|external:PreciseDate}
* versionTime Take a backup of the state of the database at this time.
* @property {databaseAdmin.spanner.admin.database.v1.ICreateBackupEncryptionConfig}
* @property {google.spanner.admin.database.v1.ICreateBackupEncryptionConfig}
* encryptionConfig An encryption configuration describing the
* encryption type and key resources in Cloud KMS to be used to encrypt
* the backup.
* @property {CallOptions} [gaxOptions] The request configuration options,
* @property {object} [gaxOptions] The request configuration options,
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
* for more details.
*/
/**
* @typedef {array} CreateBackupResponse
* @property {Backup} 0 The new {@link Backup}.
* @property {Operation} 1 An {@link Operation} object that can be used to check
* @property {google.longrunning.Operation} 1 An {@link Operation} object that can be used to check
* the status of the request.
* @property {object} 2 The full API response.
*/
/**
* @callback CreateBackupCallback
* @param {?Error} err Request error, if any.
* @param {Backup} backup The new {@link Backup}.
* @param {Operation} operation An {@link Operation} object that can be used to
* @param {google.longrunning.Operation} operation An {@link Operation} object that can be used to
* check the status of the request.
* @param {object} apiResponse The full API response.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/batch-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class BatchTransaction extends Snapshot {
}
/**
* @typedef {object} TransactionIdentifier
* @property {string} session The full session name.
* @property {string|Session} session The full session name.
* @property {string} transaction The transaction ID.
* @property {string|Date} readTimestamp The transaction read timestamp.
*/
Expand Down
112 changes: 77 additions & 35 deletions src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ type IRestoreInfoTranslatedEnum = TranslateEnumKeys<
typeof databaseAdmin.spanner.admin.database.v1.RestoreSourceType
>;

type GetMetadataResponse = [IDatabaseTranslatedEnum];
type GetMetadataCallback = RequestCallback<IDatabaseTranslatedEnum>;
type GetDatabaseMetadataResponse = [IDatabaseTranslatedEnum];
type GetDatabaseMetadataCallback = RequestCallback<IDatabaseTranslatedEnum>;

type GetSchemaCallback = RequestCallback<
string,
Expand All @@ -170,7 +170,7 @@ type GetSessionsResponse = PagedResponse<
>;

export type GetDatabaseConfig = GetConfig &
databaseAdmin.spanner.admin.database.v1.GetDatabaseRequest & {
databaseAdmin.spanner.admin.database.v1.IGetDatabaseRequest & {
gaxOptions?: CallOptions;
};
type DatabaseCloseResponse = [google.protobuf.IEmpty];
Expand Down Expand Up @@ -247,7 +247,7 @@ export interface RestoreOptions {
* @param {string} name Name of the database.
* @param {SessionPoolOptions|SessionPoolInterface} options Session pool
* configuration options or custom pool interface.
* @param {spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptions} queryOptions
* @param {google.spanner.v1.ExecuteSqlRequest.IQueryOptions} queryOptions
* The default query options to use for queries on the database.
*
* @example
Expand Down Expand Up @@ -407,6 +407,9 @@ class Database extends common.GrpcServiceObject {
* @property {number} count The number of sessions to create.
* @property {object.<string, string>} [labels] Labels to apply to each
* session.
* @property {object} [gaxOptions] Request configuration options,
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
* for more details.
*/
/**
* @typedef {array} BatchCreateSessionsResponse
Expand Down Expand Up @@ -505,7 +508,7 @@ class Database extends common.GrpcServiceObject {
* @see {@link BatchTransaction#identifier} to generate an identifier.
*
* @param {TransactionIdentifier} identifier The transaction identifier.
* @param {TransactionOptions} [options] [Transaction options](https://cloud.google.com/spanner/docs/timestamp-bounds).
* @param {object} [options] [Transaction options](https://cloud.google.com/spanner/docs/timestamp-bounds).
* @returns {BatchTransaction} A batch transaction object.
*
* @example
Expand Down Expand Up @@ -602,7 +605,7 @@ class Database extends common.GrpcServiceObject {
/**
* Create a transaction that can be used for batch querying.
*
* @param {TransactionOptions} [options] [Transaction options](https://cloud.google.com/spanner/docs/timestamp-bounds).
* @param {object} [options] [Transaction options](https://cloud.google.com/spanner/docs/timestamp-bounds).
* @param {CreateTransactionCallback} [callback] Callback function.
* @returns {Promise<CreateTransactionResponse>}
*/
Expand Down Expand Up @@ -685,7 +688,7 @@ class Database extends common.GrpcServiceObject {
* @see {@link v1.SpannerClient#createSession}
* @see [CreateSession API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.CreateSession)
*
* @param {object} [options] Configuration object.
* @param {CreateSessionOptions} [options] Configuration object.
* @param {CreateSessionCallback} [callback] Callback function.
* @returns {Promise<CreateSessionResponse>}
*
Expand Down Expand Up @@ -763,15 +766,15 @@ class Database extends common.GrpcServiceObject {
/**
* @typedef {array} CreateTableResponse
* @property {Table} 0 The new {@link Table}.
* @property {Operation} 1 An {@link Operation} object that can be used to check
* @property {google.longrunning.Operation} 1 An {@link Operation} object that can be used to check
* the status of the request.
* @property {object} 2 The full API response.
*/
/**
* @callback CreateTableCallback
* @param {?Error} err Request error, if any.
* @param {Table} table The new {@link Table}.
* @param {Operation} operation An {@link Operation} object that can be used to
* @param {google.longrunning.Operation} operation An {@link Operation} object that can be used to
* check the status of the request.
* @param {object} apiResponse The full API response.
*/
Expand Down Expand Up @@ -874,6 +877,15 @@ class Database extends common.GrpcServiceObject {
delete(gaxOptions?: CallOptions): Promise<DatabaseDeleteResponse>;
delete(callback: DatabaseDeleteCallback): void;
delete(gaxOptions: CallOptions, callback: DatabaseDeleteCallback): void;
/**
* @typedef {array} DatabaseDeleteResponse
* @property {object} 0 The full API response.
*/
/**
* @callback DatabaseDeleteCallback
* @param {?Error} err Request error, if any.
* @param {object} apiResponse The full API response.
*/
/**
* Delete the database.
*
Expand Down Expand Up @@ -1019,6 +1031,9 @@ class Database extends common.GrpcServiceObject {
* @param {options} [options] Configuration object.
* @param {boolean} [options.autoCreate=false] Automatically create the
* object if it does not exist.
* @param {object} [options.gaxOptions] Request configuration options,
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
* for more details.
* @param {GetDatabaseCallback} [callback] Callback function.
* @returns {Promise<GetDatabaseResponse>}
*
Expand Down Expand Up @@ -1077,9 +1092,12 @@ class Database extends common.GrpcServiceObject {
callback!(null, this, metadata as r.Response);
});
}
getMetadata(gaxOptions?: CallOptions): Promise<GetMetadataResponse>;
getMetadata(callback: GetMetadataCallback): void;
getMetadata(gaxOptions: CallOptions, callback: GetMetadataCallback): void;
getMetadata(gaxOptions?: CallOptions): Promise<GetDatabaseMetadataResponse>;
getMetadata(callback: GetDatabaseMetadataCallback): void;
getMetadata(
gaxOptions: CallOptions,
callback: GetDatabaseMetadataCallback
): void;
/**
* @typedef {array} GetDatabaseMetadataResponse
* @property {object} 0 The {@link Database} metadata.
Expand All @@ -1101,8 +1119,8 @@ class Database extends common.GrpcServiceObject {
* @param {object} [gaxOptions] Request configuration options,
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
* for more details.
* @param {GetMetadataCallback} [callback] Callback function.
* @returns {Promise<GetMetadataResponse>}
* @param {GetDatabaseMetadataCallback} [callback] Callback function.
* @returns {Promise<GetDatabaseMetadataResponse>}
*
* @example
* const {Spanner} = require('@google-cloud/spanner');
Expand All @@ -1128,12 +1146,12 @@ class Database extends common.GrpcServiceObject {
* });
*/
getMetadata(
gaxOptionsOrCallback?: CallOptions | GetMetadataCallback,
cb?: GetMetadataCallback
): void | Promise<GetMetadataResponse> {
gaxOptionsOrCallback?: CallOptions | GetDatabaseMetadataCallback,
cb?: GetDatabaseMetadataCallback
): void | Promise<GetDatabaseMetadataResponse> {
const callback =
typeof gaxOptionsOrCallback === 'function'
? (gaxOptionsOrCallback as GetMetadataCallback)
? (gaxOptionsOrCallback as GetDatabaseMetadataCallback)
: cb;
const gaxOpts =
typeof gaxOptionsOrCallback === 'object'
Expand Down Expand Up @@ -1172,6 +1190,12 @@ class Database extends common.GrpcServiceObject {
*
* @typedef {object} IRestoreInfoTranslatedEnum
*/
/**
* @callback GetRestoreInfoCallback
* @param {?Error} err Request error, if any.
* @param {IRestoreInfoTranslatedEnum | undefined} restoreInfo Contains the restore
* information for the database if it was restored from a backup.
*/
/**
* Retrieves the restore information of the database.
*
Expand Down Expand Up @@ -1212,6 +1236,12 @@ class Database extends common.GrpcServiceObject {
>;
getState(callback: GetStateCallback): void;
getState(options: CallOptions, callback: GetStateCallback): void;
/**
* @callback GetStateCallback
* @param {?Error} err Request error, if any.
* @param {EnumKey<typeof, google.spanner.admin.database.v1.Database.State> | undefined} state
* Contains the current state of the database if the state is defined.
*/
/**
* Retrieves the state of the database.
*
Expand All @@ -1225,7 +1255,7 @@ class Database extends common.GrpcServiceObject {
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
* for more details.
* @param {GetStateCallback} [callback] Callback function.
* @returns {Promise<EnumKey<typeof, databaseAdmin.spanner.admin.database.v1.Database.State> | undefined>}
* @returns {Promise<EnumKey<typeof, google.spanner.admin.database.v1.Database.State> | undefined>}
* When resolved, contains the current state of the database if the state
* is defined.
*
Expand Down Expand Up @@ -1870,7 +1900,7 @@ class Database extends common.GrpcServiceObject {
): void;
/**
* @typedef {object} RestoreOptions
* @property {databaseAdmin.spanner.admin.database.v1.IRestoreDatabaseEncryptionConfig}
* @property {google.spanner.admin.database.v1.IRestoreDatabaseEncryptionConfig}
* encryptionConfig An encryption configuration describing
* the encryption type and key resources in Cloud KMS used to
* encrypt/decrypt the database to restore to.
Expand All @@ -1881,15 +1911,15 @@ class Database extends common.GrpcServiceObject {
/**
* @typedef {array} RestoreDatabaseResponse
* @property {Database} 0 The new {@link Database}.
* @property {Operation} 1 An {@link Operation} object that can be used to check
* @property {google.longrunning.Operation} 1 An {@link Operation} object that can be used to check
* the status of the request.
* @property {object} 2 The full API response.
*/
/**
* @callback RestoreDatabaseCallback
* @param {?Error} err Request error, if any.
* @param {Database} database The new {@link Database}.
* @param {Operation} operation An {@link Operation} object that can be used to
* @param {google.longrunning.Operation} operation An {@link Operation} object that can be used to
* check the status of the request.
* @param {object} apiResponse The full API response.
*/
Expand All @@ -1899,11 +1929,10 @@ class Database extends common.GrpcServiceObject {
* When this call completes, the restore will have commenced but will not
* necessarily have completed.
*
* @param backupPath The path of the backup to restore.
* @param {object} [gaxOptions] Request configuration options,
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
* for more details.
* @returns Promise<RestoreDatabaseResponse> When resolved, contains the restore operation.
* @param {string} backupPath The path of the backup to restore.
* @param {RestoreOptions} [options] Request configuration options.
* @param {RestoreDatabaseCallback} [callback] Callback function.
* @returns {Promise<RestoreDatabaseResponse>} When resolved, contains the restore operation.
*
* @example
* const {Spanner} = require('@google-cloud/spanner');
Expand Down Expand Up @@ -2006,7 +2035,7 @@ class Database extends common.GrpcServiceObject {
* @property {Array<Row | Json>} 0 Rows are returned as an array objects. Each
* object has a `name` and `value` property. To get a serialized object,
* call `toJSON()`.
* @property {?ResultSetStats} 1 Query statistics, if the query is executed in
* @property {?google.spanner.v1.IResultSetStats} 1 Query statistics, if the query is executed in
* PLAN or PROFILE mode.
*/
/**
Expand All @@ -2015,7 +2044,7 @@ class Database extends common.GrpcServiceObject {
* @param {Array<Row | Json>} rows Rows are returned as an array of objects.
* Each object has a `name` and `value` property. To get a serialized
* object, call `toJSON()`.
* @param {?ResultSetStats} stats Query statistics, if the query is executed
* @param {?google.spanner.v1.IResultSetStats} stats Query statistics, if the query is executed
* in PLAN or PROFILE mode.
*/
/**
Expand Down Expand Up @@ -2187,11 +2216,8 @@ class Database extends common.GrpcServiceObject {
*
* @see {@link Transaction#runUpdate}
*
* @param {string|object} query A DML statement or
* [`ExecuteSqlRequest`](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ExecuteSqlRequest)
* object.
* @param {object} [query.params] A map of parameter name to values.
* @param {object} [query.types] A map of parameter types.
* @param {string|ExecuteSqlRequest} query A DML statement or
* {@link ExecuteSqlRequest} object.
* @param {RunUpdateCallback} [callback] Callback function.
* @returns {Promise<RunUpdateResponse>}
*/
Expand Down Expand Up @@ -2255,7 +2281,7 @@ class Database extends common.GrpcServiceObject {
* @param {string|ExecuteSqlRequest} query A SQL query or
* {@link ExecuteSqlRequest} object.
* @param {TimestampBounds} [options] Snapshot timestamp bounds.
* @returns {ReadableStream} A readable stream that emits rows.
* @returns {PartialResultStream} A readable stream that emits rows.
*
* @example
* const {Spanner} = require('@google-cloud/spanner');
Expand Down Expand Up @@ -2422,6 +2448,17 @@ class Database extends common.GrpcServiceObject {
options: RunTransactionOptions,
runFn: RunTransactionCallback
): void;
/**
* @typedef {object} RunTransactionOptions
* @property {number} [timeout] The maximum amount of time (in ms) that a
* {@link Transaction} should be ran for.
*/
/**
* @callback RunTransactionCallback
* @param {?Error} err An error returned while making this request.
* @param {Transaction} transaction The transaction object. The transaction has
* already been created, and is ready to be queried and committed against.
*/
/**
* A transaction in Cloud Spanner is a set of reads and writes that execute
* atomically at a single logical point in time across columns, rows, and tables
Expand Down Expand Up @@ -2548,6 +2585,11 @@ class Database extends common.GrpcServiceObject {
options: RunTransactionOptions,
runFn: AsyncRunTransactionCallback<T>
): Promise<T>;
/**
* @callback AsyncRunTransactionCallback
* @param {Transaction} transaction The transaction object. The transaction has
* already been created, and is ready to be queried and committed against.
*/
/**
* A transaction in Cloud Spanner is a set of reads and writes that execute
* atomically at a single logical point in time across columns, rows, and tables
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,17 +297,17 @@ class Spanner extends GrpcService {
/**
* @typedef {array} CreateInstanceResponse
* @property {Instance} 0 The new {@link Instance}.
* @property {Operation} 1 An operation object that can be used to check
* @property {google.longrunning.Operation} 1 An operation object that can be used to check
* the status of the request.
* @property {IOperation} 2 The full API response.
* @property {google.longrunning.IOperation} 2 The full API response.
*/
/**
* @callback CreateInstanceCallback
* @param {?Error} err Request error, if any.
* @param {Instance} instance The new {@link Instance}.
* @param {Operation} operation An operation object that can be used to
* @param {google.longrunning.Operation} operation An operation object that can be used to
* check the status of the request.
* @param {IOperation} apiResponse The full API response.
* @param {google.longrunning.IOperation} apiResponse The full API response.
*/
/**
* Create an instance.
Expand Down