Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions handwritten/datastore/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
entity,
Entities,
Entity,
EntityProto,

Check warning on line 46 in handwritten/datastore/src/index.ts

View workflow job for this annotation

GitHub Actions / lint

'EntityProto' is defined but never used
ValueProto,
PropertyTransform,
} from './entity';
import {AggregateField} from './aggregate';

Check warning on line 50 in handwritten/datastore/src/index.ts

View workflow job for this annotation

GitHub Actions / lint

'/home/runner/work/google-cloud-node/google-cloud-node/handwritten/datastore/src/aggregate.ts' imported multiple times
import Key = entity.Key;
export {Entity, Key, AggregateField};
import {PropertyFilter, and, or} from './filter';
Expand All @@ -67,19 +67,19 @@
PrepareEntityObjectResponse,
SaveCallback,
SaveResponse,
Mutation,

Check warning on line 70 in handwritten/datastore/src/index.ts

View workflow job for this annotation

GitHub Actions / lint

'Mutation' is defined but never used
RequestOptions,
} from './request';
import {Transaction} from './transaction';
import {promisifyAll} from '@google-cloud/promisify';
import {google} from './protos';
import {AggregateQuery} from './aggregate';

Check warning on line 76 in handwritten/datastore/src/index.ts

View workflow job for this annotation

GitHub Actions / lint

'/home/runner/work/google-cloud-node/google-cloud-node/handwritten/datastore/src/aggregate.ts' imported multiple times
import {SaveEntity} from './interfaces/save';
import {extendExcludeFromIndexes} from './utils/entity/extendExcludeFromIndexes';
import {buildEntityProto} from './utils/entity/buildEntityProto';
import IValue = google.datastore.v1.IValue;

Check warning on line 80 in handwritten/datastore/src/index.ts

View workflow job for this annotation

GitHub Actions / lint

'IValue' is defined but never used
import IEntity = google.datastore.v1.IEntity;
import ServerValue = google.datastore.v1.PropertyTransform.ServerValue;

Check warning on line 82 in handwritten/datastore/src/index.ts

View workflow job for this annotation

GitHub Actions / lint

'ServerValue' is defined but never used
import {buildPropertyTransforms} from './utils/entity/buildPropertyTransforms';

const {grpc} = new GrpcClient();
Expand Down Expand Up @@ -113,16 +113,20 @@
export type LongRunningResponse = [Operation, google.longrunning.IOperation];
export type Fallback = boolean | 'rest' | 'proto';

export interface ExportEntitiesConfig
extends Omit<google.datastore.admin.v1.IExportEntitiesRequest, 'projectId'> {
export interface ExportEntitiesConfig extends Omit<
google.datastore.admin.v1.IExportEntitiesRequest,
'projectId'
> {
bucket?: string | {name: string};
kinds?: string[];
namespaces?: string[];
gaxOptions?: CallOptions;
}

export interface ImportEntitiesConfig
extends Omit<google.datastore.admin.v1.IImportEntitiesRequest, 'projectId'> {
export interface ImportEntitiesConfig extends Omit<
google.datastore.admin.v1.IImportEntitiesRequest,
'projectId'
> {
file?: string | {bucket: {name: string}; name: string};
kinds?: string[];
namespaces?: string[];
Expand Down Expand Up @@ -486,7 +490,7 @@
auth: GoogleAuth;
constructor(options?: DatastoreOptions) {
super();
options = options || {};
options = {...options};
this.clients_ = new Map();
this.datastore = this;

Expand Down
11 changes: 11 additions & 0 deletions handwritten/datastore/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import {PassThrough, Readable} from 'stream';

import * as ds from '../src';
import {AggregateField, Datastore, DatastoreOptions} from '../src';

Check warning on line 22 in handwritten/datastore/test/index.ts

View workflow job for this annotation

GitHub Actions / lint

'/home/runner/work/google-cloud-node/google-cloud-node/handwritten/datastore/src/index.ts' imported multiple times

Check warning on line 22 in handwritten/datastore/test/index.ts

View workflow job for this annotation

GitHub Actions / lint

'Datastore' is defined but never used
import {Datastore as OriginalDatastore} from '../src';

Check warning on line 23 in handwritten/datastore/test/index.ts

View workflow job for this annotation

GitHub Actions / lint

'/home/runner/work/google-cloud-node/google-cloud-node/handwritten/datastore/src/index.ts' imported multiple times
import {
entity,
Entity,
Expand All @@ -34,7 +34,7 @@
import * as sinon from 'sinon';
import * as extend from 'extend';
import {google} from '../src/protos';
import {ServiceError} from 'google-gax';

Check warning on line 37 in handwritten/datastore/test/index.ts

View workflow job for this annotation

GitHub Actions / lint

'ServiceError' is defined but never used

// eslint-disable-next-line @typescript-eslint/no-var-requires
const v1 = require('../src/v1/index.js');
Expand Down Expand Up @@ -294,6 +294,7 @@
const datastore = new Datastore(options);

assert.notStrictEqual(datastore.options, options);
assert.deepStrictEqual(options, {a: 'b', c: 'd'});

assert.deepStrictEqual(
datastore.options,
Expand All @@ -311,6 +312,16 @@
);
});

it('should not mutate the passed options object', () => {
process.env.DATASTORE_PROJECT_ID = 'env-project-id';
const options = Object.freeze({namespace: 'ns'}) as DatastoreOptions;

const datastore = new Datastore(options);

assert.deepStrictEqual(options, {namespace: 'ns'});
assert.strictEqual(datastore.options.projectId, 'env-project-id');
});

it('should set port if detected', () => {
const determineBaseUrl_ = Datastore.prototype.determineBaseUrl_;
const port = 99;
Expand Down
Loading