Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@google-cloud/spanner

Package Overview
Dependencies
Maintainers
1
Versions
126
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/spanner - npm Package Compare versions

Comparing version 6.2.0 to 6.3.0

build/src/instance-config.d.ts

206

build/src/index.d.ts

@@ -25,2 +25,3 @@ /*!

import { Instance, CreateInstanceCallback, CreateInstanceResponse } from './instance';
import { InstanceConfig, CreateInstanceConfigCallback, CreateInstanceConfigResponse } from './instance-config';
import { grpc, GrpcClientOptions, CallOptions } from 'google-gax';

@@ -46,2 +47,5 @@ import { google, google as instanceAdmin } from '../protos/protos';

export declare type GetInstanceConfigCallback = NormalCallback<IInstanceConfig>;
export declare type GetInstanceConfigOperationsOptions = PagedOptionsWithFilter;
export declare type GetInstanceConfigOperationsResponse = PagedResponse<IOperation, instanceAdmin.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse>;
export declare type GetInstanceConfigOperationsCallback = PagedCallback<IOperation, instanceAdmin.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse>;
export interface SpannerOptions extends GrpcClientOptions {

@@ -72,2 +76,13 @@ apiEndpoint?: string;

}
export interface CreateInstanceConfigRequest {
displayName?: string;
replicas?: google.spanner.admin.instance.v1.IReplicaInfo[];
baseConfig?: string;
labels?: {
[k: string]: string;
} | null;
etag?: string;
validateOnly?: boolean;
gaxOptions?: CallOptions;
}
/**

@@ -139,2 +154,3 @@ * Translates enum values to string keys.

instances_: Map<string, Instance>;
instanceConfigs_: Map<string, InstanceConfig>;
projectIdReplaced_: boolean;

@@ -382,2 +398,102 @@ projectFormattedName_: string;

/**
* Config for the new instance config.
*
* @typedef {object} CreateInstanceConfigRequest
* @property {string} [displayName] The name of this instance configuration as
* it appears in the user interface.
* @property {google.spanner.admin.instance.v1.IReplicaInfo[]} [replicas] The
* geographic placement of nodes in this instance configuration and their
* replication properties.
* @property {string} [baseConfig] Base configuration name,
* e.g. projects/<project_name>/instanceConfigs/nam3 based on which this
* configuration is created.
* @property {Object.<string, string>} [labels] Cloud Labels are a flexible
* and lightweight mechanism for organizing cloud resources into groups
* that reflect a customer's organizational needs and deployment
* strategies. Cloud Labels can be used to filter collections of
* resources. They can be used to control how resource metrics are
* aggregated. And they can be used as arguments to policy management
* rules (e.g. route, firewall, load balancing, etc.).
* @property {string} [etag] etag is used for optimistic concurrency control
* as a way to help prevent simultaneous updates of a instance config from
* overwriting each other.
* @property {boolean} [validateOnly] An option to validate, but not actually
* execute, a request, and provide the same response.
*/
/**
* @typedef {array} CreateInstanceConfigResponse
* @property {InstanceConfig} 0 The new {@link google.spanner.admin.instance.v1.InstanceConfig}.
* @property {google.longrunning.Operation} 1 An operation object that can be
* used to check the status of the request.
* @property {google.longrunning.IOperation} 2 The full API response.
*/
/**
* @callback CreateInstanceConfigCallback
* @param {?Error} err Request error, if any.
* @param {InstanceConfig} instanceConfig The new {@link google.spanner.admin.instance.v1.InstanceConfig}.
* @param {google.longrunning.Operation} operation An operation object that
* can be used to check the status of the request.
* @param {google.longrunning.IOperation} apiResponse The full API response.
*/
/**
* Create an instance config.
*
* Wrapper around {@link v1.InstanceAdminClient#createInstanceConfig}.
*
* @see {@link v1.InstanceAdminClient#createInstanceConfig}
* @see [CreateInstanceConfig API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.CreateInstanceConfig)
*
* @throws {GoogleError} If a name is not provided.
* @throws {GoogleError} If a configuration object is not provided.
* @throws {GoogleError} If a base config is not provided in the configuration
* object.
*
* @param {string} name The name of the instance config to be created.
* @param {CreateInstanceConfigRequest} config Configuration object.
* @param {CreateInstanceConfigCallback} [callback] Callback function.
* @returns {Promise<CreateInstanceConfigResponse>}
*
* @example
* ```
* const {Spanner} = require('@google-cloud/spanner');
* const spanner = new Spanner();
*
* const [baseInstanceConfig] =
* await spanner.getInstanceConfig(baseInstanceConfigId);
* const config = {
* baseConfig: baseInstanceConfig.name,
* replicas: baseInstanceConfig.replicas.concat(baseInstanceConfig.optionalReplicas[0])
* };
*
* function callback(err, instance, operation, apiResponse) {
* if (err) {
* // Error handling omitted.
* }
*
* operation
* .on('error', function(err) {})
* .on('complete', function() {
* // Instance created successfully.
* });
* }
*
* spanner.createInstanceConfig('custom-new-instance-config', config, callback);
*
* //-
* // If the callback is omitted, we'll return a Promise.
* //-
* spanner.createInstanceConfig('custom-new-instance-config', config)
* .then(function(data) {
* const instanceConfig = data[0];
* const operation = data[1];
* return operation.promise();
* })
* .then(function() {
* // Instance config created successfully.
* });
* ```
*/
createInstanceConfig(name: string, config: CreateInstanceConfigRequest): Promise<CreateInstanceConfigResponse>;
createInstanceConfig(name: string, config: CreateInstanceConfigRequest, callback: CreateInstanceConfigCallback): void;
/**
* Lists the supported instance configurations for a given project.

@@ -564,2 +680,68 @@ *

/**
* Query object for listing instance config operations.
*
* @typedef {object} GetInstanceConfigOperationsOptions
* @property {string} [filter] An expression for filtering the results of the
* request. Filter can be configured as outlined in
* {@link v1.DatabaseAdminClient#listInstanceConfigOperations}.
* @property {number} [pageSize] Maximum number of results per page.
* @property {string} [pageToken] A previously-returned page token
* representing part of the larger set of results to view.
* @property {object} [gaxOptions] Request configuration options,
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
* for more details.
*/
/**
* @typedef {array} GetInstanceConfigOperationsResponse
* @property {google.longrunning.IOperation[]} 0 Array of {@link IOperation} instances.
* @property {object} 1 A query object to receive more results.
* @property {object} 2 The full API response.
*/
/**
* @callback GetInstanceConfigOperationsCallback
* @param {?Error} err Request error, if any.
* @param {google.longrunning.IOperation[]} 0 Array of {@link IOperation} instances.
* @param {object} nextQuery A query object to receive more results.
* @param {object} apiResponse The full API response.
*/
/**
* List pending and completed instance config operations.
*
* @see {@link #listOperations}
*
* @param {GetInstanceConfigOperationsOptions} [options] The query object for
* listing InstanceConfig operations.
* @param {gax.CallOptions} [options.gaxOptions] The request configuration
* options, See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
* for more details.
* @returns {Promise<GetInstanceConfigOperationsResponse>} When resolved,
* contains a paged list of InstanceConfig operations.
*
* @example
* ```
* const {Spanner} = require('@google-cloud/spanner');
* const spanner = new Spanner();
* const [operations] = await spanner.getInstanceConfigOperations();
*
* //-
* // To manually handle pagination, set autoPaginate:false in gaxOptions.
* //-
* let pageToken = undefined;
* do {
* const [operations, , response] = await spanner.getInstanceConfigOperations({
* pageSize: 3,
* pageToken,
* gaxOptions: {autoPaginate: false},
* });
* operations.forEach(operation => {
* // Do something with operation
* });
* pageToken = response.nextPageToken;
* } while (pageToken);
* ```
*/
getInstanceConfigOperations(options?: GetInstanceConfigOperationsOptions): Promise<GetInstanceConfigOperationsResponse>;
getInstanceConfigOperations(callback: GetInstanceConfigOperationsCallback): void;
getInstanceConfigOperations(options: GetInstanceConfigOperationsOptions, callback: GetInstanceConfigOperationsCallback): void;
/**
* Get a reference to an Instance object.

@@ -581,2 +763,18 @@ *

/**
* Get a reference to an InstanceConfig object.
*
* @throws {GoogleError} If a name is not provided.
*
* @param {string} name The name of the instance config.
* @returns {InstanceConfig} An InstanceConfig object.
*
* @example
* ```
* const {Spanner} = require('@google-cloud/spanner');
* const spanner = new Spanner();
* const instanceConfig = spanner.instanceConfig('my-instance-config');
* ```
*/
instanceConfig(name: string): InstanceConfig;
/**
* Prepare a gapic request. This will cache the GAX client and replace

@@ -777,2 +975,10 @@ * {{projectId}} placeholders, if necessary.

/**
* {@link InstanceConfig} class.
*
* @name Spanner.InstanceConfig
* @see InstanceConfig
* @type {Constructor}
*/
export { InstanceConfig };
/**
* {@link Database} class.

@@ -779,0 +985,0 @@ *

111

build/src/index.js

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.protos = exports.v1 = exports.Transaction = exports.Snapshot = exports.PartitionedDml = exports.Table = exports.SessionPool = exports.Session = exports.Backup = exports.Database = exports.Instance = exports.Spanner = void 0;
exports.protos = exports.v1 = exports.Transaction = exports.Snapshot = exports.PartitionedDml = exports.Table = exports.SessionPool = exports.Session = exports.Backup = exports.Database = exports.InstanceConfig = exports.Instance = exports.Spanner = void 0;
const service_1 = require("./common-grpc/service");

@@ -36,2 +36,4 @@ const precise_date_1 = require("@google-cloud/precise-date");

Object.defineProperty(exports, "Instance", { enumerable: true, get: function () { return instance_1.Instance; } });
const instance_config_1 = require("./instance-config");
Object.defineProperty(exports, "InstanceConfig", { enumerable: true, get: function () { return instance_config_1.InstanceConfig; } });
const google_gax_1 = require("google-gax");

@@ -148,2 +150,3 @@ const protos_1 = require("../protos/protos");

this.instances_ = new Map();
this.instanceConfigs_ = new Map();
this.projectIdReplaced_ = false;

@@ -343,2 +346,49 @@ this.projectFormattedName_ = 'projects/' + this.projectId;

}
createInstanceConfig(name, config, callback) {
if (!name) {
throw new google_gax_1.GoogleError('A name is required to create an instance config.');
}
if (!config) {
throw new google_gax_1.GoogleError([
'A configuration object is required to create an instance config.',
].join(''));
}
if (!config.baseConfig) {
throw new google_gax_1.GoogleError(['Base instance config is required to create an instance config.'].join(''));
}
const formattedName = instance_config_1.InstanceConfig.formatName_(this.projectId, name);
const displayName = config.displayName || formattedName.split('/').pop();
const reqOpts = {
parent: this.projectFormattedName_,
instanceConfigId: formattedName.split('/').pop(),
instanceConfig: extend({
name: formattedName,
displayName,
}, config),
validateOnly: config.validateOnly,
};
if (config.baseConfig.indexOf('/') === -1) {
reqOpts.instanceConfig.baseConfig = `projects/${this.projectId}/instanceConfigs/${config.baseConfig}`;
}
// validateOnly need not be passed in if it is null.
if (reqOpts.validateOnly === null || reqOpts.validateOnly === undefined)
delete reqOpts.validateOnly;
// validateOnly and gaxOptions are not fields in InstanceConfig.
delete reqOpts.instanceConfig.validateOnly;
delete reqOpts.instanceConfig.gaxOptions;
this.request({
client: 'InstanceAdminClient',
method: 'createInstanceConfig',
reqOpts,
gaxOpts: config.gaxOptions,
headers: this.resourceHeader_,
}, (err, operation, resp) => {
if (err) {
callback(err, null, null, resp);
return;
}
const instanceConfig = this.instanceConfig(formattedName);
callback(null, instanceConfig, operation, resp);
});
}
getInstanceConfigs(optionsOrCallback, cb) {

@@ -455,2 +505,35 @@ const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;

}
getInstanceConfigOperations(optionsOrCallback, cb) {
const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
const options = typeof optionsOrCallback === 'object'
? optionsOrCallback
: {};
const gaxOpts = extend(true, {}, options.gaxOptions);
let reqOpts = extend({}, options, {
parent: this.projectFormattedName_,
});
delete reqOpts.gaxOptions;
// Copy over pageSize and pageToken values from gaxOptions.
// However, values set on options take precedence.
if (gaxOpts) {
reqOpts = extend({}, {
pageSize: gaxOpts.pageSize,
pageToken: gaxOpts.pageToken,
}, reqOpts);
delete gaxOpts.pageSize;
delete gaxOpts.pageToken;
}
this.request({
client: 'InstanceAdminClient',
method: 'listInstanceConfigOperations',
reqOpts,
gaxOpts,
headers: this.resourceHeader_,
}, (err, operations, nextPageRequest, ...args) => {
const nextQuery = nextPageRequest
? extend({}, options, nextPageRequest)
: null;
callback(err, operations, nextQuery, ...args);
});
}
/**

@@ -482,2 +565,27 @@ * Get a reference to an Instance object.

/**
* Get a reference to an InstanceConfig object.
*
* @throws {GoogleError} If a name is not provided.
*
* @param {string} name The name of the instance config.
* @returns {InstanceConfig} An InstanceConfig object.
*
* @example
* ```
* const {Spanner} = require('@google-cloud/spanner');
* const spanner = new Spanner();
* const instanceConfig = spanner.instanceConfig('my-instance-config');
* ```
*/
instanceConfig(name) {
if (!name) {
throw new google_gax_1.GoogleError('A name is required to access an InstanceConfig object.');
}
const key = name.split('/').pop();
if (!this.instanceConfigs_.has(key)) {
this.instanceConfigs_.set(key, new instance_config_1.InstanceConfig(this, name));
}
return this.instanceConfigs_.get(key);
}
/**
* Prepare a gapic request. This will cache the GAX client and replace

@@ -773,2 +881,3 @@ * {{projectId}} placeholders, if necessary.

'instance',
'instanceConfig',
'int',

@@ -775,0 +884,0 @@ 'numeric',

8

package.json
{
"name": "@google-cloud/spanner",
"description": "Cloud Spanner Client Library for Node.js",
"version": "6.2.0",
"version": "6.3.0",
"license": "Apache-2.0",

@@ -54,3 +54,3 @@ "author": "Google Inc.",

"@google-cloud/common": "^4.0.0",
"@google-cloud/precise-date": "^2.0.0",
"@google-cloud/precise-date": "^3.0.0",
"@google-cloud/projectify": "^3.0.0",

@@ -68,3 +68,3 @@ "@google-cloud/promisify": "^3.0.0",

"google-auth-library": "^8.0.2",
"google-gax": "^3.0.1",
"google-gax": "^3.3.0",
"grpc-gcp": "^1.0.0",

@@ -107,3 +107,3 @@ "is": "^3.2.1",

"jsdoc-region-tag": "^2.0.0",
"linkinator": "^2.0.0",
"linkinator": "^4.0.0",
"lodash.random": "^3.2.0",

@@ -110,0 +110,0 @@ "mocha": "^9.2.2",

@@ -122,2 +122,6 @@ [//]: # "This README.md file is auto-generated, all changes to this file will be lost."

| Indexing | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/indexing.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/indexing.js,samples/README.md) |
| Creates a user-managed instance configuration. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/instance-config-create.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/instance-config-create.js,samples/README.md) |
| Deletes a user-managed instance configuration. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/instance-config-delete.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/instance-config-delete.js,samples/README.md) |
| Lists the instance configuration operations. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/instance-config-get-operations.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/instance-config-get-operations.js,samples/README.md) |
| Updates a user-managed instance configuration. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/instance-config-update.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/instance-config-update.js,samples/README.md) |
| Instance-with-processing-units | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/instance-with-processing-units.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/instance-with-processing-units.js,samples/README.md) |

@@ -124,0 +128,0 @@ | Instance | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/instance.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/instance.js,samples/README.md) |

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc