From b7f4a1c8b13bd7ab1941bd548580d3271c626d76 Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Tue, 18 Mar 2025 11:39:04 -0400 Subject: [PATCH 01/21] Work in progress property transforms --- src/entity.ts | 4 +++- src/index.ts | 5 +++++ system-test/datastore.ts | 12 ++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/entity.ts b/src/entity.ts index c12e4ee9c..166123727 100644 --- a/src/entity.ts +++ b/src/entity.ts @@ -1453,7 +1453,9 @@ export interface EntityProto { } // eslint-disable-next-line @typescript-eslint/no-explicit-any -export type Entity = any; +export type Entity = { + [k: string]: any; +}; export type Entities = Entity | Entity[]; interface KeyProtoPathElement extends google.datastore.v1.Key.IPathElement { diff --git a/src/index.ts b/src/index.ts index 20cad99c4..e4ad662e2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1099,6 +1099,7 @@ class Datastore extends DatastoreRequest { .map(DatastoreRequest.prepareEntityObject_) .forEach((entityObject: Entity, index: number) => { const mutation: Mutation = {}; + let method = 'upsert'; if (entityObject.method) { @@ -1121,6 +1122,10 @@ class Datastore extends DatastoreRequest { entityProto.key = entity.keyToKeyProto(entityObject.key); mutation[method] = entityProto; + + // We built the entityProto, now we should add the data transforms: + + mutations.push(mutation); }); diff --git a/system-test/datastore.ts b/system-test/datastore.ts index c8eeecebb..a99b783fd 100644 --- a/system-test/datastore.ts +++ b/system-test/datastore.ts @@ -3295,6 +3295,18 @@ async.each( assert.strictEqual(entity, undefined); }); }); + describe.only('Datastore mode data transforms', () => { + it('should perform a basic data transform', async () => { + const key = datastore.key(['Post', 'post1']); + const result = await datastore.save({ + key: key, + data: { + name: 'test', + blob: Buffer.from([]), + }, + }); + }); + }); }); } ); From 73b8e15dcda9c17252833827da9569ae913a53e5 Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Tue, 18 Mar 2025 13:02:56 -0400 Subject: [PATCH 02/21] Change entity back to any --- src/entity.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/entity.ts b/src/entity.ts index 166123727..c12e4ee9c 100644 --- a/src/entity.ts +++ b/src/entity.ts @@ -1453,9 +1453,7 @@ export interface EntityProto { } // eslint-disable-next-line @typescript-eslint/no-explicit-any -export type Entity = { - [k: string]: any; -}; +export type Entity = any; export type Entities = Entity | Entity[]; interface KeyProtoPathElement extends google.datastore.v1.Key.IPathElement { From 35ee5a4bf317b4ba221e8b1e3481f2dbf12a5a3c Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Tue, 18 Mar 2025 14:15:35 -0400 Subject: [PATCH 03/21] Add the new interfaces and middleware code --- src/entity.ts | 24 ++++++++++++++++++++- src/index.ts | 60 ++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 78 insertions(+), 6 deletions(-) diff --git a/src/entity.ts b/src/entity.ts index c12e4ee9c..b06375e01 100644 --- a/src/entity.ts +++ b/src/entity.ts @@ -1452,8 +1452,30 @@ export interface EntityProto { excludeFromIndexes?: boolean; } +// TODO: In practice only one of these types would be allowed: +/* + * This is the interface the user would provide transform operations in before + * they are converted to the google.datastore.v1.IPropertyTransform + * interface. + * + */ +export type PropertyTransform = { + property: string; + setToServerValue: boolean; + increment: any; + maximum: any; + minimum: any; + appendMissingElements: any[]; + removeAllFromArray: any[]; +}; + +interface EntityWithTransforms { + transforms?: PropertyTransform[]; +} + // eslint-disable-next-line @typescript-eslint/no-explicit-any -export type Entity = any; +// TODO: Call out this interface change +export type Entity = any & EntityWithTransforms; export type Entities = Entity | Entity[]; interface KeyProtoPathElement extends google.datastore.v1.Key.IPathElement { diff --git a/src/index.ts b/src/index.ts index e4ad662e2..8b701579d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -37,9 +37,16 @@ import { ServiceError, } from 'google-gax'; import * as is from 'is'; -import {Transform, pipeline} from 'stream'; +import {pipeline, Transform} from 'stream'; -import {entity, Entities, Entity, EntityProto, ValueProto} from './entity'; +import { + entity, + Entities, + Entity, + EntityProto, + ValueProto, + PropertyTransform, +} from './entity'; import {AggregateField} from './aggregate'; import Key = entity.Key; export {Entity, Key, AggregateField}; @@ -70,6 +77,9 @@ import {AggregateQuery} from './aggregate'; import {SaveEntity} from './interfaces/save'; import {extendExcludeFromIndexes} from './utils/entity/extendExcludeFromIndexes'; import {buildEntityProto} from './utils/entity/buildEntityProto'; +import IValue = google.datastore.v1.IValue; +import IEntity = google.datastore.v1.IEntity; +import ServerValue = google.datastore.v1.PropertyTransform.ServerValue; const {grpc} = new GrpcClient(); @@ -1098,7 +1108,7 @@ class Datastore extends DatastoreRequest { entities .map(DatastoreRequest.prepareEntityObject_) .forEach((entityObject: Entity, index: number) => { - const mutation: Mutation = {}; + const mutation: google.datastore.v1.IMutation = {}; let method = 'upsert'; @@ -1121,10 +1131,50 @@ class Datastore extends DatastoreRequest { entityProto.key = entity.keyToKeyProto(entityObject.key); - mutation[method] = entityProto; + mutation[method as 'upsert' | 'update' | 'insert' | 'delete'] = + entityProto as IEntity; // We built the entityProto, now we should add the data transforms: - + if (entityObject.transforms) { + mutation.propertyTransforms = []; + if (mutation.propertyTransforms) { + entityObject.transforms.forEach((transform: PropertyTransform) => { + if (transform.setToServerValue) { + mutation.propertyTransforms?.push({ + property: transform.property, + setToServerValue: ServerValue.REQUEST_TIME, + }); + } + if (transform.increment) { + mutation.propertyTransforms?.push({ + property: transform.property, + increment: entity.encodeValue( + transform.increment, + transform.property + ) as IValue, + }); + } + if (transform.maximum) { + mutation.propertyTransforms?.push({ + property: transform.property, + maximum: entity.encodeValue( + transform.maximum, + transform.property + ) as IValue, + }); + } + if (transform.increment) { + mutation.propertyTransforms?.push({ + property: transform.property, + increment: entity.encodeValue( + transform.maximum, + transform.property + ) as IValue, + }); + } + }); + } + } mutations.push(mutation); }); From f181a4cc5c7b8c7ede8a7a54549902c1f006449e Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Tue, 18 Mar 2025 14:27:44 -0400 Subject: [PATCH 04/21] Pull the build property transform into separate fn --- src/index.ts | 43 ++------------------ src/utils/entity/buildPropertyTransforms.ts | 44 +++++++++++++++++++++ 2 files changed, 48 insertions(+), 39 deletions(-) create mode 100644 src/utils/entity/buildPropertyTransforms.ts diff --git a/src/index.ts b/src/index.ts index 8b701579d..849387b31 100644 --- a/src/index.ts +++ b/src/index.ts @@ -80,6 +80,7 @@ import {buildEntityProto} from './utils/entity/buildEntityProto'; import IValue = google.datastore.v1.IValue; import IEntity = google.datastore.v1.IEntity; import ServerValue = google.datastore.v1.PropertyTransform.ServerValue; +import {buildPropertyTransforms} from './utils/entity/buildPropertyTransforms'; const {grpc} = new GrpcClient(); @@ -1136,46 +1137,10 @@ class Datastore extends DatastoreRequest { // We built the entityProto, now we should add the data transforms: if (entityObject.transforms) { - mutation.propertyTransforms = []; - if (mutation.propertyTransforms) { - entityObject.transforms.forEach((transform: PropertyTransform) => { - if (transform.setToServerValue) { - mutation.propertyTransforms?.push({ - property: transform.property, - setToServerValue: ServerValue.REQUEST_TIME, - }); - } - if (transform.increment) { - mutation.propertyTransforms?.push({ - property: transform.property, - increment: entity.encodeValue( - transform.increment, - transform.property - ) as IValue, - }); - } - if (transform.maximum) { - mutation.propertyTransforms?.push({ - property: transform.property, - maximum: entity.encodeValue( - transform.maximum, - transform.property - ) as IValue, - }); - } - if (transform.increment) { - mutation.propertyTransforms?.push({ - property: transform.property, - increment: entity.encodeValue( - transform.maximum, - transform.property - ) as IValue, - }); - } - }); - } + mutation.propertyTransforms = buildPropertyTransforms( + entityObject.transforms + ); } - mutations.push(mutation); }); diff --git a/src/utils/entity/buildPropertyTransforms.ts b/src/utils/entity/buildPropertyTransforms.ts new file mode 100644 index 000000000..5461b726f --- /dev/null +++ b/src/utils/entity/buildPropertyTransforms.ts @@ -0,0 +1,44 @@ +import {entity, PropertyTransform} from '../../entity'; +import {google} from '../../../protos/protos'; +import IValue = google.datastore.v1.IValue; +import ServerValue = google.datastore.v1.PropertyTransform.ServerValue; + +export function buildPropertyTransforms(transforms: PropertyTransform[]) { + const propertyTransforms: google.datastore.v1.IPropertyTransform[] = []; + transforms.forEach((transform: PropertyTransform) => { + if (transform.setToServerValue) { + propertyTransforms?.push({ + property: transform.property, + setToServerValue: ServerValue.REQUEST_TIME, + }); + } + if (transform.increment) { + propertyTransforms?.push({ + property: transform.property, + increment: entity.encodeValue( + transform.increment, + transform.property + ) as IValue, + }); + } + if (transform.maximum) { + propertyTransforms?.push({ + property: transform.property, + maximum: entity.encodeValue( + transform.maximum, + transform.property + ) as IValue, + }); + } + if (transform.increment) { + propertyTransforms?.push({ + property: transform.property, + increment: entity.encodeValue( + transform.maximum, + transform.property + ) as IValue, + }); + } + }); + return propertyTransforms; +} From 66e0668ff52c460d8a066d7d2404c22069628d7d Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Tue, 18 Mar 2025 15:55:42 -0400 Subject: [PATCH 05/21] Add arrays to the build transform function --- src/utils/entity/buildPropertyTransforms.ts | 54 +++++++++++++-------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/src/utils/entity/buildPropertyTransforms.ts b/src/utils/entity/buildPropertyTransforms.ts index 5461b726f..772894af2 100644 --- a/src/utils/entity/buildPropertyTransforms.ts +++ b/src/utils/entity/buildPropertyTransforms.ts @@ -6,37 +6,49 @@ import ServerValue = google.datastore.v1.PropertyTransform.ServerValue; export function buildPropertyTransforms(transforms: PropertyTransform[]) { const propertyTransforms: google.datastore.v1.IPropertyTransform[] = []; transforms.forEach((transform: PropertyTransform) => { + const property = transform.property; if (transform.setToServerValue) { - propertyTransforms?.push({ - property: transform.property, + propertyTransforms.push({ + property, setToServerValue: ServerValue.REQUEST_TIME, }); } if (transform.increment) { - propertyTransforms?.push({ - property: transform.property, - increment: entity.encodeValue( - transform.increment, - transform.property - ) as IValue, + propertyTransforms.push({ + property, + increment: entity.encodeValue(transform.increment, property) as IValue, }); } if (transform.maximum) { - propertyTransforms?.push({ - property: transform.property, - maximum: entity.encodeValue( - transform.maximum, - transform.property - ) as IValue, + propertyTransforms.push({ + property, + maximum: entity.encodeValue(transform.maximum, property) as IValue, }); } - if (transform.increment) { - propertyTransforms?.push({ - property: transform.property, - increment: entity.encodeValue( - transform.maximum, - transform.property - ) as IValue, + if (transform.minimum) { + propertyTransforms.push({ + property, + increment: entity.encodeValue(transform.minimum, property) as IValue, + }); + } + if (transform.appendMissingElements) { + propertyTransforms.push({ + property, + appendMissingElements: { + values: transform.appendMissingElements.map(element => { + return entity.encodeValue(element, property) as IValue; + }), + }, + }); + } + if (transform.removeAllFromArray) { + propertyTransforms.push({ + property, + removeAllFromArray: { + values: transform.removeAllFromArray.map(element => { + return entity.encodeValue(element, property) as IValue; + }), + }, }); } }); From 7abda1f5cc201666aa70e4638dd266bb258d93b9 Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Tue, 18 Mar 2025 15:56:03 -0400 Subject: [PATCH 06/21] Add a test for property transforms --- system-test/datastore.ts | 91 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/system-test/datastore.ts b/system-test/datastore.ts index a99b783fd..5bd2752f7 100644 --- a/system-test/datastore.ts +++ b/system-test/datastore.ts @@ -3303,8 +3303,99 @@ async.each( data: { name: 'test', blob: Buffer.from([]), + p1: 3, + p2: 4, + p3: 5, + a1: [3, 4, 5], }, + transforms: [ + { + property: 'p1', + setToServerValue: true, + }, + { + property: 'p2', + increment: 4, + }, + { + property: 'p3', + maximum: 9, + }, + { + property: 'p2', + minimum: 6, + }, + { + property: 'a1', + appendMissingElements: [5, 6], + }, + { + property: 'a1', + removeAllFromArray: [3], + }, + ], }); + // Clean the data from the server first before updating: + result.forEach(serverResult => { + serverResult.mutationResults?.forEach(mutationResult => { + delete mutationResult['updateTime']; + delete mutationResult['createTime']; + delete mutationResult['version']; + mutationResult.transformResults?.forEach(transformResult => { + delete transformResult['timestampValue']; + }); + }); + }); + assert.deepStrictEqual(result, [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + valueType: 'timestampValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '8', + valueType: 'integerValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '9', + valueType: 'integerValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '14', + valueType: 'integerValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + nullValue: 'NULL_VALUE', + valueType: 'nullValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + nullValue: 'NULL_VALUE', + valueType: 'nullValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + indexUpdates: 17, + commitTime: null, + }, + ]); + console.log(result); }); }); }); From 4ae772fe44fcd7681e54bdfc6ba38d6df56e41fe Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Tue, 18 Mar 2025 16:17:43 -0400 Subject: [PATCH 07/21] Correct test comments --- system-test/datastore.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/system-test/datastore.ts b/system-test/datastore.ts index 5bd2752f7..f10b8a235 100644 --- a/system-test/datastore.ts +++ b/system-test/datastore.ts @@ -3335,7 +3335,7 @@ async.each( }, ], }); - // Clean the data from the server first before updating: + // Clean the data from the server first before comparing: result.forEach(serverResult => { serverResult.mutationResults?.forEach(mutationResult => { delete mutationResult['updateTime']; @@ -3346,6 +3346,8 @@ async.each( }); }); }); + // Now the data should have fixed values. + // Do a comparison against the expected result. assert.deepStrictEqual(result, [ { mutationResults: [ From c5c4484520389f5fd58bbf6609671d1b1688b172 Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Tue, 18 Mar 2025 16:18:04 -0400 Subject: [PATCH 08/21] More modular build function --- src/utils/entity/buildPropertyTransforms.ts | 30 +++++++++------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/utils/entity/buildPropertyTransforms.ts b/src/utils/entity/buildPropertyTransforms.ts index 772894af2..a9cf10d8e 100644 --- a/src/utils/entity/buildPropertyTransforms.ts +++ b/src/utils/entity/buildPropertyTransforms.ts @@ -13,24 +13,18 @@ export function buildPropertyTransforms(transforms: PropertyTransform[]) { setToServerValue: ServerValue.REQUEST_TIME, }); } - if (transform.increment) { - propertyTransforms.push({ - property, - increment: entity.encodeValue(transform.increment, property) as IValue, - }); - } - if (transform.maximum) { - propertyTransforms.push({ - property, - maximum: entity.encodeValue(transform.maximum, property) as IValue, - }); - } - if (transform.minimum) { - propertyTransforms.push({ - property, - increment: entity.encodeValue(transform.minimum, property) as IValue, - }); - } + ['increment', 'maximum', 'minimum'].forEach(type => { + const castedType = type as 'increment' | 'maximum' | 'minimum'; + if (transform[castedType]) { + propertyTransforms.push({ + property, + increment: entity.encodeValue( + transform[castedType], + property + ) as IValue, + }); + } + }); if (transform.appendMissingElements) { propertyTransforms.push({ property, From a1e8e695fa12d8b1c308c42203f2325c24050a40 Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Tue, 18 Mar 2025 16:36:34 -0400 Subject: [PATCH 09/21] Update the test to check for the final result --- system-test/datastore.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/system-test/datastore.ts b/system-test/datastore.ts index f10b8a235..3dcd3ee43 100644 --- a/system-test/datastore.ts +++ b/system-test/datastore.ts @@ -3298,11 +3298,11 @@ async.each( describe.only('Datastore mode data transforms', () => { it('should perform a basic data transform', async () => { const key = datastore.key(['Post', 'post1']); + // TODO: Add a spy to the request function const result = await datastore.save({ key: key, data: { name: 'test', - blob: Buffer.from([]), p1: 3, p2: 4, p3: 5, @@ -3337,6 +3337,7 @@ async.each( }); // Clean the data from the server first before comparing: result.forEach(serverResult => { + delete serverResult['indexUpdates']; serverResult.mutationResults?.forEach(mutationResult => { delete mutationResult['updateTime']; delete mutationResult['createTime']; @@ -3367,7 +3368,7 @@ async.each( { meaning: 0, excludeFromIndexes: false, - integerValue: '9', + integerValue: '14', valueType: 'integerValue', }, { @@ -3393,10 +3394,19 @@ async.each( conflictDetected: false, }, ], - indexUpdates: 17, commitTime: null, }, ]); + // Now check the value that was actually saved to the server: + const [entity] = await datastore.get(key); + const parsedResult = JSON.parse(JSON.stringify(entity)); + delete parsedResult['p1']; // This is a timestamp so we can't consistently test this. + assert.deepStrictEqual(parsedResult, { + name: 'test', + a1: [4, 5, 6], + p2: 14, + p3: 14, + }); console.log(result); }); }); From ef41b732b6b3425773cabf8f0dd634964feba46c Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Tue, 18 Mar 2025 16:45:27 -0400 Subject: [PATCH 10/21] Add the request spy --- system-test/datastore.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/system-test/datastore.ts b/system-test/datastore.ts index 3dcd3ee43..9a6410450 100644 --- a/system-test/datastore.ts +++ b/system-test/datastore.ts @@ -26,6 +26,7 @@ import {Entities, entity, Entity} from '../src/entity'; import {Query, RunQueryInfo, ExecutionStats} from '../src/query'; import KEY_SYMBOL = entity.KEY_SYMBOL; import {transactionExpiredError} from '../src/request'; +const sinon = require('sinon'); const async = require('async'); @@ -3299,6 +3300,8 @@ async.each( it('should perform a basic data transform', async () => { const key = datastore.key(['Post', 'post1']); // TODO: Add a spy to the request function + const requestSpy = sinon.spy(datastore.request_); + datastore.request_ = requestSpy; const result = await datastore.save({ key: key, data: { @@ -3407,7 +3410,6 @@ async.each( p2: 14, p3: 14, }); - console.log(result); }); }); }); From ceb3fc46f856fc1ced1a937eb652b754e19e4b25 Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Wed, 19 Mar 2025 09:54:47 -0400 Subject: [PATCH 11/21] Fix the bug making property always increment --- src/utils/entity/buildPropertyTransforms.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/entity/buildPropertyTransforms.ts b/src/utils/entity/buildPropertyTransforms.ts index a9cf10d8e..b4118599e 100644 --- a/src/utils/entity/buildPropertyTransforms.ts +++ b/src/utils/entity/buildPropertyTransforms.ts @@ -18,7 +18,7 @@ export function buildPropertyTransforms(transforms: PropertyTransform[]) { if (transform[castedType]) { propertyTransforms.push({ property, - increment: entity.encodeValue( + [castedType]: entity.encodeValue( transform[castedType], property ) as IValue, From 81f18980aaa3bab964a195de501d692ce2e78b9e Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Wed, 19 Mar 2025 09:55:31 -0400 Subject: [PATCH 12/21] Fix the test based on the most recent source code change --- system-test/datastore.ts | 108 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 104 insertions(+), 4 deletions(-) diff --git a/system-test/datastore.ts b/system-test/datastore.ts index 9a6410450..b4c2c31a2 100644 --- a/system-test/datastore.ts +++ b/system-test/datastore.ts @@ -3371,13 +3371,13 @@ async.each( { meaning: 0, excludeFromIndexes: false, - integerValue: '14', + integerValue: '9', valueType: 'integerValue', }, { meaning: 0, excludeFromIndexes: false, - integerValue: '14', + integerValue: '6', valueType: 'integerValue', }, { @@ -3407,8 +3407,108 @@ async.each( assert.deepStrictEqual(parsedResult, { name: 'test', a1: [4, 5, 6], - p2: 14, - p3: 14, + p2: 6, + p3: 9, + }); + delete requestSpy.args[0][0].reqOpts.mutations[0].upsert.key + .partitionId['namespaceId']; + assert.deepStrictEqual(requestSpy.args[0][0], { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + partitionId: {}, + }, + properties: { + name: { + stringValue: 'test', + }, + p1: { + integerValue: '3', + }, + p2: { + integerValue: '4', + }, + p3: { + integerValue: '5', + }, + a1: { + arrayValue: { + values: [ + { + integerValue: '3', + }, + { + integerValue: '4', + }, + { + integerValue: '5', + }, + ], + }, + }, + }, + }, + propertyTransforms: [ + { + property: 'p1', + setToServerValue: 1, + }, + { + property: 'p2', + increment: { + integerValue: '4', + }, + }, + { + property: 'p3', + maximum: { + integerValue: '9', + }, + }, + { + property: 'p2', + minimum: { + integerValue: '6', + }, + }, + { + property: 'a1', + appendMissingElements: { + values: [ + { + integerValue: '5', + }, + { + integerValue: '6', + }, + ], + }, + }, + { + property: 'a1', + removeAllFromArray: { + values: [ + { + integerValue: '3', + }, + ], + }, + }, + ], + }, + ], + }, + gaxOpts: {}, }); }); }); From c4ac6399afe611702e7850db06cdc494aba50907 Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Wed, 19 Mar 2025 09:58:53 -0400 Subject: [PATCH 13/21] Refactor code for the array transforms --- src/utils/entity/buildPropertyTransforms.ts | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/utils/entity/buildPropertyTransforms.ts b/src/utils/entity/buildPropertyTransforms.ts index b4118599e..fc42b6b52 100644 --- a/src/utils/entity/buildPropertyTransforms.ts +++ b/src/utils/entity/buildPropertyTransforms.ts @@ -25,26 +25,17 @@ export function buildPropertyTransforms(transforms: PropertyTransform[]) { }); } }); - if (transform.appendMissingElements) { + ['appendMissingElements', 'removeAllFromArray'].forEach(type => { + const castedType = type as 'appendMissingElements' | 'removeAllFromArray'; propertyTransforms.push({ property, - appendMissingElements: { - values: transform.appendMissingElements.map(element => { + [castedType]: { + values: transform[castedType].map(element => { return entity.encodeValue(element, property) as IValue; }), }, }); - } - if (transform.removeAllFromArray) { - propertyTransforms.push({ - property, - removeAllFromArray: { - values: transform.removeAllFromArray.map(element => { - return entity.encodeValue(element, property) as IValue; - }), - }, - }); - } + }); }); return propertyTransforms; } From a09119bb4e65c9ba02a67320254966708798a33b Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Wed, 19 Mar 2025 10:00:20 -0400 Subject: [PATCH 14/21] =?UTF-8?q?Add=20a=20guard=20in=20case=20the=20caste?= =?UTF-8?q?d=20type=20doesn=E2=80=99t=20exist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/entity/buildPropertyTransforms.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/utils/entity/buildPropertyTransforms.ts b/src/utils/entity/buildPropertyTransforms.ts index fc42b6b52..b77101465 100644 --- a/src/utils/entity/buildPropertyTransforms.ts +++ b/src/utils/entity/buildPropertyTransforms.ts @@ -27,14 +27,16 @@ export function buildPropertyTransforms(transforms: PropertyTransform[]) { }); ['appendMissingElements', 'removeAllFromArray'].forEach(type => { const castedType = type as 'appendMissingElements' | 'removeAllFromArray'; - propertyTransforms.push({ - property, - [castedType]: { - values: transform[castedType].map(element => { - return entity.encodeValue(element, property) as IValue; - }), - }, - }); + if (transform[castedType]) { + propertyTransforms.push({ + property, + [castedType]: { + values: transform[castedType].map(element => { + return entity.encodeValue(element, property) as IValue; + }), + }, + }); + } }); }); return propertyTransforms; From 409f6a65440631dae1f96290f4686bab83bfa68d Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Wed, 19 Mar 2025 10:01:03 -0400 Subject: [PATCH 15/21] Remove only --- system-test/datastore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-test/datastore.ts b/system-test/datastore.ts index b4c2c31a2..f15d0d719 100644 --- a/system-test/datastore.ts +++ b/system-test/datastore.ts @@ -3296,7 +3296,7 @@ async.each( assert.strictEqual(entity, undefined); }); }); - describe.only('Datastore mode data transforms', () => { + describe('Datastore mode data transforms', () => { it('should perform a basic data transform', async () => { const key = datastore.key(['Post', 'post1']); // TODO: Add a spy to the request function From 6f65b43323eff00798c6cadd34629f00266785e7 Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Mon, 24 Mar 2025 14:36:38 -0400 Subject: [PATCH 16/21] Add a header --- src/utils/entity/buildPropertyTransforms.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/utils/entity/buildPropertyTransforms.ts b/src/utils/entity/buildPropertyTransforms.ts index b77101465..90c0b25ad 100644 --- a/src/utils/entity/buildPropertyTransforms.ts +++ b/src/utils/entity/buildPropertyTransforms.ts @@ -1,3 +1,17 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + import {entity, PropertyTransform} from '../../entity'; import {google} from '../../../protos/protos'; import IValue = google.datastore.v1.IValue; From 55b19139eb604f44d72ee6f16a7586abd8b3f4d3 Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Mon, 24 Mar 2025 15:07:33 -0400 Subject: [PATCH 17/21] Remove TODO --- src/entity.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/entity.ts b/src/entity.ts index b06375e01..f8dc509b2 100644 --- a/src/entity.ts +++ b/src/entity.ts @@ -1452,7 +1452,6 @@ export interface EntityProto { excludeFromIndexes?: boolean; } -// TODO: In practice only one of these types would be allowed: /* * This is the interface the user would provide transform operations in before * they are converted to the google.datastore.v1.IPropertyTransform From 2478abc9a6c88e0e485bc6963f56ca53a4401b4b Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Mon, 24 Mar 2025 15:13:01 -0400 Subject: [PATCH 18/21] Remove TODO --- system-test/datastore.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/system-test/datastore.ts b/system-test/datastore.ts index f15d0d719..69617bf83 100644 --- a/system-test/datastore.ts +++ b/system-test/datastore.ts @@ -3299,7 +3299,6 @@ async.each( describe('Datastore mode data transforms', () => { it('should perform a basic data transform', async () => { const key = datastore.key(['Post', 'post1']); - // TODO: Add a spy to the request function const requestSpy = sinon.spy(datastore.request_); datastore.request_ = requestSpy; const result = await datastore.save({ From 901cbb5a523cb69963a8c5d67975bb3179bcaa33 Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Thu, 29 May 2025 14:51:31 -0400 Subject: [PATCH 19/21] Parameterize the test --- system-test/datastore.ts | 548 ++++++++++++++++++++------------------- 1 file changed, 282 insertions(+), 266 deletions(-) diff --git a/system-test/datastore.ts b/system-test/datastore.ts index 69617bf83..6156112d4 100644 --- a/system-test/datastore.ts +++ b/system-test/datastore.ts @@ -58,7 +58,7 @@ async.each( }; const {indexes: DECLARED_INDEXES} = yaml.load( - readFileSync(path.join(__dirname, 'data', 'index.yaml'), 'utf8') + readFileSync(path.join(__dirname, 'data', 'index.yaml'), 'utf8'), ) as {indexes: google.datastore.admin.v1.IIndex[]}; // TODO/DX ensure indexes before testing, and maybe? cleanup indexes after @@ -472,10 +472,10 @@ async.each( key: secondaryDatastore.key(['Post', keyName]), data: postData, }; - } + }, ); await Promise.all( - secondaryData.map(async datum => secondaryDatastore.save(datum)) + secondaryData.map(async datum => secondaryDatastore.save(datum)), ); // Next, ensure that the default database has the right records const query = defaultDatastore @@ -486,7 +486,7 @@ async.each( assert.strictEqual(defaultDatastoreResults.length, 1); assert.strictEqual( defaultDatastoreResults[0].author, - defaultAuthor + defaultAuthor, ); // Next, ensure that the other database has the right records await Promise.all( @@ -497,12 +497,12 @@ async.each( const [results] = await secondaryDatastore.runQuery(query); assert.strictEqual(results.length, 1); assert.strictEqual(results[0].author, datum.data.author); - }) + }), ); // Cleanup await defaultDatastore.delete(defaultPostKey); await Promise.all( - secondaryData.map(datum => secondaryDatastore.delete(datum.key)) + secondaryData.map(datum => secondaryDatastore.delete(datum.key)), ); }); }); @@ -557,7 +557,7 @@ async.each( const data = { buf: Buffer.from( '010100000000000000000059400000000000006940', - 'hex' + 'hex', ), }; await datastore.save({key: postKey, data}); @@ -657,7 +657,7 @@ async.each( key: postKey, method: 'insert', data: post, - }) + }), ); const [entity] = await datastore.get(postKey); delete entity[datastore.KEY]; @@ -672,7 +672,7 @@ async.each( key: postKey, method: 'update', data: post, - }) + }), ); }); @@ -721,7 +721,7 @@ async.each( assert.strictEqual(numEntitiesEmitted, 2); datastore.delete([key1, key2], done); }); - } + }, ); }); @@ -1101,7 +1101,7 @@ async.each( and([ new PropertyFilter('family', '=', 'Stark'), new PropertyFilter('appearances', '>=', 20), - ]) + ]), ); const [entities] = await datastore.runQuery(q); assert.strictEqual(entities!.length, 6); @@ -1121,7 +1121,7 @@ async.each( or([ new PropertyFilter('family', '=', 'Stark'), new PropertyFilter('appearances', '>=', 20), - ]) + ]), ); const [entities] = await datastore.runQuery(q); assert.strictEqual(entities!.length, 8); @@ -1213,7 +1213,7 @@ async.each( }); } function checkAggregationQueryExecutionStats( - executionStats?: ExecutionStats + executionStats?: ExecutionStats, ) { // This function ensures the execution stats returned from the server are correct. // First fix stats values that will be different every time a query profiling @@ -1263,7 +1263,7 @@ async.each( assert(!info.explainMetrics); assert.deepStrictEqual( entities.sort(compare).map(entity => entity.name), - [...characters].sort(compare).map(entity => entity.name) + [...characters].sort(compare).map(entity => entity.name), ); await transaction.commit(); }); @@ -1285,7 +1285,7 @@ async.each( assert.deepStrictEqual(entities, []); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); await transaction.commit(); }); @@ -1307,7 +1307,7 @@ async.each( assert.deepStrictEqual(entities, []); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); await transaction.commit(); }); @@ -1326,13 +1326,13 @@ async.each( } assert.deepStrictEqual( entities.sort(compare).map(entity => entity.name), - [...characters].sort(compare).map(entity => entity.name) + [...characters].sort(compare).map(entity => entity.name), ); assert(info.explainMetrics); checkQueryExecutionStats(info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); await transaction.commit(); }); @@ -1360,7 +1360,7 @@ async.each( try { [entities, info] = await transaction.runAggregationQuery( aggregate, - {} + {}, ); } catch (e) { await transaction.rollback(); @@ -1378,7 +1378,7 @@ async.each( aggregate, { explainOptions: {}, - } + }, ); } catch (e) { await transaction.rollback(); @@ -1388,7 +1388,7 @@ async.each( assert.deepStrictEqual(entities, []); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan + expectedRunAggregationQueryPlan, ); await transaction.commit(); }); @@ -1402,7 +1402,7 @@ async.each( explainOptions: { analyze: false, }, - } + }, ); } catch (e) { await transaction.rollback(); @@ -1412,7 +1412,7 @@ async.each( assert.deepStrictEqual(entities, []); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan + expectedRunAggregationQueryPlan, ); await transaction.commit(); }); @@ -1424,7 +1424,7 @@ async.each( aggregate, { explainOptions: {analyze: true}, - } + }, ); } catch (e) { await transaction.rollback(); @@ -1433,11 +1433,11 @@ async.each( assert(info.explainMetrics); assert.deepStrictEqual(entities, expectedAggregationResults); checkAggregationQueryExecutionStats( - info.explainMetrics.executionStats + info.explainMetrics.executionStats, ); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan + expectedRunAggregationQueryPlan, ); await transaction.commit(); }); @@ -1450,7 +1450,7 @@ async.each( assert(!info.explainMetrics); assert.deepStrictEqual( entities.sort(compare).map(entity => entity.name), - [...characters].sort(compare).map(entity => entity.name) + [...characters].sort(compare).map(entity => entity.name), ); }); it('should run a query with explain options and no analyze option specified', async () => { @@ -1462,7 +1462,7 @@ async.each( assert(!info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); }); it('should run a query with explain options and analyze set to false', async () => { @@ -1474,7 +1474,7 @@ async.each( assert(!info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); }); it('should run a query with explain options and analyze set to true', async () => { @@ -1483,13 +1483,13 @@ async.each( }); assert.deepStrictEqual( entities.sort(compare).map(entity => entity.name), - [...characters].sort(compare).map(entity => entity.name) + [...characters].sort(compare).map(entity => entity.name), ); assert(info.explainMetrics); checkQueryExecutionStats(info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); }); }); @@ -1500,7 +1500,7 @@ async.each( assert(!info.explainMetrics); assert.deepStrictEqual( entities.sort(compare).map(entity => entity.name), - [...characters].sort(compare).map(entity => entity.name) + [...characters].sort(compare).map(entity => entity.name), ); }); it('should run a query with explain options and no value set for analyze', async () => { @@ -1510,7 +1510,7 @@ async.each( assert(!info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); }); it('should run a query with explain options and analyze set to false', async () => { @@ -1522,7 +1522,7 @@ async.each( assert(!info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); }); it('should run a query with explain options and analyze set to true', async () => { @@ -1531,14 +1531,14 @@ async.each( }); assert.deepStrictEqual( entities.sort(compare).map(entity => entity.name), - [...characters].sort(compare).map(entity => entity.name) + [...characters].sort(compare).map(entity => entity.name), ); assert(info.explainMetrics); checkQueryExecutionStats(info.explainMetrics.executionStats); assert(info.explainMetrics.planSummary); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); }); }); @@ -1562,7 +1562,7 @@ async.each( entities .sort(compare) .map((entity: Entity) => entity?.name), - [...characters].sort(compare).map(entity => entity.name) + [...characters].sort(compare).map(entity => entity.name), ); assert(!savedInfo.explainMetrics); resolve(); @@ -1590,7 +1590,7 @@ async.each( assert(!savedInfo.explainMetrics.executionStats); assert.deepStrictEqual( savedInfo.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); resolve(); }); @@ -1619,7 +1619,7 @@ async.each( assert(!savedInfo.explainMetrics.executionStats); assert.deepStrictEqual( savedInfo.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); resolve(); }); @@ -1645,15 +1645,15 @@ async.each( entities .sort(compare) .map((entity: Entity) => entity?.name), - [...characters].sort(compare).map(entity => entity.name) + [...characters].sort(compare).map(entity => entity.name), ); assert(savedInfo.explainMetrics); checkQueryExecutionStats( - savedInfo.explainMetrics.executionStats + savedInfo.explainMetrics.executionStats, ); assert.deepStrictEqual( savedInfo.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); resolve(); }); @@ -1681,14 +1681,14 @@ async.each( aggregate, { explainOptions: {}, - } + }, ); assert.deepStrictEqual(entities, []); assert(info.explainMetrics); assert(!info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan + expectedRunAggregationQueryPlan, ); }); it('should run an aggregation query with explain options specified and analyze set to false', async () => { @@ -1696,14 +1696,14 @@ async.each( aggregate, { explainOptions: {analyze: false}, - } + }, ); assert.deepStrictEqual(entities, []); assert(info.explainMetrics); assert(!info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan + expectedRunAggregationQueryPlan, ); }); it('should run an aggregation query with explain options and analyze set to true', async () => { @@ -1711,16 +1711,16 @@ async.each( aggregate, { explainOptions: {analyze: true}, - } + }, ); assert.deepStrictEqual(entities, expectedAggregationResults); assert(info.explainMetrics); checkAggregationQueryExecutionStats( - info.explainMetrics.executionStats + info.explainMetrics.executionStats, ); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan + expectedRunAggregationQueryPlan, ); }); }); @@ -1748,7 +1748,7 @@ async.each( assert(!info.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan + expectedRunAggregationQueryPlan, ); }); it('should run an aggregation query with explain options and analyze set to false', async () => { @@ -1762,7 +1762,7 @@ async.each( assert(!info.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan + expectedRunAggregationQueryPlan, ); }); it('should run an aggregation query with explain options specified and analyze set to true', async () => { @@ -1772,11 +1772,11 @@ async.each( assert.deepStrictEqual(entities, expectedAggregationResults); assert(info.explainMetrics); checkAggregationQueryExecutionStats( - info.explainMetrics.executionStats + info.explainMetrics.executionStats, ); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan + expectedRunAggregationQueryPlan, ); }); }); @@ -1871,7 +1871,7 @@ async.each( } catch (err: any) { assert.strictEqual( err.message, - '3 INVALID_ARGUMENT: Aggregations are not supported for the property: __key__' + '3 INVALID_ARGUMENT: Aggregations are not supported for the property: __key__', ); } }); @@ -1938,7 +1938,7 @@ async.each( const aggregate = datastore .createAggregationQuery(q) .addAggregation( - AggregateField.average('appearances').alias('avg1') + AggregateField.average('appearances').alias('avg1'), ); const [results] = await datastore.runAggregationQuery(aggregate); assert.deepStrictEqual(results, [{avg1: 28.166666666666668}]); @@ -1948,7 +1948,7 @@ async.each( const aggregate = datastore .createAggregationQuery(q) .addAggregation( - AggregateField.average('appearances').alias('avg1') + AggregateField.average('appearances').alias('avg1'), ); const [results] = await datastore.runAggregationQuery(aggregate); assert.deepStrictEqual(results, [{avg1: 23.375}]); @@ -2005,7 +2005,7 @@ async.each( } catch (err: any) { assert.strictEqual( err.message, - '3 INVALID_ARGUMENT: Aggregations are not supported for the property: __key__' + '3 INVALID_ARGUMENT: Aggregations are not supported for the property: __key__', ); } }); @@ -2171,7 +2171,7 @@ async.each( } catch (err: any) { assert.strictEqual( err.message, - '3 INVALID_ARGUMENT: The maximum number of aggregations allowed in an aggregation query is 5. Received: 6' + '3 INVALID_ARGUMENT: The maximum number of aggregations allowed in an aggregation query is 5. Received: 6', ); } }); @@ -2188,14 +2188,14 @@ async.each( .createQuery('Character') .filter('status', null) .filters.pop()?.val, - null + null, ); assert.strictEqual( datastore .createQuery('Character') .filter('status', '=', null) .filters.pop()?.val, - null + null, ); }); it('should filter by key', async () => { @@ -2606,7 +2606,7 @@ async.each( }); }); }); - } + }, ); }); describe('comparing times with and without transaction.run', async () => { @@ -2780,7 +2780,7 @@ async.each( await datastore.delete(key); }); async function doRunAggregationQueryPutCommit( - transaction: Transaction + transaction: Transaction, ) { const query = transaction.createQuery('Company'); const aggregateQuery = transaction @@ -2814,7 +2814,7 @@ async.each( await datastore.delete(key); }); async function doPutRunAggregationQueryCommit( - transaction: Transaction + transaction: Transaction, ) { transaction.save({key, data: obj}); const query = transaction.createQuery('Company'); @@ -2991,7 +2991,7 @@ async.each( const [results] = await datastore.runQuery(query); assert.deepStrictEqual( results.map(result => result.rating), - [100, 100] + [100, 100], ); }); it('should aggregate query within a count transaction', async () => { @@ -3140,7 +3140,7 @@ async.each( const [indexes] = await datastore.getIndexes(); assert.ok( indexes.length >= DECLARED_INDEXES.length, - 'has at least the number of indexes per system-test/data/index.yaml' + 'has at least the number of indexes per system-test/data/index.yaml', ); // Comparing index.yaml and the actual defined index in Datastore requires @@ -3151,11 +3151,11 @@ async.each( assert.ok(firstIndex, 'first index is readable'); assert.ok( firstIndex.metadata!.properties, - 'has properties collection' + 'has properties collection', ); assert.ok( firstIndex.metadata!.properties.length, - 'with properties inside' + 'with properties inside', ); assert.ok(firstIndex.metadata!.ancestor, 'has the ancestor property'); }); @@ -3184,7 +3184,7 @@ async.each( assert.deepStrictEqual( metadata, firstIndex.metadata, - 'asked index is the same as received index' + 'asked index is the same as received index', ); }); }); @@ -3204,7 +3204,7 @@ async.each( const ms = Math.pow(2, retries) * 500 + Math.random() * 1000; return new Promise(done => { console.info( - `retrying "${test.test?.title}" after attempt ${currentAttempt} in ${ms}ms` + `retrying "${test.test?.title}" after attempt ${currentAttempt} in ${ms}ms`, ); setTimeout(done, ms); }); @@ -3234,7 +3234,7 @@ async.each( // Throw an error on every retry except the last one if (currentAttempt <= numberOfRetries) { throw Error( - 'This is not the last retry so throw an error to force the test to run again' + 'This is not the last retry so throw an error to force the test to run again', ); } // Check that the attempt number and the number of times console.info is called is correct. @@ -3268,7 +3268,7 @@ async.each( ( importOperation.metadata as google.datastore.admin.v1.IImportEntitiesMetadata ).inputUrl, - `gs://${exportedFile.bucket.name}/${exportedFile.name}` + `gs://${exportedFile.bucket.name}/${exportedFile.name}`, ); await importOperation.cancel(); @@ -3296,221 +3296,237 @@ async.each( assert.strictEqual(entity, undefined); }); }); - describe('Datastore mode data transforms', () => { - it('should perform a basic data transform', async () => { - const key = datastore.key(['Post', 'post1']); - const requestSpy = sinon.spy(datastore.request_); - datastore.request_ = requestSpy; - const result = await datastore.save({ - key: key, - data: { - name: 'test', - p1: 3, - p2: 4, - p3: 5, - a1: [3, 4, 5], - }, - transforms: [ - { - property: 'p1', - setToServerValue: true, - }, - { - property: 'p2', - increment: 4, - }, - { - property: 'p3', - maximum: 9, - }, - { - property: 'p2', - minimum: 6, - }, - { - property: 'a1', - appendMissingElements: [5, 6], - }, - { - property: 'a1', - removeAllFromArray: [3], - }, - ], - }); - // Clean the data from the server first before comparing: - result.forEach(serverResult => { - delete serverResult['indexUpdates']; - serverResult.mutationResults?.forEach(mutationResult => { - delete mutationResult['updateTime']; - delete mutationResult['createTime']; - delete mutationResult['version']; - mutationResult.transformResults?.forEach(transformResult => { - delete transformResult['timestampValue']; - }); - }); - }); - // Now the data should have fixed values. - // Do a comparison against the expected result. - assert.deepStrictEqual(result, [ + describe.only('Datastore mode data transforms', () => { + const key = datastore.key(['Post', 'post1']); + async.each( + [ { - mutationResults: [ - { - transformResults: [ - { - meaning: 0, - excludeFromIndexes: false, - valueType: 'timestampValue', - }, - { - meaning: 0, - excludeFromIndexes: false, - integerValue: '8', - valueType: 'integerValue', - }, - { - meaning: 0, - excludeFromIndexes: false, - integerValue: '9', - valueType: 'integerValue', - }, - { - meaning: 0, - excludeFromIndexes: false, - integerValue: '6', - valueType: 'integerValue', - }, - { - meaning: 0, - excludeFromIndexes: false, - nullValue: 'NULL_VALUE', - valueType: 'nullValue', - }, - { - meaning: 0, - excludeFromIndexes: false, - nullValue: 'NULL_VALUE', - valueType: 'nullValue', - }, - ], - key: null, - conflictDetected: false, + name: 'should perform a basic data transform', + saveArg: { + key: key, + data: { + name: 'test', + p1: 3, + p2: 4, + p3: 5, + a1: [3, 4, 5], }, - ], - commitTime: null, - }, - ]); - // Now check the value that was actually saved to the server: - const [entity] = await datastore.get(key); - const parsedResult = JSON.parse(JSON.stringify(entity)); - delete parsedResult['p1']; // This is a timestamp so we can't consistently test this. - assert.deepStrictEqual(parsedResult, { - name: 'test', - a1: [4, 5, 6], - p2: 6, - p3: 9, - }); - delete requestSpy.args[0][0].reqOpts.mutations[0].upsert.key - .partitionId['namespaceId']; - assert.deepStrictEqual(requestSpy.args[0][0], { - client: 'DatastoreClient', - method: 'commit', - reqOpts: { - mutations: [ + transforms: [ + { + property: 'p1', + setToServerValue: true, + }, + { + property: 'p2', + increment: 4, + }, + { + property: 'p3', + maximum: 9, + }, + { + property: 'p2', + minimum: 6, + }, + { + property: 'a1', + appendMissingElements: [5, 6], + }, + { + property: 'a1', + removeAllFromArray: [3], + }, + ], + }, + saveResult: [ { - upsert: { - key: { - path: [ + mutationResults: [ + { + transformResults: [ { - kind: 'Post', - name: 'post1', + meaning: 0, + excludeFromIndexes: false, + valueType: 'timestampValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '8', + valueType: 'integerValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '9', + valueType: 'integerValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '6', + valueType: 'integerValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + nullValue: 'NULL_VALUE', + valueType: 'nullValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + nullValue: 'NULL_VALUE', + valueType: 'nullValue', }, ], - partitionId: {}, + key: null, + conflictDetected: false, }, - properties: { - name: { - stringValue: 'test', - }, - p1: { - integerValue: '3', - }, - p2: { - integerValue: '4', - }, - p3: { - integerValue: '5', - }, - a1: { - arrayValue: { - values: [ - { - integerValue: '3', - }, - { - integerValue: '4', - }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + a1: [4, 5, 6], + p2: 6, + p3: 9, + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ { - integerValue: '5', + kind: 'Post', + name: 'post1', }, ], + partitionId: {}, }, - }, - }, - }, - propertyTransforms: [ - { - property: 'p1', - setToServerValue: 1, - }, - { - property: 'p2', - increment: { - integerValue: '4', - }, - }, - { - property: 'p3', - maximum: { - integerValue: '9', - }, - }, - { - property: 'p2', - minimum: { - integerValue: '6', - }, - }, - { - property: 'a1', - appendMissingElements: { - values: [ - { + properties: { + name: { + stringValue: 'test', + }, + p1: { + integerValue: '3', + }, + p2: { + integerValue: '4', + }, + p3: { integerValue: '5', }, - { - integerValue: '6', + a1: { + arrayValue: { + values: [ + { + integerValue: '3', + }, + { + integerValue: '4', + }, + { + integerValue: '5', + }, + ], + }, }, - ], + }, }, - }, - { - property: 'a1', - removeAllFromArray: { - values: [ - { - integerValue: '3', + propertyTransforms: [ + { + property: 'p1', + setToServerValue: 1, + }, + { + property: 'p2', + increment: { + integerValue: '4', }, - ], - }, + }, + { + property: 'p3', + maximum: { + integerValue: '9', + }, + }, + { + property: 'p2', + minimum: { + integerValue: '6', + }, + }, + { + property: 'a1', + appendMissingElements: { + values: [ + { + integerValue: '5', + }, + { + integerValue: '6', + }, + ], + }, + }, + { + property: 'a1', + removeAllFromArray: { + values: [ + { + integerValue: '3', + }, + ], + }, + }, + ], }, ], }, - ], + gaxOpts: {}, + }, }, - gaxOpts: {}, - }); - }); + ], + async (testParameters: any) => { + it(testParameters.name, async () => { + const requestSpy = sinon.spy(datastore.request_); + datastore.request_ = requestSpy; + const result = await datastore.save(testParameters.saveArg); + // Clean the data from the server first before comparing: + result.forEach(serverResult => { + delete serverResult['indexUpdates']; + serverResult.mutationResults?.forEach(mutationResult => { + delete mutationResult['updateTime']; + delete mutationResult['createTime']; + delete mutationResult['version']; + mutationResult.transformResults?.forEach(transformResult => { + delete transformResult['timestampValue']; + }); + }); + }); + // Now the data should have fixed values. + // Do a comparison against the expected result. + assert.deepStrictEqual(result, testParameters.saveResult); + // Now check the value that was actually saved to the server: + const [entity] = await datastore.get(key); + const parsedResult = JSON.parse(JSON.stringify(entity)); + delete parsedResult['p1']; // This is a timestamp so we can't consistently test this. + assert.deepStrictEqual(parsedResult, testParameters.serverValue); + delete requestSpy.args[0][0].reqOpts.mutations[0].upsert.key + .partitionId['namespaceId']; + assert.deepStrictEqual( + requestSpy.args[0][0], + testParameters.gapicRequest, + ); + }); + }, + ); }); }); - } + }, ); From a4710ed96dd5881e167b0d3bbd970c07cfe2b3fe Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Thu, 29 May 2025 14:52:38 -0400 Subject: [PATCH 20/21] Ran linter --- mock-server/datastore-server.ts | 6 +- samples/concepts.js | 24 +- samples/queryFilterOr.js | 2 +- samples/tasks.js | 10 +- src/aggregate.ts | 4 +- src/entity.ts | 36 +- src/filter.ts | 2 +- src/index-class.ts | 14 +- src/index.ts | 44 +-- src/query.ts | 14 +- src/request.ts | 82 ++--- src/transaction.ts | 54 +-- src/utils/entity/buildEntityProto.ts | 2 +- src/utils/entity/extendExcludeFromIndexes.ts | 6 +- src/v1/datastore_admin_client.ts | 146 ++++---- src/v1/datastore_client.ts | 108 +++--- system-test/datastore.ts | 148 ++++---- system-test/install.ts | 4 +- test/entity.ts | 86 ++--- test/entity/buildEntityProto.ts | 4 +- test/entity/excludeIndexesAndBuildProto.ts | 28 +- test/entity/extendExcludeFromIndexes.ts | 4 +- test/entity/findLargeProperties_.ts | 2 +- .../client-initialization-testing.ts | 10 +- test/gapic-mocks/commit.ts | 8 +- test/gapic-mocks/error-mocks.ts | 2 +- test/gapic-mocks/handwritten-errors.ts | 8 +- test/gapic-mocks/runQuery.ts | 8 +- test/gapic_datastore_admin_v1.ts | 330 +++++++++--------- test/gapic_datastore_v1.ts | 230 ++++++------ test/index.ts | 144 ++++---- test/query.ts | 47 ++- test/request.ts | 60 ++-- test/transaction.ts | 212 +++++------ 34 files changed, 943 insertions(+), 946 deletions(-) diff --git a/mock-server/datastore-server.ts b/mock-server/datastore-server.ts index c2e1ee5f2..2379f525b 100644 --- a/mock-server/datastore-server.ts +++ b/mock-server/datastore-server.ts @@ -21,7 +21,7 @@ const GAX_PROTOS_DIR = resolve( // @ts-ignore // eslint-disable-next-line n/no-extraneous-require dirname(require.resolve('google-gax')), - '../protos', + '../protos' ); const grpc = require('@grpc/grpc-js'); @@ -42,7 +42,7 @@ const descriptor = grpc.loadPackageDefinition(packageDefinition); */ function grpcEndpoint( call: {}, - callback: (arg1: string | null, arg2: {}) => {}, + callback: (arg1: string | null, arg2: {}) => {} ) { // SET A BREAKPOINT HERE AND EXPLORE `call` TO SEE THE REQUEST. callback(null, {message: 'Hello'}); @@ -62,6 +62,6 @@ export function startServer(cb: () => void) { () => { console.log('server started'); cb(); - }, + } ); } diff --git a/samples/concepts.js b/samples/concepts.js index 78ebb544d..6543142b9 100644 --- a/samples/concepts.js +++ b/samples/concepts.js @@ -491,7 +491,7 @@ class Metadata extends TestHelper { and([ new PropertyFilter('__key__', '>=', startKey), new PropertyFilter('__key__', '<', endKey), - ]), + ]) ); const [entities] = await datastore.runQuery(query); @@ -616,7 +616,7 @@ class Query extends TestHelper { and([ new PropertyFilter('done', '=', false), new PropertyFilter('priority', '>=', 4), - ]), + ]) ) .order('priority', { descending: true, @@ -684,7 +684,7 @@ class Query extends TestHelper { and([ new PropertyFilter('done', '=', false), new PropertyFilter('priority', '=', 4), - ]), + ]) ); // [END datastore_composite_filter] @@ -698,7 +698,7 @@ class Query extends TestHelper { const query = datastore .createQuery('Task') .filter( - new PropertyFilter('__key__', '>', datastore.key(['Task', 'someTask'])), + new PropertyFilter('__key__', '>', datastore.key(['Task', 'someTask'])) ); // [END datastore_key_filter] @@ -814,7 +814,7 @@ class Query extends TestHelper { and([ new PropertyFilter('tag', '>', 'learn'), new PropertyFilter('tag', '<', 'math'), - ]), + ]) ); // [END datastore_array_value_inequality_range] @@ -831,7 +831,7 @@ class Query extends TestHelper { and([ new PropertyFilter('tag', '=', 'fun'), new PropertyFilter('tag', '=', 'programming'), - ]), + ]) ); // [END datastore_array_value_equality] @@ -848,7 +848,7 @@ class Query extends TestHelper { and([ new PropertyFilter('created', '>', new Date('1990-01-01T00:00:00z')), new PropertyFilter('created', '<', new Date('2000-12-31T23:59:59z')), - ]), + ]) ); // [END datastore_inequality_range] @@ -865,7 +865,7 @@ class Query extends TestHelper { and([ new PropertyFilter('priority', '>', 3), new PropertyFilter('created', '>', new Date('1990-01-01T00:00:00z')), - ]), + ]) ); // [END datastore_inequality_invalid] @@ -884,7 +884,7 @@ class Query extends TestHelper { new PropertyFilter('done', '=', false), new PropertyFilter('created', '>', new Date('1990-01-01T00:00:00z')), new PropertyFilter('created', '<', new Date('2000-12-31T23:59:59z')), - ]), + ]) ); // [END datastore_equal_and_inequality_range] @@ -1071,11 +1071,11 @@ class Transaction extends TestHelper { datastore = datastoreMock; assert.strictEqual( accounts[0].balance, - originalBalance - amountToTransfer, + originalBalance - amountToTransfer ); assert.strictEqual( accounts[1].balance, - originalBalance + amountToTransfer, + originalBalance + amountToTransfer ); } catch (err) { datastore = datastoreMock; @@ -1201,7 +1201,7 @@ class Transaction extends TestHelper { // Restore `datastore` to the mock API. datastore = datastoreMock; return Promise.reject(err); - }, + } ); } } diff --git a/samples/queryFilterOr.js b/samples/queryFilterOr.js index deb911d77..80913cd9c 100644 --- a/samples/queryFilterOr.js +++ b/samples/queryFilterOr.js @@ -37,7 +37,7 @@ async function main() { or([ new PropertyFilter('description', '=', 'Buy milk'), new PropertyFilter('description', '=', 'Feed cats'), - ]), + ]) ); const [entities] = await datastore.runQuery(query); diff --git a/samples/tasks.js b/samples/tasks.js index eca5d3be2..e31c82958 100644 --- a/samples/tasks.js +++ b/samples/tasks.js @@ -162,23 +162,23 @@ require(`yargs`) // eslint-disable-line 'new ', 'Adds a task with a description .', {}, - opts => addTask(opts.description), + opts => addTask(opts.description) ) .command('done ', 'Marks the specified task as done.', {}, opts => - markDone(opts.taskId), + markDone(opts.taskId) ) .command('merge ', 'Marks the specified task as done.', {}, opts => - merge(opts.taskId, opts.description), + merge(opts.taskId, opts.description) ) .command('list', 'Lists all tasks ordered by creation time.', {}, listTasks) .command('delete ', 'Deletes a task.', {}, opts => - deleteTask(opts.taskId), + deleteTask(opts.taskId) ) .example('node $0 new "Buy milk"', 'Adds a task with description "Buy milk".') .example('node $0 done 12345', 'Marks task 12345 as Done.') .example( 'node $0 merge 12345', - 'update task 12345 with description "Buy food".', + 'update task 12345 with description "Buy food".' ) .example('node $0 list', 'Lists all tasks ordered by creation time') .example('node $0 delete 12345', 'Deletes task 12345.') diff --git a/src/aggregate.ts b/src/aggregate.ts index 3c07aeee3..d36172e4d 100644 --- a/src/aggregate.ts +++ b/src/aggregate.ts @@ -113,7 +113,7 @@ class AggregateQuery { */ run( optionsOrCallback?: RunQueryOptions | RequestCallback, - cb?: RequestCallback, + cb?: RequestCallback ): void | Promise { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -233,7 +233,7 @@ abstract class PropertyAggregateField extends AggregateField { return Object.assign( {operator: this.operator}, this.alias_ ? {alias: this.alias_} : null, - {[this.operator]: aggregation}, + {[this.operator]: aggregation} ); } } diff --git a/src/entity.ts b/src/entity.ts index bd041f029..42742e09e 100644 --- a/src/entity.ts +++ b/src/entity.ts @@ -136,7 +136,7 @@ export namespace entity { private _entityPropertyName: string | undefined; constructor( value: number | string | ValueProto, - typeCastOptions?: IntegerTypeCastOptions, + typeCastOptions?: IntegerTypeCastOptions ) { super(typeof value === 'object' ? value.integerValue : value); this._entityPropertyName = @@ -158,7 +158,7 @@ export namespace entity { this.typeCastFunction = typeCastOptions.integerTypeCastFunction; if (typeof typeCastOptions.integerTypeCastFunction !== 'function') { throw new Error( - 'integerTypeCastFunction is not a function or was not provided.', + 'integerTypeCastFunction is not a function or was not provided.' ); } @@ -440,7 +440,7 @@ export namespace entity { if (this.parent) { serializedKey.path = this.parent.serialized.path.concat( - serializedKey.path, + serializedKey.path ); } @@ -479,7 +479,7 @@ export namespace entity { '{\n' + ' integerTypeCastFunction: provide \n' + ' properties: optionally specify property name(s) to be custom casted\n' + - '}\n', + '}\n' ); } return num; @@ -527,7 +527,7 @@ export namespace entity { */ export function decodeValueProto( valueProto: ValueProto, - wrapNumbers?: boolean | IntegerTypeCastOptions, + wrapNumbers?: boolean | IntegerTypeCastOptions ) { const valueType = valueProto.valueType!; const value = valueProto[valueType]; @@ -536,7 +536,7 @@ export namespace entity { case 'arrayValue': { // eslint-disable-next-line @typescript-eslint/no-explicit-any return value.values.map((val: any) => - entity.decodeValueProto(val, wrapNumbers), + entity.decodeValueProto(val, wrapNumbers) ); } @@ -617,7 +617,7 @@ export namespace entity { "the value for '" + property + "' property is outside of bounds of a JavaScript Number.\n" + - "Use 'Datastore.int()' to preserve accuracy during the upload.", + "Use 'Datastore.int()' to preserve accuracy during the upload." ); } value = new entity.Int(value); @@ -730,7 +730,7 @@ export namespace entity { // eslint-disable-next-line @typescript-eslint/no-explicit-any export function entityFromEntityProto( entityProto: EntityProto, - wrapNumbers?: boolean | IntegerTypeCastOptions, + wrapNumbers?: boolean | IntegerTypeCastOptions ) { // eslint-disable-next-line @typescript-eslint/no-explicit-any const entityObject: any = {}; @@ -789,7 +789,7 @@ export namespace entity { return encoded; }, // eslint-disable-next-line @typescript-eslint/no-explicit-any - {} as any, + {} as any ), }; @@ -808,7 +808,7 @@ export namespace entity { */ export function addExcludeFromIndexes( excludeFromIndexes: string[] | undefined, - entityProto: EntityProto, + entityProto: EntityProto ): EntityProto { if (excludeFromIndexes && excludeFromIndexes.length > 0) { excludeFromIndexes.forEach((excludePath: string) => { @@ -889,14 +889,14 @@ export namespace entity { // (including entity values at their roots): excludePathFromEntity( value, - remainderPath, // === '' + remainderPath // === '' ); } else { // Path traversal continues at value.entityValue, // if it is an entity, or must end at value. excludePathFromEntity( value.entityValue || value, - remainderPath, // !== '' + remainderPath // !== '' ); } }); @@ -977,7 +977,7 @@ export namespace entity { */ export function formatArray( results: ResponseResult[], - wrapNumbers?: boolean | IntegerTypeCastOptions, + wrapNumbers?: boolean | IntegerTypeCastOptions ) { return results.map(result => { const ent = entity.entityFromEntityProto(result.entity!, wrapNumbers); @@ -998,7 +998,7 @@ export namespace entity { export function findLargeProperties_( entities: Entities, path: string, - properties: string[] = [], + properties: string[] = [] ) { const MAX_DATASTORE_VALUE_LENGTH = 1500; if (Array.isArray(entities)) { @@ -1011,7 +1011,7 @@ export namespace entity { findLargeProperties_( entities[key], path.concat(`${path ? '.' : ''}${key}`), - properties, + properties ); } } else if ( @@ -1259,7 +1259,7 @@ export namespace entity { if (query.filters.length > 0 || query.entityFilters.length > 0) { // Convert all legacy filters into new property filter objects const filters = query.filters.map( - filter => new PropertyFilter(filter.name, filter.op, filter.val), + filter => new PropertyFilter(filter.name, filter.op, filter.val) ); const entityFilters = query.entityFilters; const allFilters = entityFilters.concat(filters); @@ -1299,7 +1299,7 @@ export namespace entity { loadProtos_() { const root = new Protobuf.Root(); const loadedRoot = root.loadSync( - path.join(__dirname, '..', 'protos', 'app_engine_key.proto'), + path.join(__dirname, '..', 'protos', 'app_engine_key.proto') ); loadedRoot.resolveAll(); return loadedRoot.nested; @@ -1321,7 +1321,7 @@ export namespace entity { legacyEncode( projectId: string, key: entity.Key, - locationPrefix?: string, + locationPrefix?: string ): string { const elements: {}[] = []; let currentKey = key; diff --git a/src/filter.ts b/src/filter.ts index f59ba2c6e..d062fb2e3 100644 --- a/src/filter.ts +++ b/src/filter.ts @@ -100,7 +100,7 @@ export class PropertyFilter constructor( public name: T, public op: Operator, - public val: AllowedFilterValueType, + public val: AllowedFilterValueType ) { super(); } diff --git a/src/index-class.ts b/src/index-class.ts index 49027c990..64decbed4 100644 --- a/src/index-class.ts +++ b/src/index-class.ts @@ -22,7 +22,7 @@ export interface GenericIndexCallback { ( err?: ServiceError | null, index?: Index | null, - apiResponse?: T | null, + apiResponse?: T | null ): void; } @@ -31,7 +31,7 @@ export type GetIndexResponse = [Index, IIndex]; export type IndexGetMetadataCallback = ( err?: ServiceError | null, - metadata?: IIndex | null, + metadata?: IIndex | null ) => void; export type IndexGetMetadataResponse = [IIndex]; @@ -51,7 +51,7 @@ export type GetIndexesCallback = ( err?: ServiceError | null, indexes?: Index[], nextQuery?: GetIndexesOptions, - apiResponse?: google.datastore.admin.v1.IListIndexesResponse, + apiResponse?: google.datastore.admin.v1.IListIndexesResponse ) => void; export type IIndex = google.datastore.admin.v1.IIndex; @@ -93,7 +93,7 @@ export class Index { get(gaxOptions: CallOptions, callback: GetIndexCallback): void; get( gaxOptionsOrCallback?: CallOptions | GetIndexCallback, - cb?: GetIndexCallback, + cb?: GetIndexCallback ): void | Promise { const gaxOpts = typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {}; @@ -118,11 +118,11 @@ export class Index { getMetadata(callback: IndexGetMetadataCallback): void; getMetadata( gaxOptions: CallOptions, - callback: IndexGetMetadataCallback, + callback: IndexGetMetadataCallback ): void; getMetadata( gaxOptionsOrCallback?: CallOptions | IndexGetMetadataCallback, - cb?: IndexGetMetadataCallback, + cb?: IndexGetMetadataCallback ): void | Promise { const gaxOpts = typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {}; @@ -143,7 +143,7 @@ export class Index { this.metadata = resp; } callback(err as ServiceError, resp); - }, + } ); } diff --git a/src/index.ts b/src/index.ts index f2f99ab29..849387b31 100644 --- a/src/index.ts +++ b/src/index.ts @@ -107,7 +107,7 @@ export interface LongRunningCallback { ( err: ServiceError | null, operation?: Operation, - apiResponse?: google.longrunning.IOperation, + apiResponse?: google.longrunning.IOperation ): void; } export type LongRunningResponse = [Operation, google.longrunning.IOperation]; @@ -507,7 +507,7 @@ class Datastore extends DatastoreRequest { new Set([ ...gapic.v1.DatastoreClient.scopes, ...gapic.v1.DatastoreAdminClient.scopes, - ]), + ]) ); this.options = Object.assign( @@ -518,7 +518,7 @@ class Datastore extends DatastoreRequest { servicePath: this.baseUrl_, port: typeof this.port_ === 'number' ? this.port_ : 443, }, - options, + options ); const isUsingLocalhost = this.baseUrl_ && @@ -563,7 +563,7 @@ class Datastore extends DatastoreRequest { export(config: ExportEntitiesConfig, callback: LongRunningCallback): void; export( config: ExportEntitiesConfig, - callback?: LongRunningCallback, + callback?: LongRunningCallback ): void | Promise { const reqOpts: ExportEntitiesConfig = { entityFilter: {}, @@ -611,7 +611,7 @@ class Datastore extends DatastoreRequest { gaxOpts: config.gaxOptions, }, // eslint-disable-next-line @typescript-eslint/no-explicit-any - callback as any, + callback as any ); } @@ -633,7 +633,7 @@ class Datastore extends DatastoreRequest { getIndexes(callback: GetIndexesCallback): void; getIndexes( optionsOrCallback?: GetIndexesOptions | GetIndexesCallback, - cb?: GetIndexesCallback, + cb?: GetIndexesCallback ): void | Promise { let options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -685,7 +685,7 @@ class Datastore extends DatastoreRequest { const apiResp: google.datastore.admin.v1.IListIndexesResponse = resp[2]; callback(err as ServiceError, indexes, nextQuery, apiResp); - }, + } ); } @@ -713,7 +713,7 @@ class Datastore extends DatastoreRequest { next(null, indexInstance); }, }), - () => {}, + () => {} ); } @@ -751,7 +751,7 @@ class Datastore extends DatastoreRequest { import(config: ImportEntitiesConfig, callback: LongRunningCallback): void; import( config: ImportEntitiesConfig, - callback?: LongRunningCallback, + callback?: LongRunningCallback ): void | Promise { const reqOpts: ImportEntitiesConfig = { entityFilter: {}, @@ -799,7 +799,7 @@ class Datastore extends DatastoreRequest { gaxOpts: config.gaxOptions, }, // eslint-disable-next-line @typescript-eslint/no-explicit-any - callback as any, + callback as any ); } @@ -831,7 +831,7 @@ class Datastore extends DatastoreRequest { insert(entities: Entities, callback: InsertCallback): void; insert( entities: Entities, - callback?: InsertCallback, + callback?: InsertCallback ): void | Promise { entities = arrify(entities) .map(DatastoreRequest.prepareEntityObject_) @@ -1082,13 +1082,13 @@ class Datastore extends DatastoreRequest { save( entities: Entities, gaxOptions: CallOptions, - callback: SaveCallback, + callback: SaveCallback ): void; save(entities: Entities, callback: SaveCallback): void; save( entities: Entities, gaxOptionsOrCallback?: CallOptions | SaveCallback, - cb?: SaveCallback, + cb?: SaveCallback ): void | Promise { entities = arrify(entities) as SaveEntity[]; const gaxOptions = @@ -1118,7 +1118,7 @@ class Datastore extends DatastoreRequest { method = entityObject.method; } else { throw new Error( - 'Method ' + entityObject.method + ' not recognized.', + 'Method ' + entityObject.method + ' not recognized.' ); } } @@ -1150,7 +1150,7 @@ class Datastore extends DatastoreRequest { function onCommit( err?: Error | null, - resp?: google.datastore.v1.ICommitResponse, + resp?: google.datastore.v1.ICommitResponse ) { if (err || !resp) { callback(err, resp); @@ -1183,7 +1183,7 @@ class Datastore extends DatastoreRequest { reqOpts, gaxOpts: gaxOptions, }, - onCommit, + onCommit ); } @@ -1205,7 +1205,7 @@ class Datastore extends DatastoreRequest { update(entities: Entities, callback: UpdateCallback): void; update( entities: Entities, - callback?: UpdateCallback, + callback?: UpdateCallback ): void | Promise { entities = arrify(entities) .map(DatastoreRequest.prepareEntityObject_) @@ -1235,7 +1235,7 @@ class Datastore extends DatastoreRequest { upsert(entities: Entities, callback: UpsertCallback): void; upsert( entities: Entities, - callback?: UpsertCallback, + callback?: UpsertCallback ): void | Promise { entities = arrify(entities) .map(DatastoreRequest.prepareEntityObject_) @@ -1529,7 +1529,7 @@ class Datastore extends DatastoreRequest { createQuery(namespace: string, kind: string[]): Query; createQuery( namespaceOrKind?: string | string[], - kind?: string | string[], + kind?: string | string[] ): Query { let namespace = namespaceOrKind as string; if (!kind) { @@ -1708,17 +1708,17 @@ class Datastore extends DatastoreRequest { keyToLegacyUrlSafe(key: entity.Key, locationPrefix?: string): Promise; keyToLegacyUrlSafe( key: entity.Key, - callback: KeyToLegacyUrlSafeCallback, + callback: KeyToLegacyUrlSafeCallback ): void; keyToLegacyUrlSafe( key: entity.Key, locationPrefix: string, - callback: KeyToLegacyUrlSafeCallback, + callback: KeyToLegacyUrlSafeCallback ): void; keyToLegacyUrlSafe( key: entity.Key, locationPrefixOrCallback?: string | KeyToLegacyUrlSafeCallback, - callback?: KeyToLegacyUrlSafeCallback, + callback?: KeyToLegacyUrlSafeCallback ): Promise | void { const locationPrefix = typeof locationPrefixOrCallback === 'string' diff --git a/src/query.ts b/src/query.ts index 86ff6ff45..557ae12a7 100644 --- a/src/query.ts +++ b/src/query.ts @@ -91,12 +91,12 @@ class Query { constructor( scope?: Datastore | Transaction, namespace?: string | null, - kinds?: string[], + kinds?: string[] ); constructor( scope?: Datastore | Transaction, namespaceOrKinds?: string | string[] | null, - kinds?: string[], + kinds?: string[] ) { let namespace = namespaceOrKinds as string | null; if (!kinds) { @@ -212,22 +212,22 @@ class Query { filter(filter: EntityFilter): Query; filter( property: T, - value: AllowedFilterValueType, + value: AllowedFilterValueType ): Query; filter( property: T, operator: Operator, - value: AllowedFilterValueType, + value: AllowedFilterValueType ): Query; filter( propertyOrFilter: T | EntityFilter, operatorOrValue?: Operator | AllowedFilterValueType, - value?: AllowedFilterValueType, + value?: AllowedFilterValueType ): Query { if (arguments.length > 1) { gaxInstance.warn( 'filter', - 'Providing Filter objects like Composite Filter or Property Filter is recommended when using .filter', + 'Providing Filter objects like Composite Filter or Property Filter is recommended when using .filter' ); } switch (arguments.length) { @@ -524,7 +524,7 @@ class Query { run(callback: RunQueryCallback): void; run( optionsOrCallback?: RunQueryOptions | RunQueryCallback, - cb?: RunQueryCallback, + cb?: RunQueryCallback ): void | Promise { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; diff --git a/src/request.ts b/src/request.ts index dee2a09b2..a15597a05 100644 --- a/src/request.ts +++ b/src/request.ts @@ -93,7 +93,7 @@ function decodeStruct(structValue: google.protobuf.IStruct): JSONValue { function getInfoFromStats( resp: | protos.google.datastore.v1.IRunQueryResponse - | protos.google.datastore.v1.IRunAggregationQueryResponse, + | protos.google.datastore.v1.IRunAggregationQueryResponse ): RunQueryInfo { // Decode struct values stored in planSummary and executionStats const explainMetrics: ExplainMetrics = {}; @@ -106,7 +106,7 @@ function getInfoFromStats( Object.assign(explainMetrics, { planSummary: { indexesUsed: resp.explainMetrics.planSummary.indexesUsed.map( - (index: google.protobuf.IStruct) => decodeStruct(index), + (index: google.protobuf.IStruct) => decodeStruct(index) ), }, }); @@ -330,17 +330,17 @@ class DatastoreRequest { */ allocateIds( key: entity.Key, - options: AllocateIdsOptions | number, + options: AllocateIdsOptions | number ): Promise; allocateIds( key: entity.Key, options: AllocateIdsOptions | number, - callback: AllocateIdsCallback, + callback: AllocateIdsCallback ): void; allocateIds( key: entity.Key, options: AllocateIdsOptions | number, - callback?: AllocateIdsCallback, + callback?: AllocateIdsCallback ): void | Promise { if (entity.isKeyComplete(key)) { throw new Error('An incomplete key should be provided.'); @@ -363,7 +363,7 @@ class DatastoreRequest { } const keys = arrify(resp!.keys!).map(entity.keyFromKeyProto); callback!(null, keys, resp!); - }, + } ); } @@ -405,7 +405,7 @@ class DatastoreRequest { */ createReadStream( keys: Entities, - options: CreateReadStreamOptions = {}, + options: CreateReadStreamOptions = {} ): Transform { keys = arrify(keys).map(entity.keyToKeyProto); if (keys.length === 0) { @@ -436,7 +436,7 @@ class DatastoreRequest { try { entities = entity.formatArray( resp!.found! as ResponseResult[], - options.wrapNumbers, + options.wrapNumbers ); } catch (err) { stream.destroy(err); @@ -462,7 +462,7 @@ class DatastoreRequest { .catch(err => { throw err; }); - }, + } ); }; @@ -528,12 +528,12 @@ class DatastoreRequest { delete( keys: Entities, gaxOptions: CallOptions, - callback: DeleteCallback, + callback: DeleteCallback ): void; delete( keys: entity.Key | entity.Key[], gaxOptionsOrCallback?: CallOptions | DeleteCallback, - cb?: DeleteCallback, + cb?: DeleteCallback ): void | Promise { const gaxOptions = typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {}; @@ -561,7 +561,7 @@ class DatastoreRequest { reqOpts, gaxOpts: gaxOptions, }, - callback, + callback ); } @@ -660,18 +660,18 @@ class DatastoreRequest { */ get( keys: entity.Key | entity.Key[], - options?: CreateReadStreamOptions, + options?: CreateReadStreamOptions ): Promise; get(keys: entity.Key | entity.Key[], callback: GetCallback): void; get( keys: entity.Key | entity.Key[], options: CreateReadStreamOptions, - callback: GetCallback, + callback: GetCallback ): void; get( keys: entity.Key | entity.Key[], optionsOrCallback?: CreateReadStreamOptions | GetCallback, - cb?: GetCallback, + cb?: GetCallback ): void | Promise { const options = typeof optionsOrCallback === 'object' && optionsOrCallback @@ -687,7 +687,7 @@ class DatastoreRequest { concat((results: Entity[]) => { const isSingleLookup = !Array.isArray(keys); callback(null, isSingleLookup ? results[0] : results); - }), + }) ); } catch (err: any) { callback(err); @@ -727,21 +727,21 @@ class DatastoreRequest { **/ runAggregationQuery( query: AggregateQuery, - options?: RunQueryOptions, + options?: RunQueryOptions ): Promise; runAggregationQuery( query: AggregateQuery, options: RunQueryOptions, - callback: RunAggregationQueryCallback, + callback: RunAggregationQueryCallback ): void; runAggregationQuery( query: AggregateQuery, - callback: RunAggregationQueryCallback, + callback: RunAggregationQueryCallback ): void; runAggregationQuery( query: AggregateQuery, optionsOrCallback?: RunQueryOptions | RunAggregationQueryCallback, - cb?: RequestCallback, + cb?: RequestCallback ): void | Promise { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -795,7 +795,7 @@ class DatastoreRequest { const results = res.batch.aggregationResults; const finalResults = results .map( - (aggregationResult: any) => aggregationResult.aggregateProperties, + (aggregationResult: any) => aggregationResult.aggregateProperties ) .map((aggregateProperties: any) => Object.fromEntries( @@ -803,15 +803,15 @@ class DatastoreRequest { Object.keys(aggregateProperties).map(key => [ key, entity.decodeValueProto(aggregateProperties[key]), - ]), - ), - ), + ]) + ) + ) ); callback(err, finalResults, info); } else { callback(err, [], info); } - }, + } ); } @@ -918,13 +918,13 @@ class DatastoreRequest { runQuery( query: Query, options: RunQueryOptions, - callback: RunQueryCallback, + callback: RunQueryCallback ): void; runQuery(query: Query, callback: RunQueryCallback): void; runQuery( query: Query, optionsOrCallback?: RunQueryOptions | RunQueryCallback, - cb?: RunQueryCallback, + cb?: RunQueryCallback ): void | Promise { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -942,7 +942,7 @@ class DatastoreRequest { .pipe( concat((results: Entity[]) => { callback(null, results, info); - }), + }) ); } catch (err: any) { callback(err); @@ -1010,7 +1010,7 @@ class DatastoreRequest { reqOpts, gaxOpts: options.gaxOptions, }, - onResultSet, + onResultSet ); }; @@ -1042,7 +1042,7 @@ class DatastoreRequest { try { entities = entity.formatArray( resp.batch.entityResults, - options.wrapNumbers, + options.wrapNumbers ); } catch (err) { stream.destroy(err); @@ -1095,7 +1095,7 @@ class DatastoreRequest { * @param {RunQueryStreamOptions} [options] The RunQueryStream options configuration */ private getRequestOptions( - options: RunQueryStreamOptions, + options: RunQueryStreamOptions ): SharedQueryOptions { const sharedQueryOpts = {} as SharedQueryOptions; if (isTransaction(this)) { @@ -1105,7 +1105,7 @@ class DatastoreRequest { } sharedQueryOpts.readOptions.newTransaction = getTransactionRequest( this, - {}, + {} ); sharedQueryOpts.readOptions.consistencyType = 'newTransaction'; } @@ -1138,7 +1138,7 @@ class DatastoreRequest { */ private getQueryOptions( query: Query, - options: RunQueryStreamOptions = {}, + options: RunQueryStreamOptions = {} ): SharedQueryOptions { const sharedQueryOpts = this.getRequestOptions(options); if (options.explainOptions) { @@ -1179,7 +1179,7 @@ class DatastoreRequest { merge(entities: Entities, callback: SaveCallback): void; merge( entities: Entities, - callback?: SaveCallback, + callback?: SaveCallback ): void | Promise { const transaction = this.datastore.transaction(); transaction.run(async (err: any) => { @@ -1203,7 +1203,7 @@ class DatastoreRequest { obj.method = 'upsert'; obj.data = Object.assign({}, data, obj.data); transaction.save(obj); - }), + }) ); const [response] = await transaction.commit(); @@ -1278,7 +1278,7 @@ class DatastoreRequest { if (!datastore.clients_.has(clientName)) { datastore.clients_.set( clientName, - new gapic.v1[clientName](datastore.options), + new gapic.v1[clientName](datastore.options) ); } const gaxClient = datastore.clients_.get(clientName); @@ -1374,7 +1374,7 @@ function isTransaction(request: DatastoreRequest): request is Transaction { */ function throwOnTransactionErrors( request: DatastoreRequest, - options: SharedQueryOptions, + options: SharedQueryOptions ) { const isTransaction = request.id ? true : false; if ( @@ -1399,7 +1399,7 @@ function throwOnTransactionErrors( */ export function getTransactionRequest( transaction: Transaction, - options: RunOptions, + options: RunOptions ): TransactionRequestOptions { // If transactionOptions are provide then they will be used. // Otherwise, options passed into this function are used and when absent @@ -1433,7 +1433,7 @@ export interface AllocateIdsCallback { ( a: Error | null, b: entity.Key[] | null, - c: google.datastore.v1.IAllocateIdsResponse, + c: google.datastore.v1.IAllocateIdsResponse ): void; } export interface AllocateIdsOptions { @@ -1462,7 +1462,7 @@ export interface RequestCallback { ( a?: Error | null, // eslint-disable-next-line @typescript-eslint/no-explicit-any - b?: any, + b?: any ): void; } export interface RunAggregationQueryCallback { @@ -1470,7 +1470,7 @@ export interface RunAggregationQueryCallback { a?: Error | null, // eslint-disable-next-line @typescript-eslint/no-explicit-any b?: any, - c?: RunQueryInfo, + c?: RunQueryInfo ): void; } export interface RequestConfig { diff --git a/src/transaction.ts b/src/transaction.ts index 2525b0090..7068e03cb 100644 --- a/src/transaction.ts +++ b/src/transaction.ts @@ -171,7 +171,7 @@ class Transaction extends DatastoreRequest { commit(gaxOptions: CallOptions, callback: CommitCallback): void; commit( gaxOptionsOrCallback?: CallOptions | CommitCallback, - cb?: CommitCallback, + cb?: CommitCallback ): void | Promise { const callback = typeof gaxOptionsOrCallback === 'function' @@ -191,7 +191,7 @@ class Transaction extends DatastoreRequest { () => { void this.#runCommit(gaxOptions, callback); }, - callback, + callback ); } @@ -266,12 +266,12 @@ class Transaction extends DatastoreRequest { createQuery(namespace: string, kind: string[]): Query; createQuery( namespaceOrKind?: string | string[], - kind?: string | string[], + kind?: string | string[] ): Query { return this.datastore.createQuery.call( this, namespaceOrKind as string, - kind as string[], + kind as string[] ); } @@ -344,18 +344,18 @@ class Transaction extends DatastoreRequest { */ get( keys: entity.Key | entity.Key[], - options?: CreateReadStreamOptions, + options?: CreateReadStreamOptions ): Promise; get(keys: entity.Key | entity.Key[], callback: GetCallback): void; get( keys: entity.Key | entity.Key[], options: CreateReadStreamOptions, - callback: GetCallback, + callback: GetCallback ): void; get( keys: entity.Key | entity.Key[], optionsOrCallback?: CreateReadStreamOptions | GetCallback, - cb?: GetCallback, + cb?: GetCallback ): void | Promise { const options = typeof optionsOrCallback === 'object' && optionsOrCallback @@ -432,7 +432,7 @@ class Transaction extends DatastoreRequest { rollback(gaxOptions: CallOptions, callback: RollbackCallback): void; rollback( gaxOptionsOrCallback?: CallOptions | RollbackCallback, - cb?: RollbackCallback, + cb?: RollbackCallback ): void | Promise { const gaxOptions = typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {}; @@ -457,7 +457,7 @@ class Transaction extends DatastoreRequest { this.skipCommit = true; this.state = TransactionState.EXPIRED; callback(err || null, resp); - }, + } ); } @@ -518,7 +518,7 @@ class Transaction extends DatastoreRequest { run(options: RunOptions, callback: RunCallback): void; run( optionsOrCallback?: RunOptions | RunCallback, - cb?: RunCallback, + cb?: RunCallback ): void | Promise { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -530,7 +530,7 @@ class Transaction extends DatastoreRequest { this.#processBeginResults(runResults, callback); } else { process.emitWarning( - 'run has already been called and should not be called again.', + 'run has already been called and should not be called again.' ); callback(null, this, {transaction: this.id}); } @@ -548,7 +548,7 @@ class Transaction extends DatastoreRequest { */ #runCommit( gaxOptions: CallOptions, - callback: CommitCallback, + callback: CommitCallback ): void | Promise { if (this.skipCommit) { setImmediate(callback); @@ -600,7 +600,7 @@ class Transaction extends DatastoreRequest { acc.push(entityObject); } else { lastEntityObject.args = lastEntityObject.args.concat( - entityObject.args, + entityObject.args ); } @@ -616,7 +616,7 @@ class Transaction extends DatastoreRequest { const method = modifiedEntity.method; const args = modifiedEntity.args.reverse(); Datastore.prototype[method].call(this, args, () => {}); - }, + } ); // Take the `req` array built previously, and merge them into one request to @@ -626,7 +626,7 @@ class Transaction extends DatastoreRequest { .map((x: {mutations: google.datastore.v1.Mutation}) => x.mutations) .reduce( (a: {concat: (arg0: Entity) => void}, b: Entity) => a.concat(b), - [], + [] ), }; @@ -656,10 +656,10 @@ class Transaction extends DatastoreRequest { this.requestCallbacks_.forEach( (cb: (arg0: null, arg1: Entity) => void) => { cb(null, resp); - }, + } ); callback(null, resp); - }, + } ); } @@ -674,7 +674,7 @@ class Transaction extends DatastoreRequest { **/ #processBeginResults( runResults: BeginAsyncResponse, - callback: RunCallback, + callback: RunCallback ): void { const err = runResults.err; const resp = runResults.resp; @@ -696,7 +696,7 @@ class Transaction extends DatastoreRequest { * **/ async #beginTransactionAsync( - options: RunOptions, + options: RunOptions ): Promise { return new Promise((resolve: (value: BeginAsyncResponse) => void) => { const reqOpts = { @@ -715,7 +715,7 @@ class Transaction extends DatastoreRequest { err, resp, }); - }, + } ); }); } @@ -734,18 +734,18 @@ class Transaction extends DatastoreRequest { **/ runAggregationQuery( query: AggregateQuery, - options?: RunQueryOptions, + options?: RunQueryOptions ): Promise; runAggregationQuery( query: AggregateQuery, options: RunQueryOptions, - callback: RequestCallback, + callback: RequestCallback ): void; runAggregationQuery(query: AggregateQuery, callback: RequestCallback): void; runAggregationQuery( query: AggregateQuery, optionsOrCallback?: RunQueryOptions | RequestCallback, - cb?: RequestCallback, + cb?: RequestCallback ): void | Promise { const options = typeof optionsOrCallback === 'object' && optionsOrCallback @@ -774,13 +774,13 @@ class Transaction extends DatastoreRequest { runQuery( query: Query, options: RunQueryOptions, - callback: RunQueryCallback, + callback: RunQueryCallback ): void; runQuery(query: Query, callback: RunQueryCallback): void; runQuery( query: Query, optionsOrCallback?: RunQueryOptions | RunQueryCallback, - cb?: RunQueryCallback, + cb?: RunQueryCallback ): void | Promise { const options = typeof optionsOrCallback === 'object' && optionsOrCallback @@ -1008,7 +1008,7 @@ class Transaction extends DatastoreRequest { #withBeginTransaction( gaxOptions: CallOptions | undefined, fn: () => void, - callback: (...args: [Error | null, ...T] | [Error | null]) => void, + callback: (...args: [Error | null, ...T] | [Error | null]) => void ): void { (async () => { if (this.state === TransactionState.NOT_STARTED) { @@ -1081,7 +1081,7 @@ export interface RunCallback { ( error: Error | null, transaction: Transaction | null, - response?: google.datastore.v1.IBeginTransactionResponse, + response?: google.datastore.v1.IBeginTransactionResponse ): void; } export interface RollbackCallback { diff --git a/src/utils/entity/buildEntityProto.ts b/src/utils/entity/buildEntityProto.ts index a334d8b47..a4bbe80bd 100644 --- a/src/utils/entity/buildEntityProto.ts +++ b/src/utils/entity/buildEntityProto.ts @@ -48,7 +48,7 @@ export function buildEntityProto(entityObject: Entity) { return acc; }, - {}, + {} ); // This code adds excludeFromIndexes in the right places addExcludeFromIndexes(entityObject.excludeFromIndexes, entityProto); diff --git a/src/utils/entity/extendExcludeFromIndexes.ts b/src/utils/entity/extendExcludeFromIndexes.ts index 3f3787f9e..bca29fa5b 100644 --- a/src/utils/entity/extendExcludeFromIndexes.ts +++ b/src/utils/entity/extendExcludeFromIndexes.ts @@ -37,15 +37,15 @@ export function extendExcludeFromIndexes(entityObject: Entity) { entityObject.excludeFromIndexes = entity.findLargeProperties_( data.value, data.name.toString(), - entityObject.excludeFromIndexes, + entityObject.excludeFromIndexes ); - }, + } ); } else { entityObject.excludeFromIndexes = entity.findLargeProperties_( entityObject.data, '', - entityObject.excludeFromIndexes, + entityObject.excludeFromIndexes ); } } diff --git a/src/v1/datastore_admin_client.ts b/src/v1/datastore_admin_client.ts index 1156724c0..aaf7bfd82 100644 --- a/src/v1/datastore_admin_client.ts +++ b/src/v1/datastore_admin_client.ts @@ -157,7 +157,7 @@ export class DatastoreAdminClient { */ constructor( opts?: ClientOptions, - gaxInstance?: typeof gax | typeof gax.fallback, + gaxInstance?: typeof gax | typeof gax.fallback ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof DatastoreAdminClient; @@ -167,7 +167,7 @@ export class DatastoreAdminClient { opts?.universe_domain !== opts?.universeDomain ) { throw new Error( - 'Please set either universe_domain or universeDomain, but not both.', + 'Please set either universe_domain or universeDomain, but not both.' ); } const universeDomainEnvVar = @@ -253,7 +253,7 @@ export class DatastoreAdminClient { listIndexes: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', - 'indexes', + 'indexes' ), }; @@ -290,50 +290,50 @@ export class DatastoreAdminClient { .lro(lroOptions) .operationsClient(opts); const exportEntitiesResponse = protoFilesRoot.lookup( - '.google.datastore.admin.v1.ExportEntitiesResponse', + '.google.datastore.admin.v1.ExportEntitiesResponse' ) as gax.protobuf.Type; const exportEntitiesMetadata = protoFilesRoot.lookup( - '.google.datastore.admin.v1.ExportEntitiesMetadata', + '.google.datastore.admin.v1.ExportEntitiesMetadata' ) as gax.protobuf.Type; const importEntitiesResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty', + '.google.protobuf.Empty' ) as gax.protobuf.Type; const importEntitiesMetadata = protoFilesRoot.lookup( - '.google.datastore.admin.v1.ImportEntitiesMetadata', + '.google.datastore.admin.v1.ImportEntitiesMetadata' ) as gax.protobuf.Type; const createIndexResponse = protoFilesRoot.lookup( - '.google.datastore.admin.v1.Index', + '.google.datastore.admin.v1.Index' ) as gax.protobuf.Type; const createIndexMetadata = protoFilesRoot.lookup( - '.google.datastore.admin.v1.IndexOperationMetadata', + '.google.datastore.admin.v1.IndexOperationMetadata' ) as gax.protobuf.Type; const deleteIndexResponse = protoFilesRoot.lookup( - '.google.datastore.admin.v1.Index', + '.google.datastore.admin.v1.Index' ) as gax.protobuf.Type; const deleteIndexMetadata = protoFilesRoot.lookup( - '.google.datastore.admin.v1.IndexOperationMetadata', + '.google.datastore.admin.v1.IndexOperationMetadata' ) as gax.protobuf.Type; this.descriptors.longrunning = { exportEntities: new this._gaxModule.LongrunningDescriptor( this.operationsClient, exportEntitiesResponse.decode.bind(exportEntitiesResponse), - exportEntitiesMetadata.decode.bind(exportEntitiesMetadata), + exportEntitiesMetadata.decode.bind(exportEntitiesMetadata) ), importEntities: new this._gaxModule.LongrunningDescriptor( this.operationsClient, importEntitiesResponse.decode.bind(importEntitiesResponse), - importEntitiesMetadata.decode.bind(importEntitiesMetadata), + importEntitiesMetadata.decode.bind(importEntitiesMetadata) ), createIndex: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createIndexResponse.decode.bind(createIndexResponse), - createIndexMetadata.decode.bind(createIndexMetadata), + createIndexMetadata.decode.bind(createIndexMetadata) ), deleteIndex: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteIndexResponse.decode.bind(deleteIndexResponse), - deleteIndexMetadata.decode.bind(deleteIndexMetadata), + deleteIndexMetadata.decode.bind(deleteIndexMetadata) ), }; @@ -342,7 +342,7 @@ export class DatastoreAdminClient { 'google.datastore.admin.v1.DatastoreAdmin', gapicConfig as gax.ClientConfig, opts.clientConfig || {}, - {'x-goog-api-client': clientHeader.join(' ')}, + {'x-goog-api-client': clientHeader.join(' ')} ); // Set up a dictionary of "inner API calls"; the core implementation @@ -376,12 +376,12 @@ export class DatastoreAdminClient { this.datastoreAdminStub = this._gaxGrpc.createStub( this._opts.fallback ? (this._protos as protobuf.Root).lookupService( - 'google.datastore.admin.v1.DatastoreAdmin', + 'google.datastore.admin.v1.DatastoreAdmin' ) : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.datastore.admin.v1.DatastoreAdmin, this._opts, - this._providedCustomServicePath, + this._providedCustomServicePath ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides @@ -406,7 +406,7 @@ export class DatastoreAdminClient { }, (err: Error | null | undefined) => () => { throw err; - }, + } ); const descriptor = @@ -417,7 +417,7 @@ export class DatastoreAdminClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; @@ -438,7 +438,7 @@ export class DatastoreAdminClient { ) { process.emitWarning( 'Static servicePath is deprecated, please use the instance method instead.', - 'DeprecationWarning', + 'DeprecationWarning' ); } return 'datastore.googleapis.com'; @@ -456,7 +456,7 @@ export class DatastoreAdminClient { ) { process.emitWarning( 'Static apiEndpoint is deprecated, please use the instance method instead.', - 'DeprecationWarning', + 'DeprecationWarning' ); } return 'datastore.googleapis.com'; @@ -501,7 +501,7 @@ export class DatastoreAdminClient { * @returns {Promise} A promise that resolves to string containing the project ID. */ getProjectId( - callback?: Callback, + callback?: Callback ): Promise | void { if (callback) { this.auth.getProjectId(callback); @@ -533,7 +533,7 @@ export class DatastoreAdminClient { */ getIndex( request?: protos.google.datastore.admin.v1.IGetIndexRequest, - options?: CallOptions, + options?: CallOptions ): Promise< [ protos.google.datastore.admin.v1.IIndex, @@ -548,7 +548,7 @@ export class DatastoreAdminClient { protos.google.datastore.admin.v1.IIndex, protos.google.datastore.admin.v1.IGetIndexRequest | null | undefined, {} | null | undefined - >, + > ): void; getIndex( request: protos.google.datastore.admin.v1.IGetIndexRequest, @@ -556,7 +556,7 @@ export class DatastoreAdminClient { protos.google.datastore.admin.v1.IIndex, protos.google.datastore.admin.v1.IGetIndexRequest | null | undefined, {} | null | undefined - >, + > ): void; getIndex( request?: protos.google.datastore.admin.v1.IGetIndexRequest, @@ -571,7 +571,7 @@ export class DatastoreAdminClient { protos.google.datastore.admin.v1.IIndex, protos.google.datastore.admin.v1.IGetIndexRequest | null | undefined, {} | null | undefined - >, + > ): Promise< [ protos.google.datastore.admin.v1.IIndex, @@ -621,7 +621,7 @@ export class DatastoreAdminClient { ]) => { this._log.info('getIndex response %j', response); return [response, options, rawResponse]; - }, + } ); } @@ -675,7 +675,7 @@ export class DatastoreAdminClient { */ exportEntities( request?: protos.google.datastore.admin.v1.IExportEntitiesRequest, - options?: CallOptions, + options?: CallOptions ): Promise< [ LROperation< @@ -696,7 +696,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - >, + > ): void; exportEntities( request: protos.google.datastore.admin.v1.IExportEntitiesRequest, @@ -707,7 +707,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - >, + > ): void; exportEntities( request?: protos.google.datastore.admin.v1.IExportEntitiesRequest, @@ -728,7 +728,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - >, + > ): Promise< [ LROperation< @@ -786,7 +786,7 @@ export class DatastoreAdminClient { ]) => { this._log.info('exportEntities response %j', rawResponse); return [response, rawResponse, _]; - }, + } ); } /** @@ -801,7 +801,7 @@ export class DatastoreAdminClient { * region_tag:datastore_v1_generated_DatastoreAdmin_ExportEntities_async */ async checkExportEntitiesProgress( - name: string, + name: string ): Promise< LROperation< protos.google.datastore.admin.v1.ExportEntitiesResponse, @@ -811,13 +811,13 @@ export class DatastoreAdminClient { this._log.info('exportEntities long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( - {name}, + {name} ); const [operation] = await this.operationsClient.getOperation(request); const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.exportEntities, - this._gaxModule.createDefaultBackoffSettings(), + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.datastore.admin.v1.ExportEntitiesResponse, @@ -870,7 +870,7 @@ export class DatastoreAdminClient { */ importEntities( request?: protos.google.datastore.admin.v1.IImportEntitiesRequest, - options?: CallOptions, + options?: CallOptions ): Promise< [ LROperation< @@ -891,7 +891,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - >, + > ): void; importEntities( request: protos.google.datastore.admin.v1.IImportEntitiesRequest, @@ -902,7 +902,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - >, + > ): void; importEntities( request?: protos.google.datastore.admin.v1.IImportEntitiesRequest, @@ -923,7 +923,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - >, + > ): Promise< [ LROperation< @@ -981,7 +981,7 @@ export class DatastoreAdminClient { ]) => { this._log.info('importEntities response %j', rawResponse); return [response, rawResponse, _]; - }, + } ); } /** @@ -996,7 +996,7 @@ export class DatastoreAdminClient { * region_tag:datastore_v1_generated_DatastoreAdmin_ImportEntities_async */ async checkImportEntitiesProgress( - name: string, + name: string ): Promise< LROperation< protos.google.protobuf.Empty, @@ -1006,13 +1006,13 @@ export class DatastoreAdminClient { this._log.info('importEntities long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( - {name}, + {name} ); const [operation] = await this.operationsClient.getOperation(request); const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.importEntities, - this._gaxModule.createDefaultBackoffSettings(), + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.protobuf.Empty, @@ -1055,7 +1055,7 @@ export class DatastoreAdminClient { */ createIndex( request?: protos.google.datastore.admin.v1.ICreateIndexRequest, - options?: CallOptions, + options?: CallOptions ): Promise< [ LROperation< @@ -1076,7 +1076,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - >, + > ): void; createIndex( request: protos.google.datastore.admin.v1.ICreateIndexRequest, @@ -1087,7 +1087,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - >, + > ): void; createIndex( request?: protos.google.datastore.admin.v1.ICreateIndexRequest, @@ -1108,7 +1108,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - >, + > ): Promise< [ LROperation< @@ -1166,7 +1166,7 @@ export class DatastoreAdminClient { ]) => { this._log.info('createIndex response %j', rawResponse); return [response, rawResponse, _]; - }, + } ); } /** @@ -1181,7 +1181,7 @@ export class DatastoreAdminClient { * region_tag:datastore_v1_generated_DatastoreAdmin_CreateIndex_async */ async checkCreateIndexProgress( - name: string, + name: string ): Promise< LROperation< protos.google.datastore.admin.v1.Index, @@ -1191,13 +1191,13 @@ export class DatastoreAdminClient { this._log.info('createIndex long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( - {name}, + {name} ); const [operation] = await this.operationsClient.getOperation(request); const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.createIndex, - this._gaxModule.createDefaultBackoffSettings(), + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.datastore.admin.v1.Index, @@ -1236,7 +1236,7 @@ export class DatastoreAdminClient { */ deleteIndex( request?: protos.google.datastore.admin.v1.IDeleteIndexRequest, - options?: CallOptions, + options?: CallOptions ): Promise< [ LROperation< @@ -1257,7 +1257,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - >, + > ): void; deleteIndex( request: protos.google.datastore.admin.v1.IDeleteIndexRequest, @@ -1268,7 +1268,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - >, + > ): void; deleteIndex( request?: protos.google.datastore.admin.v1.IDeleteIndexRequest, @@ -1289,7 +1289,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - >, + > ): Promise< [ LROperation< @@ -1348,7 +1348,7 @@ export class DatastoreAdminClient { ]) => { this._log.info('deleteIndex response %j', rawResponse); return [response, rawResponse, _]; - }, + } ); } /** @@ -1363,7 +1363,7 @@ export class DatastoreAdminClient { * region_tag:datastore_v1_generated_DatastoreAdmin_DeleteIndex_async */ async checkDeleteIndexProgress( - name: string, + name: string ): Promise< LROperation< protos.google.datastore.admin.v1.Index, @@ -1373,13 +1373,13 @@ export class DatastoreAdminClient { this._log.info('deleteIndex long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( - {name}, + {name} ); const [operation] = await this.operationsClient.getOperation(request); const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.deleteIndex, - this._gaxModule.createDefaultBackoffSettings(), + this._gaxModule.createDefaultBackoffSettings() ); return decodeOperation as LROperation< protos.google.datastore.admin.v1.Index, @@ -1415,7 +1415,7 @@ export class DatastoreAdminClient { */ listIndexes( request?: protos.google.datastore.admin.v1.IListIndexesRequest, - options?: CallOptions, + options?: CallOptions ): Promise< [ protos.google.datastore.admin.v1.IIndex[], @@ -1430,7 +1430,7 @@ export class DatastoreAdminClient { protos.google.datastore.admin.v1.IListIndexesRequest, protos.google.datastore.admin.v1.IListIndexesResponse | null | undefined, protos.google.datastore.admin.v1.IIndex - >, + > ): void; listIndexes( request: protos.google.datastore.admin.v1.IListIndexesRequest, @@ -1438,7 +1438,7 @@ export class DatastoreAdminClient { protos.google.datastore.admin.v1.IListIndexesRequest, protos.google.datastore.admin.v1.IListIndexesResponse | null | undefined, protos.google.datastore.admin.v1.IIndex - >, + > ): void; listIndexes( request?: protos.google.datastore.admin.v1.IListIndexesRequest, @@ -1455,7 +1455,7 @@ export class DatastoreAdminClient { protos.google.datastore.admin.v1.IListIndexesRequest, protos.google.datastore.admin.v1.IListIndexesResponse | null | undefined, protos.google.datastore.admin.v1.IIndex - >, + > ): Promise< [ protos.google.datastore.admin.v1.IIndex[], @@ -1506,7 +1506,7 @@ export class DatastoreAdminClient { ]) => { this._log.info('listIndexes values %j', response); return [response, input, output]; - }, + } ); } @@ -1535,7 +1535,7 @@ export class DatastoreAdminClient { */ listIndexesStream( request?: protos.google.datastore.admin.v1.IListIndexesRequest, - options?: CallOptions, + options?: CallOptions ): Transform { request = request || {}; options = options || {}; @@ -1554,7 +1554,7 @@ export class DatastoreAdminClient { return this.descriptors.page.listIndexes.createStream( this.innerApiCalls.listIndexes as GaxCall, request, - callSettings, + callSettings ); } @@ -1586,7 +1586,7 @@ export class DatastoreAdminClient { */ listIndexesAsync( request?: protos.google.datastore.admin.v1.IListIndexesRequest, - options?: CallOptions, + options?: CallOptions ): AsyncIterable { request = request || {}; options = options || {}; @@ -1605,7 +1605,7 @@ export class DatastoreAdminClient { return this.descriptors.page.listIndexes.asyncIterate( this.innerApiCalls['listIndexes'] as GaxCall, request as {}, - callSettings, + callSettings ) as AsyncIterable; } /** @@ -1651,7 +1651,7 @@ export class DatastoreAdminClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - >, + > ): Promise<[protos.google.longrunning.Operation]> { let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { @@ -1701,7 +1701,7 @@ export class DatastoreAdminClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions, + options?: gax.CallOptions ): AsyncIterable { options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1756,7 +1756,7 @@ export class DatastoreAdminClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - >, + > ): Promise { let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { @@ -1813,7 +1813,7 @@ export class DatastoreAdminClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - >, + > ): Promise { let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { diff --git a/src/v1/datastore_client.ts b/src/v1/datastore_client.ts index 1b1158315..a12ca3782 100644 --- a/src/v1/datastore_client.ts +++ b/src/v1/datastore_client.ts @@ -114,7 +114,7 @@ export class DatastoreClient { */ constructor( opts?: ClientOptions, - gaxInstance?: typeof gax | typeof gax.fallback, + gaxInstance?: typeof gax | typeof gax.fallback ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof DatastoreClient; @@ -124,7 +124,7 @@ export class DatastoreClient { opts?.universe_domain !== opts?.universeDomain ) { throw new Error( - 'Please set either universe_domain or universeDomain, but not both.', + 'Please set either universe_domain or universeDomain, but not both.' ); } const universeDomainEnvVar = @@ -243,7 +243,7 @@ export class DatastoreClient { 'google.datastore.v1.Datastore', gapicConfig as gax.ClientConfig, opts.clientConfig || {}, - {'x-goog-api-client': clientHeader.join(' ')}, + {'x-goog-api-client': clientHeader.join(' ')} ); // Set up a dictionary of "inner API calls"; the core implementation @@ -277,12 +277,12 @@ export class DatastoreClient { this.datastoreStub = this._gaxGrpc.createStub( this._opts.fallback ? (this._protos as protobuf.Root).lookupService( - 'google.datastore.v1.Datastore', + 'google.datastore.v1.Datastore' ) : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.datastore.v1.Datastore, this._opts, - this._providedCustomServicePath, + this._providedCustomServicePath ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides @@ -309,7 +309,7 @@ export class DatastoreClient { }, (err: Error | null | undefined) => () => { throw err; - }, + } ); const descriptor = undefined; @@ -317,7 +317,7 @@ export class DatastoreClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; @@ -338,7 +338,7 @@ export class DatastoreClient { ) { process.emitWarning( 'Static servicePath is deprecated, please use the instance method instead.', - 'DeprecationWarning', + 'DeprecationWarning' ); } return 'datastore.googleapis.com'; @@ -356,7 +356,7 @@ export class DatastoreClient { ) { process.emitWarning( 'Static apiEndpoint is deprecated, please use the instance method instead.', - 'DeprecationWarning', + 'DeprecationWarning' ); } return 'datastore.googleapis.com'; @@ -401,7 +401,7 @@ export class DatastoreClient { * @returns {Promise} A promise that resolves to string containing the project ID. */ getProjectId( - callback?: Callback, + callback?: Callback ): Promise | void { if (callback) { this.auth.getProjectId(callback); @@ -447,7 +447,7 @@ export class DatastoreClient { */ lookup( request?: protos.google.datastore.v1.ILookupRequest, - options?: CallOptions, + options?: CallOptions ): Promise< [ protos.google.datastore.v1.ILookupResponse, @@ -462,7 +462,7 @@ export class DatastoreClient { protos.google.datastore.v1.ILookupResponse, protos.google.datastore.v1.ILookupRequest | null | undefined, {} | null | undefined - >, + > ): void; lookup( request: protos.google.datastore.v1.ILookupRequest, @@ -470,7 +470,7 @@ export class DatastoreClient { protos.google.datastore.v1.ILookupResponse, protos.google.datastore.v1.ILookupRequest | null | undefined, {} | null | undefined - >, + > ): void; lookup( request?: protos.google.datastore.v1.ILookupRequest, @@ -485,7 +485,7 @@ export class DatastoreClient { protos.google.datastore.v1.ILookupResponse, protos.google.datastore.v1.ILookupRequest | null | undefined, {} | null | undefined - >, + > ): Promise< [ protos.google.datastore.v1.ILookupResponse, @@ -553,7 +553,7 @@ export class DatastoreClient { ]) => { this._log.info('lookup response %j', response); return [response, options, rawResponse]; - }, + } ); } /** @@ -599,7 +599,7 @@ export class DatastoreClient { */ runQuery( request?: protos.google.datastore.v1.IRunQueryRequest, - options?: CallOptions, + options?: CallOptions ): Promise< [ protos.google.datastore.v1.IRunQueryResponse, @@ -614,7 +614,7 @@ export class DatastoreClient { protos.google.datastore.v1.IRunQueryResponse, protos.google.datastore.v1.IRunQueryRequest | null | undefined, {} | null | undefined - >, + > ): void; runQuery( request: protos.google.datastore.v1.IRunQueryRequest, @@ -622,7 +622,7 @@ export class DatastoreClient { protos.google.datastore.v1.IRunQueryResponse, protos.google.datastore.v1.IRunQueryRequest | null | undefined, {} | null | undefined - >, + > ): void; runQuery( request?: protos.google.datastore.v1.IRunQueryRequest, @@ -637,7 +637,7 @@ export class DatastoreClient { protos.google.datastore.v1.IRunQueryResponse, protos.google.datastore.v1.IRunQueryRequest | null | undefined, {} | null | undefined - >, + > ): Promise< [ protos.google.datastore.v1.IRunQueryResponse, @@ -705,7 +705,7 @@ export class DatastoreClient { ]) => { this._log.info('runQuery response %j', response); return [response, options, rawResponse]; - }, + } ); } /** @@ -745,7 +745,7 @@ export class DatastoreClient { */ runAggregationQuery( request?: protos.google.datastore.v1.IRunAggregationQueryRequest, - options?: CallOptions, + options?: CallOptions ): Promise< [ protos.google.datastore.v1.IRunAggregationQueryResponse, @@ -760,7 +760,7 @@ export class DatastoreClient { protos.google.datastore.v1.IRunAggregationQueryResponse, protos.google.datastore.v1.IRunAggregationQueryRequest | null | undefined, {} | null | undefined - >, + > ): void; runAggregationQuery( request: protos.google.datastore.v1.IRunAggregationQueryRequest, @@ -768,7 +768,7 @@ export class DatastoreClient { protos.google.datastore.v1.IRunAggregationQueryResponse, protos.google.datastore.v1.IRunAggregationQueryRequest | null | undefined, {} | null | undefined - >, + > ): void; runAggregationQuery( request?: protos.google.datastore.v1.IRunAggregationQueryRequest, @@ -785,7 +785,7 @@ export class DatastoreClient { protos.google.datastore.v1.IRunAggregationQueryResponse, protos.google.datastore.v1.IRunAggregationQueryRequest | null | undefined, {} | null | undefined - >, + > ): Promise< [ protos.google.datastore.v1.IRunAggregationQueryResponse, @@ -855,7 +855,7 @@ export class DatastoreClient { ]) => { this._log.info('runAggregationQuery response %j', response); return [response, options, rawResponse]; - }, + } ); } /** @@ -883,7 +883,7 @@ export class DatastoreClient { */ beginTransaction( request?: protos.google.datastore.v1.IBeginTransactionRequest, - options?: CallOptions, + options?: CallOptions ): Promise< [ protos.google.datastore.v1.IBeginTransactionResponse, @@ -898,7 +898,7 @@ export class DatastoreClient { protos.google.datastore.v1.IBeginTransactionResponse, protos.google.datastore.v1.IBeginTransactionRequest | null | undefined, {} | null | undefined - >, + > ): void; beginTransaction( request: protos.google.datastore.v1.IBeginTransactionRequest, @@ -906,7 +906,7 @@ export class DatastoreClient { protos.google.datastore.v1.IBeginTransactionResponse, protos.google.datastore.v1.IBeginTransactionRequest | null | undefined, {} | null | undefined - >, + > ): void; beginTransaction( request?: protos.google.datastore.v1.IBeginTransactionRequest, @@ -923,7 +923,7 @@ export class DatastoreClient { protos.google.datastore.v1.IBeginTransactionResponse, protos.google.datastore.v1.IBeginTransactionRequest | null | undefined, {} | null | undefined - >, + > ): Promise< [ protos.google.datastore.v1.IBeginTransactionResponse, @@ -993,7 +993,7 @@ export class DatastoreClient { ]) => { this._log.info('beginTransaction response %j', response); return [response, options, rawResponse]; - }, + } ); } /** @@ -1045,7 +1045,7 @@ export class DatastoreClient { */ commit( request?: protos.google.datastore.v1.ICommitRequest, - options?: CallOptions, + options?: CallOptions ): Promise< [ protos.google.datastore.v1.ICommitResponse, @@ -1060,7 +1060,7 @@ export class DatastoreClient { protos.google.datastore.v1.ICommitResponse, protos.google.datastore.v1.ICommitRequest | null | undefined, {} | null | undefined - >, + > ): void; commit( request: protos.google.datastore.v1.ICommitRequest, @@ -1068,7 +1068,7 @@ export class DatastoreClient { protos.google.datastore.v1.ICommitResponse, protos.google.datastore.v1.ICommitRequest | null | undefined, {} | null | undefined - >, + > ): void; commit( request?: protos.google.datastore.v1.ICommitRequest, @@ -1083,7 +1083,7 @@ export class DatastoreClient { protos.google.datastore.v1.ICommitResponse, protos.google.datastore.v1.ICommitRequest | null | undefined, {} | null | undefined - >, + > ): Promise< [ protos.google.datastore.v1.ICommitResponse, @@ -1151,7 +1151,7 @@ export class DatastoreClient { ]) => { this._log.info('commit response %j', response); return [response, options, rawResponse]; - }, + } ); } /** @@ -1180,7 +1180,7 @@ export class DatastoreClient { */ rollback( request?: protos.google.datastore.v1.IRollbackRequest, - options?: CallOptions, + options?: CallOptions ): Promise< [ protos.google.datastore.v1.IRollbackResponse, @@ -1195,7 +1195,7 @@ export class DatastoreClient { protos.google.datastore.v1.IRollbackResponse, protos.google.datastore.v1.IRollbackRequest | null | undefined, {} | null | undefined - >, + > ): void; rollback( request: protos.google.datastore.v1.IRollbackRequest, @@ -1203,7 +1203,7 @@ export class DatastoreClient { protos.google.datastore.v1.IRollbackResponse, protos.google.datastore.v1.IRollbackRequest | null | undefined, {} | null | undefined - >, + > ): void; rollback( request?: protos.google.datastore.v1.IRollbackRequest, @@ -1218,7 +1218,7 @@ export class DatastoreClient { protos.google.datastore.v1.IRollbackResponse, protos.google.datastore.v1.IRollbackRequest | null | undefined, {} | null | undefined - >, + > ): Promise< [ protos.google.datastore.v1.IRollbackResponse, @@ -1286,7 +1286,7 @@ export class DatastoreClient { ]) => { this._log.info('rollback response %j', response); return [response, options, rawResponse]; - }, + } ); } /** @@ -1316,7 +1316,7 @@ export class DatastoreClient { */ allocateIds( request?: protos.google.datastore.v1.IAllocateIdsRequest, - options?: CallOptions, + options?: CallOptions ): Promise< [ protos.google.datastore.v1.IAllocateIdsResponse, @@ -1331,7 +1331,7 @@ export class DatastoreClient { protos.google.datastore.v1.IAllocateIdsResponse, protos.google.datastore.v1.IAllocateIdsRequest | null | undefined, {} | null | undefined - >, + > ): void; allocateIds( request: protos.google.datastore.v1.IAllocateIdsRequest, @@ -1339,7 +1339,7 @@ export class DatastoreClient { protos.google.datastore.v1.IAllocateIdsResponse, protos.google.datastore.v1.IAllocateIdsRequest | null | undefined, {} | null | undefined - >, + > ): void; allocateIds( request?: protos.google.datastore.v1.IAllocateIdsRequest, @@ -1354,7 +1354,7 @@ export class DatastoreClient { protos.google.datastore.v1.IAllocateIdsResponse, protos.google.datastore.v1.IAllocateIdsRequest | null | undefined, {} | null | undefined - >, + > ): Promise< [ protos.google.datastore.v1.IAllocateIdsResponse, @@ -1422,7 +1422,7 @@ export class DatastoreClient { ]) => { this._log.info('allocateIds response %j', response); return [response, options, rawResponse]; - }, + } ); } /** @@ -1452,7 +1452,7 @@ export class DatastoreClient { */ reserveIds( request?: protos.google.datastore.v1.IReserveIdsRequest, - options?: CallOptions, + options?: CallOptions ): Promise< [ protos.google.datastore.v1.IReserveIdsResponse, @@ -1467,7 +1467,7 @@ export class DatastoreClient { protos.google.datastore.v1.IReserveIdsResponse, protos.google.datastore.v1.IReserveIdsRequest | null | undefined, {} | null | undefined - >, + > ): void; reserveIds( request: protos.google.datastore.v1.IReserveIdsRequest, @@ -1475,7 +1475,7 @@ export class DatastoreClient { protos.google.datastore.v1.IReserveIdsResponse, protos.google.datastore.v1.IReserveIdsRequest | null | undefined, {} | null | undefined - >, + > ): void; reserveIds( request?: protos.google.datastore.v1.IReserveIdsRequest, @@ -1490,7 +1490,7 @@ export class DatastoreClient { protos.google.datastore.v1.IReserveIdsResponse, protos.google.datastore.v1.IReserveIdsRequest | null | undefined, {} | null | undefined - >, + > ): Promise< [ protos.google.datastore.v1.IReserveIdsResponse, @@ -1558,7 +1558,7 @@ export class DatastoreClient { ]) => { this._log.info('reserveIds response %j', response); return [response, options, rawResponse]; - }, + } ); } @@ -1605,7 +1605,7 @@ export class DatastoreClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - >, + > ): Promise<[protos.google.longrunning.Operation]> { let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { @@ -1655,7 +1655,7 @@ export class DatastoreClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions, + options?: gax.CallOptions ): AsyncIterable { options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1710,7 +1710,7 @@ export class DatastoreClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - >, + > ): Promise { let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { @@ -1767,7 +1767,7 @@ export class DatastoreClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - >, + > ): Promise { let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { diff --git a/system-test/datastore.ts b/system-test/datastore.ts index 137b33f7b..6b149674f 100644 --- a/system-test/datastore.ts +++ b/system-test/datastore.ts @@ -58,7 +58,7 @@ async.each( }; const {indexes: DECLARED_INDEXES} = yaml.load( - readFileSync(path.join(__dirname, 'data', 'index.yaml'), 'utf8'), + readFileSync(path.join(__dirname, 'data', 'index.yaml'), 'utf8') ) as {indexes: google.datastore.admin.v1.IIndex[]}; // TODO/DX ensure indexes before testing, and maybe? cleanup indexes after @@ -472,10 +472,10 @@ async.each( key: secondaryDatastore.key(['Post', keyName]), data: postData, }; - }, + } ); await Promise.all( - secondaryData.map(async datum => secondaryDatastore.save(datum)), + secondaryData.map(async datum => secondaryDatastore.save(datum)) ); // Next, ensure that the default database has the right records const query = defaultDatastore @@ -486,7 +486,7 @@ async.each( assert.strictEqual(defaultDatastoreResults.length, 1); assert.strictEqual( defaultDatastoreResults[0].author, - defaultAuthor, + defaultAuthor ); // Next, ensure that the other database has the right records await Promise.all( @@ -497,12 +497,12 @@ async.each( const [results] = await secondaryDatastore.runQuery(query); assert.strictEqual(results.length, 1); assert.strictEqual(results[0].author, datum.data.author); - }), + }) ); // Cleanup await defaultDatastore.delete(defaultPostKey); await Promise.all( - secondaryData.map(datum => secondaryDatastore.delete(datum.key)), + secondaryData.map(datum => secondaryDatastore.delete(datum.key)) ); }); }); @@ -557,7 +557,7 @@ async.each( const data = { buf: Buffer.from( '010100000000000000000059400000000000006940', - 'hex', + 'hex' ), }; await datastore.save({key: postKey, data}); @@ -657,7 +657,7 @@ async.each( key: postKey, method: 'insert', data: post, - }), + }) ); const [entity] = await datastore.get(postKey); delete entity[datastore.KEY]; @@ -672,7 +672,7 @@ async.each( key: postKey, method: 'update', data: post, - }), + }) ); }); @@ -721,7 +721,7 @@ async.each( assert.strictEqual(numEntitiesEmitted, 2); datastore.delete([key1, key2], done); }); - }, + } ); }); @@ -1101,7 +1101,7 @@ async.each( and([ new PropertyFilter('family', '=', 'Stark'), new PropertyFilter('appearances', '>=', 20), - ]), + ]) ); const [entities] = await datastore.runQuery(q); assert.strictEqual(entities!.length, 6); @@ -1121,7 +1121,7 @@ async.each( or([ new PropertyFilter('family', '=', 'Stark'), new PropertyFilter('appearances', '>=', 20), - ]), + ]) ); const [entities] = await datastore.runQuery(q); assert.strictEqual(entities!.length, 8); @@ -1213,7 +1213,7 @@ async.each( }); } function checkAggregationQueryExecutionStats( - executionStats?: ExecutionStats, + executionStats?: ExecutionStats ) { // This function ensures the execution stats returned from the server are correct. // First fix stats values that will be different every time a query profiling @@ -1263,7 +1263,7 @@ async.each( assert(!info.explainMetrics); assert.deepStrictEqual( entities.sort(compare).map(entity => entity.name), - [...characters].sort(compare).map(entity => entity.name), + [...characters].sort(compare).map(entity => entity.name) ); await transaction.commit(); }); @@ -1285,7 +1285,7 @@ async.each( assert.deepStrictEqual(entities, []); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan, + expectedRunQueryPlan ); await transaction.commit(); }); @@ -1307,7 +1307,7 @@ async.each( assert.deepStrictEqual(entities, []); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan, + expectedRunQueryPlan ); await transaction.commit(); }); @@ -1326,13 +1326,13 @@ async.each( } assert.deepStrictEqual( entities.sort(compare).map(entity => entity.name), - [...characters].sort(compare).map(entity => entity.name), + [...characters].sort(compare).map(entity => entity.name) ); assert(info.explainMetrics); checkQueryExecutionStats(info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan, + expectedRunQueryPlan ); await transaction.commit(); }); @@ -1360,7 +1360,7 @@ async.each( try { [entities, info] = await transaction.runAggregationQuery( aggregate, - {}, + {} ); } catch (e) { await transaction.rollback(); @@ -1378,7 +1378,7 @@ async.each( aggregate, { explainOptions: {}, - }, + } ); } catch (e) { await transaction.rollback(); @@ -1388,7 +1388,7 @@ async.each( assert.deepStrictEqual(entities, []); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan, + expectedRunAggregationQueryPlan ); await transaction.commit(); }); @@ -1402,7 +1402,7 @@ async.each( explainOptions: { analyze: false, }, - }, + } ); } catch (e) { await transaction.rollback(); @@ -1412,7 +1412,7 @@ async.each( assert.deepStrictEqual(entities, []); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan, + expectedRunAggregationQueryPlan ); await transaction.commit(); }); @@ -1424,7 +1424,7 @@ async.each( aggregate, { explainOptions: {analyze: true}, - }, + } ); } catch (e) { await transaction.rollback(); @@ -1433,11 +1433,11 @@ async.each( assert(info.explainMetrics); assert.deepStrictEqual(entities, expectedAggregationResults); checkAggregationQueryExecutionStats( - info.explainMetrics.executionStats, + info.explainMetrics.executionStats ); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan, + expectedRunAggregationQueryPlan ); await transaction.commit(); }); @@ -1450,7 +1450,7 @@ async.each( assert(!info.explainMetrics); assert.deepStrictEqual( entities.sort(compare).map(entity => entity.name), - [...characters].sort(compare).map(entity => entity.name), + [...characters].sort(compare).map(entity => entity.name) ); }); it('should run a query with explain options and no analyze option specified', async () => { @@ -1462,7 +1462,7 @@ async.each( assert(!info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan, + expectedRunQueryPlan ); }); it('should run a query with explain options and analyze set to false', async () => { @@ -1474,7 +1474,7 @@ async.each( assert(!info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan, + expectedRunQueryPlan ); }); it('should run a query with explain options and analyze set to true', async () => { @@ -1483,13 +1483,13 @@ async.each( }); assert.deepStrictEqual( entities.sort(compare).map(entity => entity.name), - [...characters].sort(compare).map(entity => entity.name), + [...characters].sort(compare).map(entity => entity.name) ); assert(info.explainMetrics); checkQueryExecutionStats(info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan, + expectedRunQueryPlan ); }); }); @@ -1500,7 +1500,7 @@ async.each( assert(!info.explainMetrics); assert.deepStrictEqual( entities.sort(compare).map(entity => entity.name), - [...characters].sort(compare).map(entity => entity.name), + [...characters].sort(compare).map(entity => entity.name) ); }); it('should run a query with explain options and no value set for analyze', async () => { @@ -1510,7 +1510,7 @@ async.each( assert(!info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan, + expectedRunQueryPlan ); }); it('should run a query with explain options and analyze set to false', async () => { @@ -1522,7 +1522,7 @@ async.each( assert(!info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan, + expectedRunQueryPlan ); }); it('should run a query with explain options and analyze set to true', async () => { @@ -1531,14 +1531,14 @@ async.each( }); assert.deepStrictEqual( entities.sort(compare).map(entity => entity.name), - [...characters].sort(compare).map(entity => entity.name), + [...characters].sort(compare).map(entity => entity.name) ); assert(info.explainMetrics); checkQueryExecutionStats(info.explainMetrics.executionStats); assert(info.explainMetrics.planSummary); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan, + expectedRunQueryPlan ); }); }); @@ -1562,7 +1562,7 @@ async.each( entities .sort(compare) .map((entity: Entity) => entity?.name), - [...characters].sort(compare).map(entity => entity.name), + [...characters].sort(compare).map(entity => entity.name) ); assert(!savedInfo.explainMetrics); resolve(); @@ -1590,7 +1590,7 @@ async.each( assert(!savedInfo.explainMetrics.executionStats); assert.deepStrictEqual( savedInfo.explainMetrics.planSummary, - expectedRunQueryPlan, + expectedRunQueryPlan ); resolve(); }); @@ -1619,7 +1619,7 @@ async.each( assert(!savedInfo.explainMetrics.executionStats); assert.deepStrictEqual( savedInfo.explainMetrics.planSummary, - expectedRunQueryPlan, + expectedRunQueryPlan ); resolve(); }); @@ -1645,15 +1645,15 @@ async.each( entities .sort(compare) .map((entity: Entity) => entity?.name), - [...characters].sort(compare).map(entity => entity.name), + [...characters].sort(compare).map(entity => entity.name) ); assert(savedInfo.explainMetrics); checkQueryExecutionStats( - savedInfo.explainMetrics.executionStats, + savedInfo.explainMetrics.executionStats ); assert.deepStrictEqual( savedInfo.explainMetrics.planSummary, - expectedRunQueryPlan, + expectedRunQueryPlan ); resolve(); }); @@ -1681,14 +1681,14 @@ async.each( aggregate, { explainOptions: {}, - }, + } ); assert.deepStrictEqual(entities, []); assert(info.explainMetrics); assert(!info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan, + expectedRunAggregationQueryPlan ); }); it('should run an aggregation query with explain options specified and analyze set to false', async () => { @@ -1696,14 +1696,14 @@ async.each( aggregate, { explainOptions: {analyze: false}, - }, + } ); assert.deepStrictEqual(entities, []); assert(info.explainMetrics); assert(!info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan, + expectedRunAggregationQueryPlan ); }); it('should run an aggregation query with explain options and analyze set to true', async () => { @@ -1711,16 +1711,16 @@ async.each( aggregate, { explainOptions: {analyze: true}, - }, + } ); assert.deepStrictEqual(entities, expectedAggregationResults); assert(info.explainMetrics); checkAggregationQueryExecutionStats( - info.explainMetrics.executionStats, + info.explainMetrics.executionStats ); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan, + expectedRunAggregationQueryPlan ); }); }); @@ -1748,7 +1748,7 @@ async.each( assert(!info.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan, + expectedRunAggregationQueryPlan ); }); it('should run an aggregation query with explain options and analyze set to false', async () => { @@ -1762,7 +1762,7 @@ async.each( assert(!info.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan, + expectedRunAggregationQueryPlan ); }); it('should run an aggregation query with explain options specified and analyze set to true', async () => { @@ -1772,11 +1772,11 @@ async.each( assert.deepStrictEqual(entities, expectedAggregationResults); assert(info.explainMetrics); checkAggregationQueryExecutionStats( - info.explainMetrics.executionStats, + info.explainMetrics.executionStats ); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan, + expectedRunAggregationQueryPlan ); }); }); @@ -1871,7 +1871,7 @@ async.each( } catch (err: any) { assert.strictEqual( err.message, - '3 INVALID_ARGUMENT: Aggregations are not supported for the property: __key__', + '3 INVALID_ARGUMENT: Aggregations are not supported for the property: __key__' ); } }); @@ -1938,7 +1938,7 @@ async.each( const aggregate = datastore .createAggregationQuery(q) .addAggregation( - AggregateField.average('appearances').alias('avg1'), + AggregateField.average('appearances').alias('avg1') ); const [results] = await datastore.runAggregationQuery(aggregate); assert.deepStrictEqual(results, [{avg1: 28.166666666666668}]); @@ -1948,7 +1948,7 @@ async.each( const aggregate = datastore .createAggregationQuery(q) .addAggregation( - AggregateField.average('appearances').alias('avg1'), + AggregateField.average('appearances').alias('avg1') ); const [results] = await datastore.runAggregationQuery(aggregate); assert.deepStrictEqual(results, [{avg1: 23.375}]); @@ -2005,7 +2005,7 @@ async.each( } catch (err: any) { assert.strictEqual( err.message, - '3 INVALID_ARGUMENT: Aggregations are not supported for the property: __key__', + '3 INVALID_ARGUMENT: Aggregations are not supported for the property: __key__' ); } }); @@ -2171,7 +2171,7 @@ async.each( } catch (err: any) { assert.strictEqual( err.message, - '3 INVALID_ARGUMENT: The maximum number of aggregations allowed in an aggregation query is 5. Received: 6', + '3 INVALID_ARGUMENT: The maximum number of aggregations allowed in an aggregation query is 5. Received: 6' ); } }); @@ -2188,14 +2188,14 @@ async.each( .createQuery('Character') .filter('status', null) .filters.pop()?.val, - null, + null ); assert.strictEqual( datastore .createQuery('Character') .filter('status', '=', null) .filters.pop()?.val, - null, + null ); }); it('should filter by key', async () => { @@ -2606,7 +2606,7 @@ async.each( }); }); }); - }, + } ); }); describe('comparing times with and without transaction.run', async () => { @@ -2780,7 +2780,7 @@ async.each( await datastore.delete(key); }); async function doRunAggregationQueryPutCommit( - transaction: Transaction, + transaction: Transaction ) { const query = transaction.createQuery('Company'); const aggregateQuery = transaction @@ -2814,7 +2814,7 @@ async.each( await datastore.delete(key); }); async function doPutRunAggregationQueryCommit( - transaction: Transaction, + transaction: Transaction ) { transaction.save({key, data: obj}); const query = transaction.createQuery('Company'); @@ -2991,7 +2991,7 @@ async.each( const [results] = await datastore.runQuery(query); assert.deepStrictEqual( results.map(result => result.rating), - [100, 100], + [100, 100] ); }); it('should aggregate query within a count transaction', async () => { @@ -3140,7 +3140,7 @@ async.each( const [indexes] = await datastore.getIndexes(); assert.ok( indexes.length >= DECLARED_INDEXES.length, - 'has at least the number of indexes per system-test/data/index.yaml', + 'has at least the number of indexes per system-test/data/index.yaml' ); // Comparing index.yaml and the actual defined index in Datastore requires @@ -3151,11 +3151,11 @@ async.each( assert.ok(firstIndex, 'first index is readable'); assert.ok( firstIndex.metadata!.properties, - 'has properties collection', + 'has properties collection' ); assert.ok( firstIndex.metadata!.properties.length, - 'with properties inside', + 'with properties inside' ); assert.ok(firstIndex.metadata!.ancestor, 'has the ancestor property'); }); @@ -3184,7 +3184,7 @@ async.each( assert.deepStrictEqual( metadata, firstIndex.metadata, - 'asked index is the same as received index', + 'asked index is the same as received index' ); }); }); @@ -3204,7 +3204,7 @@ async.each( const ms = Math.pow(2, retries) * 500 + Math.random() * 1000; return new Promise(done => { console.info( - `retrying "${test.test?.title}" after attempt ${currentAttempt} in ${ms}ms`, + `retrying "${test.test?.title}" after attempt ${currentAttempt} in ${ms}ms` ); setTimeout(done, ms); }); @@ -3234,7 +3234,7 @@ async.each( // Throw an error on every retry except the last one if (currentAttempt <= numberOfRetries) { throw Error( - 'This is not the last retry so throw an error to force the test to run again', + 'This is not the last retry so throw an error to force the test to run again' ); } // Check that the attempt number and the number of times console.info is called is correct. @@ -3268,7 +3268,7 @@ async.each( ( importOperation.metadata as google.datastore.admin.v1.IImportEntitiesMetadata ).inputUrl, - `gs://${exportedFile.bucket.name}/${exportedFile.name}`, + `gs://${exportedFile.bucket.name}/${exportedFile.name}` ); await importOperation.cancel(); @@ -3521,12 +3521,12 @@ async.each( .partitionId['namespaceId']; assert.deepStrictEqual( requestSpy.args[0][0], - testParameters.gapicRequest, + testParameters.gapicRequest ); }); - }, + } ); }); }); - }, + } ); diff --git a/system-test/install.ts b/system-test/install.ts index 5257a7ba1..d927b3436 100644 --- a/system-test/install.ts +++ b/system-test/install.ts @@ -28,7 +28,7 @@ describe('📦 pack-n-play test', () => { sample: { description: 'TypeScript user can use the type definitions', ts: readFileSync( - './system-test/fixtures/sample/src/index.ts', + './system-test/fixtures/sample/src/index.ts' ).toString(), }, }; @@ -42,7 +42,7 @@ describe('📦 pack-n-play test', () => { sample: { description: 'JavaScript user can use the library', ts: readFileSync( - './system-test/fixtures/sample/src/index.js', + './system-test/fixtures/sample/src/index.js' ).toString(), }, }; diff --git a/test/entity.ts b/test/entity.ts index 2d4060573..88b4c1d10 100644 --- a/test/entity.ts +++ b/test/entity.ts @@ -40,7 +40,7 @@ export function outOfBoundsError(opts: { '{\n' + ' integerTypeCastFunction: provide \n' + ' properties: optionally specify property name(s) to be custom casted\n' + - '}\n', + '}\n' ); } @@ -127,7 +127,7 @@ describe('entity', () => { it('should throw if integerTypeCastOptions is provided but integerTypeCastFunction is not', () => { assert.throws( () => new testEntity.Int(valueProto, {}).valueOf(), - /integerTypeCastFunction is not a function or was not provided\./, + /integerTypeCastFunction is not a function or was not provided\./ ); }); @@ -163,7 +163,7 @@ describe('entity', () => { () => { new testEntity.Int(largeIntegerValue).valueOf(); }, - outOfBoundsError({integerValue: largeIntegerValue}), + outOfBoundsError({integerValue: largeIntegerValue}) ); // should throw when string is passed @@ -171,7 +171,7 @@ describe('entity', () => { () => { new testEntity.Int(smallIntegerValue.toString()).valueOf(); }, - outOfBoundsError({integerValue: smallIntegerValue}), + outOfBoundsError({integerValue: smallIntegerValue}) ); }); @@ -187,7 +187,7 @@ describe('entity', () => { () => { new testEntity.Int(valueProto); }, - new RegExp(`Integer value ${largeIntegerValue} is out of bounds.`), + new RegExp(`Integer value ${largeIntegerValue} is out of bounds.`) ); }); }); @@ -199,7 +199,7 @@ describe('entity', () => { new testEntity.Int(valueProto, { integerTypeCastFunction: {}, }).valueOf(), - /integerTypeCastFunction is not a function or was not provided\./, + /integerTypeCastFunction is not a function or was not provided\./ ); }); @@ -459,7 +459,7 @@ describe('entity', () => { assert.deepStrictEqual( testEntity.decodeValueProto(valueProto), - expectedValue, + expectedValue ); }); @@ -467,7 +467,7 @@ describe('entity', () => { const decodeValueProto = testEntity.decodeValueProto; testEntity.decodeValueProto = ( valueProto: {}, - wrapNumbers?: boolean | {}, + wrapNumbers?: boolean | {} ) => { assert.strictEqual(wrapNumbers, undefined); @@ -486,7 +486,7 @@ describe('entity', () => { let run = false; testEntity.decodeValueProto = ( valueProto: {}, - wrapNumbers?: boolean | {}, + wrapNumbers?: boolean | {} ) => { if (!run) { run = true; @@ -500,14 +500,14 @@ describe('entity', () => { assert.deepStrictEqual( testEntity.decodeValueProto(valueProto, wrapNumbersBoolean), - expectedValue, + expectedValue ); // reset the run flag. run = false; assert.deepStrictEqual( testEntity.decodeValueProto(valueProto, wrapNumbersObject), - expectedValue, + expectedValue ); }); }); @@ -528,7 +528,7 @@ describe('entity', () => { assert.strictEqual( testEntity.decodeValueProto(valueProto), - expectedValue, + expectedValue ); }); @@ -542,7 +542,7 @@ describe('entity', () => { testEntity.entityFromEntityProto = ( entityProto: {}, - wrapNumbers?: boolean | {}, + wrapNumbers?: boolean | {} ) => { assert.strictEqual(wrapNumbers, undefined); assert.strictEqual(entityProto, expectedValue); @@ -551,7 +551,7 @@ describe('entity', () => { assert.strictEqual( testEntity.decodeValueProto(valueProto), - expectedValue, + expectedValue ); }); @@ -567,7 +567,7 @@ describe('entity', () => { testEntity.entityFromEntityProto = ( entityProto: {}, - wrapNumbers?: boolean | {}, + wrapNumbers?: boolean | {} ) => { // verify that `wrapNumbers`param is passed (boolean or object) assert.ok(wrapNumbers); @@ -577,12 +577,12 @@ describe('entity', () => { assert.strictEqual( testEntity.decodeValueProto(valueProto, wrapNumbersBoolean), - expectedValue, + expectedValue ); assert.strictEqual( testEntity.decodeValueProto(valueProto, wrapNumbersObject), - expectedValue, + expectedValue ); }); }); @@ -597,7 +597,7 @@ describe('entity', () => { it('should not wrap ints by default', () => { assert.strictEqual( typeof testEntity.decodeValueProto(valueProto), - 'number', + 'number' ); }); @@ -653,7 +653,7 @@ describe('entity', () => { assert.strictEqual( testEntity.decodeValueProto(valueProto, wrapNumbers), - takeFirstTen(Number.MAX_SAFE_INTEGER), + takeFirstTen(Number.MAX_SAFE_INTEGER) ); assert.strictEqual(takeFirstTen.called, true); }); @@ -671,9 +671,9 @@ describe('entity', () => { .valueOf(), (err: Error) => { return new RegExp( - `integerTypeCastFunction threw an error:\n\n - ${errorMessage}`, + `integerTypeCastFunction threw an error:\n\n - ${errorMessage}` ).test(err.message); - }, + } ); }); }); @@ -689,7 +689,7 @@ describe('entity', () => { assert.deepStrictEqual( testEntity.decodeValueProto(valueProto), - expectedValue, + expectedValue ); }); @@ -715,7 +715,7 @@ describe('entity', () => { assert.strictEqual( testEntity.decodeValueProto(valueProto), - expectedValue, + expectedValue ); }); @@ -734,7 +734,7 @@ describe('entity', () => { assert.strictEqual( testEntity.decodeValueProto(valueProto), - expectedValue, + expectedValue ); }); @@ -756,7 +756,7 @@ describe('entity', () => { assert.deepStrictEqual( testEntity.decodeValueProto(valueProto), - expectedValue, + expectedValue ); }); @@ -770,7 +770,7 @@ describe('entity', () => { assert.strictEqual( testEntity.decodeValueProto(valueProto), - expectedValue, + expectedValue ); }); }); @@ -1035,7 +1035,7 @@ describe('entity', () => { assert.deepStrictEqual( testEntity.entityFromEntityProto(entityProto), - expectedEntity, + expectedEntity ); }); @@ -1106,14 +1106,14 @@ describe('entity', () => { assert.deepStrictEqual( testEntity.entityToEntityProto(entityObject), - expectedEntityProto, + expectedEntityProto ); }); it('should respect excludeFromIndexes', () => { assert.deepStrictEqual( testEntity.entityToEntityProto(entityObject), - expectedEntityProto, + expectedEntityProto ); }); @@ -1155,7 +1155,7 @@ describe('entity', () => { assert.deepStrictEqual( testEntity.entityToEntityProto(entityObject), - expectedEntityProto, + expectedEntityProto ); }); }); @@ -1355,7 +1355,7 @@ describe('entity', () => { assert.strictEqual((e as Error).name, 'InvalidKey'); assert.strictEqual( (e as Error).message, - 'Ancestor keys require an id or name.', + 'Ancestor keys require an id or name.' ); done(); } @@ -1439,7 +1439,7 @@ describe('entity', () => { assert.strictEqual((e as Error).name, 'InvalidKey'); assert.strictEqual( (e as Error).message, - 'A key should contain at least a kind.', + 'A key should contain at least a kind.' ); done(); } @@ -1457,7 +1457,7 @@ describe('entity', () => { assert.strictEqual((e as Error).name, 'InvalidKey'); assert.strictEqual( (e as Error).message, - 'Ancestor keys require an id or name.', + 'Ancestor keys require an id or name.' ); done(); } @@ -1618,12 +1618,12 @@ describe('entity', () => { .filter( new PropertyFilter('__key__', 'IN', [ new entity.Key({path: ['Kind1', 'key1']}), - ]), + ]) ); assert.deepStrictEqual( testEntity.queryToQueryProto(query), - keyWithInQuery, + keyWithInQuery ); }); @@ -1661,7 +1661,7 @@ describe('entity', () => { and([ new PropertyFilter('name', '=', 'John'), new PropertyFilter('__key__', 'HAS_ANCESTOR', ancestorKey), - ]), + ]) ) .start('start') .end('end') @@ -1705,7 +1705,7 @@ describe('entity', () => { assert.strictEqual( urlSafeKey.convertToBase64_(buffer), - 'SGVsbG8gV29ybGQ', + 'SGVsbG8gV29ybGQ' ); }); }); @@ -1714,7 +1714,7 @@ describe('entity', () => { it('should convert encoded url safe key to buffer', () => { assert.deepStrictEqual( urlSafeKey.convertToBuffer_('aGVsbG8gd29ybGQgZnJvbSBkYXRhc3RvcmU'), - Buffer.from('hello world from datastore'), + Buffer.from('hello world from datastore') ); }); }); @@ -1732,7 +1732,7 @@ describe('entity', () => { 'ahFzfmdyYXNzLWNsdW1wLTQ3OXIVCxIEVGFzayILc2FtcGxldGFzazEMogECTlM'; assert.strictEqual( urlSafeKey.legacyEncode(PROJECT_ID, key, LOCATION_PREFIX), - encodedKey, + encodedKey ); }); @@ -1747,7 +1747,7 @@ describe('entity', () => { 'ag9ncmFzcy1jbHVtcC00NzlyFQsSBFRhc2siC3NhbXBsZXRhc2sxDA'; assert.strictEqual( urlSafeKey.legacyEncode(PROJECT_ID, key), - encodedKey, + encodedKey ); }); @@ -1761,7 +1761,7 @@ describe('entity', () => { const encodedKey = 'ag9ncmFzcy1jbHVtcC00NzlyEQsSBFRhc2sYgICA3NWunAoM'; assert.strictEqual( urlSafeKey.legacyEncode(PROJECT_ID, key), - encodedKey, + encodedKey ); }); @@ -1775,7 +1775,7 @@ describe('entity', () => { const encodedKey = 'ag9ncmFzcy1jbHVtcC00NzlyEQsSBFRhc2sYgICA3NWunAoM'; assert.strictEqual( urlSafeKey.legacyEncode(PROJECT_ID, key), - encodedKey, + encodedKey ); }); @@ -1788,7 +1788,7 @@ describe('entity', () => { 'ahFzfmdyYXNzLWNsdW1wLTQ3OXIqCxIEVGFzayILc2FtcGxldGFzazEMCxIEVGFzayILc2FtcGxldGFzazIM'; assert.strictEqual( urlSafeKey.legacyEncode(PROJECT_ID, key, LOCATION_PREFIX), - encodedKey, + encodedKey ); }); }); diff --git a/test/entity/buildEntityProto.ts b/test/entity/buildEntityProto.ts index 2d2c868df..3f646bc0f 100644 --- a/test/entity/buildEntityProto.ts +++ b/test/entity/buildEntityProto.ts @@ -81,9 +81,9 @@ describe('buildEntityProto', () => { } assert.deepStrictEqual( buildEntityProto(test.entityObject), - test.expectedProto, + test.expectedProto ); }); - }, + } ); }); diff --git a/test/entity/excludeIndexesAndBuildProto.ts b/test/entity/excludeIndexesAndBuildProto.ts index 56ce08231..9526c1ee9 100644 --- a/test/entity/excludeIndexesAndBuildProto.ts +++ b/test/entity/excludeIndexesAndBuildProto.ts @@ -44,13 +44,13 @@ describe('excludeIndexesAndBuildProto', () => { if (entityProtoSubset.stringValue === longString) { if (entityProtoSubset.excludeFromIndexes !== true) { assert.fail( - `The entity proto at ${path} should excludeFromIndexes`, + `The entity proto at ${path} should excludeFromIndexes` ); } } else { if (entityProtoSubset.excludeFromIndexes === true) { assert.fail( - `The entity proto at ${path} should not excludeFromIndexes`, + `The entity proto at ${path} should not excludeFromIndexes` ); } } @@ -82,7 +82,7 @@ describe('excludeIndexesAndBuildProto', () => { }, }, }, - '', + '' ); }); it('should not throw an assertion error for long strings in the top level', () => { @@ -99,7 +99,7 @@ describe('excludeIndexesAndBuildProto', () => { }, }, }, - '', + '' ); }); it('should throw an assertion error for a missing excludeFromIndexes: true', () => { @@ -116,13 +116,13 @@ describe('excludeIndexesAndBuildProto', () => { }, }, }, - '', + '' ); assert.fail('checkEntityProto should have failed'); } catch (e) { assert.strictEqual( (e as ServiceError).message, - 'The entity proto at .properties.name should excludeFromIndexes', + 'The entity proto at .properties.name should excludeFromIndexes' ); } }); @@ -141,13 +141,13 @@ describe('excludeIndexesAndBuildProto', () => { }, }, }, - '', + '' ); assert.fail('checkEntityProto should have failed'); } catch (e) { assert.strictEqual( (e as ServiceError).message, - 'The entity proto at .properties.name should not excludeFromIndexes', + 'The entity proto at .properties.name should not excludeFromIndexes' ); } }); @@ -181,13 +181,13 @@ describe('excludeIndexesAndBuildProto', () => { }, }, }, - '', + '' ); assert.fail('checkEntityProto should have failed'); } catch (e) { assert.strictEqual( (e as ServiceError).message, - 'The entity proto at .properties.name.arrayValue.values.[1].entityValue.properties.metadata should not excludeFromIndexes', + 'The entity proto at .properties.name.arrayValue.values.[1].entityValue.properties.metadata should not excludeFromIndexes' ); } }); @@ -262,7 +262,7 @@ describe('excludeIndexesAndBuildProto', () => { */ function getGeneratedTestComponents( baseElement: {}, - baseTestName: string, + baseTestName: string ): GeneratedTestCase[] { const maxDepth = 5; const generatedTestCasesByDepth: GeneratedTestCase[][] = [ @@ -315,7 +315,7 @@ describe('excludeIndexesAndBuildProto', () => { value: longString, otherProperty: longString, }, - 'with long string properties and path ', + 'with long string properties and path ' ), getGeneratedTestComponents( { @@ -323,7 +323,7 @@ describe('excludeIndexesAndBuildProto', () => { value: 'short value', otherProperty: longString, }, - 'with long name property and path ', + 'with long name property and path ' ), ] .flat() @@ -375,6 +375,6 @@ describe('excludeIndexesAndBuildProto', () => { const entityProto = buildEntityProto(entityObject); checkEntityProto(entityProto, ''); }); - }, + } ); }); diff --git a/test/entity/extendExcludeFromIndexes.ts b/test/entity/extendExcludeFromIndexes.ts index 936dbaa48..77c7f3d80 100644 --- a/test/entity/extendExcludeFromIndexes.ts +++ b/test/entity/extendExcludeFromIndexes.ts @@ -165,9 +165,9 @@ describe('extendExcludeFromIndexes', () => { extendExcludeFromIndexes(entityObject); assert.deepStrictEqual( entityObject.excludeFromIndexes, - test.expectedOutput, + test.expectedOutput ); }); - }, + } ); }); diff --git a/test/entity/findLargeProperties_.ts b/test/entity/findLargeProperties_.ts index 028955baf..ed99df75e 100644 --- a/test/entity/findLargeProperties_.ts +++ b/test/entity/findLargeProperties_.ts @@ -160,6 +160,6 @@ describe('findLargeProperties_', () => { const output = findLargeProperties_(test.entities, '', []); assert.deepStrictEqual(output, test.expectedOutput); }); - }, + } ); }); diff --git a/test/gapic-mocks/client-initialization-testing.ts b/test/gapic-mocks/client-initialization-testing.ts index de5230ae3..d0be6c437 100644 --- a/test/gapic-mocks/client-initialization-testing.ts +++ b/test/gapic-mocks/client-initialization-testing.ts @@ -59,7 +59,7 @@ class FakeDatastoreClient extends DatastoreClient { protos.google.datastore.v1.ILookupResponse, protos.google.datastore.v1.ILookupRequest | null | undefined, {} | null | undefined - >, + > ): Promise< [ protos.google.datastore.v1.ILookupResponse, @@ -97,7 +97,7 @@ describe('Client Initialization Testing', () => { function compareRequest( request: DatastoreRequest, expectedFallback: Fallback, - done: mocha.Done, + done: mocha.Done ) { try { const client = request.datastore.clients_.get(clientName); @@ -138,7 +138,7 @@ describe('Client Initialization Testing', () => { // The CI environment can't fetch project id so the function that // fetches the project id needs to be mocked out. request.datastore.auth.getProjectId = ( - callback: (err: any, projectId: string) => void, + callback: (err: any, projectId: string) => void ) => { callback(null, 'some-project-id'); }; @@ -149,7 +149,7 @@ describe('Client Initialization Testing', () => { {client: clientName, method: 'lookup'}, () => { compareRequest(request, testParameters.expectedFallback, done); - }, + } ); }); it('should set the rest parameter in the data client when calling request_', done => { @@ -159,7 +159,7 @@ describe('Client Initialization Testing', () => { }); }); }); - }, + } ); }); }); diff --git a/test/gapic-mocks/commit.ts b/test/gapic-mocks/commit.ts index 3ef17096b..796776230 100644 --- a/test/gapic-mocks/commit.ts +++ b/test/gapic-mocks/commit.ts @@ -531,7 +531,7 @@ describe('Commit', () => { * strings replaced. */ function replaceLongStrings( - input?: google.datastore.v1.IMutation[] | null, + input?: google.datastore.v1.IMutation[] | null ) { const stringifiedInput = JSON.stringify(input); const replacedInput = stringifiedInput @@ -553,8 +553,8 @@ describe('Commit', () => { options: CallOptions, callback: ( err?: unknown, - res?: protos.google.datastore.v1.ICommitResponse, - ) => void, + res?: protos.google.datastore.v1.ICommitResponse + ) => void ) => { try { const actual = replaceLongStrings(request.mutations); @@ -578,7 +578,7 @@ describe('Commit', () => { excludeLargeProperties: test.excludeLargeProperties, }); }); - }, + } ); }); }); diff --git a/test/gapic-mocks/error-mocks.ts b/test/gapic-mocks/error-mocks.ts index 507c795ee..226859e6c 100644 --- a/test/gapic-mocks/error-mocks.ts +++ b/test/gapic-mocks/error-mocks.ts @@ -56,7 +56,7 @@ export function getCallbackExpectingError(done: mocha.Done, message: string) { export function errorOnGapicCall( datastore: Datastore, clientName: string, - done: mocha.Done, + done: mocha.Done ) { const dataClient = datastore.clients_.get(clientName); if (dataClient) { diff --git a/test/gapic-mocks/handwritten-errors.ts b/test/gapic-mocks/handwritten-errors.ts index bba7952e2..59c743ee5 100644 --- a/test/gapic-mocks/handwritten-errors.ts +++ b/test/gapic-mocks/handwritten-errors.ts @@ -60,7 +60,7 @@ describe('HandwrittenLayerErrors', () => { transaction.runQuery( query, testParameters.options, - getCallbackExpectingError(done, testParameters.expectedError), + getCallbackExpectingError(done, testParameters.expectedError) ); }); it('should error when runQueryStream is used', done => { @@ -85,7 +85,7 @@ describe('HandwrittenLayerErrors', () => { transaction.runAggregationQuery( aggregate, testParameters.options, - getCallbackExpectingError(done, testParameters.expectedError), + getCallbackExpectingError(done, testParameters.expectedError) ); }); it('should error when get is used', done => { @@ -95,7 +95,7 @@ describe('HandwrittenLayerErrors', () => { transaction.get( keys, testParameters.options, - getCallbackExpectingError(done, testParameters.expectedError), + getCallbackExpectingError(done, testParameters.expectedError) ); }); it('should error when createReadStream is used', done => { @@ -111,7 +111,7 @@ describe('HandwrittenLayerErrors', () => { } }); }); - }, + } ); }); }); diff --git a/test/gapic-mocks/runQuery.ts b/test/gapic-mocks/runQuery.ts index 1710d2a63..d54d8649f 100644 --- a/test/gapic-mocks/runQuery.ts +++ b/test/gapic-mocks/runQuery.ts @@ -25,7 +25,7 @@ describe('Run Query', () => { // This function is used for doing assertion checks. // The idea is to check that the right request gets passed to the commit function in the Gapic layer. function setRunQueryComparison( - compareFn: (request: protos.google.datastore.v1.IRunQueryRequest) => void, + compareFn: (request: protos.google.datastore.v1.IRunQueryRequest) => void ) { const dataClient = datastore.clients_.get(clientName); if (dataClient) { @@ -34,8 +34,8 @@ describe('Run Query', () => { options: any, callback: ( err?: unknown, - res?: protos.google.datastore.v1.IRunQueryResponse, - ) => void, + res?: protos.google.datastore.v1.IRunQueryResponse + ) => void ) => { try { compareFn(request); @@ -72,7 +72,7 @@ describe('Run Query', () => { }, projectId: 'project-id', }); - }, + } ); const transaction = datastore.transaction(); const query = datastore.createQuery('Task'); diff --git a/test/gapic_datastore_admin_v1.ts b/test/gapic_datastore_admin_v1.ts index 33169355d..c168bcbc9 100644 --- a/test/gapic_datastore_admin_v1.ts +++ b/test/gapic_datastore_admin_v1.ts @@ -30,7 +30,7 @@ import {protobuf, LROperation, operationsProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects const root = protobuf.Root.fromJSON( - require('../protos/protos.json'), + require('../protos/protos.json') ).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -47,7 +47,7 @@ function generateSampleMessage(instance: T) { instance.constructor as typeof protobuf.Message ).toObject(instance as protobuf.Message, {defaults: true}); return (instance.constructor as typeof protobuf.Message).fromObject( - filledObject, + filledObject ) as T; } @@ -59,7 +59,7 @@ function stubSimpleCall(response?: ResponseType, error?: Error) { function stubSimpleCallWithCallback( response?: ResponseType, - error?: Error, + error?: Error ) { return error ? sinon.stub().callsArgWith(2, error) @@ -69,7 +69,7 @@ function stubSimpleCallWithCallback( function stubLongRunningCall( response?: ResponseType, callError?: Error, - lroError?: Error, + lroError?: Error ) { const innerStub = lroError ? sinon.stub().rejects(lroError) @@ -85,7 +85,7 @@ function stubLongRunningCall( function stubLongRunningCallWithCallback( response?: ResponseType, callError?: Error, - lroError?: Error, + lroError?: Error ) { const innerStub = lroError ? sinon.stub().rejects(lroError) @@ -100,7 +100,7 @@ function stubLongRunningCallWithCallback( function stubPageStreamingCall( responses?: ResponseType[], - error?: Error, + error?: Error ) { const pagingStub = sinon.stub(); if (responses) { @@ -138,7 +138,7 @@ function stubPageStreamingCall( function stubAsyncIterationCall( responses?: ResponseType[], - error?: Error, + error?: Error ) { let counter = 0; const asyncIterable = { @@ -347,21 +347,21 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.GetIndexRequest(), + new protos.google.datastore.admin.v1.GetIndexRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.GetIndexRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const defaultValue2 = getTypeDefaultValue( '.google.datastore.admin.v1.GetIndexRequest', - ['indexId'], + ['indexId'] ); request.indexId = defaultValue2; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.datastore.admin.v1.Index(), + new protos.google.datastore.admin.v1.Index() ); client.innerApiCalls.getIndex = stubSimpleCall(expectedResponse); const [response] = await client.getIndex(request); @@ -383,21 +383,21 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.GetIndexRequest(), + new protos.google.datastore.admin.v1.GetIndexRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.GetIndexRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const defaultValue2 = getTypeDefaultValue( '.google.datastore.admin.v1.GetIndexRequest', - ['indexId'], + ['indexId'] ); request.indexId = defaultValue2; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.datastore.admin.v1.Index(), + new protos.google.datastore.admin.v1.Index() ); client.innerApiCalls.getIndex = stubSimpleCallWithCallback(expectedResponse); @@ -406,14 +406,14 @@ describe('v1.DatastoreAdminClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.admin.v1.IIndex | null, + result?: protos.google.datastore.admin.v1.IIndex | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const response = await promise; @@ -435,16 +435,16 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.GetIndexRequest(), + new protos.google.datastore.admin.v1.GetIndexRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.GetIndexRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const defaultValue2 = getTypeDefaultValue( '.google.datastore.admin.v1.GetIndexRequest', - ['indexId'], + ['indexId'] ); request.indexId = defaultValue2; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; @@ -468,16 +468,16 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.GetIndexRequest(), + new protos.google.datastore.admin.v1.GetIndexRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.GetIndexRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const defaultValue2 = getTypeDefaultValue( '.google.datastore.admin.v1.GetIndexRequest', - ['indexId'], + ['indexId'] ); request.indexId = defaultValue2; const expectedError = new Error('The client has already been closed.'); @@ -494,16 +494,16 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ExportEntitiesRequest(), + new protos.google.datastore.admin.v1.ExportEntitiesRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ExportEntitiesRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation(), + new protos.google.longrunning.Operation() ); client.innerApiCalls.exportEntities = stubLongRunningCall(expectedResponse); @@ -527,16 +527,16 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ExportEntitiesRequest(), + new protos.google.datastore.admin.v1.ExportEntitiesRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ExportEntitiesRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation(), + new protos.google.longrunning.Operation() ); client.innerApiCalls.exportEntities = stubLongRunningCallWithCallback(expectedResponse); @@ -548,14 +548,14 @@ describe('v1.DatastoreAdminClient', () => { result?: LROperation< protos.google.datastore.admin.v1.IExportEntitiesResponse, protos.google.datastore.admin.v1.IExportEntitiesMetadata - > | null, + > | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const operation = (await promise) as LROperation< @@ -581,18 +581,18 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ExportEntitiesRequest(), + new protos.google.datastore.admin.v1.ExportEntitiesRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ExportEntitiesRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedError = new Error('expected'); client.innerApiCalls.exportEntities = stubLongRunningCall( undefined, - expectedError, + expectedError ); await assert.rejects(client.exportEntities(request), expectedError); const actualRequest = ( @@ -612,11 +612,11 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ExportEntitiesRequest(), + new protos.google.datastore.admin.v1.ExportEntitiesRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ExportEntitiesRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; @@ -624,7 +624,7 @@ describe('v1.DatastoreAdminClient', () => { client.innerApiCalls.exportEntities = stubLongRunningCall( undefined, undefined, - expectedError, + expectedError ); const [operation] = await client.exportEntities(request); await assert.rejects(operation.promise(), expectedError); @@ -645,7 +645,7 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation(), + new operationsProtos.google.longrunning.Operation() ); expectedResponse.name = 'test'; expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; @@ -653,7 +653,7 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.getOperation = stubSimpleCall(expectedResponse); const decodedOperation = await client.checkExportEntitiesProgress( - expectedResponse.name, + expectedResponse.name ); assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); assert(decodedOperation.metadata); @@ -670,11 +670,11 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.getOperation = stubSimpleCall( undefined, - expectedError, + expectedError ); await assert.rejects( client.checkExportEntitiesProgress(''), - expectedError, + expectedError ); assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); @@ -688,16 +688,16 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ImportEntitiesRequest(), + new protos.google.datastore.admin.v1.ImportEntitiesRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ImportEntitiesRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation(), + new protos.google.longrunning.Operation() ); client.innerApiCalls.importEntities = stubLongRunningCall(expectedResponse); @@ -721,16 +721,16 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ImportEntitiesRequest(), + new protos.google.datastore.admin.v1.ImportEntitiesRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ImportEntitiesRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation(), + new protos.google.longrunning.Operation() ); client.innerApiCalls.importEntities = stubLongRunningCallWithCallback(expectedResponse); @@ -742,14 +742,14 @@ describe('v1.DatastoreAdminClient', () => { result?: LROperation< protos.google.protobuf.IEmpty, protos.google.datastore.admin.v1.IImportEntitiesMetadata - > | null, + > | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const operation = (await promise) as LROperation< @@ -775,18 +775,18 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ImportEntitiesRequest(), + new protos.google.datastore.admin.v1.ImportEntitiesRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ImportEntitiesRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedError = new Error('expected'); client.innerApiCalls.importEntities = stubLongRunningCall( undefined, - expectedError, + expectedError ); await assert.rejects(client.importEntities(request), expectedError); const actualRequest = ( @@ -806,11 +806,11 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ImportEntitiesRequest(), + new protos.google.datastore.admin.v1.ImportEntitiesRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ImportEntitiesRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; @@ -818,7 +818,7 @@ describe('v1.DatastoreAdminClient', () => { client.innerApiCalls.importEntities = stubLongRunningCall( undefined, undefined, - expectedError, + expectedError ); const [operation] = await client.importEntities(request); await assert.rejects(operation.promise(), expectedError); @@ -839,7 +839,7 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation(), + new operationsProtos.google.longrunning.Operation() ); expectedResponse.name = 'test'; expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; @@ -847,7 +847,7 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.getOperation = stubSimpleCall(expectedResponse); const decodedOperation = await client.checkImportEntitiesProgress( - expectedResponse.name, + expectedResponse.name ); assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); assert(decodedOperation.metadata); @@ -864,11 +864,11 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.getOperation = stubSimpleCall( undefined, - expectedError, + expectedError ); await assert.rejects( client.checkImportEntitiesProgress(''), - expectedError, + expectedError ); assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); @@ -882,16 +882,16 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.CreateIndexRequest(), + new protos.google.datastore.admin.v1.CreateIndexRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.CreateIndexRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation(), + new protos.google.longrunning.Operation() ); client.innerApiCalls.createIndex = stubLongRunningCall(expectedResponse); const [operation] = await client.createIndex(request); @@ -914,16 +914,16 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.CreateIndexRequest(), + new protos.google.datastore.admin.v1.CreateIndexRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.CreateIndexRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation(), + new protos.google.longrunning.Operation() ); client.innerApiCalls.createIndex = stubLongRunningCallWithCallback(expectedResponse); @@ -935,14 +935,14 @@ describe('v1.DatastoreAdminClient', () => { result?: LROperation< protos.google.datastore.admin.v1.IIndex, protos.google.datastore.admin.v1.IIndexOperationMetadata - > | null, + > | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const operation = (await promise) as LROperation< @@ -968,18 +968,18 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.CreateIndexRequest(), + new protos.google.datastore.admin.v1.CreateIndexRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.CreateIndexRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedError = new Error('expected'); client.innerApiCalls.createIndex = stubLongRunningCall( undefined, - expectedError, + expectedError ); await assert.rejects(client.createIndex(request), expectedError); const actualRequest = ( @@ -999,11 +999,11 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.CreateIndexRequest(), + new protos.google.datastore.admin.v1.CreateIndexRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.CreateIndexRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; @@ -1011,7 +1011,7 @@ describe('v1.DatastoreAdminClient', () => { client.innerApiCalls.createIndex = stubLongRunningCall( undefined, undefined, - expectedError, + expectedError ); const [operation] = await client.createIndex(request); await assert.rejects(operation.promise(), expectedError); @@ -1032,7 +1032,7 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation(), + new operationsProtos.google.longrunning.Operation() ); expectedResponse.name = 'test'; expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; @@ -1040,7 +1040,7 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.getOperation = stubSimpleCall(expectedResponse); const decodedOperation = await client.checkCreateIndexProgress( - expectedResponse.name, + expectedResponse.name ); assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); assert(decodedOperation.metadata); @@ -1057,7 +1057,7 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.getOperation = stubSimpleCall( undefined, - expectedError, + expectedError ); await assert.rejects(client.checkCreateIndexProgress(''), expectedError); assert((client.operationsClient.getOperation as SinonStub).getCall(0)); @@ -1072,21 +1072,21 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.DeleteIndexRequest(), + new protos.google.datastore.admin.v1.DeleteIndexRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.DeleteIndexRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const defaultValue2 = getTypeDefaultValue( '.google.datastore.admin.v1.DeleteIndexRequest', - ['indexId'], + ['indexId'] ); request.indexId = defaultValue2; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation(), + new protos.google.longrunning.Operation() ); client.innerApiCalls.deleteIndex = stubLongRunningCall(expectedResponse); const [operation] = await client.deleteIndex(request); @@ -1109,21 +1109,21 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.DeleteIndexRequest(), + new protos.google.datastore.admin.v1.DeleteIndexRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.DeleteIndexRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const defaultValue2 = getTypeDefaultValue( '.google.datastore.admin.v1.DeleteIndexRequest', - ['indexId'], + ['indexId'] ); request.indexId = defaultValue2; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation(), + new protos.google.longrunning.Operation() ); client.innerApiCalls.deleteIndex = stubLongRunningCallWithCallback(expectedResponse); @@ -1135,14 +1135,14 @@ describe('v1.DatastoreAdminClient', () => { result?: LROperation< protos.google.datastore.admin.v1.IIndex, protos.google.datastore.admin.v1.IIndexOperationMetadata - > | null, + > | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const operation = (await promise) as LROperation< @@ -1168,23 +1168,23 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.DeleteIndexRequest(), + new protos.google.datastore.admin.v1.DeleteIndexRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.DeleteIndexRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const defaultValue2 = getTypeDefaultValue( '.google.datastore.admin.v1.DeleteIndexRequest', - ['indexId'], + ['indexId'] ); request.indexId = defaultValue2; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteIndex = stubLongRunningCall( undefined, - expectedError, + expectedError ); await assert.rejects(client.deleteIndex(request), expectedError); const actualRequest = ( @@ -1204,16 +1204,16 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.DeleteIndexRequest(), + new protos.google.datastore.admin.v1.DeleteIndexRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.DeleteIndexRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const defaultValue2 = getTypeDefaultValue( '.google.datastore.admin.v1.DeleteIndexRequest', - ['indexId'], + ['indexId'] ); request.indexId = defaultValue2; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; @@ -1221,7 +1221,7 @@ describe('v1.DatastoreAdminClient', () => { client.innerApiCalls.deleteIndex = stubLongRunningCall( undefined, undefined, - expectedError, + expectedError ); const [operation] = await client.deleteIndex(request); await assert.rejects(operation.promise(), expectedError); @@ -1242,7 +1242,7 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation(), + new operationsProtos.google.longrunning.Operation() ); expectedResponse.name = 'test'; expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; @@ -1250,7 +1250,7 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.getOperation = stubSimpleCall(expectedResponse); const decodedOperation = await client.checkDeleteIndexProgress( - expectedResponse.name, + expectedResponse.name ); assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); assert(decodedOperation.metadata); @@ -1267,7 +1267,7 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.getOperation = stubSimpleCall( undefined, - expectedError, + expectedError ); await assert.rejects(client.checkDeleteIndexProgress(''), expectedError); assert((client.operationsClient.getOperation as SinonStub).getCall(0)); @@ -1282,11 +1282,11 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ListIndexesRequest(), + new protos.google.datastore.admin.v1.ListIndexesRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ListIndexesRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; @@ -1315,11 +1315,11 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ListIndexesRequest(), + new protos.google.datastore.admin.v1.ListIndexesRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ListIndexesRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; @@ -1335,14 +1335,14 @@ describe('v1.DatastoreAdminClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.admin.v1.IIndex[] | null, + result?: protos.google.datastore.admin.v1.IIndex[] | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const response = await promise; @@ -1364,18 +1364,18 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ListIndexesRequest(), + new protos.google.datastore.admin.v1.ListIndexesRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ListIndexesRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedError = new Error('expected'); client.innerApiCalls.listIndexes = stubSimpleCall( undefined, - expectedError, + expectedError ); await assert.rejects(client.listIndexes(request), expectedError); const actualRequest = ( @@ -1395,11 +1395,11 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ListIndexesRequest(), + new protos.google.datastore.admin.v1.ListIndexesRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ListIndexesRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; @@ -1417,7 +1417,7 @@ describe('v1.DatastoreAdminClient', () => { 'data', (response: protos.google.datastore.admin.v1.Index) => { responses.push(response); - }, + } ); stream.on('end', () => { resolve(responses); @@ -1431,14 +1431,14 @@ describe('v1.DatastoreAdminClient', () => { assert( (client.descriptors.page.listIndexes.createStream as SinonStub) .getCall(0) - .calledWith(client.innerApiCalls.listIndexes, request), + .calledWith(client.innerApiCalls.listIndexes, request) ); assert( (client.descriptors.page.listIndexes.createStream as SinonStub) .getCall(0) .args[2].otherArgs.headers[ 'x-goog-request-params' - ].includes(expectedHeaderRequestParams), + ].includes(expectedHeaderRequestParams) ); }); @@ -1449,18 +1449,18 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ListIndexesRequest(), + new protos.google.datastore.admin.v1.ListIndexesRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ListIndexesRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedError = new Error('expected'); client.descriptors.page.listIndexes.createStream = stubPageStreamingCall( undefined, - expectedError, + expectedError ); const stream = client.listIndexesStream(request); const promise = new Promise((resolve, reject) => { @@ -1469,7 +1469,7 @@ describe('v1.DatastoreAdminClient', () => { 'data', (response: protos.google.datastore.admin.v1.Index) => { responses.push(response); - }, + } ); stream.on('end', () => { resolve(responses); @@ -1482,14 +1482,14 @@ describe('v1.DatastoreAdminClient', () => { assert( (client.descriptors.page.listIndexes.createStream as SinonStub) .getCall(0) - .calledWith(client.innerApiCalls.listIndexes, request), + .calledWith(client.innerApiCalls.listIndexes, request) ); assert( (client.descriptors.page.listIndexes.createStream as SinonStub) .getCall(0) .args[2].otherArgs.headers[ 'x-goog-request-params' - ].includes(expectedHeaderRequestParams), + ].includes(expectedHeaderRequestParams) ); }); @@ -1500,11 +1500,11 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ListIndexesRequest(), + new protos.google.datastore.admin.v1.ListIndexesRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ListIndexesRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; @@ -1523,16 +1523,16 @@ describe('v1.DatastoreAdminClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert.deepStrictEqual( (client.descriptors.page.listIndexes.asyncIterate as SinonStub).getCall( - 0, + 0 ).args[1], - request, + request ); assert( (client.descriptors.page.listIndexes.asyncIterate as SinonStub) .getCall(0) .args[2].otherArgs.headers[ 'x-goog-request-params' - ].includes(expectedHeaderRequestParams), + ].includes(expectedHeaderRequestParams) ); }); @@ -1543,18 +1543,18 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ListIndexesRequest(), + new protos.google.datastore.admin.v1.ListIndexesRequest() ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ListIndexesRequest', - ['projectId'], + ['projectId'] ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedError = new Error('expected'); client.descriptors.page.listIndexes.asyncIterate = stubAsyncIterationCall( undefined, - expectedError, + expectedError ); const iterable = client.listIndexesAsync(request); await assert.rejects(async () => { @@ -1565,16 +1565,16 @@ describe('v1.DatastoreAdminClient', () => { }); assert.deepStrictEqual( (client.descriptors.page.listIndexes.asyncIterate as SinonStub).getCall( - 0, + 0 ).args[1], - request, + request ); assert( (client.descriptors.page.listIndexes.asyncIterate as SinonStub) .getCall(0) .args[2].otherArgs.headers[ 'x-goog-request-params' - ].includes(expectedHeaderRequestParams), + ].includes(expectedHeaderRequestParams) ); }); }); @@ -1586,10 +1586,10 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest(), + new operationsProtos.google.longrunning.GetOperationRequest() ); const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation(), + new operationsProtos.google.longrunning.Operation() ); client.operationsClient.getOperation = stubSimpleCall(expectedResponse); const response = await client.getOperation(request); @@ -1597,7 +1597,7 @@ describe('v1.DatastoreAdminClient', () => { assert( (client.operationsClient.getOperation as SinonStub) .getCall(0) - .calledWith(request), + .calledWith(request) ); }); it('invokes getOperation without error using callback', async () => { @@ -1606,10 +1606,10 @@ describe('v1.DatastoreAdminClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest(), + new operationsProtos.google.longrunning.GetOperationRequest() ); const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation(), + new operationsProtos.google.longrunning.Operation() ); client.operationsClient.getOperation = sinon .stub() @@ -1620,14 +1620,14 @@ describe('v1.DatastoreAdminClient', () => { undefined, ( err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null, + result?: operationsProtos.google.longrunning.Operation | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const response = await promise; @@ -1640,12 +1640,12 @@ describe('v1.DatastoreAdminClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest(), + new operationsProtos.google.longrunning.GetOperationRequest() ); const expectedError = new Error('expected'); client.operationsClient.getOperation = stubSimpleCall( undefined, - expectedError, + expectedError ); await assert.rejects(async () => { await client.getOperation(request); @@ -1653,7 +1653,7 @@ describe('v1.DatastoreAdminClient', () => { assert( (client.operationsClient.getOperation as SinonStub) .getCall(0) - .calledWith(request), + .calledWith(request) ); }); }); @@ -1665,10 +1665,10 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest(), + new operationsProtos.google.longrunning.CancelOperationRequest() ); const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty(), + new protos.google.protobuf.Empty() ); client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); @@ -1677,7 +1677,7 @@ describe('v1.DatastoreAdminClient', () => { assert( (client.operationsClient.cancelOperation as SinonStub) .getCall(0) - .calledWith(request), + .calledWith(request) ); }); it('invokes cancelOperation without error using callback', async () => { @@ -1686,10 +1686,10 @@ describe('v1.DatastoreAdminClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest(), + new operationsProtos.google.longrunning.CancelOperationRequest() ); const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty(), + new protos.google.protobuf.Empty() ); client.operationsClient.cancelOperation = sinon .stub() @@ -1700,14 +1700,14 @@ describe('v1.DatastoreAdminClient', () => { undefined, ( err?: Error | null, - result?: protos.google.protobuf.Empty | null, + result?: protos.google.protobuf.Empty | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const response = await promise; @@ -1720,12 +1720,12 @@ describe('v1.DatastoreAdminClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest(), + new operationsProtos.google.longrunning.CancelOperationRequest() ); const expectedError = new Error('expected'); client.operationsClient.cancelOperation = stubSimpleCall( undefined, - expectedError, + expectedError ); await assert.rejects(async () => { await client.cancelOperation(request); @@ -1733,7 +1733,7 @@ describe('v1.DatastoreAdminClient', () => { assert( (client.operationsClient.cancelOperation as SinonStub) .getCall(0) - .calledWith(request), + .calledWith(request) ); }); }); @@ -1745,10 +1745,10 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest(), + new operationsProtos.google.longrunning.DeleteOperationRequest() ); const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty(), + new protos.google.protobuf.Empty() ); client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); @@ -1757,7 +1757,7 @@ describe('v1.DatastoreAdminClient', () => { assert( (client.operationsClient.deleteOperation as SinonStub) .getCall(0) - .calledWith(request), + .calledWith(request) ); }); it('invokes deleteOperation without error using callback', async () => { @@ -1766,10 +1766,10 @@ describe('v1.DatastoreAdminClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest(), + new operationsProtos.google.longrunning.DeleteOperationRequest() ); const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty(), + new protos.google.protobuf.Empty() ); client.operationsClient.deleteOperation = sinon .stub() @@ -1780,14 +1780,14 @@ describe('v1.DatastoreAdminClient', () => { undefined, ( err?: Error | null, - result?: protos.google.protobuf.Empty | null, + result?: protos.google.protobuf.Empty | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const response = await promise; @@ -1800,12 +1800,12 @@ describe('v1.DatastoreAdminClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest(), + new operationsProtos.google.longrunning.DeleteOperationRequest() ); const expectedError = new Error('expected'); client.operationsClient.deleteOperation = stubSimpleCall( undefined, - expectedError, + expectedError ); await assert.rejects(async () => { await client.deleteOperation(request); @@ -1813,7 +1813,7 @@ describe('v1.DatastoreAdminClient', () => { assert( (client.operationsClient.deleteOperation as SinonStub) .getCall(0) - .calledWith(request), + .calledWith(request) ); }); }); @@ -1824,17 +1824,17 @@ describe('v1.DatastoreAdminClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest(), + new operationsProtos.google.longrunning.ListOperationsRequest() ); const expectedResponse = [ generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse(), + new operationsProtos.google.longrunning.ListOperationsResponse() ), generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse(), + new operationsProtos.google.longrunning.ListOperationsResponse() ), generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse(), + new operationsProtos.google.longrunning.ListOperationsResponse() ), ]; client.operationsClient.descriptor.listOperations.asyncIterate = @@ -1850,7 +1850,7 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.descriptor.listOperations .asyncIterate as SinonStub ).getCall(0).args[1], - request, + request ); }); it('uses async iteration with listOperations with error', async () => { @@ -1860,7 +1860,7 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest(), + new operationsProtos.google.longrunning.ListOperationsRequest() ); const expectedError = new Error('expected'); client.operationsClient.descriptor.listOperations.asyncIterate = @@ -1877,7 +1877,7 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.descriptor.listOperations .asyncIterate as SinonStub ).getCall(0).args[1], - request, + request ); }); }); diff --git a/test/gapic_datastore_v1.ts b/test/gapic_datastore_v1.ts index 23c97b88c..1c7ee6608 100644 --- a/test/gapic_datastore_v1.ts +++ b/test/gapic_datastore_v1.ts @@ -28,7 +28,7 @@ import {protobuf, operationsProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects const root = protobuf.Root.fromJSON( - require('../protos/protos.json'), + require('../protos/protos.json') ).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -45,7 +45,7 @@ function generateSampleMessage(instance: T) { instance.constructor as typeof protobuf.Message ).toObject(instance as protobuf.Message, {defaults: true}); return (instance.constructor as typeof protobuf.Message).fromObject( - filledObject, + filledObject ) as T; } @@ -57,7 +57,7 @@ function stubSimpleCall(response?: ResponseType, error?: Error) { function stubSimpleCallWithCallback( response?: ResponseType, - error?: Error, + error?: Error ) { return error ? sinon.stub().callsArgWith(2, error) @@ -66,7 +66,7 @@ function stubSimpleCallWithCallback( function stubAsyncIterationCall( responses?: ResponseType[], - error?: Error, + error?: Error ) { let counter = 0; const asyncIterable = { @@ -273,19 +273,19 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.LookupRequest(), + new protos.google.datastore.v1.LookupRequest() ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.LookupResponse(), + new protos.google.datastore.v1.LookupResponse() ); client.innerApiCalls.lookup = stubSimpleCall(expectedResponse); const [response] = await client.lookup(request); assert.deepStrictEqual(response, expectedResponse); const actualRequest = (client.innerApiCalls.lookup as SinonStub).getCall( - 0, + 0 ).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( @@ -301,13 +301,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.LookupRequest(), + new protos.google.datastore.v1.LookupRequest() ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.LookupResponse(), + new protos.google.datastore.v1.LookupResponse() ); client.innerApiCalls.lookup = stubSimpleCallWithCallback(expectedResponse); @@ -316,20 +316,20 @@ describe('v1.DatastoreClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.v1.ILookupResponse | null, + result?: protos.google.datastore.v1.ILookupResponse | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); const actualRequest = (client.innerApiCalls.lookup as SinonStub).getCall( - 0, + 0 ).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( @@ -345,7 +345,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.LookupRequest(), + new protos.google.datastore.v1.LookupRequest() ); // path template is empty request.databaseId = 'value'; @@ -354,7 +354,7 @@ describe('v1.DatastoreClient', () => { client.innerApiCalls.lookup = stubSimpleCall(undefined, expectedError); await assert.rejects(client.lookup(request), expectedError); const actualRequest = (client.innerApiCalls.lookup as SinonStub).getCall( - 0, + 0 ).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( @@ -370,7 +370,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.LookupRequest(), + new protos.google.datastore.v1.LookupRequest() ); // path template is empty request.databaseId = 'value'; @@ -388,13 +388,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RunQueryRequest(), + new protos.google.datastore.v1.RunQueryRequest() ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.RunQueryResponse(), + new protos.google.datastore.v1.RunQueryResponse() ); client.innerApiCalls.runQuery = stubSimpleCall(expectedResponse); const [response] = await client.runQuery(request); @@ -416,13 +416,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RunQueryRequest(), + new protos.google.datastore.v1.RunQueryRequest() ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.RunQueryResponse(), + new protos.google.datastore.v1.RunQueryResponse() ); client.innerApiCalls.runQuery = stubSimpleCallWithCallback(expectedResponse); @@ -431,14 +431,14 @@ describe('v1.DatastoreClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.v1.IRunQueryResponse | null, + result?: protos.google.datastore.v1.IRunQueryResponse | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const response = await promise; @@ -460,7 +460,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RunQueryRequest(), + new protos.google.datastore.v1.RunQueryRequest() ); // path template is empty request.databaseId = 'value'; @@ -485,7 +485,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RunQueryRequest(), + new protos.google.datastore.v1.RunQueryRequest() ); // path template is empty request.databaseId = 'value'; @@ -503,13 +503,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RunAggregationQueryRequest(), + new protos.google.datastore.v1.RunAggregationQueryRequest() ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.RunAggregationQueryResponse(), + new protos.google.datastore.v1.RunAggregationQueryResponse() ); client.innerApiCalls.runAggregationQuery = stubSimpleCall(expectedResponse); @@ -532,13 +532,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RunAggregationQueryRequest(), + new protos.google.datastore.v1.RunAggregationQueryRequest() ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.RunAggregationQueryResponse(), + new protos.google.datastore.v1.RunAggregationQueryResponse() ); client.innerApiCalls.runAggregationQuery = stubSimpleCallWithCallback(expectedResponse); @@ -547,14 +547,14 @@ describe('v1.DatastoreClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.v1.IRunAggregationQueryResponse | null, + result?: protos.google.datastore.v1.IRunAggregationQueryResponse | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const response = await promise; @@ -576,7 +576,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RunAggregationQueryRequest(), + new protos.google.datastore.v1.RunAggregationQueryRequest() ); // path template is empty request.databaseId = 'value'; @@ -584,7 +584,7 @@ describe('v1.DatastoreClient', () => { const expectedError = new Error('expected'); client.innerApiCalls.runAggregationQuery = stubSimpleCall( undefined, - expectedError, + expectedError ); await assert.rejects(client.runAggregationQuery(request), expectedError); const actualRequest = ( @@ -604,7 +604,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RunAggregationQueryRequest(), + new protos.google.datastore.v1.RunAggregationQueryRequest() ); // path template is empty request.databaseId = 'value'; @@ -622,13 +622,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.BeginTransactionRequest(), + new protos.google.datastore.v1.BeginTransactionRequest() ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.BeginTransactionResponse(), + new protos.google.datastore.v1.BeginTransactionResponse() ); client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); const [response] = await client.beginTransaction(request); @@ -650,13 +650,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.BeginTransactionRequest(), + new protos.google.datastore.v1.BeginTransactionRequest() ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.BeginTransactionResponse(), + new protos.google.datastore.v1.BeginTransactionResponse() ); client.innerApiCalls.beginTransaction = stubSimpleCallWithCallback(expectedResponse); @@ -665,14 +665,14 @@ describe('v1.DatastoreClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.v1.IBeginTransactionResponse | null, + result?: protos.google.datastore.v1.IBeginTransactionResponse | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const response = await promise; @@ -694,7 +694,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.BeginTransactionRequest(), + new protos.google.datastore.v1.BeginTransactionRequest() ); // path template is empty request.databaseId = 'value'; @@ -702,7 +702,7 @@ describe('v1.DatastoreClient', () => { const expectedError = new Error('expected'); client.innerApiCalls.beginTransaction = stubSimpleCall( undefined, - expectedError, + expectedError ); await assert.rejects(client.beginTransaction(request), expectedError); const actualRequest = ( @@ -722,7 +722,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.BeginTransactionRequest(), + new protos.google.datastore.v1.BeginTransactionRequest() ); // path template is empty request.databaseId = 'value'; @@ -740,19 +740,19 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.CommitRequest(), + new protos.google.datastore.v1.CommitRequest() ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.CommitResponse(), + new protos.google.datastore.v1.CommitResponse() ); client.innerApiCalls.commit = stubSimpleCall(expectedResponse); const [response] = await client.commit(request); assert.deepStrictEqual(response, expectedResponse); const actualRequest = (client.innerApiCalls.commit as SinonStub).getCall( - 0, + 0 ).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( @@ -768,13 +768,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.CommitRequest(), + new protos.google.datastore.v1.CommitRequest() ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.CommitResponse(), + new protos.google.datastore.v1.CommitResponse() ); client.innerApiCalls.commit = stubSimpleCallWithCallback(expectedResponse); @@ -783,20 +783,20 @@ describe('v1.DatastoreClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.v1.ICommitResponse | null, + result?: protos.google.datastore.v1.ICommitResponse | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); const actualRequest = (client.innerApiCalls.commit as SinonStub).getCall( - 0, + 0 ).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( @@ -812,7 +812,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.CommitRequest(), + new protos.google.datastore.v1.CommitRequest() ); // path template is empty request.databaseId = 'value'; @@ -821,7 +821,7 @@ describe('v1.DatastoreClient', () => { client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); await assert.rejects(client.commit(request), expectedError); const actualRequest = (client.innerApiCalls.commit as SinonStub).getCall( - 0, + 0 ).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( @@ -837,7 +837,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.CommitRequest(), + new protos.google.datastore.v1.CommitRequest() ); // path template is empty request.databaseId = 'value'; @@ -855,13 +855,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RollbackRequest(), + new protos.google.datastore.v1.RollbackRequest() ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.RollbackResponse(), + new protos.google.datastore.v1.RollbackResponse() ); client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); const [response] = await client.rollback(request); @@ -883,13 +883,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RollbackRequest(), + new protos.google.datastore.v1.RollbackRequest() ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.RollbackResponse(), + new protos.google.datastore.v1.RollbackResponse() ); client.innerApiCalls.rollback = stubSimpleCallWithCallback(expectedResponse); @@ -898,14 +898,14 @@ describe('v1.DatastoreClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.v1.IRollbackResponse | null, + result?: protos.google.datastore.v1.IRollbackResponse | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const response = await promise; @@ -927,7 +927,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RollbackRequest(), + new protos.google.datastore.v1.RollbackRequest() ); // path template is empty request.databaseId = 'value'; @@ -952,7 +952,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RollbackRequest(), + new protos.google.datastore.v1.RollbackRequest() ); // path template is empty request.databaseId = 'value'; @@ -970,13 +970,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.AllocateIdsRequest(), + new protos.google.datastore.v1.AllocateIdsRequest() ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.AllocateIdsResponse(), + new protos.google.datastore.v1.AllocateIdsResponse() ); client.innerApiCalls.allocateIds = stubSimpleCall(expectedResponse); const [response] = await client.allocateIds(request); @@ -998,13 +998,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.AllocateIdsRequest(), + new protos.google.datastore.v1.AllocateIdsRequest() ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.AllocateIdsResponse(), + new protos.google.datastore.v1.AllocateIdsResponse() ); client.innerApiCalls.allocateIds = stubSimpleCallWithCallback(expectedResponse); @@ -1013,14 +1013,14 @@ describe('v1.DatastoreClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.v1.IAllocateIdsResponse | null, + result?: protos.google.datastore.v1.IAllocateIdsResponse | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const response = await promise; @@ -1042,7 +1042,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.AllocateIdsRequest(), + new protos.google.datastore.v1.AllocateIdsRequest() ); // path template is empty request.databaseId = 'value'; @@ -1050,7 +1050,7 @@ describe('v1.DatastoreClient', () => { const expectedError = new Error('expected'); client.innerApiCalls.allocateIds = stubSimpleCall( undefined, - expectedError, + expectedError ); await assert.rejects(client.allocateIds(request), expectedError); const actualRequest = ( @@ -1070,7 +1070,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.AllocateIdsRequest(), + new protos.google.datastore.v1.AllocateIdsRequest() ); // path template is empty request.databaseId = 'value'; @@ -1088,13 +1088,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.ReserveIdsRequest(), + new protos.google.datastore.v1.ReserveIdsRequest() ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.ReserveIdsResponse(), + new protos.google.datastore.v1.ReserveIdsResponse() ); client.innerApiCalls.reserveIds = stubSimpleCall(expectedResponse); const [response] = await client.reserveIds(request); @@ -1116,13 +1116,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.ReserveIdsRequest(), + new protos.google.datastore.v1.ReserveIdsRequest() ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.ReserveIdsResponse(), + new protos.google.datastore.v1.ReserveIdsResponse() ); client.innerApiCalls.reserveIds = stubSimpleCallWithCallback(expectedResponse); @@ -1131,14 +1131,14 @@ describe('v1.DatastoreClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.v1.IReserveIdsResponse | null, + result?: protos.google.datastore.v1.IReserveIdsResponse | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const response = await promise; @@ -1160,7 +1160,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.ReserveIdsRequest(), + new protos.google.datastore.v1.ReserveIdsRequest() ); // path template is empty request.databaseId = 'value'; @@ -1168,7 +1168,7 @@ describe('v1.DatastoreClient', () => { const expectedError = new Error('expected'); client.innerApiCalls.reserveIds = stubSimpleCall( undefined, - expectedError, + expectedError ); await assert.rejects(client.reserveIds(request), expectedError); const actualRequest = ( @@ -1188,7 +1188,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.ReserveIdsRequest(), + new protos.google.datastore.v1.ReserveIdsRequest() ); // path template is empty request.databaseId = 'value'; @@ -1205,10 +1205,10 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest(), + new operationsProtos.google.longrunning.GetOperationRequest() ); const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation(), + new operationsProtos.google.longrunning.Operation() ); client.operationsClient.getOperation = stubSimpleCall(expectedResponse); const response = await client.getOperation(request); @@ -1216,7 +1216,7 @@ describe('v1.DatastoreClient', () => { assert( (client.operationsClient.getOperation as SinonStub) .getCall(0) - .calledWith(request), + .calledWith(request) ); }); it('invokes getOperation without error using callback', async () => { @@ -1225,10 +1225,10 @@ describe('v1.DatastoreClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest(), + new operationsProtos.google.longrunning.GetOperationRequest() ); const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation(), + new operationsProtos.google.longrunning.Operation() ); client.operationsClient.getOperation = sinon .stub() @@ -1239,14 +1239,14 @@ describe('v1.DatastoreClient', () => { undefined, ( err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null, + result?: operationsProtos.google.longrunning.Operation | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const response = await promise; @@ -1259,12 +1259,12 @@ describe('v1.DatastoreClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest(), + new operationsProtos.google.longrunning.GetOperationRequest() ); const expectedError = new Error('expected'); client.operationsClient.getOperation = stubSimpleCall( undefined, - expectedError, + expectedError ); await assert.rejects(async () => { await client.getOperation(request); @@ -1272,7 +1272,7 @@ describe('v1.DatastoreClient', () => { assert( (client.operationsClient.getOperation as SinonStub) .getCall(0) - .calledWith(request), + .calledWith(request) ); }); }); @@ -1284,10 +1284,10 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest(), + new operationsProtos.google.longrunning.CancelOperationRequest() ); const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty(), + new protos.google.protobuf.Empty() ); client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); @@ -1296,7 +1296,7 @@ describe('v1.DatastoreClient', () => { assert( (client.operationsClient.cancelOperation as SinonStub) .getCall(0) - .calledWith(request), + .calledWith(request) ); }); it('invokes cancelOperation without error using callback', async () => { @@ -1305,10 +1305,10 @@ describe('v1.DatastoreClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest(), + new operationsProtos.google.longrunning.CancelOperationRequest() ); const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty(), + new protos.google.protobuf.Empty() ); client.operationsClient.cancelOperation = sinon .stub() @@ -1319,14 +1319,14 @@ describe('v1.DatastoreClient', () => { undefined, ( err?: Error | null, - result?: protos.google.protobuf.Empty | null, + result?: protos.google.protobuf.Empty | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const response = await promise; @@ -1339,12 +1339,12 @@ describe('v1.DatastoreClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest(), + new operationsProtos.google.longrunning.CancelOperationRequest() ); const expectedError = new Error('expected'); client.operationsClient.cancelOperation = stubSimpleCall( undefined, - expectedError, + expectedError ); await assert.rejects(async () => { await client.cancelOperation(request); @@ -1352,7 +1352,7 @@ describe('v1.DatastoreClient', () => { assert( (client.operationsClient.cancelOperation as SinonStub) .getCall(0) - .calledWith(request), + .calledWith(request) ); }); }); @@ -1364,10 +1364,10 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest(), + new operationsProtos.google.longrunning.DeleteOperationRequest() ); const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty(), + new protos.google.protobuf.Empty() ); client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); @@ -1376,7 +1376,7 @@ describe('v1.DatastoreClient', () => { assert( (client.operationsClient.deleteOperation as SinonStub) .getCall(0) - .calledWith(request), + .calledWith(request) ); }); it('invokes deleteOperation without error using callback', async () => { @@ -1385,10 +1385,10 @@ describe('v1.DatastoreClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest(), + new operationsProtos.google.longrunning.DeleteOperationRequest() ); const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty(), + new protos.google.protobuf.Empty() ); client.operationsClient.deleteOperation = sinon .stub() @@ -1399,14 +1399,14 @@ describe('v1.DatastoreClient', () => { undefined, ( err?: Error | null, - result?: protos.google.protobuf.Empty | null, + result?: protos.google.protobuf.Empty | null ) => { if (err) { reject(err); } else { resolve(result); } - }, + } ); }); const response = await promise; @@ -1419,12 +1419,12 @@ describe('v1.DatastoreClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest(), + new operationsProtos.google.longrunning.DeleteOperationRequest() ); const expectedError = new Error('expected'); client.operationsClient.deleteOperation = stubSimpleCall( undefined, - expectedError, + expectedError ); await assert.rejects(async () => { await client.deleteOperation(request); @@ -1432,7 +1432,7 @@ describe('v1.DatastoreClient', () => { assert( (client.operationsClient.deleteOperation as SinonStub) .getCall(0) - .calledWith(request), + .calledWith(request) ); }); }); @@ -1443,17 +1443,17 @@ describe('v1.DatastoreClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest(), + new operationsProtos.google.longrunning.ListOperationsRequest() ); const expectedResponse = [ generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse(), + new operationsProtos.google.longrunning.ListOperationsResponse() ), generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse(), + new operationsProtos.google.longrunning.ListOperationsResponse() ), generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse(), + new operationsProtos.google.longrunning.ListOperationsResponse() ), ]; client.operationsClient.descriptor.listOperations.asyncIterate = @@ -1469,7 +1469,7 @@ describe('v1.DatastoreClient', () => { client.operationsClient.descriptor.listOperations .asyncIterate as SinonStub ).getCall(0).args[1], - request, + request ); }); it('uses async iteration with listOperations with error', async () => { @@ -1479,7 +1479,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest(), + new operationsProtos.google.longrunning.ListOperationsRequest() ); const expectedError = new Error('expected'); client.operationsClient.descriptor.listOperations.asyncIterate = @@ -1496,7 +1496,7 @@ describe('v1.DatastoreClient', () => { client.operationsClient.descriptor.listOperations .asyncIterate as SinonStub ).getCall(0).args[1], - request, + request ); }); }); diff --git a/test/index.ts b/test/index.ts index a0074bd7f..abd9c487f 100644 --- a/test/index.ts +++ b/test/index.ts @@ -188,7 +188,7 @@ async.each( '../src/utils/entity/buildEntityProto.js', { '../../entity.js': {entity: fakeEntity}, - }, + } ); Datastore = proxyquire('../src', { './entity.js': {entity: fakeEntity}, @@ -266,7 +266,7 @@ async.each( it('should set the default base URL', () => { assert.strictEqual( datastore.defaultBaseUrl_, - 'datastore.googleapis.com', + 'datastore.googleapis.com' ); }); @@ -306,8 +306,8 @@ async.each( port: 443, projectId: undefined, }, - options, - ), + options + ) ); }); @@ -374,7 +374,7 @@ async.each( }); assert.strictEqual( datastore.options.sslCreds, - fakeInsecureCreds, + fakeInsecureCreds ); }); }); @@ -428,7 +428,7 @@ async.each( }); assert.strictEqual( datastore.options.sslCreds, - fakeInsecureCreds, + fakeInsecureCreds ); }); }); @@ -456,7 +456,7 @@ async.each( }); assert.strictEqual( datastore.options.sslCreds, - fakeInsecureCreds, + fakeInsecureCreds ); }); }); @@ -623,14 +623,14 @@ async.each( it('should expose a MORE_RESULTS_AFTER_CURSOR helper', () => { assert.strictEqual( Datastore.MORE_RESULTS_AFTER_CURSOR, - 'MORE_RESULTS_AFTER_CURSOR', + 'MORE_RESULTS_AFTER_CURSOR' ); }); it('should also be on the prototype', () => { assert.strictEqual( datastore.MORE_RESULTS_AFTER_CURSOR, - Datastore.MORE_RESULTS_AFTER_CURSOR, + Datastore.MORE_RESULTS_AFTER_CURSOR ); }); }); @@ -639,14 +639,14 @@ async.each( it('should expose a MORE_RESULTS_AFTER_LIMIT helper', () => { assert.strictEqual( Datastore.MORE_RESULTS_AFTER_LIMIT, - 'MORE_RESULTS_AFTER_LIMIT', + 'MORE_RESULTS_AFTER_LIMIT' ); }); it('should also be on the prototype', () => { assert.strictEqual( datastore.MORE_RESULTS_AFTER_LIMIT, - Datastore.MORE_RESULTS_AFTER_LIMIT, + Datastore.MORE_RESULTS_AFTER_LIMIT ); }); }); @@ -659,7 +659,7 @@ async.each( it('should also be on the prototype', () => { assert.strictEqual( datastore.NO_MORE_RESULTS, - Datastore.NO_MORE_RESULTS, + Datastore.NO_MORE_RESULTS ); }); }); @@ -704,7 +704,7 @@ async.each( datastore.request_ = (config: any) => { assert.strictEqual( config.reqOpts.outputUrlPrefix, - `gs://${bucket}`, + `gs://${bucket}` ); done(); }; @@ -731,7 +731,7 @@ async.each( datastore.request_ = (config: any) => { assert.strictEqual( config.reqOpts.outputUrlPrefix, - `gs://${bucket.name}`, + `gs://${bucket.name}` ); done(); }; @@ -752,7 +752,7 @@ async.each( bucket: 'bucket', outputUrlPrefix: 'output-url-prefix', }, - assert.ifError, + assert.ifError ); }, /Both `bucket` and `outputUrlPrefix` were provided\./); }); @@ -778,7 +778,7 @@ async.each( kinds: ['kind1', 'kind2'], entityFilter: {}, }, - assert.ifError, + assert.ifError ); }, /Both `entityFilter` and `kinds` were provided\./); }); @@ -791,7 +791,7 @@ async.each( datastore.request_ = (config: any) => { assert.deepStrictEqual( config.reqOpts.entityFilter.namespaceIds, - namespaces, + namespaces ); done(); }; @@ -807,7 +807,7 @@ async.each( namespaces: ['ns1', 'ns2'], entityFilter: {}, }, - assert.ifError, + assert.ifError ); }, /Both `entityFilter` and `namespaces` were provided\./); }); @@ -906,11 +906,11 @@ async.each( datastore.request_ = (config: any) => { assert.strictEqual( config.reqOpts.pageSize, - options.gaxOptions.pageSize, + options.gaxOptions.pageSize ); assert.strictEqual( config.reqOpts.pageToken, - options.gaxOptions.pageToken, + options.gaxOptions.pageToken ); done(); }; @@ -981,7 +981,7 @@ async.each( // eslint-disable-next-line @typescript-eslint/no-explicit-any datastore.request_ = (config: any) => { assert( - Object.keys(options.gaxOptions).every(k => !config.reqOpts[k]), + Object.keys(options.gaxOptions).every(k => !config.reqOpts[k]) ); done(); }; @@ -998,7 +998,7 @@ async.each( datastore.request_ = (config: any) => { assert.strictEqual( config.gaxOpts.autoPaginate, - options.autoPaginate, + options.autoPaginate ); done(); }; @@ -1039,7 +1039,7 @@ async.each( assert.strictEqual(nextQuery, null); assert.strictEqual(apiResp, apiResponse); done(); - }, + } ); }); @@ -1082,7 +1082,7 @@ async.each( assert.ifError(err); assert.deepStrictEqual(_nextQuery, nextQuery); done(); - }, + } ); }); }); @@ -1158,7 +1158,7 @@ async.each( file: 'file', inputUrl: 'gs://file', }, - assert.ifError, + assert.ifError ); }, /Both `file` and `inputUrl` were provided\./); }); @@ -1194,7 +1194,7 @@ async.each( datastore.request_ = (config: any) => { assert.strictEqual( config.reqOpts.inputUrl, - `gs://${file.bucket.name}/${file.name}`, + `gs://${file.bucket.name}/${file.name}` ); done(); }; @@ -1229,7 +1229,7 @@ async.each( kinds: ['kind1', 'kind2'], entityFilter: {}, }, - assert.ifError, + assert.ifError ); }, /Both `entityFilter` and `kinds` were provided\./); }); @@ -1242,7 +1242,7 @@ async.each( datastore.request_ = (config: any) => { assert.deepStrictEqual( config.reqOpts.entityFilter.namespaceIds, - namespaces, + namespaces ); done(); }; @@ -1258,7 +1258,7 @@ async.each( namespaces: ['ns1', 'ns2'], entityFilter: {}, }, - assert.ifError, + assert.ifError ); }, /Both `entityFilter` and `namespaces` were provided\./); }); @@ -1476,7 +1476,7 @@ async.each( {key, data: {k: 'v'}}, {key, data: {k: 'v'}}, ], - done, + done ); }); @@ -1508,7 +1508,7 @@ async.each( datastore.request_ = (config: RequestConfig, callback: Function) => { assert.deepStrictEqual( config.reqOpts!.mutations![0].upsert!.properties, - expectedProperties, + expectedProperties ); callback(); }; @@ -1540,7 +1540,7 @@ async.each( data: {}, }, gaxOptions, - assert.ifError, + assert.ifError ); }); @@ -1561,12 +1561,12 @@ async.each( }, () => { done('Should not reach callback'); - }, + } ); } catch (err: unknown) { assert.strictEqual( (err as {message: string}).message, - 'Unsupported field value, undefined, was provided.', + 'Unsupported field value, undefined, was provided.' ); done(); return; @@ -1591,14 +1591,14 @@ async.each( }, () => { done('Should not reach callback'); - }, + } ); } catch (err: unknown) { assert( [ "Cannot read properties of null (reading 'toString')", // Later Node versions "Cannot read property 'toString' of null", // Node 14 - ].includes((err as {message: string}).message), + ].includes((err as {message: string}).message) ); done(); return; @@ -1655,7 +1655,7 @@ async.each( {key, method: 'update', data: {k2: 'v2'}}, {key, method: 'upsert', data: {k3: 'v3'}}, ], - done, + done ); }); @@ -1669,7 +1669,7 @@ async.each( k: 'v', }, }, - assert.ifError, + assert.ifError ); }, /Method auto_insert_id not recognized/); }); @@ -1712,7 +1712,7 @@ async.each( assert.ifError(err); assert.strictEqual(mockCommitResponse, apiResponse); done(); - }, + } ); }); @@ -1736,7 +1736,7 @@ async.each( }, ], }, - assert.ifError, + assert.ifError ); }); @@ -1763,7 +1763,7 @@ async.each( }, ], }, - assert.ifError, + assert.ifError ); }); @@ -1837,7 +1837,7 @@ async.each( data, excludeFromIndexes: ['.*'], }, - assert.ifError, + assert.ifError ); }); @@ -1919,7 +1919,7 @@ async.each( 'metadata.longStringArray[].*', ], }, - assert.ifError, + assert.ifError ); }); @@ -1946,7 +1946,7 @@ async.each( }, ], }, - assert.ifError, + assert.ifError ); }); @@ -2009,12 +2009,12 @@ async.each( assert.strictEqual( (config.reqOpts!.mutations![0].upsert! as Entity) .excludeLargeProperties, - true, + true ); assert.deepStrictEqual( (config.reqOpts!.mutations![0].upsert! as Entity) .excludeFromIndexes, - excludeFromIndexes, + excludeFromIndexes ); done(); }; @@ -2025,7 +2025,7 @@ async.each( data, excludeLargeProperties: true, }, - assert.ifError, + assert.ifError ); }); @@ -2046,7 +2046,7 @@ async.each( assert.deepStrictEqual( config.reqOpts!.mutations![0].upsert!.properties!.name .excludeFromIndexes, - true, + true ); done(); }; @@ -2057,7 +2057,7 @@ async.each( data, excludeLargeProperties: true, }, - assert.ifError, + assert.ifError ); }); @@ -2109,7 +2109,7 @@ async.each( assert.strictEqual(keyProtos[1], response.mutationResults[1].key); done(); - }, + } ); }); @@ -2129,7 +2129,7 @@ async.each( assert.strictEqual( typeof datastore.requestCallbacks_[0], - 'function', + 'function' ); assert.strictEqual(typeof datastore.requests_[0], 'object'); }); @@ -2349,7 +2349,7 @@ async.each( (err: Error | null | undefined, urlSafeKey: string) => { assert.ifError(err); assert.strictEqual(urlSafeKey, base64EndocdedUrlSafeKey); - }, + } ); }); @@ -2370,7 +2370,7 @@ async.each( (err: Error | null | undefined, urlSafeKey: string) => { assert.ifError(err); assert.strictEqual(urlSafeKey, base64EndocdedUrlSafeKey); - }, + } ); }); @@ -2385,7 +2385,7 @@ async.each( (err: Error | null | undefined, urlSafeKey: string) => { assert.strictEqual(err, error); assert.strictEqual(urlSafeKey, undefined); - }, + } ); }); }); @@ -2495,7 +2495,7 @@ async.each( // Mock out the request function to compare config passed into it. datastore.request_ = ( config: RequestConfig, - callback: RequestCallback, + callback: RequestCallback ) => { try { assert.deepStrictEqual(config, expectedConfig); @@ -2510,13 +2510,13 @@ async.each( const key = datastore.key(['Post', 'Post1']); const entities = Object.assign( {key}, - onSaveTest.entitiesWithoutKey, + onSaveTest.entitiesWithoutKey ); const results = await datastore.save(entities); assert.deepStrictEqual(results, ['some-data']); } }); - }, + } ); }); }); @@ -2529,7 +2529,7 @@ async.each( }); assert.strictEqual( otherDatastore.getDatabaseId(), - SECOND_DATABASE_ID, + SECOND_DATABASE_ID ); }); }); @@ -2661,13 +2661,13 @@ async.each( // Mock out the request function to compare config passed into it. datastore.request_ = ( config: RequestConfig, - callback: RequestCallback, + callback: RequestCallback ) => { assert.deepStrictEqual(config.client, 'DatastoreClient'); assert.deepStrictEqual(config.method, 'runQuery'); assert.deepStrictEqual( config.reqOpts?.explainOptions, - modeOptions.expectedExplainOptions, + modeOptions.expectedExplainOptions ); callback( null, @@ -2678,8 +2678,8 @@ async.each( moreResults: 'NO_MORE_RESULTS', }, }, - modeOptions.explainMetrics, - ), + modeOptions.explainMetrics + ) ); }; const ancestor = datastore.key(['Book', 'GoT']); @@ -2688,28 +2688,28 @@ async.each( .hasAncestor(ancestor); const [entities, info] = await datastore.runQuery( q, - modeOptions.options, + modeOptions.options ); assert.deepStrictEqual(entities, []); assert.deepStrictEqual( info, Object.assign( {moreResults: 'NO_MORE_RESULTS'}, - modeOptions.expectedInfo, - ), + modeOptions.expectedInfo + ) ); }); it('should provide correct request/response data for runAggregationQuery', async () => { // Mock out the request function to compare config passed into it. datastore.request_ = ( config: RequestConfig, - callback: RequestCallback, + callback: RequestCallback ) => { assert.deepStrictEqual(config.client, 'DatastoreClient'); assert.deepStrictEqual(config.method, 'runAggregationQuery'); assert.deepStrictEqual( config.reqOpts?.explainOptions, - modeOptions.expectedExplainOptions, + modeOptions.expectedExplainOptions ); callback( null, @@ -2720,8 +2720,8 @@ async.each( moreResults: 'NO_MORE_RESULTS', }, }, - modeOptions.explainMetrics, - ), + modeOptions.explainMetrics + ) ); }; const ancestor = datastore.key(['Book', 'GoT']); @@ -2733,15 +2733,15 @@ async.each( .addAggregation(AggregateField.sum('appearances')); const [entities, info] = await datastore.runAggregationQuery( aggregate, - modeOptions.options, + modeOptions.options ); assert.deepStrictEqual(entities, []); assert.deepStrictEqual(info, modeOptions.expectedInfo); }); }); - }, + } ); }); }); - }, + } ); diff --git a/test/query.ts b/test/query.ts index 7238a4433..a6d32f696 100644 --- a/test/query.ts +++ b/test/query.ts @@ -86,7 +86,7 @@ describe('Query', () => { { alias: 'alias1', count: {}, - }, + } ); }); it('should produce the right proto with a sum aggregation', () => { @@ -100,7 +100,7 @@ describe('Query', () => { name: 'property1', }, }, - }, + } ); }); it('should produce the right proto with an average aggregation', () => { @@ -114,7 +114,7 @@ describe('Query', () => { }, }, operator: 'avg', - }, + } ); }); }); @@ -126,21 +126,21 @@ describe('Query', () => { function compareAggregations( aggregateQuery: AggregateQuery, - aggregateFields: AggregateField[], + aggregateFields: AggregateField[] ) { const addAggregationsAggregate = generateAggregateQuery(); addAggregationsAggregate.addAggregations(aggregateFields); const addAggregationAggregate = generateAggregateQuery(); aggregateFields.forEach(aggregateField => - addAggregationAggregate.addAggregation(aggregateField), + addAggregationAggregate.addAggregation(aggregateField) ); assert.deepStrictEqual( aggregateQuery.aggregations, - addAggregationsAggregate.aggregations, + addAggregationsAggregate.aggregations ); assert.deepStrictEqual( aggregateQuery.aggregations, - addAggregationAggregate.aggregations, + addAggregationAggregate.aggregations ); assert.deepStrictEqual(aggregateQuery.aggregations, aggregateFields); } @@ -149,8 +149,8 @@ describe('Query', () => { compareAggregations( generateAggregateQuery().count('total1').count('total2'), ['total1', 'total2'].map(alias => - AggregateField.count().alias(alias), - ), + AggregateField.count().alias(alias) + ) ); }); it('should compare equivalent sum aggregation queries', () => { @@ -161,7 +161,7 @@ describe('Query', () => { [ AggregateField.sum('property1').alias('alias1'), AggregateField.sum('property2').alias('alias2'), - ], + ] ); }); it('should compare equivalent average aggregation queries', () => { @@ -172,7 +172,7 @@ describe('Query', () => { [ AggregateField.average('property1').alias('alias1'), AggregateField.average('property2').alias('alias2'), - ], + ] ); }); }); @@ -180,16 +180,13 @@ describe('Query', () => { it('should compare equivalent count aggregation queries', () => { compareAggregations( generateAggregateQuery().count().count(), - ['total1', 'total2'].map(() => AggregateField.count()), + ['total1', 'total2'].map(() => AggregateField.count()) ); }); it('should compare equivalent sum aggregation queries', () => { compareAggregations( generateAggregateQuery().sum('property1').sum('property2'), - [ - AggregateField.sum('property1'), - AggregateField.sum('property2'), - ], + [AggregateField.sum('property1'), AggregateField.sum('property2')] ); }); it('should compare equivalent average aggregation queries', () => { @@ -200,7 +197,7 @@ describe('Query', () => { [ AggregateField.average('property1'), AggregateField.average('property2'), - ], + ] ); }); }); @@ -213,7 +210,7 @@ describe('Query', () => { const onWarning = (warning: {message: unknown}) => { assert.strictEqual( warning.message, - 'Providing Filter objects like Composite Filter or Property Filter is recommended when using .filter', + 'Providing Filter objects like Composite Filter or Property Filter is recommended when using .filter' ); process.removeListener('warning', onWarning); done(); @@ -297,7 +294,7 @@ describe('Query', () => { const query = new Query(['kind1']).filter( 'count', ' < ', - 123, + 123 ); assert.strictEqual(query.filters[0].op, '<'); @@ -334,7 +331,7 @@ describe('Query', () => { it('should support filter with Filter', () => { const now = new Date(); const query = new Query(['kind1']).filter( - new PropertyFilter('date', '<=', now), + new PropertyFilter('date', '<=', now) ); const filter = query.entityFilters[0]; @@ -348,7 +345,7 @@ describe('Query', () => { or([ new PropertyFilter('date', '<=', now), new PropertyFilter('name', '=', 'Stephen'), - ]), + ]) ); const filter = query.entityFilters[0]; assert.strictEqual(filter.op, 'OR'); @@ -365,11 +362,11 @@ describe('Query', () => { it('should accept null as value', () => { assert.strictEqual( new Query(['kind1']).filter('status', null).filters.pop()?.val, - null, + null ); assert.strictEqual( new Query(['kind1']).filter('status', '=', null).filters.pop()?.val, - null, + null ); }); }); @@ -606,14 +603,14 @@ describe('Query', () => { dataClient['commit'] = ( request: any, options: any, - callback: (err?: unknown) => void, + callback: (err?: unknown) => void ) => { try { assert.strictEqual(request.databaseId, SECOND_DATABASE_ID); assert.strictEqual(request.projectId, projectId); assert.strictEqual( options.headers['google-cloud-resource-prefix'], - `projects/${projectId}`, + `projects/${projectId}` ); } catch (e) { callback(e); diff --git a/test/request.ts b/test/request.ts index 48f582381..600421c16 100644 --- a/test/request.ts +++ b/test/request.ts @@ -113,7 +113,7 @@ describe('Request', () => { assert.notStrictEqual(preparedEntityObject.data.nested, obj.data.nested); assert.deepStrictEqual( preparedEntityObject, - expectedPreparedEntityObject, + expectedPreparedEntityObject ); }); @@ -123,7 +123,7 @@ describe('Request', () => { const entityObject: any = {data: true}; entityObject[entity.KEY_SYMBOL] = key; const preparedEntityObject = Request.prepareEntityObject_( - entityObject, + entityObject ) as Any; assert.strictEqual(preparedEntityObject.key, key); assert.strictEqual(preparedEntityObject.data.data, entityObject.data); @@ -218,7 +218,7 @@ describe('Request', () => { assert.strictEqual(keys, null); assert.strictEqual(resp, API_RESPONSE); done(); - }, + } ); }); }); @@ -251,7 +251,7 @@ describe('Request', () => { assert.deepStrictEqual(keys, [key]); assert.strictEqual(resp, API_RESPONSE); done(); - }, + } ); }); }); @@ -284,7 +284,7 @@ describe('Request', () => { assert.strictEqual(config.method, 'lookup'); assert.deepStrictEqual( config.reqOpts!.keys[0], - entity.keyToKeyProto(key), + entity.keyToKeyProto(key) ); done(); }; @@ -390,7 +390,7 @@ describe('Request', () => { .on('error', (err: Error) => { assert.deepStrictEqual( err, - outOfBoundsError({integerValue: largeInt, propertyName}), + outOfBoundsError({integerValue: largeInt, propertyName}) ); setImmediate(() => { assert.strictEqual(stream.destroyed, true); @@ -637,7 +637,7 @@ describe('Request', () => { assert.ifError(err); assert.deepStrictEqual(resp, apiResponse); done(); - }, + } ); }); @@ -786,7 +786,7 @@ describe('Request', () => { request.createReadStream.getCall(0).args[1]; assert.strictEqual( typeof createReadStreamOptions.wrapNumbers, - 'boolean', + 'boolean' ); done(); }); @@ -808,14 +808,14 @@ describe('Request', () => { request.createReadStream.getCall(0).args[1]; assert.strictEqual( createReadStreamOptions.wrapNumbers, - integerTypeCastOptions, + integerTypeCastOptions ); assert.deepStrictEqual( createReadStreamOptions.wrapNumbers, - integerTypeCastOptions, + integerTypeCastOptions ); done(); - }, + } ); }); }); @@ -876,7 +876,7 @@ describe('Request', () => { assert.strictEqual(config.reqOpts!.query, queryProto); assert.strictEqual( config.reqOpts!.partitionId!.namespaceId, - query.namespace, + query.namespace ); assert.strictEqual(config.gaxOpts, undefined); @@ -988,7 +988,7 @@ describe('Request', () => { .on('error', (err: Error) => { assert.deepStrictEqual( err, - outOfBoundsError({integerValue: largeInt, propertyName}), + outOfBoundsError({integerValue: largeInt, propertyName}) ); setImmediate(() => { assert.strictEqual(stream.destroyed, true); @@ -1122,7 +1122,7 @@ describe('Request', () => { sandbox.stub(entity, 'formatArray').callsFake(array => { assert.strictEqual( array, - entityResultsPerApiCall[timesRequestCalled], + entityResultsPerApiCall[timesRequestCalled] ); return entityResultsPerApiCall[timesRequestCalled]; }); @@ -1151,7 +1151,7 @@ describe('Request', () => { FakeQuery.prototype.start = function (endCursor) { assert.strictEqual( endCursor, - apiResponse.batch.endCursor.toString('base64'), + apiResponse.batch.endCursor.toString('base64') ); startCalled = true; return this; @@ -1168,7 +1168,7 @@ describe('Request', () => { if (timesRequestCalled === 1) { assert.strictEqual( limit_, - entityResultsPerApiCall[1].length - query.limitVal, + entityResultsPerApiCall[1].length - query.limitVal ); } else { // Should restore the original limit. @@ -1340,7 +1340,7 @@ describe('Request', () => { assert.strictEqual(spy.args[0], query); assert.strictEqual(spy.args[1], options); done(); - }, + } ); }); @@ -1380,14 +1380,14 @@ describe('Request', () => { const runQueryOptions = request.runQueryStream.getCall(0).args[1]; assert.strictEqual( runQueryOptions.wrapNumbers, - integerTypeCastOptions, + integerTypeCastOptions ); assert.deepStrictEqual( runQueryOptions.wrapNumbers, - integerTypeCastOptions, + integerTypeCastOptions ); done(); - }, + } ); }); }); @@ -1494,7 +1494,7 @@ describe('Request', () => { transaction.save = (modifiedData: PrepareEntityObjectResponse) => { assert.deepStrictEqual( modifiedData.data, - Object.assign({}, entityObject, updatedEntityObject), + Object.assign({}, entityObject, updatedEntityObject) ); }; @@ -1517,7 +1517,7 @@ describe('Request', () => { transaction.modifiedEntities_.forEach((entity, index) => { assert.deepStrictEqual( entity.args[0].data, - Object.assign({}, entityObject, updatedEntityObject[index]), + Object.assign({}, entityObject, updatedEntityObject[index]) ); }); return [{}] as CommitResponse; @@ -1528,7 +1528,7 @@ describe('Request', () => { {key, data: updatedEntityObject[0]}, {key, data: updatedEntityObject[1]}, ], - done, + done ); }); @@ -1725,7 +1725,7 @@ describe('Request', () => { (err: Error, requestFn: Function) => { assert.ifError(err); requestFn(); - }, + } ); }); }); @@ -1755,7 +1755,7 @@ describe('Request', () => { (err: Error, requestFn: Function) => { assert.ifError(err); requestFn(); - }, + } ); }); @@ -1776,7 +1776,7 @@ describe('Request', () => { (err: Error, requestFn: Function) => { assert.ifError(err); requestFn(); - }, + } ); }); @@ -1790,7 +1790,7 @@ describe('Request', () => { lookup(reqOpts: RequestOptions) { assert.strictEqual( reqOpts.readOptions!.transaction, - TRANSACTION_ID, + TRANSACTION_ID ); done(); }, @@ -1801,7 +1801,7 @@ describe('Request', () => { (err: Error, requestFn: Function) => { assert.ifError(err); requestFn(); - }, + } ); }); @@ -1815,7 +1815,7 @@ describe('Request', () => { runQuery(reqOpts: RequestOptions) { assert.strictEqual( reqOpts.readOptions!.transaction, - TRANSACTION_ID, + TRANSACTION_ID ); done(); }, @@ -1826,7 +1826,7 @@ describe('Request', () => { (err: Error, requestFn: Function) => { assert.ifError(err); requestFn(); - }, + } ); }); diff --git a/test/transaction.ts b/test/transaction.ts index 4da7bdb17..965ee6b14 100644 --- a/test/transaction.ts +++ b/test/transaction.ts @@ -197,12 +197,12 @@ async.each( // This is useful for tests that need to know when the mocked function is called. callBackSignaler: ( callbackReached: GapicFunctionName, - request?: RequestType, + request?: RequestType ) => void = () => {}; constructor( err: Error | null = null, - resp: google.datastore.v1.IBeginTransactionResponse = testRunResp, + resp: google.datastore.v1.IBeginTransactionResponse = testRunResp ) { const namespace = 'run-without-mock'; const projectId = 'project-id'; @@ -223,7 +223,7 @@ async.each( // Datastore Gapic clients haven't been initialized yet, so we initialize them here. datastore.clients_.set( dataClientName, - new gapic.v1[dataClientName](options), + new gapic.v1[dataClientName](options) ); const dataClient = datastore.clients_.get(dataClientName); // Mock begin transaction @@ -241,13 +241,13 @@ async.each( | null | undefined, {} | null | undefined - >, + > ) => { // Calls a user provided function that will receive this string // Usually used to track when this code was reached relative to other code this.callBackSignaler( GapicFunctionName.BEGIN_TRANSACTION, - request, + request ); callback(err, resp); }; @@ -262,7 +262,7 @@ async.each( mockGapicFunction( functionName: GapicFunctionName, response: ResponseType, - error: Error | null, + error: Error | null ) { const dataClient = this.dataClient; // Check here that function hasn't been mocked out already @@ -286,7 +286,7 @@ async.each( ResponseType, RequestType | null | undefined, {} | null | undefined - >, + > ) => { this.callBackSignaler(functionName, request); callback(error, response); @@ -327,7 +327,7 @@ async.each( beforeEach(async () => { transactionWrapper = new MockedTransactionWrapper( new Error(testErrorMessage), - undefined, + undefined ); }); it('should send back the error when awaiting a promise', async () => { @@ -341,7 +341,7 @@ async.each( it('should send back the error when using a callback', done => { const commitCallback: CommitCallback = ( error: Error | null | undefined, - response?: google.datastore.v1.ICommitResponse, + response?: google.datastore.v1.ICommitResponse ) => { try { assert(error); @@ -382,7 +382,7 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.COMMIT, testCommitResp, - new Error(testErrorMessage), + new Error(testErrorMessage) ); }); @@ -398,7 +398,7 @@ async.each( it('should send back the error when using a callback', done => { const commitCallback: CommitCallback = ( error: Error | null | undefined, - response?: google.datastore.v1.ICommitResponse, + response?: google.datastore.v1.ICommitResponse ) => { try { assert(error); @@ -419,7 +419,7 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.COMMIT, testCommitResp, - null, + null ); }); it('should send back the response when awaiting a promise', async () => { @@ -431,7 +431,7 @@ async.each( it('should send back the response when using a callback', done => { const commitCallback: CommitCallback = ( error: Error | null | undefined, - response?: google.datastore.v1.ICommitResponse, + response?: google.datastore.v1.ICommitResponse ) => { try { assert.strictEqual(error, null); @@ -489,7 +489,7 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.RUN_AGGREGATION_QUERY, runAggregationQueryResp, - new Error(testErrorMessage), + new Error(testErrorMessage) ); }); @@ -505,7 +505,7 @@ async.each( it('should send back the error when using a callback', done => { const runAggregateQueryCallback: RequestCallback = ( error: Error | null | undefined, - response?: unknown, + response?: unknown ) => { try { assert(error); @@ -519,7 +519,7 @@ async.each( transaction.run(() => { transaction.runAggregationQuery( aggregate, - runAggregateQueryCallback, + runAggregateQueryCallback ); }); }); @@ -529,7 +529,7 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.RUN_AGGREGATION_QUERY, runAggregationQueryResp, - null, + null ); }); it('should send back the response when awaiting a promise', async () => { @@ -539,13 +539,13 @@ async.each( const [runAggregateQueryResults] = allResults; assert.deepStrictEqual( runAggregateQueryResults, - runAggregationQueryUserResp, + runAggregationQueryUserResp ); }); it('should send back the response when using a callback', done => { const runAggregateQueryCallback: CommitCallback = ( error: Error | null | undefined, - response?: unknown, + response?: unknown ) => { try { assert.strictEqual(error, null); @@ -558,7 +558,7 @@ async.each( transaction.run(() => { transaction.runAggregationQuery( aggregate, - runAggregateQueryCallback, + runAggregateQueryCallback ); }); }); @@ -594,7 +594,7 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.RUN_QUERY, runQueryResp, - new Error(testErrorMessage), + new Error(testErrorMessage) ); }); @@ -611,7 +611,7 @@ async.each( const callback: RunQueryCallback = ( error: Error | null | undefined, entities?: Entity[], - info?: RunQueryInfo, + info?: RunQueryInfo ) => { try { assert(error); @@ -633,7 +633,7 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.RUN_QUERY, runQueryResp, - null, + null ); }); it('should send back the response when awaiting a promise', async () => { @@ -646,7 +646,7 @@ async.each( const callback: RunQueryCallback = ( error: Error | null | undefined, entities?: Entity[], - info?: RunQueryInfo, + info?: RunQueryInfo ) => { try { assert.strictEqual(error, null); @@ -711,7 +711,7 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.LOOKUP, getResp, - new Error(testErrorMessage), + new Error(testErrorMessage) ); }); @@ -727,7 +727,7 @@ async.each( it('should send back the error when using a callback', done => { const callback: GetCallback = ( err?: Error | null, - entity?: Entities, + entity?: Entities ) => { try { assert(err); @@ -748,7 +748,7 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.LOOKUP, getResp, - null, + null ); }); it('should send back the response when awaiting a promise', async () => { @@ -760,7 +760,7 @@ async.each( it('should send back the response when using a callback', done => { const callback: GetCallback = ( err?: Error | null, - entity?: Entities, + entity?: Entities ) => { try { const result = entity[transactionWrapper.datastore.KEY]; @@ -938,12 +938,12 @@ async.each( try { assert.deepStrictEqual( this.eventOrder, - this.expectedEventOrder, + this.expectedEventOrder ); if (this.expectedRequests) { assert.deepStrictEqual( this.requests, - this.expectedRequests, + this.expectedRequests ); } this.#done(); @@ -960,14 +960,14 @@ async.each( expectedRequests?: { call: GapicFunctionName; request?: RequestType; - }[], + }[] ) { this.expectedEventOrder = expectedOrder; this.expectedRequests = expectedRequests; this.#done = done; transactionWrapper.callBackSignaler = ( call: GapicFunctionName, - request?: RequestType, + request?: RequestType ) => { try { this.requests.push({call, request}); @@ -1003,7 +1003,7 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.COMMIT, testCommitResp, - null, + null ); }); @@ -1017,7 +1017,7 @@ async.each( UserCodeEvent.RUN_CALLBACK, GapicFunctionName.COMMIT, UserCodeEvent.COMMIT_CALLBACK, - ], + ] ); transaction.run(tester.push(UserCodeEvent.RUN_CALLBACK)); transaction.commit(tester.push(UserCodeEvent.COMMIT_CALLBACK)); @@ -1032,7 +1032,7 @@ async.each( GapicFunctionName.BEGIN_TRANSACTION, GapicFunctionName.COMMIT, UserCodeEvent.COMMIT_CALLBACK, - ], + ] ); transaction.commit(tester.push(UserCodeEvent.COMMIT_CALLBACK)); tester.push(UserCodeEvent.CUSTOM_EVENT)(); @@ -1046,7 +1046,7 @@ async.each( GapicFunctionName.BEGIN_TRANSACTION, UserCodeEvent.RUN_CALLBACK, UserCodeEvent.RUN_CALLBACK, - ], + ] ); transaction.run(tester.push(UserCodeEvent.RUN_CALLBACK)); transaction.run(tester.push(UserCodeEvent.RUN_CALLBACK)); @@ -1062,7 +1062,7 @@ async.each( UserCodeEvent.RUN_CALLBACK, GapicFunctionName.COMMIT, UserCodeEvent.COMMIT_CALLBACK, - ], + ] ); transaction.commit(tester.push(UserCodeEvent.COMMIT_CALLBACK)); transaction.run(tester.push(UserCodeEvent.RUN_CALLBACK)); @@ -1076,22 +1076,22 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.COMMIT, testCommitResp, - null, + null ); transactionWrapper.mockGapicFunction( GapicFunctionName.LOOKUP, testLookupResp, - null, + null ); transactionWrapper.mockGapicFunction( GapicFunctionName.RUN_QUERY, testRunQueryResp, - null, + null ); transactionWrapper.mockGapicFunction( GapicFunctionName.RUN_AGGREGATION_QUERY, testRunAggregationQueryResp, - null, + null ); }); const beginTransactionRequest = { @@ -1181,7 +1181,7 @@ async.each( GapicFunctionName.COMMIT, UserCodeEvent.COMMIT_CALLBACK, ], - expectedRequests, + expectedRequests ); transaction.save({ key, @@ -1199,7 +1199,7 @@ async.each( GapicFunctionName.COMMIT, UserCodeEvent.COMMIT_CALLBACK, ], - expectedRequests, + expectedRequests ); transaction.save({ key, @@ -1241,7 +1241,7 @@ async.each( UserCodeEvent.GET_CALLBACK, UserCodeEvent.GET_CALLBACK, ], - expectedRequests, + expectedRequests ); transaction.get(key, tester.push(UserCodeEvent.GET_CALLBACK)); transaction.get(key, tester.push(UserCodeEvent.GET_CALLBACK)); @@ -1283,7 +1283,7 @@ async.each( UserCodeEvent.GET_CALLBACK, UserCodeEvent.GET_CALLBACK, ], - expectedRequests, + expectedRequests ); transaction.run(tester.push(UserCodeEvent.RUN_CALLBACK)); transaction.get(key, tester.push(UserCodeEvent.GET_CALLBACK)); @@ -1385,22 +1385,22 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.RUN_AGGREGATION_QUERY, runAggregationQueryResp, - null, + null ); transactionWrapper.mockGapicFunction( GapicFunctionName.LOOKUP, getResp, - null, + null ); transactionWrapper.mockGapicFunction( GapicFunctionName.RUN_QUERY, runQueryResp, - null, + null ); transactionWrapper.mockGapicFunction( GapicFunctionName.COMMIT, testCommitResp, - null, + null ); }); describe('lookup, lookup, put, commit', () => { @@ -1410,13 +1410,13 @@ async.each( // It ensures the data that reaches the gapic layer is correct. transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType, + request?: RequestType ) => { try { switch (callbackReached) { case GapicFunctionName.BEGIN_TRANSACTION: throw Error( - 'BeginTransaction should not have been called', + 'BeginTransaction should not have been called' ); case GapicFunctionName.LOOKUP: { const lookupRequest = @@ -1444,18 +1444,18 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL', + 'TRANSACTIONAL' ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction, + testRunResp.transaction ); done(); break; } default: throw Error( - 'A gapic function was called that should not have been called', + 'A gapic function was called that should not have been called' ); } } catch (err: any) { @@ -1480,7 +1480,7 @@ async.each( // It ensures the data that reaches the gapic layer is correct. transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType, + request?: RequestType ) => { try { switch (callbackReached) { @@ -1504,11 +1504,11 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL', + 'TRANSACTIONAL' ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction, + testRunResp.transaction ); assert.strictEqual(beginCount, 1); done(); @@ -1516,7 +1516,7 @@ async.each( } default: throw Error( - 'A gapic function was called that should not have been called', + 'A gapic function was called that should not have been called' ); } } catch (err: any) { @@ -1543,13 +1543,13 @@ async.each( // It ensures the data that reaches the gapic layer is correct. transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType, + request?: RequestType ) => { try { switch (callbackReached) { case GapicFunctionName.BEGIN_TRANSACTION: throw Error( - 'BeginTransaction should not have been called', + 'BeginTransaction should not have been called' ); case GapicFunctionName.LOOKUP: { const lookupRequest = @@ -1573,18 +1573,18 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL', + 'TRANSACTIONAL' ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction, + testRunResp.transaction ); done(); break; } default: throw Error( - 'A gapic function was called that should not have been called', + 'A gapic function was called that should not have been called' ); } } catch (err: any) { @@ -1611,7 +1611,7 @@ async.each( // It ensures the data that reaches the gapic layer is correct. transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType, + request?: RequestType ) => { try { switch (callbackReached) { @@ -1643,11 +1643,11 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL', + 'TRANSACTIONAL' ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction, + testRunResp.transaction ); assert.strictEqual(beginCount, 1); done(); @@ -1655,7 +1655,7 @@ async.each( } default: throw Error( - 'A gapic function was called that should not have been called', + 'A gapic function was called that should not have been called' ); } } catch (err: any) { @@ -1684,13 +1684,13 @@ async.each( // It ensures the data that reaches the gapic layer is correct. transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType, + request?: RequestType ) => { try { switch (callbackReached) { case GapicFunctionName.BEGIN_TRANSACTION: throw Error( - 'BeginTransaction should not have been called', + 'BeginTransaction should not have been called' ); case GapicFunctionName.LOOKUP: { const lookupRequest = @@ -1708,7 +1708,7 @@ async.each( { newTransaction: {}, consistencyType: 'newTransaction', - }, + } ); break; } @@ -1717,18 +1717,18 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL', + 'TRANSACTIONAL' ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction, + testRunResp.transaction ); done(); break; } default: throw Error( - 'A gapic function was called that should not have been called', + 'A gapic function was called that should not have been called' ); } } catch (err: any) { @@ -1758,7 +1758,7 @@ async.each( // It ensures the data that reaches the gapic layer is correct. transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType, + request?: RequestType ) => { try { switch (callbackReached) { @@ -1784,7 +1784,7 @@ async.each( runAggregationQueryRequest.readOptions, { transaction: testRunResp.transaction, - }, + } ); break; } @@ -1793,11 +1793,11 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL', + 'TRANSACTIONAL' ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction, + testRunResp.transaction ); assert.strictEqual(beginCount, 1); done(); @@ -1805,7 +1805,7 @@ async.each( } default: throw Error( - 'A gapic function was called that should not have been called', + 'A gapic function was called that should not have been called' ); } } catch (err: any) { @@ -1837,13 +1837,13 @@ async.each( // It ensures the data that reaches the gapic layer is correct. transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType, + request?: RequestType ) => { try { switch (callbackReached) { case GapicFunctionName.BEGIN_TRANSACTION: throw Error( - 'BeginTransaction should not have been called', + 'BeginTransaction should not have been called' ); case GapicFunctionName.LOOKUP: { const lookupRequest = @@ -1859,18 +1859,18 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL', + 'TRANSACTIONAL' ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction, + testRunResp.transaction ); done(); break; } default: throw Error( - 'A gapic function was called that should not have been called', + 'A gapic function was called that should not have been called' ); } } catch (err: any) { @@ -1895,7 +1895,7 @@ async.each( // It ensures the data that reaches the gapic layer is correct. transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType, + request?: RequestType ) => { try { switch (callbackReached) { @@ -1919,11 +1919,11 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL', + 'TRANSACTIONAL' ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction, + testRunResp.transaction ); assert.strictEqual(beginCount, 1); done(); @@ -1931,7 +1931,7 @@ async.each( } default: throw Error( - 'A gapic function was called that should not have been called', + 'A gapic function was called that should not have been called' ); } } catch (err: any) { @@ -1959,7 +1959,7 @@ async.each( // It ensures the data that reaches the gapic layer is correct. transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType, + request?: RequestType ) => { try { switch (callbackReached) { @@ -1975,11 +1975,11 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL', + 'TRANSACTIONAL' ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction, + testRunResp.transaction ); assert.strictEqual(beginCount, 1); done(); @@ -1987,7 +1987,7 @@ async.each( } default: throw Error( - 'A gapic function was called that should not have been called', + 'A gapic function was called that should not have been called' ); } } catch (err: any) { @@ -2010,7 +2010,7 @@ async.each( let beginCount = 0; transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType, + request?: RequestType ) => { try { switch (callbackReached) { @@ -2034,11 +2034,11 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL', + 'TRANSACTIONAL' ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction, + testRunResp.transaction ); assert.strictEqual(beginCount, 1); done(); @@ -2046,7 +2046,7 @@ async.each( } default: throw Error( - 'A gapic function was called that should not have been called', + 'A gapic function was called that should not have been called' ); } } catch (err: any) { @@ -2097,7 +2097,7 @@ async.each( // Datastore Gapic clients haven't been initialized yet, so we initialize them here. datastore.clients_.set( dataClientName, - new gapic.v1[dataClientName](options), + new gapic.v1[dataClientName](options) ); dataClient = datastore.clients_.get(dataClientName); if (dataClient && dataClient.beginTransaction) { @@ -2124,7 +2124,7 @@ async.each( | null | undefined, {} | null | undefined - >, + > ) => { callback(err, testRunResp); }; @@ -2150,7 +2150,7 @@ async.each( const runCallback: RunCallback = ( error: Error | null, transaction: Transaction | null, - response?: google.datastore.v1.IBeginTransactionResponse, + response?: google.datastore.v1.IBeginTransactionResponse ) => { try { assert(error); @@ -2180,7 +2180,7 @@ async.each( const runCallback: RunCallback = ( error: Error | null, transaction: Transaction | null, - response?: google.datastore.v1.IBeginTransactionResponse, + response?: google.datastore.v1.IBeginTransactionResponse ) => { try { assert.strictEqual(error, null); @@ -2496,7 +2496,7 @@ async.each( // the rollback function to reach request_. transaction.request_ = ( config: RequestConfig, - callback: RequestCallback, + callback: RequestCallback ) => { callback(null, {transaction: Buffer.from(TRANSACTION_ID)}); }; @@ -2603,7 +2603,7 @@ async.each( transaction.request_ = (config: Any) => { assert.deepStrictEqual( config.reqOpts.transactionOptions.readOnly, - {}, + {} ); done(); }; @@ -2617,7 +2617,7 @@ async.each( transaction.request_ = config => { assert.deepStrictEqual( config.reqOpts!.transactionOptions!.readOnly, - {}, + {} ); done(); }; @@ -2637,7 +2637,7 @@ async.each( config.reqOpts!.transactionOptions!.readWrite, { previousTransaction: options.transactionId, - }, + } ); done(); }; @@ -2653,7 +2653,7 @@ async.each( config.reqOpts!.transactionOptions!.readWrite, { previousTransaction: transaction.id, - }, + } ); done(); }; @@ -2749,7 +2749,7 @@ async.each( transaction.save(entities); assert.strictEqual( transaction.modifiedEntities_.length, - entities.length, + entities.length ); transaction.modifiedEntities_.forEach((queuedEntity: Entity) => { assert.strictEqual(queuedEntity.method, 'save'); @@ -2855,7 +2855,7 @@ async.each( }); }); }); - }, + } ); describe('getTransactionRequest', () => { From ac966304e539dfe27ac89f7a8cf9b19938c0af8c Mon Sep 17 00:00:00 2001 From: Daniel Bruce Date: Fri, 30 May 2025 11:44:36 -0400 Subject: [PATCH 21/21] Run the linter --- mock-server/datastore-server.ts | 6 +- samples/concepts.js | 24 +- samples/queryFilterOr.js | 2 +- samples/tasks.js | 10 +- src/aggregate.ts | 4 +- src/entity.ts | 36 +- src/filter.ts | 2 +- src/index-class.ts | 14 +- src/index.ts | 46 +-- src/query.ts | 14 +- src/request.ts | 82 ++--- src/transaction.ts | 54 +-- src/utils/entity/buildEntityProto.ts | 2 +- src/utils/entity/buildPropertyTransforms.ts | 2 +- src/utils/entity/extendExcludeFromIndexes.ts | 6 +- src/v1/datastore_admin_client.ts | 146 ++++---- src/v1/datastore_client.ts | 108 +++--- system-test/datastore.ts | 148 ++++---- system-test/install.ts | 4 +- test/entity.ts | 86 ++--- test/entity/buildEntityProto.ts | 4 +- test/entity/excludeIndexesAndBuildProto.ts | 28 +- test/entity/extendExcludeFromIndexes.ts | 4 +- test/entity/findLargeProperties_.ts | 2 +- .../client-initialization-testing.ts | 10 +- test/gapic-mocks/commit.ts | 8 +- test/gapic-mocks/error-mocks.ts | 2 +- test/gapic-mocks/handwritten-errors.ts | 8 +- test/gapic-mocks/runQuery.ts | 8 +- test/gapic_datastore_admin_v1.ts | 330 +++++++++--------- test/gapic_datastore_v1.ts | 230 ++++++------ test/index.ts | 144 ++++---- test/query.ts | 47 +-- test/request.ts | 60 ++-- test/transaction.ts | 212 +++++------ 35 files changed, 948 insertions(+), 945 deletions(-) diff --git a/mock-server/datastore-server.ts b/mock-server/datastore-server.ts index 2379f525b..c2e1ee5f2 100644 --- a/mock-server/datastore-server.ts +++ b/mock-server/datastore-server.ts @@ -21,7 +21,7 @@ const GAX_PROTOS_DIR = resolve( // @ts-ignore // eslint-disable-next-line n/no-extraneous-require dirname(require.resolve('google-gax')), - '../protos' + '../protos', ); const grpc = require('@grpc/grpc-js'); @@ -42,7 +42,7 @@ const descriptor = grpc.loadPackageDefinition(packageDefinition); */ function grpcEndpoint( call: {}, - callback: (arg1: string | null, arg2: {}) => {} + callback: (arg1: string | null, arg2: {}) => {}, ) { // SET A BREAKPOINT HERE AND EXPLORE `call` TO SEE THE REQUEST. callback(null, {message: 'Hello'}); @@ -62,6 +62,6 @@ export function startServer(cb: () => void) { () => { console.log('server started'); cb(); - } + }, ); } diff --git a/samples/concepts.js b/samples/concepts.js index 6543142b9..78ebb544d 100644 --- a/samples/concepts.js +++ b/samples/concepts.js @@ -491,7 +491,7 @@ class Metadata extends TestHelper { and([ new PropertyFilter('__key__', '>=', startKey), new PropertyFilter('__key__', '<', endKey), - ]) + ]), ); const [entities] = await datastore.runQuery(query); @@ -616,7 +616,7 @@ class Query extends TestHelper { and([ new PropertyFilter('done', '=', false), new PropertyFilter('priority', '>=', 4), - ]) + ]), ) .order('priority', { descending: true, @@ -684,7 +684,7 @@ class Query extends TestHelper { and([ new PropertyFilter('done', '=', false), new PropertyFilter('priority', '=', 4), - ]) + ]), ); // [END datastore_composite_filter] @@ -698,7 +698,7 @@ class Query extends TestHelper { const query = datastore .createQuery('Task') .filter( - new PropertyFilter('__key__', '>', datastore.key(['Task', 'someTask'])) + new PropertyFilter('__key__', '>', datastore.key(['Task', 'someTask'])), ); // [END datastore_key_filter] @@ -814,7 +814,7 @@ class Query extends TestHelper { and([ new PropertyFilter('tag', '>', 'learn'), new PropertyFilter('tag', '<', 'math'), - ]) + ]), ); // [END datastore_array_value_inequality_range] @@ -831,7 +831,7 @@ class Query extends TestHelper { and([ new PropertyFilter('tag', '=', 'fun'), new PropertyFilter('tag', '=', 'programming'), - ]) + ]), ); // [END datastore_array_value_equality] @@ -848,7 +848,7 @@ class Query extends TestHelper { and([ new PropertyFilter('created', '>', new Date('1990-01-01T00:00:00z')), new PropertyFilter('created', '<', new Date('2000-12-31T23:59:59z')), - ]) + ]), ); // [END datastore_inequality_range] @@ -865,7 +865,7 @@ class Query extends TestHelper { and([ new PropertyFilter('priority', '>', 3), new PropertyFilter('created', '>', new Date('1990-01-01T00:00:00z')), - ]) + ]), ); // [END datastore_inequality_invalid] @@ -884,7 +884,7 @@ class Query extends TestHelper { new PropertyFilter('done', '=', false), new PropertyFilter('created', '>', new Date('1990-01-01T00:00:00z')), new PropertyFilter('created', '<', new Date('2000-12-31T23:59:59z')), - ]) + ]), ); // [END datastore_equal_and_inequality_range] @@ -1071,11 +1071,11 @@ class Transaction extends TestHelper { datastore = datastoreMock; assert.strictEqual( accounts[0].balance, - originalBalance - amountToTransfer + originalBalance - amountToTransfer, ); assert.strictEqual( accounts[1].balance, - originalBalance + amountToTransfer + originalBalance + amountToTransfer, ); } catch (err) { datastore = datastoreMock; @@ -1201,7 +1201,7 @@ class Transaction extends TestHelper { // Restore `datastore` to the mock API. datastore = datastoreMock; return Promise.reject(err); - } + }, ); } } diff --git a/samples/queryFilterOr.js b/samples/queryFilterOr.js index 80913cd9c..deb911d77 100644 --- a/samples/queryFilterOr.js +++ b/samples/queryFilterOr.js @@ -37,7 +37,7 @@ async function main() { or([ new PropertyFilter('description', '=', 'Buy milk'), new PropertyFilter('description', '=', 'Feed cats'), - ]) + ]), ); const [entities] = await datastore.runQuery(query); diff --git a/samples/tasks.js b/samples/tasks.js index e31c82958..eca5d3be2 100644 --- a/samples/tasks.js +++ b/samples/tasks.js @@ -162,23 +162,23 @@ require(`yargs`) // eslint-disable-line 'new ', 'Adds a task with a description .', {}, - opts => addTask(opts.description) + opts => addTask(opts.description), ) .command('done ', 'Marks the specified task as done.', {}, opts => - markDone(opts.taskId) + markDone(opts.taskId), ) .command('merge ', 'Marks the specified task as done.', {}, opts => - merge(opts.taskId, opts.description) + merge(opts.taskId, opts.description), ) .command('list', 'Lists all tasks ordered by creation time.', {}, listTasks) .command('delete ', 'Deletes a task.', {}, opts => - deleteTask(opts.taskId) + deleteTask(opts.taskId), ) .example('node $0 new "Buy milk"', 'Adds a task with description "Buy milk".') .example('node $0 done 12345', 'Marks task 12345 as Done.') .example( 'node $0 merge 12345', - 'update task 12345 with description "Buy food".' + 'update task 12345 with description "Buy food".', ) .example('node $0 list', 'Lists all tasks ordered by creation time') .example('node $0 delete 12345', 'Deletes task 12345.') diff --git a/src/aggregate.ts b/src/aggregate.ts index d36172e4d..3c07aeee3 100644 --- a/src/aggregate.ts +++ b/src/aggregate.ts @@ -113,7 +113,7 @@ class AggregateQuery { */ run( optionsOrCallback?: RunQueryOptions | RequestCallback, - cb?: RequestCallback + cb?: RequestCallback, ): void | Promise { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -233,7 +233,7 @@ abstract class PropertyAggregateField extends AggregateField { return Object.assign( {operator: this.operator}, this.alias_ ? {alias: this.alias_} : null, - {[this.operator]: aggregation} + {[this.operator]: aggregation}, ); } } diff --git a/src/entity.ts b/src/entity.ts index 42742e09e..bd041f029 100644 --- a/src/entity.ts +++ b/src/entity.ts @@ -136,7 +136,7 @@ export namespace entity { private _entityPropertyName: string | undefined; constructor( value: number | string | ValueProto, - typeCastOptions?: IntegerTypeCastOptions + typeCastOptions?: IntegerTypeCastOptions, ) { super(typeof value === 'object' ? value.integerValue : value); this._entityPropertyName = @@ -158,7 +158,7 @@ export namespace entity { this.typeCastFunction = typeCastOptions.integerTypeCastFunction; if (typeof typeCastOptions.integerTypeCastFunction !== 'function') { throw new Error( - 'integerTypeCastFunction is not a function or was not provided.' + 'integerTypeCastFunction is not a function or was not provided.', ); } @@ -440,7 +440,7 @@ export namespace entity { if (this.parent) { serializedKey.path = this.parent.serialized.path.concat( - serializedKey.path + serializedKey.path, ); } @@ -479,7 +479,7 @@ export namespace entity { '{\n' + ' integerTypeCastFunction: provide \n' + ' properties: optionally specify property name(s) to be custom casted\n' + - '}\n' + '}\n', ); } return num; @@ -527,7 +527,7 @@ export namespace entity { */ export function decodeValueProto( valueProto: ValueProto, - wrapNumbers?: boolean | IntegerTypeCastOptions + wrapNumbers?: boolean | IntegerTypeCastOptions, ) { const valueType = valueProto.valueType!; const value = valueProto[valueType]; @@ -536,7 +536,7 @@ export namespace entity { case 'arrayValue': { // eslint-disable-next-line @typescript-eslint/no-explicit-any return value.values.map((val: any) => - entity.decodeValueProto(val, wrapNumbers) + entity.decodeValueProto(val, wrapNumbers), ); } @@ -617,7 +617,7 @@ export namespace entity { "the value for '" + property + "' property is outside of bounds of a JavaScript Number.\n" + - "Use 'Datastore.int()' to preserve accuracy during the upload." + "Use 'Datastore.int()' to preserve accuracy during the upload.", ); } value = new entity.Int(value); @@ -730,7 +730,7 @@ export namespace entity { // eslint-disable-next-line @typescript-eslint/no-explicit-any export function entityFromEntityProto( entityProto: EntityProto, - wrapNumbers?: boolean | IntegerTypeCastOptions + wrapNumbers?: boolean | IntegerTypeCastOptions, ) { // eslint-disable-next-line @typescript-eslint/no-explicit-any const entityObject: any = {}; @@ -789,7 +789,7 @@ export namespace entity { return encoded; }, // eslint-disable-next-line @typescript-eslint/no-explicit-any - {} as any + {} as any, ), }; @@ -808,7 +808,7 @@ export namespace entity { */ export function addExcludeFromIndexes( excludeFromIndexes: string[] | undefined, - entityProto: EntityProto + entityProto: EntityProto, ): EntityProto { if (excludeFromIndexes && excludeFromIndexes.length > 0) { excludeFromIndexes.forEach((excludePath: string) => { @@ -889,14 +889,14 @@ export namespace entity { // (including entity values at their roots): excludePathFromEntity( value, - remainderPath // === '' + remainderPath, // === '' ); } else { // Path traversal continues at value.entityValue, // if it is an entity, or must end at value. excludePathFromEntity( value.entityValue || value, - remainderPath // !== '' + remainderPath, // !== '' ); } }); @@ -977,7 +977,7 @@ export namespace entity { */ export function formatArray( results: ResponseResult[], - wrapNumbers?: boolean | IntegerTypeCastOptions + wrapNumbers?: boolean | IntegerTypeCastOptions, ) { return results.map(result => { const ent = entity.entityFromEntityProto(result.entity!, wrapNumbers); @@ -998,7 +998,7 @@ export namespace entity { export function findLargeProperties_( entities: Entities, path: string, - properties: string[] = [] + properties: string[] = [], ) { const MAX_DATASTORE_VALUE_LENGTH = 1500; if (Array.isArray(entities)) { @@ -1011,7 +1011,7 @@ export namespace entity { findLargeProperties_( entities[key], path.concat(`${path ? '.' : ''}${key}`), - properties + properties, ); } } else if ( @@ -1259,7 +1259,7 @@ export namespace entity { if (query.filters.length > 0 || query.entityFilters.length > 0) { // Convert all legacy filters into new property filter objects const filters = query.filters.map( - filter => new PropertyFilter(filter.name, filter.op, filter.val) + filter => new PropertyFilter(filter.name, filter.op, filter.val), ); const entityFilters = query.entityFilters; const allFilters = entityFilters.concat(filters); @@ -1299,7 +1299,7 @@ export namespace entity { loadProtos_() { const root = new Protobuf.Root(); const loadedRoot = root.loadSync( - path.join(__dirname, '..', 'protos', 'app_engine_key.proto') + path.join(__dirname, '..', 'protos', 'app_engine_key.proto'), ); loadedRoot.resolveAll(); return loadedRoot.nested; @@ -1321,7 +1321,7 @@ export namespace entity { legacyEncode( projectId: string, key: entity.Key, - locationPrefix?: string + locationPrefix?: string, ): string { const elements: {}[] = []; let currentKey = key; diff --git a/src/filter.ts b/src/filter.ts index d062fb2e3..f59ba2c6e 100644 --- a/src/filter.ts +++ b/src/filter.ts @@ -100,7 +100,7 @@ export class PropertyFilter constructor( public name: T, public op: Operator, - public val: AllowedFilterValueType + public val: AllowedFilterValueType, ) { super(); } diff --git a/src/index-class.ts b/src/index-class.ts index 64decbed4..49027c990 100644 --- a/src/index-class.ts +++ b/src/index-class.ts @@ -22,7 +22,7 @@ export interface GenericIndexCallback { ( err?: ServiceError | null, index?: Index | null, - apiResponse?: T | null + apiResponse?: T | null, ): void; } @@ -31,7 +31,7 @@ export type GetIndexResponse = [Index, IIndex]; export type IndexGetMetadataCallback = ( err?: ServiceError | null, - metadata?: IIndex | null + metadata?: IIndex | null, ) => void; export type IndexGetMetadataResponse = [IIndex]; @@ -51,7 +51,7 @@ export type GetIndexesCallback = ( err?: ServiceError | null, indexes?: Index[], nextQuery?: GetIndexesOptions, - apiResponse?: google.datastore.admin.v1.IListIndexesResponse + apiResponse?: google.datastore.admin.v1.IListIndexesResponse, ) => void; export type IIndex = google.datastore.admin.v1.IIndex; @@ -93,7 +93,7 @@ export class Index { get(gaxOptions: CallOptions, callback: GetIndexCallback): void; get( gaxOptionsOrCallback?: CallOptions | GetIndexCallback, - cb?: GetIndexCallback + cb?: GetIndexCallback, ): void | Promise { const gaxOpts = typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {}; @@ -118,11 +118,11 @@ export class Index { getMetadata(callback: IndexGetMetadataCallback): void; getMetadata( gaxOptions: CallOptions, - callback: IndexGetMetadataCallback + callback: IndexGetMetadataCallback, ): void; getMetadata( gaxOptionsOrCallback?: CallOptions | IndexGetMetadataCallback, - cb?: IndexGetMetadataCallback + cb?: IndexGetMetadataCallback, ): void | Promise { const gaxOpts = typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {}; @@ -143,7 +143,7 @@ export class Index { this.metadata = resp; } callback(err as ServiceError, resp); - } + }, ); } diff --git a/src/index.ts b/src/index.ts index 849387b31..64f0fb9e1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -107,7 +107,7 @@ export interface LongRunningCallback { ( err: ServiceError | null, operation?: Operation, - apiResponse?: google.longrunning.IOperation + apiResponse?: google.longrunning.IOperation, ): void; } export type LongRunningResponse = [Operation, google.longrunning.IOperation]; @@ -507,7 +507,7 @@ class Datastore extends DatastoreRequest { new Set([ ...gapic.v1.DatastoreClient.scopes, ...gapic.v1.DatastoreAdminClient.scopes, - ]) + ]), ); this.options = Object.assign( @@ -518,7 +518,7 @@ class Datastore extends DatastoreRequest { servicePath: this.baseUrl_, port: typeof this.port_ === 'number' ? this.port_ : 443, }, - options + options, ); const isUsingLocalhost = this.baseUrl_ && @@ -563,7 +563,7 @@ class Datastore extends DatastoreRequest { export(config: ExportEntitiesConfig, callback: LongRunningCallback): void; export( config: ExportEntitiesConfig, - callback?: LongRunningCallback + callback?: LongRunningCallback, ): void | Promise { const reqOpts: ExportEntitiesConfig = { entityFilter: {}, @@ -611,7 +611,7 @@ class Datastore extends DatastoreRequest { gaxOpts: config.gaxOptions, }, // eslint-disable-next-line @typescript-eslint/no-explicit-any - callback as any + callback as any, ); } @@ -633,7 +633,7 @@ class Datastore extends DatastoreRequest { getIndexes(callback: GetIndexesCallback): void; getIndexes( optionsOrCallback?: GetIndexesOptions | GetIndexesCallback, - cb?: GetIndexesCallback + cb?: GetIndexesCallback, ): void | Promise { let options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -685,7 +685,7 @@ class Datastore extends DatastoreRequest { const apiResp: google.datastore.admin.v1.IListIndexesResponse = resp[2]; callback(err as ServiceError, indexes, nextQuery, apiResp); - } + }, ); } @@ -713,7 +713,7 @@ class Datastore extends DatastoreRequest { next(null, indexInstance); }, }), - () => {} + () => {}, ); } @@ -751,7 +751,7 @@ class Datastore extends DatastoreRequest { import(config: ImportEntitiesConfig, callback: LongRunningCallback): void; import( config: ImportEntitiesConfig, - callback?: LongRunningCallback + callback?: LongRunningCallback, ): void | Promise { const reqOpts: ImportEntitiesConfig = { entityFilter: {}, @@ -799,7 +799,7 @@ class Datastore extends DatastoreRequest { gaxOpts: config.gaxOptions, }, // eslint-disable-next-line @typescript-eslint/no-explicit-any - callback as any + callback as any, ); } @@ -831,7 +831,7 @@ class Datastore extends DatastoreRequest { insert(entities: Entities, callback: InsertCallback): void; insert( entities: Entities, - callback?: InsertCallback + callback?: InsertCallback, ): void | Promise { entities = arrify(entities) .map(DatastoreRequest.prepareEntityObject_) @@ -1082,13 +1082,13 @@ class Datastore extends DatastoreRequest { save( entities: Entities, gaxOptions: CallOptions, - callback: SaveCallback + callback: SaveCallback, ): void; save(entities: Entities, callback: SaveCallback): void; save( entities: Entities, gaxOptionsOrCallback?: CallOptions | SaveCallback, - cb?: SaveCallback + cb?: SaveCallback, ): void | Promise { entities = arrify(entities) as SaveEntity[]; const gaxOptions = @@ -1118,7 +1118,7 @@ class Datastore extends DatastoreRequest { method = entityObject.method; } else { throw new Error( - 'Method ' + entityObject.method + ' not recognized.' + 'Method ' + entityObject.method + ' not recognized.', ); } } @@ -1138,7 +1138,7 @@ class Datastore extends DatastoreRequest { // We built the entityProto, now we should add the data transforms: if (entityObject.transforms) { mutation.propertyTransforms = buildPropertyTransforms( - entityObject.transforms + entityObject.transforms, ); } mutations.push(mutation); @@ -1150,7 +1150,7 @@ class Datastore extends DatastoreRequest { function onCommit( err?: Error | null, - resp?: google.datastore.v1.ICommitResponse + resp?: google.datastore.v1.ICommitResponse, ) { if (err || !resp) { callback(err, resp); @@ -1183,7 +1183,7 @@ class Datastore extends DatastoreRequest { reqOpts, gaxOpts: gaxOptions, }, - onCommit + onCommit, ); } @@ -1205,7 +1205,7 @@ class Datastore extends DatastoreRequest { update(entities: Entities, callback: UpdateCallback): void; update( entities: Entities, - callback?: UpdateCallback + callback?: UpdateCallback, ): void | Promise { entities = arrify(entities) .map(DatastoreRequest.prepareEntityObject_) @@ -1235,7 +1235,7 @@ class Datastore extends DatastoreRequest { upsert(entities: Entities, callback: UpsertCallback): void; upsert( entities: Entities, - callback?: UpsertCallback + callback?: UpsertCallback, ): void | Promise { entities = arrify(entities) .map(DatastoreRequest.prepareEntityObject_) @@ -1529,7 +1529,7 @@ class Datastore extends DatastoreRequest { createQuery(namespace: string, kind: string[]): Query; createQuery( namespaceOrKind?: string | string[], - kind?: string | string[] + kind?: string | string[], ): Query { let namespace = namespaceOrKind as string; if (!kind) { @@ -1708,17 +1708,17 @@ class Datastore extends DatastoreRequest { keyToLegacyUrlSafe(key: entity.Key, locationPrefix?: string): Promise; keyToLegacyUrlSafe( key: entity.Key, - callback: KeyToLegacyUrlSafeCallback + callback: KeyToLegacyUrlSafeCallback, ): void; keyToLegacyUrlSafe( key: entity.Key, locationPrefix: string, - callback: KeyToLegacyUrlSafeCallback + callback: KeyToLegacyUrlSafeCallback, ): void; keyToLegacyUrlSafe( key: entity.Key, locationPrefixOrCallback?: string | KeyToLegacyUrlSafeCallback, - callback?: KeyToLegacyUrlSafeCallback + callback?: KeyToLegacyUrlSafeCallback, ): Promise | void { const locationPrefix = typeof locationPrefixOrCallback === 'string' diff --git a/src/query.ts b/src/query.ts index 557ae12a7..86ff6ff45 100644 --- a/src/query.ts +++ b/src/query.ts @@ -91,12 +91,12 @@ class Query { constructor( scope?: Datastore | Transaction, namespace?: string | null, - kinds?: string[] + kinds?: string[], ); constructor( scope?: Datastore | Transaction, namespaceOrKinds?: string | string[] | null, - kinds?: string[] + kinds?: string[], ) { let namespace = namespaceOrKinds as string | null; if (!kinds) { @@ -212,22 +212,22 @@ class Query { filter(filter: EntityFilter): Query; filter( property: T, - value: AllowedFilterValueType + value: AllowedFilterValueType, ): Query; filter( property: T, operator: Operator, - value: AllowedFilterValueType + value: AllowedFilterValueType, ): Query; filter( propertyOrFilter: T | EntityFilter, operatorOrValue?: Operator | AllowedFilterValueType, - value?: AllowedFilterValueType + value?: AllowedFilterValueType, ): Query { if (arguments.length > 1) { gaxInstance.warn( 'filter', - 'Providing Filter objects like Composite Filter or Property Filter is recommended when using .filter' + 'Providing Filter objects like Composite Filter or Property Filter is recommended when using .filter', ); } switch (arguments.length) { @@ -524,7 +524,7 @@ class Query { run(callback: RunQueryCallback): void; run( optionsOrCallback?: RunQueryOptions | RunQueryCallback, - cb?: RunQueryCallback + cb?: RunQueryCallback, ): void | Promise { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; diff --git a/src/request.ts b/src/request.ts index a15597a05..dee2a09b2 100644 --- a/src/request.ts +++ b/src/request.ts @@ -93,7 +93,7 @@ function decodeStruct(structValue: google.protobuf.IStruct): JSONValue { function getInfoFromStats( resp: | protos.google.datastore.v1.IRunQueryResponse - | protos.google.datastore.v1.IRunAggregationQueryResponse + | protos.google.datastore.v1.IRunAggregationQueryResponse, ): RunQueryInfo { // Decode struct values stored in planSummary and executionStats const explainMetrics: ExplainMetrics = {}; @@ -106,7 +106,7 @@ function getInfoFromStats( Object.assign(explainMetrics, { planSummary: { indexesUsed: resp.explainMetrics.planSummary.indexesUsed.map( - (index: google.protobuf.IStruct) => decodeStruct(index) + (index: google.protobuf.IStruct) => decodeStruct(index), ), }, }); @@ -330,17 +330,17 @@ class DatastoreRequest { */ allocateIds( key: entity.Key, - options: AllocateIdsOptions | number + options: AllocateIdsOptions | number, ): Promise; allocateIds( key: entity.Key, options: AllocateIdsOptions | number, - callback: AllocateIdsCallback + callback: AllocateIdsCallback, ): void; allocateIds( key: entity.Key, options: AllocateIdsOptions | number, - callback?: AllocateIdsCallback + callback?: AllocateIdsCallback, ): void | Promise { if (entity.isKeyComplete(key)) { throw new Error('An incomplete key should be provided.'); @@ -363,7 +363,7 @@ class DatastoreRequest { } const keys = arrify(resp!.keys!).map(entity.keyFromKeyProto); callback!(null, keys, resp!); - } + }, ); } @@ -405,7 +405,7 @@ class DatastoreRequest { */ createReadStream( keys: Entities, - options: CreateReadStreamOptions = {} + options: CreateReadStreamOptions = {}, ): Transform { keys = arrify(keys).map(entity.keyToKeyProto); if (keys.length === 0) { @@ -436,7 +436,7 @@ class DatastoreRequest { try { entities = entity.formatArray( resp!.found! as ResponseResult[], - options.wrapNumbers + options.wrapNumbers, ); } catch (err) { stream.destroy(err); @@ -462,7 +462,7 @@ class DatastoreRequest { .catch(err => { throw err; }); - } + }, ); }; @@ -528,12 +528,12 @@ class DatastoreRequest { delete( keys: Entities, gaxOptions: CallOptions, - callback: DeleteCallback + callback: DeleteCallback, ): void; delete( keys: entity.Key | entity.Key[], gaxOptionsOrCallback?: CallOptions | DeleteCallback, - cb?: DeleteCallback + cb?: DeleteCallback, ): void | Promise { const gaxOptions = typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {}; @@ -561,7 +561,7 @@ class DatastoreRequest { reqOpts, gaxOpts: gaxOptions, }, - callback + callback, ); } @@ -660,18 +660,18 @@ class DatastoreRequest { */ get( keys: entity.Key | entity.Key[], - options?: CreateReadStreamOptions + options?: CreateReadStreamOptions, ): Promise; get(keys: entity.Key | entity.Key[], callback: GetCallback): void; get( keys: entity.Key | entity.Key[], options: CreateReadStreamOptions, - callback: GetCallback + callback: GetCallback, ): void; get( keys: entity.Key | entity.Key[], optionsOrCallback?: CreateReadStreamOptions | GetCallback, - cb?: GetCallback + cb?: GetCallback, ): void | Promise { const options = typeof optionsOrCallback === 'object' && optionsOrCallback @@ -687,7 +687,7 @@ class DatastoreRequest { concat((results: Entity[]) => { const isSingleLookup = !Array.isArray(keys); callback(null, isSingleLookup ? results[0] : results); - }) + }), ); } catch (err: any) { callback(err); @@ -727,21 +727,21 @@ class DatastoreRequest { **/ runAggregationQuery( query: AggregateQuery, - options?: RunQueryOptions + options?: RunQueryOptions, ): Promise; runAggregationQuery( query: AggregateQuery, options: RunQueryOptions, - callback: RunAggregationQueryCallback + callback: RunAggregationQueryCallback, ): void; runAggregationQuery( query: AggregateQuery, - callback: RunAggregationQueryCallback + callback: RunAggregationQueryCallback, ): void; runAggregationQuery( query: AggregateQuery, optionsOrCallback?: RunQueryOptions | RunAggregationQueryCallback, - cb?: RequestCallback + cb?: RequestCallback, ): void | Promise { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -795,7 +795,7 @@ class DatastoreRequest { const results = res.batch.aggregationResults; const finalResults = results .map( - (aggregationResult: any) => aggregationResult.aggregateProperties + (aggregationResult: any) => aggregationResult.aggregateProperties, ) .map((aggregateProperties: any) => Object.fromEntries( @@ -803,15 +803,15 @@ class DatastoreRequest { Object.keys(aggregateProperties).map(key => [ key, entity.decodeValueProto(aggregateProperties[key]), - ]) - ) - ) + ]), + ), + ), ); callback(err, finalResults, info); } else { callback(err, [], info); } - } + }, ); } @@ -918,13 +918,13 @@ class DatastoreRequest { runQuery( query: Query, options: RunQueryOptions, - callback: RunQueryCallback + callback: RunQueryCallback, ): void; runQuery(query: Query, callback: RunQueryCallback): void; runQuery( query: Query, optionsOrCallback?: RunQueryOptions | RunQueryCallback, - cb?: RunQueryCallback + cb?: RunQueryCallback, ): void | Promise { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -942,7 +942,7 @@ class DatastoreRequest { .pipe( concat((results: Entity[]) => { callback(null, results, info); - }) + }), ); } catch (err: any) { callback(err); @@ -1010,7 +1010,7 @@ class DatastoreRequest { reqOpts, gaxOpts: options.gaxOptions, }, - onResultSet + onResultSet, ); }; @@ -1042,7 +1042,7 @@ class DatastoreRequest { try { entities = entity.formatArray( resp.batch.entityResults, - options.wrapNumbers + options.wrapNumbers, ); } catch (err) { stream.destroy(err); @@ -1095,7 +1095,7 @@ class DatastoreRequest { * @param {RunQueryStreamOptions} [options] The RunQueryStream options configuration */ private getRequestOptions( - options: RunQueryStreamOptions + options: RunQueryStreamOptions, ): SharedQueryOptions { const sharedQueryOpts = {} as SharedQueryOptions; if (isTransaction(this)) { @@ -1105,7 +1105,7 @@ class DatastoreRequest { } sharedQueryOpts.readOptions.newTransaction = getTransactionRequest( this, - {} + {}, ); sharedQueryOpts.readOptions.consistencyType = 'newTransaction'; } @@ -1138,7 +1138,7 @@ class DatastoreRequest { */ private getQueryOptions( query: Query, - options: RunQueryStreamOptions = {} + options: RunQueryStreamOptions = {}, ): SharedQueryOptions { const sharedQueryOpts = this.getRequestOptions(options); if (options.explainOptions) { @@ -1179,7 +1179,7 @@ class DatastoreRequest { merge(entities: Entities, callback: SaveCallback): void; merge( entities: Entities, - callback?: SaveCallback + callback?: SaveCallback, ): void | Promise { const transaction = this.datastore.transaction(); transaction.run(async (err: any) => { @@ -1203,7 +1203,7 @@ class DatastoreRequest { obj.method = 'upsert'; obj.data = Object.assign({}, data, obj.data); transaction.save(obj); - }) + }), ); const [response] = await transaction.commit(); @@ -1278,7 +1278,7 @@ class DatastoreRequest { if (!datastore.clients_.has(clientName)) { datastore.clients_.set( clientName, - new gapic.v1[clientName](datastore.options) + new gapic.v1[clientName](datastore.options), ); } const gaxClient = datastore.clients_.get(clientName); @@ -1374,7 +1374,7 @@ function isTransaction(request: DatastoreRequest): request is Transaction { */ function throwOnTransactionErrors( request: DatastoreRequest, - options: SharedQueryOptions + options: SharedQueryOptions, ) { const isTransaction = request.id ? true : false; if ( @@ -1399,7 +1399,7 @@ function throwOnTransactionErrors( */ export function getTransactionRequest( transaction: Transaction, - options: RunOptions + options: RunOptions, ): TransactionRequestOptions { // If transactionOptions are provide then they will be used. // Otherwise, options passed into this function are used and when absent @@ -1433,7 +1433,7 @@ export interface AllocateIdsCallback { ( a: Error | null, b: entity.Key[] | null, - c: google.datastore.v1.IAllocateIdsResponse + c: google.datastore.v1.IAllocateIdsResponse, ): void; } export interface AllocateIdsOptions { @@ -1462,7 +1462,7 @@ export interface RequestCallback { ( a?: Error | null, // eslint-disable-next-line @typescript-eslint/no-explicit-any - b?: any + b?: any, ): void; } export interface RunAggregationQueryCallback { @@ -1470,7 +1470,7 @@ export interface RunAggregationQueryCallback { a?: Error | null, // eslint-disable-next-line @typescript-eslint/no-explicit-any b?: any, - c?: RunQueryInfo + c?: RunQueryInfo, ): void; } export interface RequestConfig { diff --git a/src/transaction.ts b/src/transaction.ts index 7068e03cb..2525b0090 100644 --- a/src/transaction.ts +++ b/src/transaction.ts @@ -171,7 +171,7 @@ class Transaction extends DatastoreRequest { commit(gaxOptions: CallOptions, callback: CommitCallback): void; commit( gaxOptionsOrCallback?: CallOptions | CommitCallback, - cb?: CommitCallback + cb?: CommitCallback, ): void | Promise { const callback = typeof gaxOptionsOrCallback === 'function' @@ -191,7 +191,7 @@ class Transaction extends DatastoreRequest { () => { void this.#runCommit(gaxOptions, callback); }, - callback + callback, ); } @@ -266,12 +266,12 @@ class Transaction extends DatastoreRequest { createQuery(namespace: string, kind: string[]): Query; createQuery( namespaceOrKind?: string | string[], - kind?: string | string[] + kind?: string | string[], ): Query { return this.datastore.createQuery.call( this, namespaceOrKind as string, - kind as string[] + kind as string[], ); } @@ -344,18 +344,18 @@ class Transaction extends DatastoreRequest { */ get( keys: entity.Key | entity.Key[], - options?: CreateReadStreamOptions + options?: CreateReadStreamOptions, ): Promise; get(keys: entity.Key | entity.Key[], callback: GetCallback): void; get( keys: entity.Key | entity.Key[], options: CreateReadStreamOptions, - callback: GetCallback + callback: GetCallback, ): void; get( keys: entity.Key | entity.Key[], optionsOrCallback?: CreateReadStreamOptions | GetCallback, - cb?: GetCallback + cb?: GetCallback, ): void | Promise { const options = typeof optionsOrCallback === 'object' && optionsOrCallback @@ -432,7 +432,7 @@ class Transaction extends DatastoreRequest { rollback(gaxOptions: CallOptions, callback: RollbackCallback): void; rollback( gaxOptionsOrCallback?: CallOptions | RollbackCallback, - cb?: RollbackCallback + cb?: RollbackCallback, ): void | Promise { const gaxOptions = typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {}; @@ -457,7 +457,7 @@ class Transaction extends DatastoreRequest { this.skipCommit = true; this.state = TransactionState.EXPIRED; callback(err || null, resp); - } + }, ); } @@ -518,7 +518,7 @@ class Transaction extends DatastoreRequest { run(options: RunOptions, callback: RunCallback): void; run( optionsOrCallback?: RunOptions | RunCallback, - cb?: RunCallback + cb?: RunCallback, ): void | Promise { const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; @@ -530,7 +530,7 @@ class Transaction extends DatastoreRequest { this.#processBeginResults(runResults, callback); } else { process.emitWarning( - 'run has already been called and should not be called again.' + 'run has already been called and should not be called again.', ); callback(null, this, {transaction: this.id}); } @@ -548,7 +548,7 @@ class Transaction extends DatastoreRequest { */ #runCommit( gaxOptions: CallOptions, - callback: CommitCallback + callback: CommitCallback, ): void | Promise { if (this.skipCommit) { setImmediate(callback); @@ -600,7 +600,7 @@ class Transaction extends DatastoreRequest { acc.push(entityObject); } else { lastEntityObject.args = lastEntityObject.args.concat( - entityObject.args + entityObject.args, ); } @@ -616,7 +616,7 @@ class Transaction extends DatastoreRequest { const method = modifiedEntity.method; const args = modifiedEntity.args.reverse(); Datastore.prototype[method].call(this, args, () => {}); - } + }, ); // Take the `req` array built previously, and merge them into one request to @@ -626,7 +626,7 @@ class Transaction extends DatastoreRequest { .map((x: {mutations: google.datastore.v1.Mutation}) => x.mutations) .reduce( (a: {concat: (arg0: Entity) => void}, b: Entity) => a.concat(b), - [] + [], ), }; @@ -656,10 +656,10 @@ class Transaction extends DatastoreRequest { this.requestCallbacks_.forEach( (cb: (arg0: null, arg1: Entity) => void) => { cb(null, resp); - } + }, ); callback(null, resp); - } + }, ); } @@ -674,7 +674,7 @@ class Transaction extends DatastoreRequest { **/ #processBeginResults( runResults: BeginAsyncResponse, - callback: RunCallback + callback: RunCallback, ): void { const err = runResults.err; const resp = runResults.resp; @@ -696,7 +696,7 @@ class Transaction extends DatastoreRequest { * **/ async #beginTransactionAsync( - options: RunOptions + options: RunOptions, ): Promise { return new Promise((resolve: (value: BeginAsyncResponse) => void) => { const reqOpts = { @@ -715,7 +715,7 @@ class Transaction extends DatastoreRequest { err, resp, }); - } + }, ); }); } @@ -734,18 +734,18 @@ class Transaction extends DatastoreRequest { **/ runAggregationQuery( query: AggregateQuery, - options?: RunQueryOptions + options?: RunQueryOptions, ): Promise; runAggregationQuery( query: AggregateQuery, options: RunQueryOptions, - callback: RequestCallback + callback: RequestCallback, ): void; runAggregationQuery(query: AggregateQuery, callback: RequestCallback): void; runAggregationQuery( query: AggregateQuery, optionsOrCallback?: RunQueryOptions | RequestCallback, - cb?: RequestCallback + cb?: RequestCallback, ): void | Promise { const options = typeof optionsOrCallback === 'object' && optionsOrCallback @@ -774,13 +774,13 @@ class Transaction extends DatastoreRequest { runQuery( query: Query, options: RunQueryOptions, - callback: RunQueryCallback + callback: RunQueryCallback, ): void; runQuery(query: Query, callback: RunQueryCallback): void; runQuery( query: Query, optionsOrCallback?: RunQueryOptions | RunQueryCallback, - cb?: RunQueryCallback + cb?: RunQueryCallback, ): void | Promise { const options = typeof optionsOrCallback === 'object' && optionsOrCallback @@ -1008,7 +1008,7 @@ class Transaction extends DatastoreRequest { #withBeginTransaction( gaxOptions: CallOptions | undefined, fn: () => void, - callback: (...args: [Error | null, ...T] | [Error | null]) => void + callback: (...args: [Error | null, ...T] | [Error | null]) => void, ): void { (async () => { if (this.state === TransactionState.NOT_STARTED) { @@ -1081,7 +1081,7 @@ export interface RunCallback { ( error: Error | null, transaction: Transaction | null, - response?: google.datastore.v1.IBeginTransactionResponse + response?: google.datastore.v1.IBeginTransactionResponse, ): void; } export interface RollbackCallback { diff --git a/src/utils/entity/buildEntityProto.ts b/src/utils/entity/buildEntityProto.ts index a4bbe80bd..a334d8b47 100644 --- a/src/utils/entity/buildEntityProto.ts +++ b/src/utils/entity/buildEntityProto.ts @@ -48,7 +48,7 @@ export function buildEntityProto(entityObject: Entity) { return acc; }, - {} + {}, ); // This code adds excludeFromIndexes in the right places addExcludeFromIndexes(entityObject.excludeFromIndexes, entityProto); diff --git a/src/utils/entity/buildPropertyTransforms.ts b/src/utils/entity/buildPropertyTransforms.ts index 90c0b25ad..aae250fa6 100644 --- a/src/utils/entity/buildPropertyTransforms.ts +++ b/src/utils/entity/buildPropertyTransforms.ts @@ -34,7 +34,7 @@ export function buildPropertyTransforms(transforms: PropertyTransform[]) { property, [castedType]: entity.encodeValue( transform[castedType], - property + property, ) as IValue, }); } diff --git a/src/utils/entity/extendExcludeFromIndexes.ts b/src/utils/entity/extendExcludeFromIndexes.ts index bca29fa5b..3f3787f9e 100644 --- a/src/utils/entity/extendExcludeFromIndexes.ts +++ b/src/utils/entity/extendExcludeFromIndexes.ts @@ -37,15 +37,15 @@ export function extendExcludeFromIndexes(entityObject: Entity) { entityObject.excludeFromIndexes = entity.findLargeProperties_( data.value, data.name.toString(), - entityObject.excludeFromIndexes + entityObject.excludeFromIndexes, ); - } + }, ); } else { entityObject.excludeFromIndexes = entity.findLargeProperties_( entityObject.data, '', - entityObject.excludeFromIndexes + entityObject.excludeFromIndexes, ); } } diff --git a/src/v1/datastore_admin_client.ts b/src/v1/datastore_admin_client.ts index aaf7bfd82..1156724c0 100644 --- a/src/v1/datastore_admin_client.ts +++ b/src/v1/datastore_admin_client.ts @@ -157,7 +157,7 @@ export class DatastoreAdminClient { */ constructor( opts?: ClientOptions, - gaxInstance?: typeof gax | typeof gax.fallback + gaxInstance?: typeof gax | typeof gax.fallback, ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof DatastoreAdminClient; @@ -167,7 +167,7 @@ export class DatastoreAdminClient { opts?.universe_domain !== opts?.universeDomain ) { throw new Error( - 'Please set either universe_domain or universeDomain, but not both.' + 'Please set either universe_domain or universeDomain, but not both.', ); } const universeDomainEnvVar = @@ -253,7 +253,7 @@ export class DatastoreAdminClient { listIndexes: new this._gaxModule.PageDescriptor( 'pageToken', 'nextPageToken', - 'indexes' + 'indexes', ), }; @@ -290,50 +290,50 @@ export class DatastoreAdminClient { .lro(lroOptions) .operationsClient(opts); const exportEntitiesResponse = protoFilesRoot.lookup( - '.google.datastore.admin.v1.ExportEntitiesResponse' + '.google.datastore.admin.v1.ExportEntitiesResponse', ) as gax.protobuf.Type; const exportEntitiesMetadata = protoFilesRoot.lookup( - '.google.datastore.admin.v1.ExportEntitiesMetadata' + '.google.datastore.admin.v1.ExportEntitiesMetadata', ) as gax.protobuf.Type; const importEntitiesResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty' + '.google.protobuf.Empty', ) as gax.protobuf.Type; const importEntitiesMetadata = protoFilesRoot.lookup( - '.google.datastore.admin.v1.ImportEntitiesMetadata' + '.google.datastore.admin.v1.ImportEntitiesMetadata', ) as gax.protobuf.Type; const createIndexResponse = protoFilesRoot.lookup( - '.google.datastore.admin.v1.Index' + '.google.datastore.admin.v1.Index', ) as gax.protobuf.Type; const createIndexMetadata = protoFilesRoot.lookup( - '.google.datastore.admin.v1.IndexOperationMetadata' + '.google.datastore.admin.v1.IndexOperationMetadata', ) as gax.protobuf.Type; const deleteIndexResponse = protoFilesRoot.lookup( - '.google.datastore.admin.v1.Index' + '.google.datastore.admin.v1.Index', ) as gax.protobuf.Type; const deleteIndexMetadata = protoFilesRoot.lookup( - '.google.datastore.admin.v1.IndexOperationMetadata' + '.google.datastore.admin.v1.IndexOperationMetadata', ) as gax.protobuf.Type; this.descriptors.longrunning = { exportEntities: new this._gaxModule.LongrunningDescriptor( this.operationsClient, exportEntitiesResponse.decode.bind(exportEntitiesResponse), - exportEntitiesMetadata.decode.bind(exportEntitiesMetadata) + exportEntitiesMetadata.decode.bind(exportEntitiesMetadata), ), importEntities: new this._gaxModule.LongrunningDescriptor( this.operationsClient, importEntitiesResponse.decode.bind(importEntitiesResponse), - importEntitiesMetadata.decode.bind(importEntitiesMetadata) + importEntitiesMetadata.decode.bind(importEntitiesMetadata), ), createIndex: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createIndexResponse.decode.bind(createIndexResponse), - createIndexMetadata.decode.bind(createIndexMetadata) + createIndexMetadata.decode.bind(createIndexMetadata), ), deleteIndex: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteIndexResponse.decode.bind(deleteIndexResponse), - deleteIndexMetadata.decode.bind(deleteIndexMetadata) + deleteIndexMetadata.decode.bind(deleteIndexMetadata), ), }; @@ -342,7 +342,7 @@ export class DatastoreAdminClient { 'google.datastore.admin.v1.DatastoreAdmin', gapicConfig as gax.ClientConfig, opts.clientConfig || {}, - {'x-goog-api-client': clientHeader.join(' ')} + {'x-goog-api-client': clientHeader.join(' ')}, ); // Set up a dictionary of "inner API calls"; the core implementation @@ -376,12 +376,12 @@ export class DatastoreAdminClient { this.datastoreAdminStub = this._gaxGrpc.createStub( this._opts.fallback ? (this._protos as protobuf.Root).lookupService( - 'google.datastore.admin.v1.DatastoreAdmin' + 'google.datastore.admin.v1.DatastoreAdmin', ) : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.datastore.admin.v1.DatastoreAdmin, this._opts, - this._providedCustomServicePath + this._providedCustomServicePath, ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides @@ -406,7 +406,7 @@ export class DatastoreAdminClient { }, (err: Error | null | undefined) => () => { throw err; - } + }, ); const descriptor = @@ -417,7 +417,7 @@ export class DatastoreAdminClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -438,7 +438,7 @@ export class DatastoreAdminClient { ) { process.emitWarning( 'Static servicePath is deprecated, please use the instance method instead.', - 'DeprecationWarning' + 'DeprecationWarning', ); } return 'datastore.googleapis.com'; @@ -456,7 +456,7 @@ export class DatastoreAdminClient { ) { process.emitWarning( 'Static apiEndpoint is deprecated, please use the instance method instead.', - 'DeprecationWarning' + 'DeprecationWarning', ); } return 'datastore.googleapis.com'; @@ -501,7 +501,7 @@ export class DatastoreAdminClient { * @returns {Promise} A promise that resolves to string containing the project ID. */ getProjectId( - callback?: Callback + callback?: Callback, ): Promise | void { if (callback) { this.auth.getProjectId(callback); @@ -533,7 +533,7 @@ export class DatastoreAdminClient { */ getIndex( request?: protos.google.datastore.admin.v1.IGetIndexRequest, - options?: CallOptions + options?: CallOptions, ): Promise< [ protos.google.datastore.admin.v1.IIndex, @@ -548,7 +548,7 @@ export class DatastoreAdminClient { protos.google.datastore.admin.v1.IIndex, protos.google.datastore.admin.v1.IGetIndexRequest | null | undefined, {} | null | undefined - > + >, ): void; getIndex( request: protos.google.datastore.admin.v1.IGetIndexRequest, @@ -556,7 +556,7 @@ export class DatastoreAdminClient { protos.google.datastore.admin.v1.IIndex, protos.google.datastore.admin.v1.IGetIndexRequest | null | undefined, {} | null | undefined - > + >, ): void; getIndex( request?: protos.google.datastore.admin.v1.IGetIndexRequest, @@ -571,7 +571,7 @@ export class DatastoreAdminClient { protos.google.datastore.admin.v1.IIndex, protos.google.datastore.admin.v1.IGetIndexRequest | null | undefined, {} | null | undefined - > + >, ): Promise< [ protos.google.datastore.admin.v1.IIndex, @@ -621,7 +621,7 @@ export class DatastoreAdminClient { ]) => { this._log.info('getIndex response %j', response); return [response, options, rawResponse]; - } + }, ); } @@ -675,7 +675,7 @@ export class DatastoreAdminClient { */ exportEntities( request?: protos.google.datastore.admin.v1.IExportEntitiesRequest, - options?: CallOptions + options?: CallOptions, ): Promise< [ LROperation< @@ -696,7 +696,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - > + >, ): void; exportEntities( request: protos.google.datastore.admin.v1.IExportEntitiesRequest, @@ -707,7 +707,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - > + >, ): void; exportEntities( request?: protos.google.datastore.admin.v1.IExportEntitiesRequest, @@ -728,7 +728,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - > + >, ): Promise< [ LROperation< @@ -786,7 +786,7 @@ export class DatastoreAdminClient { ]) => { this._log.info('exportEntities response %j', rawResponse); return [response, rawResponse, _]; - } + }, ); } /** @@ -801,7 +801,7 @@ export class DatastoreAdminClient { * region_tag:datastore_v1_generated_DatastoreAdmin_ExportEntities_async */ async checkExportEntitiesProgress( - name: string + name: string, ): Promise< LROperation< protos.google.datastore.admin.v1.ExportEntitiesResponse, @@ -811,13 +811,13 @@ export class DatastoreAdminClient { this._log.info('exportEntities long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( - {name} + {name}, ); const [operation] = await this.operationsClient.getOperation(request); const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.exportEntities, - this._gaxModule.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings(), ); return decodeOperation as LROperation< protos.google.datastore.admin.v1.ExportEntitiesResponse, @@ -870,7 +870,7 @@ export class DatastoreAdminClient { */ importEntities( request?: protos.google.datastore.admin.v1.IImportEntitiesRequest, - options?: CallOptions + options?: CallOptions, ): Promise< [ LROperation< @@ -891,7 +891,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - > + >, ): void; importEntities( request: protos.google.datastore.admin.v1.IImportEntitiesRequest, @@ -902,7 +902,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - > + >, ): void; importEntities( request?: protos.google.datastore.admin.v1.IImportEntitiesRequest, @@ -923,7 +923,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - > + >, ): Promise< [ LROperation< @@ -981,7 +981,7 @@ export class DatastoreAdminClient { ]) => { this._log.info('importEntities response %j', rawResponse); return [response, rawResponse, _]; - } + }, ); } /** @@ -996,7 +996,7 @@ export class DatastoreAdminClient { * region_tag:datastore_v1_generated_DatastoreAdmin_ImportEntities_async */ async checkImportEntitiesProgress( - name: string + name: string, ): Promise< LROperation< protos.google.protobuf.Empty, @@ -1006,13 +1006,13 @@ export class DatastoreAdminClient { this._log.info('importEntities long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( - {name} + {name}, ); const [operation] = await this.operationsClient.getOperation(request); const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.importEntities, - this._gaxModule.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings(), ); return decodeOperation as LROperation< protos.google.protobuf.Empty, @@ -1055,7 +1055,7 @@ export class DatastoreAdminClient { */ createIndex( request?: protos.google.datastore.admin.v1.ICreateIndexRequest, - options?: CallOptions + options?: CallOptions, ): Promise< [ LROperation< @@ -1076,7 +1076,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - > + >, ): void; createIndex( request: protos.google.datastore.admin.v1.ICreateIndexRequest, @@ -1087,7 +1087,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - > + >, ): void; createIndex( request?: protos.google.datastore.admin.v1.ICreateIndexRequest, @@ -1108,7 +1108,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - > + >, ): Promise< [ LROperation< @@ -1166,7 +1166,7 @@ export class DatastoreAdminClient { ]) => { this._log.info('createIndex response %j', rawResponse); return [response, rawResponse, _]; - } + }, ); } /** @@ -1181,7 +1181,7 @@ export class DatastoreAdminClient { * region_tag:datastore_v1_generated_DatastoreAdmin_CreateIndex_async */ async checkCreateIndexProgress( - name: string + name: string, ): Promise< LROperation< protos.google.datastore.admin.v1.Index, @@ -1191,13 +1191,13 @@ export class DatastoreAdminClient { this._log.info('createIndex long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( - {name} + {name}, ); const [operation] = await this.operationsClient.getOperation(request); const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.createIndex, - this._gaxModule.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings(), ); return decodeOperation as LROperation< protos.google.datastore.admin.v1.Index, @@ -1236,7 +1236,7 @@ export class DatastoreAdminClient { */ deleteIndex( request?: protos.google.datastore.admin.v1.IDeleteIndexRequest, - options?: CallOptions + options?: CallOptions, ): Promise< [ LROperation< @@ -1257,7 +1257,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - > + >, ): void; deleteIndex( request: protos.google.datastore.admin.v1.IDeleteIndexRequest, @@ -1268,7 +1268,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - > + >, ): void; deleteIndex( request?: protos.google.datastore.admin.v1.IDeleteIndexRequest, @@ -1289,7 +1289,7 @@ export class DatastoreAdminClient { >, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined - > + >, ): Promise< [ LROperation< @@ -1348,7 +1348,7 @@ export class DatastoreAdminClient { ]) => { this._log.info('deleteIndex response %j', rawResponse); return [response, rawResponse, _]; - } + }, ); } /** @@ -1363,7 +1363,7 @@ export class DatastoreAdminClient { * region_tag:datastore_v1_generated_DatastoreAdmin_DeleteIndex_async */ async checkDeleteIndexProgress( - name: string + name: string, ): Promise< LROperation< protos.google.datastore.admin.v1.Index, @@ -1373,13 +1373,13 @@ export class DatastoreAdminClient { this._log.info('deleteIndex long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( - {name} + {name}, ); const [operation] = await this.operationsClient.getOperation(request); const decodeOperation = new this._gaxModule.Operation( operation, this.descriptors.longrunning.deleteIndex, - this._gaxModule.createDefaultBackoffSettings() + this._gaxModule.createDefaultBackoffSettings(), ); return decodeOperation as LROperation< protos.google.datastore.admin.v1.Index, @@ -1415,7 +1415,7 @@ export class DatastoreAdminClient { */ listIndexes( request?: protos.google.datastore.admin.v1.IListIndexesRequest, - options?: CallOptions + options?: CallOptions, ): Promise< [ protos.google.datastore.admin.v1.IIndex[], @@ -1430,7 +1430,7 @@ export class DatastoreAdminClient { protos.google.datastore.admin.v1.IListIndexesRequest, protos.google.datastore.admin.v1.IListIndexesResponse | null | undefined, protos.google.datastore.admin.v1.IIndex - > + >, ): void; listIndexes( request: protos.google.datastore.admin.v1.IListIndexesRequest, @@ -1438,7 +1438,7 @@ export class DatastoreAdminClient { protos.google.datastore.admin.v1.IListIndexesRequest, protos.google.datastore.admin.v1.IListIndexesResponse | null | undefined, protos.google.datastore.admin.v1.IIndex - > + >, ): void; listIndexes( request?: protos.google.datastore.admin.v1.IListIndexesRequest, @@ -1455,7 +1455,7 @@ export class DatastoreAdminClient { protos.google.datastore.admin.v1.IListIndexesRequest, protos.google.datastore.admin.v1.IListIndexesResponse | null | undefined, protos.google.datastore.admin.v1.IIndex - > + >, ): Promise< [ protos.google.datastore.admin.v1.IIndex[], @@ -1506,7 +1506,7 @@ export class DatastoreAdminClient { ]) => { this._log.info('listIndexes values %j', response); return [response, input, output]; - } + }, ); } @@ -1535,7 +1535,7 @@ export class DatastoreAdminClient { */ listIndexesStream( request?: protos.google.datastore.admin.v1.IListIndexesRequest, - options?: CallOptions + options?: CallOptions, ): Transform { request = request || {}; options = options || {}; @@ -1554,7 +1554,7 @@ export class DatastoreAdminClient { return this.descriptors.page.listIndexes.createStream( this.innerApiCalls.listIndexes as GaxCall, request, - callSettings + callSettings, ); } @@ -1586,7 +1586,7 @@ export class DatastoreAdminClient { */ listIndexesAsync( request?: protos.google.datastore.admin.v1.IListIndexesRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { request = request || {}; options = options || {}; @@ -1605,7 +1605,7 @@ export class DatastoreAdminClient { return this.descriptors.page.listIndexes.asyncIterate( this.innerApiCalls['listIndexes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } /** @@ -1651,7 +1651,7 @@ export class DatastoreAdminClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { @@ -1701,7 +1701,7 @@ export class DatastoreAdminClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1756,7 +1756,7 @@ export class DatastoreAdminClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { @@ -1813,7 +1813,7 @@ export class DatastoreAdminClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { diff --git a/src/v1/datastore_client.ts b/src/v1/datastore_client.ts index a12ca3782..1b1158315 100644 --- a/src/v1/datastore_client.ts +++ b/src/v1/datastore_client.ts @@ -114,7 +114,7 @@ export class DatastoreClient { */ constructor( opts?: ClientOptions, - gaxInstance?: typeof gax | typeof gax.fallback + gaxInstance?: typeof gax | typeof gax.fallback, ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof DatastoreClient; @@ -124,7 +124,7 @@ export class DatastoreClient { opts?.universe_domain !== opts?.universeDomain ) { throw new Error( - 'Please set either universe_domain or universeDomain, but not both.' + 'Please set either universe_domain or universeDomain, but not both.', ); } const universeDomainEnvVar = @@ -243,7 +243,7 @@ export class DatastoreClient { 'google.datastore.v1.Datastore', gapicConfig as gax.ClientConfig, opts.clientConfig || {}, - {'x-goog-api-client': clientHeader.join(' ')} + {'x-goog-api-client': clientHeader.join(' ')}, ); // Set up a dictionary of "inner API calls"; the core implementation @@ -277,12 +277,12 @@ export class DatastoreClient { this.datastoreStub = this._gaxGrpc.createStub( this._opts.fallback ? (this._protos as protobuf.Root).lookupService( - 'google.datastore.v1.Datastore' + 'google.datastore.v1.Datastore', ) : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.datastore.v1.Datastore, this._opts, - this._providedCustomServicePath + this._providedCustomServicePath, ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides @@ -309,7 +309,7 @@ export class DatastoreClient { }, (err: Error | null | undefined) => () => { throw err; - } + }, ); const descriptor = undefined; @@ -317,7 +317,7 @@ export class DatastoreClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -338,7 +338,7 @@ export class DatastoreClient { ) { process.emitWarning( 'Static servicePath is deprecated, please use the instance method instead.', - 'DeprecationWarning' + 'DeprecationWarning', ); } return 'datastore.googleapis.com'; @@ -356,7 +356,7 @@ export class DatastoreClient { ) { process.emitWarning( 'Static apiEndpoint is deprecated, please use the instance method instead.', - 'DeprecationWarning' + 'DeprecationWarning', ); } return 'datastore.googleapis.com'; @@ -401,7 +401,7 @@ export class DatastoreClient { * @returns {Promise} A promise that resolves to string containing the project ID. */ getProjectId( - callback?: Callback + callback?: Callback, ): Promise | void { if (callback) { this.auth.getProjectId(callback); @@ -447,7 +447,7 @@ export class DatastoreClient { */ lookup( request?: protos.google.datastore.v1.ILookupRequest, - options?: CallOptions + options?: CallOptions, ): Promise< [ protos.google.datastore.v1.ILookupResponse, @@ -462,7 +462,7 @@ export class DatastoreClient { protos.google.datastore.v1.ILookupResponse, protos.google.datastore.v1.ILookupRequest | null | undefined, {} | null | undefined - > + >, ): void; lookup( request: protos.google.datastore.v1.ILookupRequest, @@ -470,7 +470,7 @@ export class DatastoreClient { protos.google.datastore.v1.ILookupResponse, protos.google.datastore.v1.ILookupRequest | null | undefined, {} | null | undefined - > + >, ): void; lookup( request?: protos.google.datastore.v1.ILookupRequest, @@ -485,7 +485,7 @@ export class DatastoreClient { protos.google.datastore.v1.ILookupResponse, protos.google.datastore.v1.ILookupRequest | null | undefined, {} | null | undefined - > + >, ): Promise< [ protos.google.datastore.v1.ILookupResponse, @@ -553,7 +553,7 @@ export class DatastoreClient { ]) => { this._log.info('lookup response %j', response); return [response, options, rawResponse]; - } + }, ); } /** @@ -599,7 +599,7 @@ export class DatastoreClient { */ runQuery( request?: protos.google.datastore.v1.IRunQueryRequest, - options?: CallOptions + options?: CallOptions, ): Promise< [ protos.google.datastore.v1.IRunQueryResponse, @@ -614,7 +614,7 @@ export class DatastoreClient { protos.google.datastore.v1.IRunQueryResponse, protos.google.datastore.v1.IRunQueryRequest | null | undefined, {} | null | undefined - > + >, ): void; runQuery( request: protos.google.datastore.v1.IRunQueryRequest, @@ -622,7 +622,7 @@ export class DatastoreClient { protos.google.datastore.v1.IRunQueryResponse, protos.google.datastore.v1.IRunQueryRequest | null | undefined, {} | null | undefined - > + >, ): void; runQuery( request?: protos.google.datastore.v1.IRunQueryRequest, @@ -637,7 +637,7 @@ export class DatastoreClient { protos.google.datastore.v1.IRunQueryResponse, protos.google.datastore.v1.IRunQueryRequest | null | undefined, {} | null | undefined - > + >, ): Promise< [ protos.google.datastore.v1.IRunQueryResponse, @@ -705,7 +705,7 @@ export class DatastoreClient { ]) => { this._log.info('runQuery response %j', response); return [response, options, rawResponse]; - } + }, ); } /** @@ -745,7 +745,7 @@ export class DatastoreClient { */ runAggregationQuery( request?: protos.google.datastore.v1.IRunAggregationQueryRequest, - options?: CallOptions + options?: CallOptions, ): Promise< [ protos.google.datastore.v1.IRunAggregationQueryResponse, @@ -760,7 +760,7 @@ export class DatastoreClient { protos.google.datastore.v1.IRunAggregationQueryResponse, protos.google.datastore.v1.IRunAggregationQueryRequest | null | undefined, {} | null | undefined - > + >, ): void; runAggregationQuery( request: protos.google.datastore.v1.IRunAggregationQueryRequest, @@ -768,7 +768,7 @@ export class DatastoreClient { protos.google.datastore.v1.IRunAggregationQueryResponse, protos.google.datastore.v1.IRunAggregationQueryRequest | null | undefined, {} | null | undefined - > + >, ): void; runAggregationQuery( request?: protos.google.datastore.v1.IRunAggregationQueryRequest, @@ -785,7 +785,7 @@ export class DatastoreClient { protos.google.datastore.v1.IRunAggregationQueryResponse, protos.google.datastore.v1.IRunAggregationQueryRequest | null | undefined, {} | null | undefined - > + >, ): Promise< [ protos.google.datastore.v1.IRunAggregationQueryResponse, @@ -855,7 +855,7 @@ export class DatastoreClient { ]) => { this._log.info('runAggregationQuery response %j', response); return [response, options, rawResponse]; - } + }, ); } /** @@ -883,7 +883,7 @@ export class DatastoreClient { */ beginTransaction( request?: protos.google.datastore.v1.IBeginTransactionRequest, - options?: CallOptions + options?: CallOptions, ): Promise< [ protos.google.datastore.v1.IBeginTransactionResponse, @@ -898,7 +898,7 @@ export class DatastoreClient { protos.google.datastore.v1.IBeginTransactionResponse, protos.google.datastore.v1.IBeginTransactionRequest | null | undefined, {} | null | undefined - > + >, ): void; beginTransaction( request: protos.google.datastore.v1.IBeginTransactionRequest, @@ -906,7 +906,7 @@ export class DatastoreClient { protos.google.datastore.v1.IBeginTransactionResponse, protos.google.datastore.v1.IBeginTransactionRequest | null | undefined, {} | null | undefined - > + >, ): void; beginTransaction( request?: protos.google.datastore.v1.IBeginTransactionRequest, @@ -923,7 +923,7 @@ export class DatastoreClient { protos.google.datastore.v1.IBeginTransactionResponse, protos.google.datastore.v1.IBeginTransactionRequest | null | undefined, {} | null | undefined - > + >, ): Promise< [ protos.google.datastore.v1.IBeginTransactionResponse, @@ -993,7 +993,7 @@ export class DatastoreClient { ]) => { this._log.info('beginTransaction response %j', response); return [response, options, rawResponse]; - } + }, ); } /** @@ -1045,7 +1045,7 @@ export class DatastoreClient { */ commit( request?: protos.google.datastore.v1.ICommitRequest, - options?: CallOptions + options?: CallOptions, ): Promise< [ protos.google.datastore.v1.ICommitResponse, @@ -1060,7 +1060,7 @@ export class DatastoreClient { protos.google.datastore.v1.ICommitResponse, protos.google.datastore.v1.ICommitRequest | null | undefined, {} | null | undefined - > + >, ): void; commit( request: protos.google.datastore.v1.ICommitRequest, @@ -1068,7 +1068,7 @@ export class DatastoreClient { protos.google.datastore.v1.ICommitResponse, protos.google.datastore.v1.ICommitRequest | null | undefined, {} | null | undefined - > + >, ): void; commit( request?: protos.google.datastore.v1.ICommitRequest, @@ -1083,7 +1083,7 @@ export class DatastoreClient { protos.google.datastore.v1.ICommitResponse, protos.google.datastore.v1.ICommitRequest | null | undefined, {} | null | undefined - > + >, ): Promise< [ protos.google.datastore.v1.ICommitResponse, @@ -1151,7 +1151,7 @@ export class DatastoreClient { ]) => { this._log.info('commit response %j', response); return [response, options, rawResponse]; - } + }, ); } /** @@ -1180,7 +1180,7 @@ export class DatastoreClient { */ rollback( request?: protos.google.datastore.v1.IRollbackRequest, - options?: CallOptions + options?: CallOptions, ): Promise< [ protos.google.datastore.v1.IRollbackResponse, @@ -1195,7 +1195,7 @@ export class DatastoreClient { protos.google.datastore.v1.IRollbackResponse, protos.google.datastore.v1.IRollbackRequest | null | undefined, {} | null | undefined - > + >, ): void; rollback( request: protos.google.datastore.v1.IRollbackRequest, @@ -1203,7 +1203,7 @@ export class DatastoreClient { protos.google.datastore.v1.IRollbackResponse, protos.google.datastore.v1.IRollbackRequest | null | undefined, {} | null | undefined - > + >, ): void; rollback( request?: protos.google.datastore.v1.IRollbackRequest, @@ -1218,7 +1218,7 @@ export class DatastoreClient { protos.google.datastore.v1.IRollbackResponse, protos.google.datastore.v1.IRollbackRequest | null | undefined, {} | null | undefined - > + >, ): Promise< [ protos.google.datastore.v1.IRollbackResponse, @@ -1286,7 +1286,7 @@ export class DatastoreClient { ]) => { this._log.info('rollback response %j', response); return [response, options, rawResponse]; - } + }, ); } /** @@ -1316,7 +1316,7 @@ export class DatastoreClient { */ allocateIds( request?: protos.google.datastore.v1.IAllocateIdsRequest, - options?: CallOptions + options?: CallOptions, ): Promise< [ protos.google.datastore.v1.IAllocateIdsResponse, @@ -1331,7 +1331,7 @@ export class DatastoreClient { protos.google.datastore.v1.IAllocateIdsResponse, protos.google.datastore.v1.IAllocateIdsRequest | null | undefined, {} | null | undefined - > + >, ): void; allocateIds( request: protos.google.datastore.v1.IAllocateIdsRequest, @@ -1339,7 +1339,7 @@ export class DatastoreClient { protos.google.datastore.v1.IAllocateIdsResponse, protos.google.datastore.v1.IAllocateIdsRequest | null | undefined, {} | null | undefined - > + >, ): void; allocateIds( request?: protos.google.datastore.v1.IAllocateIdsRequest, @@ -1354,7 +1354,7 @@ export class DatastoreClient { protos.google.datastore.v1.IAllocateIdsResponse, protos.google.datastore.v1.IAllocateIdsRequest | null | undefined, {} | null | undefined - > + >, ): Promise< [ protos.google.datastore.v1.IAllocateIdsResponse, @@ -1422,7 +1422,7 @@ export class DatastoreClient { ]) => { this._log.info('allocateIds response %j', response); return [response, options, rawResponse]; - } + }, ); } /** @@ -1452,7 +1452,7 @@ export class DatastoreClient { */ reserveIds( request?: protos.google.datastore.v1.IReserveIdsRequest, - options?: CallOptions + options?: CallOptions, ): Promise< [ protos.google.datastore.v1.IReserveIdsResponse, @@ -1467,7 +1467,7 @@ export class DatastoreClient { protos.google.datastore.v1.IReserveIdsResponse, protos.google.datastore.v1.IReserveIdsRequest | null | undefined, {} | null | undefined - > + >, ): void; reserveIds( request: protos.google.datastore.v1.IReserveIdsRequest, @@ -1475,7 +1475,7 @@ export class DatastoreClient { protos.google.datastore.v1.IReserveIdsResponse, protos.google.datastore.v1.IReserveIdsRequest | null | undefined, {} | null | undefined - > + >, ): void; reserveIds( request?: protos.google.datastore.v1.IReserveIdsRequest, @@ -1490,7 +1490,7 @@ export class DatastoreClient { protos.google.datastore.v1.IReserveIdsResponse, protos.google.datastore.v1.IReserveIdsRequest | null | undefined, {} | null | undefined - > + >, ): Promise< [ protos.google.datastore.v1.IReserveIdsResponse, @@ -1558,7 +1558,7 @@ export class DatastoreClient { ]) => { this._log.info('reserveIds response %j', response); return [response, options, rawResponse]; - } + }, ); } @@ -1605,7 +1605,7 @@ export class DatastoreClient { protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined - > + >, ): Promise<[protos.google.longrunning.Operation]> { let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { @@ -1655,7 +1655,7 @@ export class DatastoreClient { */ listOperationsAsync( request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions + options?: gax.CallOptions, ): AsyncIterable { options = options || {}; options.otherArgs = options.otherArgs || {}; @@ -1710,7 +1710,7 @@ export class DatastoreClient { protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null - > + >, ): Promise { let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { @@ -1767,7 +1767,7 @@ export class DatastoreClient { protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined - > + >, ): Promise { let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { diff --git a/system-test/datastore.ts b/system-test/datastore.ts index 6b149674f..137b33f7b 100644 --- a/system-test/datastore.ts +++ b/system-test/datastore.ts @@ -58,7 +58,7 @@ async.each( }; const {indexes: DECLARED_INDEXES} = yaml.load( - readFileSync(path.join(__dirname, 'data', 'index.yaml'), 'utf8') + readFileSync(path.join(__dirname, 'data', 'index.yaml'), 'utf8'), ) as {indexes: google.datastore.admin.v1.IIndex[]}; // TODO/DX ensure indexes before testing, and maybe? cleanup indexes after @@ -472,10 +472,10 @@ async.each( key: secondaryDatastore.key(['Post', keyName]), data: postData, }; - } + }, ); await Promise.all( - secondaryData.map(async datum => secondaryDatastore.save(datum)) + secondaryData.map(async datum => secondaryDatastore.save(datum)), ); // Next, ensure that the default database has the right records const query = defaultDatastore @@ -486,7 +486,7 @@ async.each( assert.strictEqual(defaultDatastoreResults.length, 1); assert.strictEqual( defaultDatastoreResults[0].author, - defaultAuthor + defaultAuthor, ); // Next, ensure that the other database has the right records await Promise.all( @@ -497,12 +497,12 @@ async.each( const [results] = await secondaryDatastore.runQuery(query); assert.strictEqual(results.length, 1); assert.strictEqual(results[0].author, datum.data.author); - }) + }), ); // Cleanup await defaultDatastore.delete(defaultPostKey); await Promise.all( - secondaryData.map(datum => secondaryDatastore.delete(datum.key)) + secondaryData.map(datum => secondaryDatastore.delete(datum.key)), ); }); }); @@ -557,7 +557,7 @@ async.each( const data = { buf: Buffer.from( '010100000000000000000059400000000000006940', - 'hex' + 'hex', ), }; await datastore.save({key: postKey, data}); @@ -657,7 +657,7 @@ async.each( key: postKey, method: 'insert', data: post, - }) + }), ); const [entity] = await datastore.get(postKey); delete entity[datastore.KEY]; @@ -672,7 +672,7 @@ async.each( key: postKey, method: 'update', data: post, - }) + }), ); }); @@ -721,7 +721,7 @@ async.each( assert.strictEqual(numEntitiesEmitted, 2); datastore.delete([key1, key2], done); }); - } + }, ); }); @@ -1101,7 +1101,7 @@ async.each( and([ new PropertyFilter('family', '=', 'Stark'), new PropertyFilter('appearances', '>=', 20), - ]) + ]), ); const [entities] = await datastore.runQuery(q); assert.strictEqual(entities!.length, 6); @@ -1121,7 +1121,7 @@ async.each( or([ new PropertyFilter('family', '=', 'Stark'), new PropertyFilter('appearances', '>=', 20), - ]) + ]), ); const [entities] = await datastore.runQuery(q); assert.strictEqual(entities!.length, 8); @@ -1213,7 +1213,7 @@ async.each( }); } function checkAggregationQueryExecutionStats( - executionStats?: ExecutionStats + executionStats?: ExecutionStats, ) { // This function ensures the execution stats returned from the server are correct. // First fix stats values that will be different every time a query profiling @@ -1263,7 +1263,7 @@ async.each( assert(!info.explainMetrics); assert.deepStrictEqual( entities.sort(compare).map(entity => entity.name), - [...characters].sort(compare).map(entity => entity.name) + [...characters].sort(compare).map(entity => entity.name), ); await transaction.commit(); }); @@ -1285,7 +1285,7 @@ async.each( assert.deepStrictEqual(entities, []); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); await transaction.commit(); }); @@ -1307,7 +1307,7 @@ async.each( assert.deepStrictEqual(entities, []); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); await transaction.commit(); }); @@ -1326,13 +1326,13 @@ async.each( } assert.deepStrictEqual( entities.sort(compare).map(entity => entity.name), - [...characters].sort(compare).map(entity => entity.name) + [...characters].sort(compare).map(entity => entity.name), ); assert(info.explainMetrics); checkQueryExecutionStats(info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); await transaction.commit(); }); @@ -1360,7 +1360,7 @@ async.each( try { [entities, info] = await transaction.runAggregationQuery( aggregate, - {} + {}, ); } catch (e) { await transaction.rollback(); @@ -1378,7 +1378,7 @@ async.each( aggregate, { explainOptions: {}, - } + }, ); } catch (e) { await transaction.rollback(); @@ -1388,7 +1388,7 @@ async.each( assert.deepStrictEqual(entities, []); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan + expectedRunAggregationQueryPlan, ); await transaction.commit(); }); @@ -1402,7 +1402,7 @@ async.each( explainOptions: { analyze: false, }, - } + }, ); } catch (e) { await transaction.rollback(); @@ -1412,7 +1412,7 @@ async.each( assert.deepStrictEqual(entities, []); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan + expectedRunAggregationQueryPlan, ); await transaction.commit(); }); @@ -1424,7 +1424,7 @@ async.each( aggregate, { explainOptions: {analyze: true}, - } + }, ); } catch (e) { await transaction.rollback(); @@ -1433,11 +1433,11 @@ async.each( assert(info.explainMetrics); assert.deepStrictEqual(entities, expectedAggregationResults); checkAggregationQueryExecutionStats( - info.explainMetrics.executionStats + info.explainMetrics.executionStats, ); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan + expectedRunAggregationQueryPlan, ); await transaction.commit(); }); @@ -1450,7 +1450,7 @@ async.each( assert(!info.explainMetrics); assert.deepStrictEqual( entities.sort(compare).map(entity => entity.name), - [...characters].sort(compare).map(entity => entity.name) + [...characters].sort(compare).map(entity => entity.name), ); }); it('should run a query with explain options and no analyze option specified', async () => { @@ -1462,7 +1462,7 @@ async.each( assert(!info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); }); it('should run a query with explain options and analyze set to false', async () => { @@ -1474,7 +1474,7 @@ async.each( assert(!info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); }); it('should run a query with explain options and analyze set to true', async () => { @@ -1483,13 +1483,13 @@ async.each( }); assert.deepStrictEqual( entities.sort(compare).map(entity => entity.name), - [...characters].sort(compare).map(entity => entity.name) + [...characters].sort(compare).map(entity => entity.name), ); assert(info.explainMetrics); checkQueryExecutionStats(info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); }); }); @@ -1500,7 +1500,7 @@ async.each( assert(!info.explainMetrics); assert.deepStrictEqual( entities.sort(compare).map(entity => entity.name), - [...characters].sort(compare).map(entity => entity.name) + [...characters].sort(compare).map(entity => entity.name), ); }); it('should run a query with explain options and no value set for analyze', async () => { @@ -1510,7 +1510,7 @@ async.each( assert(!info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); }); it('should run a query with explain options and analyze set to false', async () => { @@ -1522,7 +1522,7 @@ async.each( assert(!info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); }); it('should run a query with explain options and analyze set to true', async () => { @@ -1531,14 +1531,14 @@ async.each( }); assert.deepStrictEqual( entities.sort(compare).map(entity => entity.name), - [...characters].sort(compare).map(entity => entity.name) + [...characters].sort(compare).map(entity => entity.name), ); assert(info.explainMetrics); checkQueryExecutionStats(info.explainMetrics.executionStats); assert(info.explainMetrics.planSummary); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); }); }); @@ -1562,7 +1562,7 @@ async.each( entities .sort(compare) .map((entity: Entity) => entity?.name), - [...characters].sort(compare).map(entity => entity.name) + [...characters].sort(compare).map(entity => entity.name), ); assert(!savedInfo.explainMetrics); resolve(); @@ -1590,7 +1590,7 @@ async.each( assert(!savedInfo.explainMetrics.executionStats); assert.deepStrictEqual( savedInfo.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); resolve(); }); @@ -1619,7 +1619,7 @@ async.each( assert(!savedInfo.explainMetrics.executionStats); assert.deepStrictEqual( savedInfo.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); resolve(); }); @@ -1645,15 +1645,15 @@ async.each( entities .sort(compare) .map((entity: Entity) => entity?.name), - [...characters].sort(compare).map(entity => entity.name) + [...characters].sort(compare).map(entity => entity.name), ); assert(savedInfo.explainMetrics); checkQueryExecutionStats( - savedInfo.explainMetrics.executionStats + savedInfo.explainMetrics.executionStats, ); assert.deepStrictEqual( savedInfo.explainMetrics.planSummary, - expectedRunQueryPlan + expectedRunQueryPlan, ); resolve(); }); @@ -1681,14 +1681,14 @@ async.each( aggregate, { explainOptions: {}, - } + }, ); assert.deepStrictEqual(entities, []); assert(info.explainMetrics); assert(!info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan + expectedRunAggregationQueryPlan, ); }); it('should run an aggregation query with explain options specified and analyze set to false', async () => { @@ -1696,14 +1696,14 @@ async.each( aggregate, { explainOptions: {analyze: false}, - } + }, ); assert.deepStrictEqual(entities, []); assert(info.explainMetrics); assert(!info.explainMetrics.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan + expectedRunAggregationQueryPlan, ); }); it('should run an aggregation query with explain options and analyze set to true', async () => { @@ -1711,16 +1711,16 @@ async.each( aggregate, { explainOptions: {analyze: true}, - } + }, ); assert.deepStrictEqual(entities, expectedAggregationResults); assert(info.explainMetrics); checkAggregationQueryExecutionStats( - info.explainMetrics.executionStats + info.explainMetrics.executionStats, ); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan + expectedRunAggregationQueryPlan, ); }); }); @@ -1748,7 +1748,7 @@ async.each( assert(!info.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan + expectedRunAggregationQueryPlan, ); }); it('should run an aggregation query with explain options and analyze set to false', async () => { @@ -1762,7 +1762,7 @@ async.each( assert(!info.executionStats); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan + expectedRunAggregationQueryPlan, ); }); it('should run an aggregation query with explain options specified and analyze set to true', async () => { @@ -1772,11 +1772,11 @@ async.each( assert.deepStrictEqual(entities, expectedAggregationResults); assert(info.explainMetrics); checkAggregationQueryExecutionStats( - info.explainMetrics.executionStats + info.explainMetrics.executionStats, ); assert.deepStrictEqual( info.explainMetrics.planSummary, - expectedRunAggregationQueryPlan + expectedRunAggregationQueryPlan, ); }); }); @@ -1871,7 +1871,7 @@ async.each( } catch (err: any) { assert.strictEqual( err.message, - '3 INVALID_ARGUMENT: Aggregations are not supported for the property: __key__' + '3 INVALID_ARGUMENT: Aggregations are not supported for the property: __key__', ); } }); @@ -1938,7 +1938,7 @@ async.each( const aggregate = datastore .createAggregationQuery(q) .addAggregation( - AggregateField.average('appearances').alias('avg1') + AggregateField.average('appearances').alias('avg1'), ); const [results] = await datastore.runAggregationQuery(aggregate); assert.deepStrictEqual(results, [{avg1: 28.166666666666668}]); @@ -1948,7 +1948,7 @@ async.each( const aggregate = datastore .createAggregationQuery(q) .addAggregation( - AggregateField.average('appearances').alias('avg1') + AggregateField.average('appearances').alias('avg1'), ); const [results] = await datastore.runAggregationQuery(aggregate); assert.deepStrictEqual(results, [{avg1: 23.375}]); @@ -2005,7 +2005,7 @@ async.each( } catch (err: any) { assert.strictEqual( err.message, - '3 INVALID_ARGUMENT: Aggregations are not supported for the property: __key__' + '3 INVALID_ARGUMENT: Aggregations are not supported for the property: __key__', ); } }); @@ -2171,7 +2171,7 @@ async.each( } catch (err: any) { assert.strictEqual( err.message, - '3 INVALID_ARGUMENT: The maximum number of aggregations allowed in an aggregation query is 5. Received: 6' + '3 INVALID_ARGUMENT: The maximum number of aggregations allowed in an aggregation query is 5. Received: 6', ); } }); @@ -2188,14 +2188,14 @@ async.each( .createQuery('Character') .filter('status', null) .filters.pop()?.val, - null + null, ); assert.strictEqual( datastore .createQuery('Character') .filter('status', '=', null) .filters.pop()?.val, - null + null, ); }); it('should filter by key', async () => { @@ -2606,7 +2606,7 @@ async.each( }); }); }); - } + }, ); }); describe('comparing times with and without transaction.run', async () => { @@ -2780,7 +2780,7 @@ async.each( await datastore.delete(key); }); async function doRunAggregationQueryPutCommit( - transaction: Transaction + transaction: Transaction, ) { const query = transaction.createQuery('Company'); const aggregateQuery = transaction @@ -2814,7 +2814,7 @@ async.each( await datastore.delete(key); }); async function doPutRunAggregationQueryCommit( - transaction: Transaction + transaction: Transaction, ) { transaction.save({key, data: obj}); const query = transaction.createQuery('Company'); @@ -2991,7 +2991,7 @@ async.each( const [results] = await datastore.runQuery(query); assert.deepStrictEqual( results.map(result => result.rating), - [100, 100] + [100, 100], ); }); it('should aggregate query within a count transaction', async () => { @@ -3140,7 +3140,7 @@ async.each( const [indexes] = await datastore.getIndexes(); assert.ok( indexes.length >= DECLARED_INDEXES.length, - 'has at least the number of indexes per system-test/data/index.yaml' + 'has at least the number of indexes per system-test/data/index.yaml', ); // Comparing index.yaml and the actual defined index in Datastore requires @@ -3151,11 +3151,11 @@ async.each( assert.ok(firstIndex, 'first index is readable'); assert.ok( firstIndex.metadata!.properties, - 'has properties collection' + 'has properties collection', ); assert.ok( firstIndex.metadata!.properties.length, - 'with properties inside' + 'with properties inside', ); assert.ok(firstIndex.metadata!.ancestor, 'has the ancestor property'); }); @@ -3184,7 +3184,7 @@ async.each( assert.deepStrictEqual( metadata, firstIndex.metadata, - 'asked index is the same as received index' + 'asked index is the same as received index', ); }); }); @@ -3204,7 +3204,7 @@ async.each( const ms = Math.pow(2, retries) * 500 + Math.random() * 1000; return new Promise(done => { console.info( - `retrying "${test.test?.title}" after attempt ${currentAttempt} in ${ms}ms` + `retrying "${test.test?.title}" after attempt ${currentAttempt} in ${ms}ms`, ); setTimeout(done, ms); }); @@ -3234,7 +3234,7 @@ async.each( // Throw an error on every retry except the last one if (currentAttempt <= numberOfRetries) { throw Error( - 'This is not the last retry so throw an error to force the test to run again' + 'This is not the last retry so throw an error to force the test to run again', ); } // Check that the attempt number and the number of times console.info is called is correct. @@ -3268,7 +3268,7 @@ async.each( ( importOperation.metadata as google.datastore.admin.v1.IImportEntitiesMetadata ).inputUrl, - `gs://${exportedFile.bucket.name}/${exportedFile.name}` + `gs://${exportedFile.bucket.name}/${exportedFile.name}`, ); await importOperation.cancel(); @@ -3521,12 +3521,12 @@ async.each( .partitionId['namespaceId']; assert.deepStrictEqual( requestSpy.args[0][0], - testParameters.gapicRequest + testParameters.gapicRequest, ); }); - } + }, ); }); }); - } + }, ); diff --git a/system-test/install.ts b/system-test/install.ts index d927b3436..5257a7ba1 100644 --- a/system-test/install.ts +++ b/system-test/install.ts @@ -28,7 +28,7 @@ describe('📦 pack-n-play test', () => { sample: { description: 'TypeScript user can use the type definitions', ts: readFileSync( - './system-test/fixtures/sample/src/index.ts' + './system-test/fixtures/sample/src/index.ts', ).toString(), }, }; @@ -42,7 +42,7 @@ describe('📦 pack-n-play test', () => { sample: { description: 'JavaScript user can use the library', ts: readFileSync( - './system-test/fixtures/sample/src/index.js' + './system-test/fixtures/sample/src/index.js', ).toString(), }, }; diff --git a/test/entity.ts b/test/entity.ts index 88b4c1d10..2d4060573 100644 --- a/test/entity.ts +++ b/test/entity.ts @@ -40,7 +40,7 @@ export function outOfBoundsError(opts: { '{\n' + ' integerTypeCastFunction: provide \n' + ' properties: optionally specify property name(s) to be custom casted\n' + - '}\n' + '}\n', ); } @@ -127,7 +127,7 @@ describe('entity', () => { it('should throw if integerTypeCastOptions is provided but integerTypeCastFunction is not', () => { assert.throws( () => new testEntity.Int(valueProto, {}).valueOf(), - /integerTypeCastFunction is not a function or was not provided\./ + /integerTypeCastFunction is not a function or was not provided\./, ); }); @@ -163,7 +163,7 @@ describe('entity', () => { () => { new testEntity.Int(largeIntegerValue).valueOf(); }, - outOfBoundsError({integerValue: largeIntegerValue}) + outOfBoundsError({integerValue: largeIntegerValue}), ); // should throw when string is passed @@ -171,7 +171,7 @@ describe('entity', () => { () => { new testEntity.Int(smallIntegerValue.toString()).valueOf(); }, - outOfBoundsError({integerValue: smallIntegerValue}) + outOfBoundsError({integerValue: smallIntegerValue}), ); }); @@ -187,7 +187,7 @@ describe('entity', () => { () => { new testEntity.Int(valueProto); }, - new RegExp(`Integer value ${largeIntegerValue} is out of bounds.`) + new RegExp(`Integer value ${largeIntegerValue} is out of bounds.`), ); }); }); @@ -199,7 +199,7 @@ describe('entity', () => { new testEntity.Int(valueProto, { integerTypeCastFunction: {}, }).valueOf(), - /integerTypeCastFunction is not a function or was not provided\./ + /integerTypeCastFunction is not a function or was not provided\./, ); }); @@ -459,7 +459,7 @@ describe('entity', () => { assert.deepStrictEqual( testEntity.decodeValueProto(valueProto), - expectedValue + expectedValue, ); }); @@ -467,7 +467,7 @@ describe('entity', () => { const decodeValueProto = testEntity.decodeValueProto; testEntity.decodeValueProto = ( valueProto: {}, - wrapNumbers?: boolean | {} + wrapNumbers?: boolean | {}, ) => { assert.strictEqual(wrapNumbers, undefined); @@ -486,7 +486,7 @@ describe('entity', () => { let run = false; testEntity.decodeValueProto = ( valueProto: {}, - wrapNumbers?: boolean | {} + wrapNumbers?: boolean | {}, ) => { if (!run) { run = true; @@ -500,14 +500,14 @@ describe('entity', () => { assert.deepStrictEqual( testEntity.decodeValueProto(valueProto, wrapNumbersBoolean), - expectedValue + expectedValue, ); // reset the run flag. run = false; assert.deepStrictEqual( testEntity.decodeValueProto(valueProto, wrapNumbersObject), - expectedValue + expectedValue, ); }); }); @@ -528,7 +528,7 @@ describe('entity', () => { assert.strictEqual( testEntity.decodeValueProto(valueProto), - expectedValue + expectedValue, ); }); @@ -542,7 +542,7 @@ describe('entity', () => { testEntity.entityFromEntityProto = ( entityProto: {}, - wrapNumbers?: boolean | {} + wrapNumbers?: boolean | {}, ) => { assert.strictEqual(wrapNumbers, undefined); assert.strictEqual(entityProto, expectedValue); @@ -551,7 +551,7 @@ describe('entity', () => { assert.strictEqual( testEntity.decodeValueProto(valueProto), - expectedValue + expectedValue, ); }); @@ -567,7 +567,7 @@ describe('entity', () => { testEntity.entityFromEntityProto = ( entityProto: {}, - wrapNumbers?: boolean | {} + wrapNumbers?: boolean | {}, ) => { // verify that `wrapNumbers`param is passed (boolean or object) assert.ok(wrapNumbers); @@ -577,12 +577,12 @@ describe('entity', () => { assert.strictEqual( testEntity.decodeValueProto(valueProto, wrapNumbersBoolean), - expectedValue + expectedValue, ); assert.strictEqual( testEntity.decodeValueProto(valueProto, wrapNumbersObject), - expectedValue + expectedValue, ); }); }); @@ -597,7 +597,7 @@ describe('entity', () => { it('should not wrap ints by default', () => { assert.strictEqual( typeof testEntity.decodeValueProto(valueProto), - 'number' + 'number', ); }); @@ -653,7 +653,7 @@ describe('entity', () => { assert.strictEqual( testEntity.decodeValueProto(valueProto, wrapNumbers), - takeFirstTen(Number.MAX_SAFE_INTEGER) + takeFirstTen(Number.MAX_SAFE_INTEGER), ); assert.strictEqual(takeFirstTen.called, true); }); @@ -671,9 +671,9 @@ describe('entity', () => { .valueOf(), (err: Error) => { return new RegExp( - `integerTypeCastFunction threw an error:\n\n - ${errorMessage}` + `integerTypeCastFunction threw an error:\n\n - ${errorMessage}`, ).test(err.message); - } + }, ); }); }); @@ -689,7 +689,7 @@ describe('entity', () => { assert.deepStrictEqual( testEntity.decodeValueProto(valueProto), - expectedValue + expectedValue, ); }); @@ -715,7 +715,7 @@ describe('entity', () => { assert.strictEqual( testEntity.decodeValueProto(valueProto), - expectedValue + expectedValue, ); }); @@ -734,7 +734,7 @@ describe('entity', () => { assert.strictEqual( testEntity.decodeValueProto(valueProto), - expectedValue + expectedValue, ); }); @@ -756,7 +756,7 @@ describe('entity', () => { assert.deepStrictEqual( testEntity.decodeValueProto(valueProto), - expectedValue + expectedValue, ); }); @@ -770,7 +770,7 @@ describe('entity', () => { assert.strictEqual( testEntity.decodeValueProto(valueProto), - expectedValue + expectedValue, ); }); }); @@ -1035,7 +1035,7 @@ describe('entity', () => { assert.deepStrictEqual( testEntity.entityFromEntityProto(entityProto), - expectedEntity + expectedEntity, ); }); @@ -1106,14 +1106,14 @@ describe('entity', () => { assert.deepStrictEqual( testEntity.entityToEntityProto(entityObject), - expectedEntityProto + expectedEntityProto, ); }); it('should respect excludeFromIndexes', () => { assert.deepStrictEqual( testEntity.entityToEntityProto(entityObject), - expectedEntityProto + expectedEntityProto, ); }); @@ -1155,7 +1155,7 @@ describe('entity', () => { assert.deepStrictEqual( testEntity.entityToEntityProto(entityObject), - expectedEntityProto + expectedEntityProto, ); }); }); @@ -1355,7 +1355,7 @@ describe('entity', () => { assert.strictEqual((e as Error).name, 'InvalidKey'); assert.strictEqual( (e as Error).message, - 'Ancestor keys require an id or name.' + 'Ancestor keys require an id or name.', ); done(); } @@ -1439,7 +1439,7 @@ describe('entity', () => { assert.strictEqual((e as Error).name, 'InvalidKey'); assert.strictEqual( (e as Error).message, - 'A key should contain at least a kind.' + 'A key should contain at least a kind.', ); done(); } @@ -1457,7 +1457,7 @@ describe('entity', () => { assert.strictEqual((e as Error).name, 'InvalidKey'); assert.strictEqual( (e as Error).message, - 'Ancestor keys require an id or name.' + 'Ancestor keys require an id or name.', ); done(); } @@ -1618,12 +1618,12 @@ describe('entity', () => { .filter( new PropertyFilter('__key__', 'IN', [ new entity.Key({path: ['Kind1', 'key1']}), - ]) + ]), ); assert.deepStrictEqual( testEntity.queryToQueryProto(query), - keyWithInQuery + keyWithInQuery, ); }); @@ -1661,7 +1661,7 @@ describe('entity', () => { and([ new PropertyFilter('name', '=', 'John'), new PropertyFilter('__key__', 'HAS_ANCESTOR', ancestorKey), - ]) + ]), ) .start('start') .end('end') @@ -1705,7 +1705,7 @@ describe('entity', () => { assert.strictEqual( urlSafeKey.convertToBase64_(buffer), - 'SGVsbG8gV29ybGQ' + 'SGVsbG8gV29ybGQ', ); }); }); @@ -1714,7 +1714,7 @@ describe('entity', () => { it('should convert encoded url safe key to buffer', () => { assert.deepStrictEqual( urlSafeKey.convertToBuffer_('aGVsbG8gd29ybGQgZnJvbSBkYXRhc3RvcmU'), - Buffer.from('hello world from datastore') + Buffer.from('hello world from datastore'), ); }); }); @@ -1732,7 +1732,7 @@ describe('entity', () => { 'ahFzfmdyYXNzLWNsdW1wLTQ3OXIVCxIEVGFzayILc2FtcGxldGFzazEMogECTlM'; assert.strictEqual( urlSafeKey.legacyEncode(PROJECT_ID, key, LOCATION_PREFIX), - encodedKey + encodedKey, ); }); @@ -1747,7 +1747,7 @@ describe('entity', () => { 'ag9ncmFzcy1jbHVtcC00NzlyFQsSBFRhc2siC3NhbXBsZXRhc2sxDA'; assert.strictEqual( urlSafeKey.legacyEncode(PROJECT_ID, key), - encodedKey + encodedKey, ); }); @@ -1761,7 +1761,7 @@ describe('entity', () => { const encodedKey = 'ag9ncmFzcy1jbHVtcC00NzlyEQsSBFRhc2sYgICA3NWunAoM'; assert.strictEqual( urlSafeKey.legacyEncode(PROJECT_ID, key), - encodedKey + encodedKey, ); }); @@ -1775,7 +1775,7 @@ describe('entity', () => { const encodedKey = 'ag9ncmFzcy1jbHVtcC00NzlyEQsSBFRhc2sYgICA3NWunAoM'; assert.strictEqual( urlSafeKey.legacyEncode(PROJECT_ID, key), - encodedKey + encodedKey, ); }); @@ -1788,7 +1788,7 @@ describe('entity', () => { 'ahFzfmdyYXNzLWNsdW1wLTQ3OXIqCxIEVGFzayILc2FtcGxldGFzazEMCxIEVGFzayILc2FtcGxldGFzazIM'; assert.strictEqual( urlSafeKey.legacyEncode(PROJECT_ID, key, LOCATION_PREFIX), - encodedKey + encodedKey, ); }); }); diff --git a/test/entity/buildEntityProto.ts b/test/entity/buildEntityProto.ts index 3f646bc0f..2d2c868df 100644 --- a/test/entity/buildEntityProto.ts +++ b/test/entity/buildEntityProto.ts @@ -81,9 +81,9 @@ describe('buildEntityProto', () => { } assert.deepStrictEqual( buildEntityProto(test.entityObject), - test.expectedProto + test.expectedProto, ); }); - } + }, ); }); diff --git a/test/entity/excludeIndexesAndBuildProto.ts b/test/entity/excludeIndexesAndBuildProto.ts index 9526c1ee9..56ce08231 100644 --- a/test/entity/excludeIndexesAndBuildProto.ts +++ b/test/entity/excludeIndexesAndBuildProto.ts @@ -44,13 +44,13 @@ describe('excludeIndexesAndBuildProto', () => { if (entityProtoSubset.stringValue === longString) { if (entityProtoSubset.excludeFromIndexes !== true) { assert.fail( - `The entity proto at ${path} should excludeFromIndexes` + `The entity proto at ${path} should excludeFromIndexes`, ); } } else { if (entityProtoSubset.excludeFromIndexes === true) { assert.fail( - `The entity proto at ${path} should not excludeFromIndexes` + `The entity proto at ${path} should not excludeFromIndexes`, ); } } @@ -82,7 +82,7 @@ describe('excludeIndexesAndBuildProto', () => { }, }, }, - '' + '', ); }); it('should not throw an assertion error for long strings in the top level', () => { @@ -99,7 +99,7 @@ describe('excludeIndexesAndBuildProto', () => { }, }, }, - '' + '', ); }); it('should throw an assertion error for a missing excludeFromIndexes: true', () => { @@ -116,13 +116,13 @@ describe('excludeIndexesAndBuildProto', () => { }, }, }, - '' + '', ); assert.fail('checkEntityProto should have failed'); } catch (e) { assert.strictEqual( (e as ServiceError).message, - 'The entity proto at .properties.name should excludeFromIndexes' + 'The entity proto at .properties.name should excludeFromIndexes', ); } }); @@ -141,13 +141,13 @@ describe('excludeIndexesAndBuildProto', () => { }, }, }, - '' + '', ); assert.fail('checkEntityProto should have failed'); } catch (e) { assert.strictEqual( (e as ServiceError).message, - 'The entity proto at .properties.name should not excludeFromIndexes' + 'The entity proto at .properties.name should not excludeFromIndexes', ); } }); @@ -181,13 +181,13 @@ describe('excludeIndexesAndBuildProto', () => { }, }, }, - '' + '', ); assert.fail('checkEntityProto should have failed'); } catch (e) { assert.strictEqual( (e as ServiceError).message, - 'The entity proto at .properties.name.arrayValue.values.[1].entityValue.properties.metadata should not excludeFromIndexes' + 'The entity proto at .properties.name.arrayValue.values.[1].entityValue.properties.metadata should not excludeFromIndexes', ); } }); @@ -262,7 +262,7 @@ describe('excludeIndexesAndBuildProto', () => { */ function getGeneratedTestComponents( baseElement: {}, - baseTestName: string + baseTestName: string, ): GeneratedTestCase[] { const maxDepth = 5; const generatedTestCasesByDepth: GeneratedTestCase[][] = [ @@ -315,7 +315,7 @@ describe('excludeIndexesAndBuildProto', () => { value: longString, otherProperty: longString, }, - 'with long string properties and path ' + 'with long string properties and path ', ), getGeneratedTestComponents( { @@ -323,7 +323,7 @@ describe('excludeIndexesAndBuildProto', () => { value: 'short value', otherProperty: longString, }, - 'with long name property and path ' + 'with long name property and path ', ), ] .flat() @@ -375,6 +375,6 @@ describe('excludeIndexesAndBuildProto', () => { const entityProto = buildEntityProto(entityObject); checkEntityProto(entityProto, ''); }); - } + }, ); }); diff --git a/test/entity/extendExcludeFromIndexes.ts b/test/entity/extendExcludeFromIndexes.ts index 77c7f3d80..936dbaa48 100644 --- a/test/entity/extendExcludeFromIndexes.ts +++ b/test/entity/extendExcludeFromIndexes.ts @@ -165,9 +165,9 @@ describe('extendExcludeFromIndexes', () => { extendExcludeFromIndexes(entityObject); assert.deepStrictEqual( entityObject.excludeFromIndexes, - test.expectedOutput + test.expectedOutput, ); }); - } + }, ); }); diff --git a/test/entity/findLargeProperties_.ts b/test/entity/findLargeProperties_.ts index ed99df75e..028955baf 100644 --- a/test/entity/findLargeProperties_.ts +++ b/test/entity/findLargeProperties_.ts @@ -160,6 +160,6 @@ describe('findLargeProperties_', () => { const output = findLargeProperties_(test.entities, '', []); assert.deepStrictEqual(output, test.expectedOutput); }); - } + }, ); }); diff --git a/test/gapic-mocks/client-initialization-testing.ts b/test/gapic-mocks/client-initialization-testing.ts index d0be6c437..de5230ae3 100644 --- a/test/gapic-mocks/client-initialization-testing.ts +++ b/test/gapic-mocks/client-initialization-testing.ts @@ -59,7 +59,7 @@ class FakeDatastoreClient extends DatastoreClient { protos.google.datastore.v1.ILookupResponse, protos.google.datastore.v1.ILookupRequest | null | undefined, {} | null | undefined - > + >, ): Promise< [ protos.google.datastore.v1.ILookupResponse, @@ -97,7 +97,7 @@ describe('Client Initialization Testing', () => { function compareRequest( request: DatastoreRequest, expectedFallback: Fallback, - done: mocha.Done + done: mocha.Done, ) { try { const client = request.datastore.clients_.get(clientName); @@ -138,7 +138,7 @@ describe('Client Initialization Testing', () => { // The CI environment can't fetch project id so the function that // fetches the project id needs to be mocked out. request.datastore.auth.getProjectId = ( - callback: (err: any, projectId: string) => void + callback: (err: any, projectId: string) => void, ) => { callback(null, 'some-project-id'); }; @@ -149,7 +149,7 @@ describe('Client Initialization Testing', () => { {client: clientName, method: 'lookup'}, () => { compareRequest(request, testParameters.expectedFallback, done); - } + }, ); }); it('should set the rest parameter in the data client when calling request_', done => { @@ -159,7 +159,7 @@ describe('Client Initialization Testing', () => { }); }); }); - } + }, ); }); }); diff --git a/test/gapic-mocks/commit.ts b/test/gapic-mocks/commit.ts index 796776230..3ef17096b 100644 --- a/test/gapic-mocks/commit.ts +++ b/test/gapic-mocks/commit.ts @@ -531,7 +531,7 @@ describe('Commit', () => { * strings replaced. */ function replaceLongStrings( - input?: google.datastore.v1.IMutation[] | null + input?: google.datastore.v1.IMutation[] | null, ) { const stringifiedInput = JSON.stringify(input); const replacedInput = stringifiedInput @@ -553,8 +553,8 @@ describe('Commit', () => { options: CallOptions, callback: ( err?: unknown, - res?: protos.google.datastore.v1.ICommitResponse - ) => void + res?: protos.google.datastore.v1.ICommitResponse, + ) => void, ) => { try { const actual = replaceLongStrings(request.mutations); @@ -578,7 +578,7 @@ describe('Commit', () => { excludeLargeProperties: test.excludeLargeProperties, }); }); - } + }, ); }); }); diff --git a/test/gapic-mocks/error-mocks.ts b/test/gapic-mocks/error-mocks.ts index 226859e6c..507c795ee 100644 --- a/test/gapic-mocks/error-mocks.ts +++ b/test/gapic-mocks/error-mocks.ts @@ -56,7 +56,7 @@ export function getCallbackExpectingError(done: mocha.Done, message: string) { export function errorOnGapicCall( datastore: Datastore, clientName: string, - done: mocha.Done + done: mocha.Done, ) { const dataClient = datastore.clients_.get(clientName); if (dataClient) { diff --git a/test/gapic-mocks/handwritten-errors.ts b/test/gapic-mocks/handwritten-errors.ts index 59c743ee5..bba7952e2 100644 --- a/test/gapic-mocks/handwritten-errors.ts +++ b/test/gapic-mocks/handwritten-errors.ts @@ -60,7 +60,7 @@ describe('HandwrittenLayerErrors', () => { transaction.runQuery( query, testParameters.options, - getCallbackExpectingError(done, testParameters.expectedError) + getCallbackExpectingError(done, testParameters.expectedError), ); }); it('should error when runQueryStream is used', done => { @@ -85,7 +85,7 @@ describe('HandwrittenLayerErrors', () => { transaction.runAggregationQuery( aggregate, testParameters.options, - getCallbackExpectingError(done, testParameters.expectedError) + getCallbackExpectingError(done, testParameters.expectedError), ); }); it('should error when get is used', done => { @@ -95,7 +95,7 @@ describe('HandwrittenLayerErrors', () => { transaction.get( keys, testParameters.options, - getCallbackExpectingError(done, testParameters.expectedError) + getCallbackExpectingError(done, testParameters.expectedError), ); }); it('should error when createReadStream is used', done => { @@ -111,7 +111,7 @@ describe('HandwrittenLayerErrors', () => { } }); }); - } + }, ); }); }); diff --git a/test/gapic-mocks/runQuery.ts b/test/gapic-mocks/runQuery.ts index d54d8649f..1710d2a63 100644 --- a/test/gapic-mocks/runQuery.ts +++ b/test/gapic-mocks/runQuery.ts @@ -25,7 +25,7 @@ describe('Run Query', () => { // This function is used for doing assertion checks. // The idea is to check that the right request gets passed to the commit function in the Gapic layer. function setRunQueryComparison( - compareFn: (request: protos.google.datastore.v1.IRunQueryRequest) => void + compareFn: (request: protos.google.datastore.v1.IRunQueryRequest) => void, ) { const dataClient = datastore.clients_.get(clientName); if (dataClient) { @@ -34,8 +34,8 @@ describe('Run Query', () => { options: any, callback: ( err?: unknown, - res?: protos.google.datastore.v1.IRunQueryResponse - ) => void + res?: protos.google.datastore.v1.IRunQueryResponse, + ) => void, ) => { try { compareFn(request); @@ -72,7 +72,7 @@ describe('Run Query', () => { }, projectId: 'project-id', }); - } + }, ); const transaction = datastore.transaction(); const query = datastore.createQuery('Task'); diff --git a/test/gapic_datastore_admin_v1.ts b/test/gapic_datastore_admin_v1.ts index c168bcbc9..33169355d 100644 --- a/test/gapic_datastore_admin_v1.ts +++ b/test/gapic_datastore_admin_v1.ts @@ -30,7 +30,7 @@ import {protobuf, LROperation, operationsProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects const root = protobuf.Root.fromJSON( - require('../protos/protos.json') + require('../protos/protos.json'), ).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -47,7 +47,7 @@ function generateSampleMessage(instance: T) { instance.constructor as typeof protobuf.Message ).toObject(instance as protobuf.Message, {defaults: true}); return (instance.constructor as typeof protobuf.Message).fromObject( - filledObject + filledObject, ) as T; } @@ -59,7 +59,7 @@ function stubSimpleCall(response?: ResponseType, error?: Error) { function stubSimpleCallWithCallback( response?: ResponseType, - error?: Error + error?: Error, ) { return error ? sinon.stub().callsArgWith(2, error) @@ -69,7 +69,7 @@ function stubSimpleCallWithCallback( function stubLongRunningCall( response?: ResponseType, callError?: Error, - lroError?: Error + lroError?: Error, ) { const innerStub = lroError ? sinon.stub().rejects(lroError) @@ -85,7 +85,7 @@ function stubLongRunningCall( function stubLongRunningCallWithCallback( response?: ResponseType, callError?: Error, - lroError?: Error + lroError?: Error, ) { const innerStub = lroError ? sinon.stub().rejects(lroError) @@ -100,7 +100,7 @@ function stubLongRunningCallWithCallback( function stubPageStreamingCall( responses?: ResponseType[], - error?: Error + error?: Error, ) { const pagingStub = sinon.stub(); if (responses) { @@ -138,7 +138,7 @@ function stubPageStreamingCall( function stubAsyncIterationCall( responses?: ResponseType[], - error?: Error + error?: Error, ) { let counter = 0; const asyncIterable = { @@ -347,21 +347,21 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.GetIndexRequest() + new protos.google.datastore.admin.v1.GetIndexRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.GetIndexRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const defaultValue2 = getTypeDefaultValue( '.google.datastore.admin.v1.GetIndexRequest', - ['indexId'] + ['indexId'], ); request.indexId = defaultValue2; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.datastore.admin.v1.Index() + new protos.google.datastore.admin.v1.Index(), ); client.innerApiCalls.getIndex = stubSimpleCall(expectedResponse); const [response] = await client.getIndex(request); @@ -383,21 +383,21 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.GetIndexRequest() + new protos.google.datastore.admin.v1.GetIndexRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.GetIndexRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const defaultValue2 = getTypeDefaultValue( '.google.datastore.admin.v1.GetIndexRequest', - ['indexId'] + ['indexId'], ); request.indexId = defaultValue2; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.datastore.admin.v1.Index() + new protos.google.datastore.admin.v1.Index(), ); client.innerApiCalls.getIndex = stubSimpleCallWithCallback(expectedResponse); @@ -406,14 +406,14 @@ describe('v1.DatastoreAdminClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.admin.v1.IIndex | null + result?: protos.google.datastore.admin.v1.IIndex | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const response = await promise; @@ -435,16 +435,16 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.GetIndexRequest() + new protos.google.datastore.admin.v1.GetIndexRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.GetIndexRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const defaultValue2 = getTypeDefaultValue( '.google.datastore.admin.v1.GetIndexRequest', - ['indexId'] + ['indexId'], ); request.indexId = defaultValue2; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; @@ -468,16 +468,16 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.GetIndexRequest() + new protos.google.datastore.admin.v1.GetIndexRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.GetIndexRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const defaultValue2 = getTypeDefaultValue( '.google.datastore.admin.v1.GetIndexRequest', - ['indexId'] + ['indexId'], ); request.indexId = defaultValue2; const expectedError = new Error('The client has already been closed.'); @@ -494,16 +494,16 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ExportEntitiesRequest() + new protos.google.datastore.admin.v1.ExportEntitiesRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ExportEntitiesRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() + new protos.google.longrunning.Operation(), ); client.innerApiCalls.exportEntities = stubLongRunningCall(expectedResponse); @@ -527,16 +527,16 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ExportEntitiesRequest() + new protos.google.datastore.admin.v1.ExportEntitiesRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ExportEntitiesRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() + new protos.google.longrunning.Operation(), ); client.innerApiCalls.exportEntities = stubLongRunningCallWithCallback(expectedResponse); @@ -548,14 +548,14 @@ describe('v1.DatastoreAdminClient', () => { result?: LROperation< protos.google.datastore.admin.v1.IExportEntitiesResponse, protos.google.datastore.admin.v1.IExportEntitiesMetadata - > | null + > | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const operation = (await promise) as LROperation< @@ -581,18 +581,18 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ExportEntitiesRequest() + new protos.google.datastore.admin.v1.ExportEntitiesRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ExportEntitiesRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedError = new Error('expected'); client.innerApiCalls.exportEntities = stubLongRunningCall( undefined, - expectedError + expectedError, ); await assert.rejects(client.exportEntities(request), expectedError); const actualRequest = ( @@ -612,11 +612,11 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ExportEntitiesRequest() + new protos.google.datastore.admin.v1.ExportEntitiesRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ExportEntitiesRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; @@ -624,7 +624,7 @@ describe('v1.DatastoreAdminClient', () => { client.innerApiCalls.exportEntities = stubLongRunningCall( undefined, undefined, - expectedError + expectedError, ); const [operation] = await client.exportEntities(request); await assert.rejects(operation.promise(), expectedError); @@ -645,7 +645,7 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() + new operationsProtos.google.longrunning.Operation(), ); expectedResponse.name = 'test'; expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; @@ -653,7 +653,7 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.getOperation = stubSimpleCall(expectedResponse); const decodedOperation = await client.checkExportEntitiesProgress( - expectedResponse.name + expectedResponse.name, ); assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); assert(decodedOperation.metadata); @@ -670,11 +670,11 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.getOperation = stubSimpleCall( undefined, - expectedError + expectedError, ); await assert.rejects( client.checkExportEntitiesProgress(''), - expectedError + expectedError, ); assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); @@ -688,16 +688,16 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ImportEntitiesRequest() + new protos.google.datastore.admin.v1.ImportEntitiesRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ImportEntitiesRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() + new protos.google.longrunning.Operation(), ); client.innerApiCalls.importEntities = stubLongRunningCall(expectedResponse); @@ -721,16 +721,16 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ImportEntitiesRequest() + new protos.google.datastore.admin.v1.ImportEntitiesRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ImportEntitiesRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() + new protos.google.longrunning.Operation(), ); client.innerApiCalls.importEntities = stubLongRunningCallWithCallback(expectedResponse); @@ -742,14 +742,14 @@ describe('v1.DatastoreAdminClient', () => { result?: LROperation< protos.google.protobuf.IEmpty, protos.google.datastore.admin.v1.IImportEntitiesMetadata - > | null + > | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const operation = (await promise) as LROperation< @@ -775,18 +775,18 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ImportEntitiesRequest() + new protos.google.datastore.admin.v1.ImportEntitiesRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ImportEntitiesRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedError = new Error('expected'); client.innerApiCalls.importEntities = stubLongRunningCall( undefined, - expectedError + expectedError, ); await assert.rejects(client.importEntities(request), expectedError); const actualRequest = ( @@ -806,11 +806,11 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ImportEntitiesRequest() + new protos.google.datastore.admin.v1.ImportEntitiesRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ImportEntitiesRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; @@ -818,7 +818,7 @@ describe('v1.DatastoreAdminClient', () => { client.innerApiCalls.importEntities = stubLongRunningCall( undefined, undefined, - expectedError + expectedError, ); const [operation] = await client.importEntities(request); await assert.rejects(operation.promise(), expectedError); @@ -839,7 +839,7 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() + new operationsProtos.google.longrunning.Operation(), ); expectedResponse.name = 'test'; expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; @@ -847,7 +847,7 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.getOperation = stubSimpleCall(expectedResponse); const decodedOperation = await client.checkImportEntitiesProgress( - expectedResponse.name + expectedResponse.name, ); assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); assert(decodedOperation.metadata); @@ -864,11 +864,11 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.getOperation = stubSimpleCall( undefined, - expectedError + expectedError, ); await assert.rejects( client.checkImportEntitiesProgress(''), - expectedError + expectedError, ); assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); @@ -882,16 +882,16 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.CreateIndexRequest() + new protos.google.datastore.admin.v1.CreateIndexRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.CreateIndexRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() + new protos.google.longrunning.Operation(), ); client.innerApiCalls.createIndex = stubLongRunningCall(expectedResponse); const [operation] = await client.createIndex(request); @@ -914,16 +914,16 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.CreateIndexRequest() + new protos.google.datastore.admin.v1.CreateIndexRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.CreateIndexRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() + new protos.google.longrunning.Operation(), ); client.innerApiCalls.createIndex = stubLongRunningCallWithCallback(expectedResponse); @@ -935,14 +935,14 @@ describe('v1.DatastoreAdminClient', () => { result?: LROperation< protos.google.datastore.admin.v1.IIndex, protos.google.datastore.admin.v1.IIndexOperationMetadata - > | null + > | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const operation = (await promise) as LROperation< @@ -968,18 +968,18 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.CreateIndexRequest() + new protos.google.datastore.admin.v1.CreateIndexRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.CreateIndexRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedError = new Error('expected'); client.innerApiCalls.createIndex = stubLongRunningCall( undefined, - expectedError + expectedError, ); await assert.rejects(client.createIndex(request), expectedError); const actualRequest = ( @@ -999,11 +999,11 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.CreateIndexRequest() + new protos.google.datastore.admin.v1.CreateIndexRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.CreateIndexRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; @@ -1011,7 +1011,7 @@ describe('v1.DatastoreAdminClient', () => { client.innerApiCalls.createIndex = stubLongRunningCall( undefined, undefined, - expectedError + expectedError, ); const [operation] = await client.createIndex(request); await assert.rejects(operation.promise(), expectedError); @@ -1032,7 +1032,7 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() + new operationsProtos.google.longrunning.Operation(), ); expectedResponse.name = 'test'; expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; @@ -1040,7 +1040,7 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.getOperation = stubSimpleCall(expectedResponse); const decodedOperation = await client.checkCreateIndexProgress( - expectedResponse.name + expectedResponse.name, ); assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); assert(decodedOperation.metadata); @@ -1057,7 +1057,7 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.getOperation = stubSimpleCall( undefined, - expectedError + expectedError, ); await assert.rejects(client.checkCreateIndexProgress(''), expectedError); assert((client.operationsClient.getOperation as SinonStub).getCall(0)); @@ -1072,21 +1072,21 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.DeleteIndexRequest() + new protos.google.datastore.admin.v1.DeleteIndexRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.DeleteIndexRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const defaultValue2 = getTypeDefaultValue( '.google.datastore.admin.v1.DeleteIndexRequest', - ['indexId'] + ['indexId'], ); request.indexId = defaultValue2; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() + new protos.google.longrunning.Operation(), ); client.innerApiCalls.deleteIndex = stubLongRunningCall(expectedResponse); const [operation] = await client.deleteIndex(request); @@ -1109,21 +1109,21 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.DeleteIndexRequest() + new protos.google.datastore.admin.v1.DeleteIndexRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.DeleteIndexRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const defaultValue2 = getTypeDefaultValue( '.google.datastore.admin.v1.DeleteIndexRequest', - ['indexId'] + ['indexId'], ); request.indexId = defaultValue2; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() + new protos.google.longrunning.Operation(), ); client.innerApiCalls.deleteIndex = stubLongRunningCallWithCallback(expectedResponse); @@ -1135,14 +1135,14 @@ describe('v1.DatastoreAdminClient', () => { result?: LROperation< protos.google.datastore.admin.v1.IIndex, protos.google.datastore.admin.v1.IIndexOperationMetadata - > | null + > | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const operation = (await promise) as LROperation< @@ -1168,23 +1168,23 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.DeleteIndexRequest() + new protos.google.datastore.admin.v1.DeleteIndexRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.DeleteIndexRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const defaultValue2 = getTypeDefaultValue( '.google.datastore.admin.v1.DeleteIndexRequest', - ['indexId'] + ['indexId'], ); request.indexId = defaultValue2; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteIndex = stubLongRunningCall( undefined, - expectedError + expectedError, ); await assert.rejects(client.deleteIndex(request), expectedError); const actualRequest = ( @@ -1204,16 +1204,16 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.DeleteIndexRequest() + new protos.google.datastore.admin.v1.DeleteIndexRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.DeleteIndexRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const defaultValue2 = getTypeDefaultValue( '.google.datastore.admin.v1.DeleteIndexRequest', - ['indexId'] + ['indexId'], ); request.indexId = defaultValue2; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; @@ -1221,7 +1221,7 @@ describe('v1.DatastoreAdminClient', () => { client.innerApiCalls.deleteIndex = stubLongRunningCall( undefined, undefined, - expectedError + expectedError, ); const [operation] = await client.deleteIndex(request); await assert.rejects(operation.promise(), expectedError); @@ -1242,7 +1242,7 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() + new operationsProtos.google.longrunning.Operation(), ); expectedResponse.name = 'test'; expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; @@ -1250,7 +1250,7 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.getOperation = stubSimpleCall(expectedResponse); const decodedOperation = await client.checkDeleteIndexProgress( - expectedResponse.name + expectedResponse.name, ); assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); assert(decodedOperation.metadata); @@ -1267,7 +1267,7 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.getOperation = stubSimpleCall( undefined, - expectedError + expectedError, ); await assert.rejects(client.checkDeleteIndexProgress(''), expectedError); assert((client.operationsClient.getOperation as SinonStub).getCall(0)); @@ -1282,11 +1282,11 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ListIndexesRequest() + new protos.google.datastore.admin.v1.ListIndexesRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ListIndexesRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; @@ -1315,11 +1315,11 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ListIndexesRequest() + new protos.google.datastore.admin.v1.ListIndexesRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ListIndexesRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; @@ -1335,14 +1335,14 @@ describe('v1.DatastoreAdminClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.admin.v1.IIndex[] | null + result?: protos.google.datastore.admin.v1.IIndex[] | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const response = await promise; @@ -1364,18 +1364,18 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ListIndexesRequest() + new protos.google.datastore.admin.v1.ListIndexesRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ListIndexesRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedError = new Error('expected'); client.innerApiCalls.listIndexes = stubSimpleCall( undefined, - expectedError + expectedError, ); await assert.rejects(client.listIndexes(request), expectedError); const actualRequest = ( @@ -1395,11 +1395,11 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ListIndexesRequest() + new protos.google.datastore.admin.v1.ListIndexesRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ListIndexesRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; @@ -1417,7 +1417,7 @@ describe('v1.DatastoreAdminClient', () => { 'data', (response: protos.google.datastore.admin.v1.Index) => { responses.push(response); - } + }, ); stream.on('end', () => { resolve(responses); @@ -1431,14 +1431,14 @@ describe('v1.DatastoreAdminClient', () => { assert( (client.descriptors.page.listIndexes.createStream as SinonStub) .getCall(0) - .calledWith(client.innerApiCalls.listIndexes, request) + .calledWith(client.innerApiCalls.listIndexes, request), ); assert( (client.descriptors.page.listIndexes.createStream as SinonStub) .getCall(0) .args[2].otherArgs.headers[ 'x-goog-request-params' - ].includes(expectedHeaderRequestParams) + ].includes(expectedHeaderRequestParams), ); }); @@ -1449,18 +1449,18 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ListIndexesRequest() + new protos.google.datastore.admin.v1.ListIndexesRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ListIndexesRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedError = new Error('expected'); client.descriptors.page.listIndexes.createStream = stubPageStreamingCall( undefined, - expectedError + expectedError, ); const stream = client.listIndexesStream(request); const promise = new Promise((resolve, reject) => { @@ -1469,7 +1469,7 @@ describe('v1.DatastoreAdminClient', () => { 'data', (response: protos.google.datastore.admin.v1.Index) => { responses.push(response); - } + }, ); stream.on('end', () => { resolve(responses); @@ -1482,14 +1482,14 @@ describe('v1.DatastoreAdminClient', () => { assert( (client.descriptors.page.listIndexes.createStream as SinonStub) .getCall(0) - .calledWith(client.innerApiCalls.listIndexes, request) + .calledWith(client.innerApiCalls.listIndexes, request), ); assert( (client.descriptors.page.listIndexes.createStream as SinonStub) .getCall(0) .args[2].otherArgs.headers[ 'x-goog-request-params' - ].includes(expectedHeaderRequestParams) + ].includes(expectedHeaderRequestParams), ); }); @@ -1500,11 +1500,11 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ListIndexesRequest() + new protos.google.datastore.admin.v1.ListIndexesRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ListIndexesRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; @@ -1523,16 +1523,16 @@ describe('v1.DatastoreAdminClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert.deepStrictEqual( (client.descriptors.page.listIndexes.asyncIterate as SinonStub).getCall( - 0 + 0, ).args[1], - request + request, ); assert( (client.descriptors.page.listIndexes.asyncIterate as SinonStub) .getCall(0) .args[2].otherArgs.headers[ 'x-goog-request-params' - ].includes(expectedHeaderRequestParams) + ].includes(expectedHeaderRequestParams), ); }); @@ -1543,18 +1543,18 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.admin.v1.ListIndexesRequest() + new protos.google.datastore.admin.v1.ListIndexesRequest(), ); const defaultValue1 = getTypeDefaultValue( '.google.datastore.admin.v1.ListIndexesRequest', - ['projectId'] + ['projectId'], ); request.projectId = defaultValue1; const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; const expectedError = new Error('expected'); client.descriptors.page.listIndexes.asyncIterate = stubAsyncIterationCall( undefined, - expectedError + expectedError, ); const iterable = client.listIndexesAsync(request); await assert.rejects(async () => { @@ -1565,16 +1565,16 @@ describe('v1.DatastoreAdminClient', () => { }); assert.deepStrictEqual( (client.descriptors.page.listIndexes.asyncIterate as SinonStub).getCall( - 0 + 0, ).args[1], - request + request, ); assert( (client.descriptors.page.listIndexes.asyncIterate as SinonStub) .getCall(0) .args[2].otherArgs.headers[ 'x-goog-request-params' - ].includes(expectedHeaderRequestParams) + ].includes(expectedHeaderRequestParams), ); }); }); @@ -1586,10 +1586,10 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() + new operationsProtos.google.longrunning.GetOperationRequest(), ); const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() + new operationsProtos.google.longrunning.Operation(), ); client.operationsClient.getOperation = stubSimpleCall(expectedResponse); const response = await client.getOperation(request); @@ -1597,7 +1597,7 @@ describe('v1.DatastoreAdminClient', () => { assert( (client.operationsClient.getOperation as SinonStub) .getCall(0) - .calledWith(request) + .calledWith(request), ); }); it('invokes getOperation without error using callback', async () => { @@ -1606,10 +1606,10 @@ describe('v1.DatastoreAdminClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() + new operationsProtos.google.longrunning.GetOperationRequest(), ); const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() + new operationsProtos.google.longrunning.Operation(), ); client.operationsClient.getOperation = sinon .stub() @@ -1620,14 +1620,14 @@ describe('v1.DatastoreAdminClient', () => { undefined, ( err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null + result?: operationsProtos.google.longrunning.Operation | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const response = await promise; @@ -1640,12 +1640,12 @@ describe('v1.DatastoreAdminClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() + new operationsProtos.google.longrunning.GetOperationRequest(), ); const expectedError = new Error('expected'); client.operationsClient.getOperation = stubSimpleCall( undefined, - expectedError + expectedError, ); await assert.rejects(async () => { await client.getOperation(request); @@ -1653,7 +1653,7 @@ describe('v1.DatastoreAdminClient', () => { assert( (client.operationsClient.getOperation as SinonStub) .getCall(0) - .calledWith(request) + .calledWith(request), ); }); }); @@ -1665,10 +1665,10 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() + new operationsProtos.google.longrunning.CancelOperationRequest(), ); const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() + new protos.google.protobuf.Empty(), ); client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); @@ -1677,7 +1677,7 @@ describe('v1.DatastoreAdminClient', () => { assert( (client.operationsClient.cancelOperation as SinonStub) .getCall(0) - .calledWith(request) + .calledWith(request), ); }); it('invokes cancelOperation without error using callback', async () => { @@ -1686,10 +1686,10 @@ describe('v1.DatastoreAdminClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() + new operationsProtos.google.longrunning.CancelOperationRequest(), ); const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() + new protos.google.protobuf.Empty(), ); client.operationsClient.cancelOperation = sinon .stub() @@ -1700,14 +1700,14 @@ describe('v1.DatastoreAdminClient', () => { undefined, ( err?: Error | null, - result?: protos.google.protobuf.Empty | null + result?: protos.google.protobuf.Empty | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const response = await promise; @@ -1720,12 +1720,12 @@ describe('v1.DatastoreAdminClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() + new operationsProtos.google.longrunning.CancelOperationRequest(), ); const expectedError = new Error('expected'); client.operationsClient.cancelOperation = stubSimpleCall( undefined, - expectedError + expectedError, ); await assert.rejects(async () => { await client.cancelOperation(request); @@ -1733,7 +1733,7 @@ describe('v1.DatastoreAdminClient', () => { assert( (client.operationsClient.cancelOperation as SinonStub) .getCall(0) - .calledWith(request) + .calledWith(request), ); }); }); @@ -1745,10 +1745,10 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() + new operationsProtos.google.longrunning.DeleteOperationRequest(), ); const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() + new protos.google.protobuf.Empty(), ); client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); @@ -1757,7 +1757,7 @@ describe('v1.DatastoreAdminClient', () => { assert( (client.operationsClient.deleteOperation as SinonStub) .getCall(0) - .calledWith(request) + .calledWith(request), ); }); it('invokes deleteOperation without error using callback', async () => { @@ -1766,10 +1766,10 @@ describe('v1.DatastoreAdminClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() + new operationsProtos.google.longrunning.DeleteOperationRequest(), ); const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() + new protos.google.protobuf.Empty(), ); client.operationsClient.deleteOperation = sinon .stub() @@ -1780,14 +1780,14 @@ describe('v1.DatastoreAdminClient', () => { undefined, ( err?: Error | null, - result?: protos.google.protobuf.Empty | null + result?: protos.google.protobuf.Empty | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const response = await promise; @@ -1800,12 +1800,12 @@ describe('v1.DatastoreAdminClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() + new operationsProtos.google.longrunning.DeleteOperationRequest(), ); const expectedError = new Error('expected'); client.operationsClient.deleteOperation = stubSimpleCall( undefined, - expectedError + expectedError, ); await assert.rejects(async () => { await client.deleteOperation(request); @@ -1813,7 +1813,7 @@ describe('v1.DatastoreAdminClient', () => { assert( (client.operationsClient.deleteOperation as SinonStub) .getCall(0) - .calledWith(request) + .calledWith(request), ); }); }); @@ -1824,17 +1824,17 @@ describe('v1.DatastoreAdminClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() + new operationsProtos.google.longrunning.ListOperationsRequest(), ); const expectedResponse = [ generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() + new operationsProtos.google.longrunning.ListOperationsResponse(), ), generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() + new operationsProtos.google.longrunning.ListOperationsResponse(), ), generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() + new operationsProtos.google.longrunning.ListOperationsResponse(), ), ]; client.operationsClient.descriptor.listOperations.asyncIterate = @@ -1850,7 +1850,7 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.descriptor.listOperations .asyncIterate as SinonStub ).getCall(0).args[1], - request + request, ); }); it('uses async iteration with listOperations with error', async () => { @@ -1860,7 +1860,7 @@ describe('v1.DatastoreAdminClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() + new operationsProtos.google.longrunning.ListOperationsRequest(), ); const expectedError = new Error('expected'); client.operationsClient.descriptor.listOperations.asyncIterate = @@ -1877,7 +1877,7 @@ describe('v1.DatastoreAdminClient', () => { client.operationsClient.descriptor.listOperations .asyncIterate as SinonStub ).getCall(0).args[1], - request + request, ); }); }); diff --git a/test/gapic_datastore_v1.ts b/test/gapic_datastore_v1.ts index 1c7ee6608..23c97b88c 100644 --- a/test/gapic_datastore_v1.ts +++ b/test/gapic_datastore_v1.ts @@ -28,7 +28,7 @@ import {protobuf, operationsProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects const root = protobuf.Root.fromJSON( - require('../protos/protos.json') + require('../protos/protos.json'), ).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -45,7 +45,7 @@ function generateSampleMessage(instance: T) { instance.constructor as typeof protobuf.Message ).toObject(instance as protobuf.Message, {defaults: true}); return (instance.constructor as typeof protobuf.Message).fromObject( - filledObject + filledObject, ) as T; } @@ -57,7 +57,7 @@ function stubSimpleCall(response?: ResponseType, error?: Error) { function stubSimpleCallWithCallback( response?: ResponseType, - error?: Error + error?: Error, ) { return error ? sinon.stub().callsArgWith(2, error) @@ -66,7 +66,7 @@ function stubSimpleCallWithCallback( function stubAsyncIterationCall( responses?: ResponseType[], - error?: Error + error?: Error, ) { let counter = 0; const asyncIterable = { @@ -273,19 +273,19 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.LookupRequest() + new protos.google.datastore.v1.LookupRequest(), ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.LookupResponse() + new protos.google.datastore.v1.LookupResponse(), ); client.innerApiCalls.lookup = stubSimpleCall(expectedResponse); const [response] = await client.lookup(request); assert.deepStrictEqual(response, expectedResponse); const actualRequest = (client.innerApiCalls.lookup as SinonStub).getCall( - 0 + 0, ).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( @@ -301,13 +301,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.LookupRequest() + new protos.google.datastore.v1.LookupRequest(), ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.LookupResponse() + new protos.google.datastore.v1.LookupResponse(), ); client.innerApiCalls.lookup = stubSimpleCallWithCallback(expectedResponse); @@ -316,20 +316,20 @@ describe('v1.DatastoreClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.v1.ILookupResponse | null + result?: protos.google.datastore.v1.ILookupResponse | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); const actualRequest = (client.innerApiCalls.lookup as SinonStub).getCall( - 0 + 0, ).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( @@ -345,7 +345,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.LookupRequest() + new protos.google.datastore.v1.LookupRequest(), ); // path template is empty request.databaseId = 'value'; @@ -354,7 +354,7 @@ describe('v1.DatastoreClient', () => { client.innerApiCalls.lookup = stubSimpleCall(undefined, expectedError); await assert.rejects(client.lookup(request), expectedError); const actualRequest = (client.innerApiCalls.lookup as SinonStub).getCall( - 0 + 0, ).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( @@ -370,7 +370,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.LookupRequest() + new protos.google.datastore.v1.LookupRequest(), ); // path template is empty request.databaseId = 'value'; @@ -388,13 +388,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RunQueryRequest() + new protos.google.datastore.v1.RunQueryRequest(), ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.RunQueryResponse() + new protos.google.datastore.v1.RunQueryResponse(), ); client.innerApiCalls.runQuery = stubSimpleCall(expectedResponse); const [response] = await client.runQuery(request); @@ -416,13 +416,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RunQueryRequest() + new protos.google.datastore.v1.RunQueryRequest(), ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.RunQueryResponse() + new protos.google.datastore.v1.RunQueryResponse(), ); client.innerApiCalls.runQuery = stubSimpleCallWithCallback(expectedResponse); @@ -431,14 +431,14 @@ describe('v1.DatastoreClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.v1.IRunQueryResponse | null + result?: protos.google.datastore.v1.IRunQueryResponse | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const response = await promise; @@ -460,7 +460,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RunQueryRequest() + new protos.google.datastore.v1.RunQueryRequest(), ); // path template is empty request.databaseId = 'value'; @@ -485,7 +485,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RunQueryRequest() + new protos.google.datastore.v1.RunQueryRequest(), ); // path template is empty request.databaseId = 'value'; @@ -503,13 +503,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RunAggregationQueryRequest() + new protos.google.datastore.v1.RunAggregationQueryRequest(), ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.RunAggregationQueryResponse() + new protos.google.datastore.v1.RunAggregationQueryResponse(), ); client.innerApiCalls.runAggregationQuery = stubSimpleCall(expectedResponse); @@ -532,13 +532,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RunAggregationQueryRequest() + new protos.google.datastore.v1.RunAggregationQueryRequest(), ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.RunAggregationQueryResponse() + new protos.google.datastore.v1.RunAggregationQueryResponse(), ); client.innerApiCalls.runAggregationQuery = stubSimpleCallWithCallback(expectedResponse); @@ -547,14 +547,14 @@ describe('v1.DatastoreClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.v1.IRunAggregationQueryResponse | null + result?: protos.google.datastore.v1.IRunAggregationQueryResponse | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const response = await promise; @@ -576,7 +576,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RunAggregationQueryRequest() + new protos.google.datastore.v1.RunAggregationQueryRequest(), ); // path template is empty request.databaseId = 'value'; @@ -584,7 +584,7 @@ describe('v1.DatastoreClient', () => { const expectedError = new Error('expected'); client.innerApiCalls.runAggregationQuery = stubSimpleCall( undefined, - expectedError + expectedError, ); await assert.rejects(client.runAggregationQuery(request), expectedError); const actualRequest = ( @@ -604,7 +604,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RunAggregationQueryRequest() + new protos.google.datastore.v1.RunAggregationQueryRequest(), ); // path template is empty request.databaseId = 'value'; @@ -622,13 +622,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.BeginTransactionRequest() + new protos.google.datastore.v1.BeginTransactionRequest(), ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.BeginTransactionResponse() + new protos.google.datastore.v1.BeginTransactionResponse(), ); client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); const [response] = await client.beginTransaction(request); @@ -650,13 +650,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.BeginTransactionRequest() + new protos.google.datastore.v1.BeginTransactionRequest(), ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.BeginTransactionResponse() + new protos.google.datastore.v1.BeginTransactionResponse(), ); client.innerApiCalls.beginTransaction = stubSimpleCallWithCallback(expectedResponse); @@ -665,14 +665,14 @@ describe('v1.DatastoreClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.v1.IBeginTransactionResponse | null + result?: protos.google.datastore.v1.IBeginTransactionResponse | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const response = await promise; @@ -694,7 +694,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.BeginTransactionRequest() + new protos.google.datastore.v1.BeginTransactionRequest(), ); // path template is empty request.databaseId = 'value'; @@ -702,7 +702,7 @@ describe('v1.DatastoreClient', () => { const expectedError = new Error('expected'); client.innerApiCalls.beginTransaction = stubSimpleCall( undefined, - expectedError + expectedError, ); await assert.rejects(client.beginTransaction(request), expectedError); const actualRequest = ( @@ -722,7 +722,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.BeginTransactionRequest() + new protos.google.datastore.v1.BeginTransactionRequest(), ); // path template is empty request.databaseId = 'value'; @@ -740,19 +740,19 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.CommitRequest() + new protos.google.datastore.v1.CommitRequest(), ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.CommitResponse() + new protos.google.datastore.v1.CommitResponse(), ); client.innerApiCalls.commit = stubSimpleCall(expectedResponse); const [response] = await client.commit(request); assert.deepStrictEqual(response, expectedResponse); const actualRequest = (client.innerApiCalls.commit as SinonStub).getCall( - 0 + 0, ).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( @@ -768,13 +768,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.CommitRequest() + new protos.google.datastore.v1.CommitRequest(), ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.CommitResponse() + new protos.google.datastore.v1.CommitResponse(), ); client.innerApiCalls.commit = stubSimpleCallWithCallback(expectedResponse); @@ -783,20 +783,20 @@ describe('v1.DatastoreClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.v1.ICommitResponse | null + result?: protos.google.datastore.v1.ICommitResponse | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); const actualRequest = (client.innerApiCalls.commit as SinonStub).getCall( - 0 + 0, ).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( @@ -812,7 +812,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.CommitRequest() + new protos.google.datastore.v1.CommitRequest(), ); // path template is empty request.databaseId = 'value'; @@ -821,7 +821,7 @@ describe('v1.DatastoreClient', () => { client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); await assert.rejects(client.commit(request), expectedError); const actualRequest = (client.innerApiCalls.commit as SinonStub).getCall( - 0 + 0, ).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( @@ -837,7 +837,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.CommitRequest() + new protos.google.datastore.v1.CommitRequest(), ); // path template is empty request.databaseId = 'value'; @@ -855,13 +855,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RollbackRequest() + new protos.google.datastore.v1.RollbackRequest(), ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.RollbackResponse() + new protos.google.datastore.v1.RollbackResponse(), ); client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); const [response] = await client.rollback(request); @@ -883,13 +883,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RollbackRequest() + new protos.google.datastore.v1.RollbackRequest(), ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.RollbackResponse() + new protos.google.datastore.v1.RollbackResponse(), ); client.innerApiCalls.rollback = stubSimpleCallWithCallback(expectedResponse); @@ -898,14 +898,14 @@ describe('v1.DatastoreClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.v1.IRollbackResponse | null + result?: protos.google.datastore.v1.IRollbackResponse | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const response = await promise; @@ -927,7 +927,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RollbackRequest() + new protos.google.datastore.v1.RollbackRequest(), ); // path template is empty request.databaseId = 'value'; @@ -952,7 +952,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.RollbackRequest() + new protos.google.datastore.v1.RollbackRequest(), ); // path template is empty request.databaseId = 'value'; @@ -970,13 +970,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.AllocateIdsRequest() + new protos.google.datastore.v1.AllocateIdsRequest(), ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.AllocateIdsResponse() + new protos.google.datastore.v1.AllocateIdsResponse(), ); client.innerApiCalls.allocateIds = stubSimpleCall(expectedResponse); const [response] = await client.allocateIds(request); @@ -998,13 +998,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.AllocateIdsRequest() + new protos.google.datastore.v1.AllocateIdsRequest(), ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.AllocateIdsResponse() + new protos.google.datastore.v1.AllocateIdsResponse(), ); client.innerApiCalls.allocateIds = stubSimpleCallWithCallback(expectedResponse); @@ -1013,14 +1013,14 @@ describe('v1.DatastoreClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.v1.IAllocateIdsResponse | null + result?: protos.google.datastore.v1.IAllocateIdsResponse | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const response = await promise; @@ -1042,7 +1042,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.AllocateIdsRequest() + new protos.google.datastore.v1.AllocateIdsRequest(), ); // path template is empty request.databaseId = 'value'; @@ -1050,7 +1050,7 @@ describe('v1.DatastoreClient', () => { const expectedError = new Error('expected'); client.innerApiCalls.allocateIds = stubSimpleCall( undefined, - expectedError + expectedError, ); await assert.rejects(client.allocateIds(request), expectedError); const actualRequest = ( @@ -1070,7 +1070,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.AllocateIdsRequest() + new protos.google.datastore.v1.AllocateIdsRequest(), ); // path template is empty request.databaseId = 'value'; @@ -1088,13 +1088,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.ReserveIdsRequest() + new protos.google.datastore.v1.ReserveIdsRequest(), ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.ReserveIdsResponse() + new protos.google.datastore.v1.ReserveIdsResponse(), ); client.innerApiCalls.reserveIds = stubSimpleCall(expectedResponse); const [response] = await client.reserveIds(request); @@ -1116,13 +1116,13 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.ReserveIdsRequest() + new protos.google.datastore.v1.ReserveIdsRequest(), ); // path template is empty request.databaseId = 'value'; const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( - new protos.google.datastore.v1.ReserveIdsResponse() + new protos.google.datastore.v1.ReserveIdsResponse(), ); client.innerApiCalls.reserveIds = stubSimpleCallWithCallback(expectedResponse); @@ -1131,14 +1131,14 @@ describe('v1.DatastoreClient', () => { request, ( err?: Error | null, - result?: protos.google.datastore.v1.IReserveIdsResponse | null + result?: protos.google.datastore.v1.IReserveIdsResponse | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const response = await promise; @@ -1160,7 +1160,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.ReserveIdsRequest() + new protos.google.datastore.v1.ReserveIdsRequest(), ); // path template is empty request.databaseId = 'value'; @@ -1168,7 +1168,7 @@ describe('v1.DatastoreClient', () => { const expectedError = new Error('expected'); client.innerApiCalls.reserveIds = stubSimpleCall( undefined, - expectedError + expectedError, ); await assert.rejects(client.reserveIds(request), expectedError); const actualRequest = ( @@ -1188,7 +1188,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new protos.google.datastore.v1.ReserveIdsRequest() + new protos.google.datastore.v1.ReserveIdsRequest(), ); // path template is empty request.databaseId = 'value'; @@ -1205,10 +1205,10 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() + new operationsProtos.google.longrunning.GetOperationRequest(), ); const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() + new operationsProtos.google.longrunning.Operation(), ); client.operationsClient.getOperation = stubSimpleCall(expectedResponse); const response = await client.getOperation(request); @@ -1216,7 +1216,7 @@ describe('v1.DatastoreClient', () => { assert( (client.operationsClient.getOperation as SinonStub) .getCall(0) - .calledWith(request) + .calledWith(request), ); }); it('invokes getOperation without error using callback', async () => { @@ -1225,10 +1225,10 @@ describe('v1.DatastoreClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() + new operationsProtos.google.longrunning.GetOperationRequest(), ); const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() + new operationsProtos.google.longrunning.Operation(), ); client.operationsClient.getOperation = sinon .stub() @@ -1239,14 +1239,14 @@ describe('v1.DatastoreClient', () => { undefined, ( err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null + result?: operationsProtos.google.longrunning.Operation | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const response = await promise; @@ -1259,12 +1259,12 @@ describe('v1.DatastoreClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() + new operationsProtos.google.longrunning.GetOperationRequest(), ); const expectedError = new Error('expected'); client.operationsClient.getOperation = stubSimpleCall( undefined, - expectedError + expectedError, ); await assert.rejects(async () => { await client.getOperation(request); @@ -1272,7 +1272,7 @@ describe('v1.DatastoreClient', () => { assert( (client.operationsClient.getOperation as SinonStub) .getCall(0) - .calledWith(request) + .calledWith(request), ); }); }); @@ -1284,10 +1284,10 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() + new operationsProtos.google.longrunning.CancelOperationRequest(), ); const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() + new protos.google.protobuf.Empty(), ); client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); @@ -1296,7 +1296,7 @@ describe('v1.DatastoreClient', () => { assert( (client.operationsClient.cancelOperation as SinonStub) .getCall(0) - .calledWith(request) + .calledWith(request), ); }); it('invokes cancelOperation without error using callback', async () => { @@ -1305,10 +1305,10 @@ describe('v1.DatastoreClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() + new operationsProtos.google.longrunning.CancelOperationRequest(), ); const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() + new protos.google.protobuf.Empty(), ); client.operationsClient.cancelOperation = sinon .stub() @@ -1319,14 +1319,14 @@ describe('v1.DatastoreClient', () => { undefined, ( err?: Error | null, - result?: protos.google.protobuf.Empty | null + result?: protos.google.protobuf.Empty | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const response = await promise; @@ -1339,12 +1339,12 @@ describe('v1.DatastoreClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() + new operationsProtos.google.longrunning.CancelOperationRequest(), ); const expectedError = new Error('expected'); client.operationsClient.cancelOperation = stubSimpleCall( undefined, - expectedError + expectedError, ); await assert.rejects(async () => { await client.cancelOperation(request); @@ -1352,7 +1352,7 @@ describe('v1.DatastoreClient', () => { assert( (client.operationsClient.cancelOperation as SinonStub) .getCall(0) - .calledWith(request) + .calledWith(request), ); }); }); @@ -1364,10 +1364,10 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() + new operationsProtos.google.longrunning.DeleteOperationRequest(), ); const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() + new protos.google.protobuf.Empty(), ); client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); @@ -1376,7 +1376,7 @@ describe('v1.DatastoreClient', () => { assert( (client.operationsClient.deleteOperation as SinonStub) .getCall(0) - .calledWith(request) + .calledWith(request), ); }); it('invokes deleteOperation without error using callback', async () => { @@ -1385,10 +1385,10 @@ describe('v1.DatastoreClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() + new operationsProtos.google.longrunning.DeleteOperationRequest(), ); const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() + new protos.google.protobuf.Empty(), ); client.operationsClient.deleteOperation = sinon .stub() @@ -1399,14 +1399,14 @@ describe('v1.DatastoreClient', () => { undefined, ( err?: Error | null, - result?: protos.google.protobuf.Empty | null + result?: protos.google.protobuf.Empty | null, ) => { if (err) { reject(err); } else { resolve(result); } - } + }, ); }); const response = await promise; @@ -1419,12 +1419,12 @@ describe('v1.DatastoreClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() + new operationsProtos.google.longrunning.DeleteOperationRequest(), ); const expectedError = new Error('expected'); client.operationsClient.deleteOperation = stubSimpleCall( undefined, - expectedError + expectedError, ); await assert.rejects(async () => { await client.deleteOperation(request); @@ -1432,7 +1432,7 @@ describe('v1.DatastoreClient', () => { assert( (client.operationsClient.deleteOperation as SinonStub) .getCall(0) - .calledWith(request) + .calledWith(request), ); }); }); @@ -1443,17 +1443,17 @@ describe('v1.DatastoreClient', () => { projectId: 'bogus', }); const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() + new operationsProtos.google.longrunning.ListOperationsRequest(), ); const expectedResponse = [ generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() + new operationsProtos.google.longrunning.ListOperationsResponse(), ), generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() + new operationsProtos.google.longrunning.ListOperationsResponse(), ), generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() + new operationsProtos.google.longrunning.ListOperationsResponse(), ), ]; client.operationsClient.descriptor.listOperations.asyncIterate = @@ -1469,7 +1469,7 @@ describe('v1.DatastoreClient', () => { client.operationsClient.descriptor.listOperations .asyncIterate as SinonStub ).getCall(0).args[1], - request + request, ); }); it('uses async iteration with listOperations with error', async () => { @@ -1479,7 +1479,7 @@ describe('v1.DatastoreClient', () => { }); await client.initialize(); const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() + new operationsProtos.google.longrunning.ListOperationsRequest(), ); const expectedError = new Error('expected'); client.operationsClient.descriptor.listOperations.asyncIterate = @@ -1496,7 +1496,7 @@ describe('v1.DatastoreClient', () => { client.operationsClient.descriptor.listOperations .asyncIterate as SinonStub ).getCall(0).args[1], - request + request, ); }); }); diff --git a/test/index.ts b/test/index.ts index abd9c487f..a0074bd7f 100644 --- a/test/index.ts +++ b/test/index.ts @@ -188,7 +188,7 @@ async.each( '../src/utils/entity/buildEntityProto.js', { '../../entity.js': {entity: fakeEntity}, - } + }, ); Datastore = proxyquire('../src', { './entity.js': {entity: fakeEntity}, @@ -266,7 +266,7 @@ async.each( it('should set the default base URL', () => { assert.strictEqual( datastore.defaultBaseUrl_, - 'datastore.googleapis.com' + 'datastore.googleapis.com', ); }); @@ -306,8 +306,8 @@ async.each( port: 443, projectId: undefined, }, - options - ) + options, + ), ); }); @@ -374,7 +374,7 @@ async.each( }); assert.strictEqual( datastore.options.sslCreds, - fakeInsecureCreds + fakeInsecureCreds, ); }); }); @@ -428,7 +428,7 @@ async.each( }); assert.strictEqual( datastore.options.sslCreds, - fakeInsecureCreds + fakeInsecureCreds, ); }); }); @@ -456,7 +456,7 @@ async.each( }); assert.strictEqual( datastore.options.sslCreds, - fakeInsecureCreds + fakeInsecureCreds, ); }); }); @@ -623,14 +623,14 @@ async.each( it('should expose a MORE_RESULTS_AFTER_CURSOR helper', () => { assert.strictEqual( Datastore.MORE_RESULTS_AFTER_CURSOR, - 'MORE_RESULTS_AFTER_CURSOR' + 'MORE_RESULTS_AFTER_CURSOR', ); }); it('should also be on the prototype', () => { assert.strictEqual( datastore.MORE_RESULTS_AFTER_CURSOR, - Datastore.MORE_RESULTS_AFTER_CURSOR + Datastore.MORE_RESULTS_AFTER_CURSOR, ); }); }); @@ -639,14 +639,14 @@ async.each( it('should expose a MORE_RESULTS_AFTER_LIMIT helper', () => { assert.strictEqual( Datastore.MORE_RESULTS_AFTER_LIMIT, - 'MORE_RESULTS_AFTER_LIMIT' + 'MORE_RESULTS_AFTER_LIMIT', ); }); it('should also be on the prototype', () => { assert.strictEqual( datastore.MORE_RESULTS_AFTER_LIMIT, - Datastore.MORE_RESULTS_AFTER_LIMIT + Datastore.MORE_RESULTS_AFTER_LIMIT, ); }); }); @@ -659,7 +659,7 @@ async.each( it('should also be on the prototype', () => { assert.strictEqual( datastore.NO_MORE_RESULTS, - Datastore.NO_MORE_RESULTS + Datastore.NO_MORE_RESULTS, ); }); }); @@ -704,7 +704,7 @@ async.each( datastore.request_ = (config: any) => { assert.strictEqual( config.reqOpts.outputUrlPrefix, - `gs://${bucket}` + `gs://${bucket}`, ); done(); }; @@ -731,7 +731,7 @@ async.each( datastore.request_ = (config: any) => { assert.strictEqual( config.reqOpts.outputUrlPrefix, - `gs://${bucket.name}` + `gs://${bucket.name}`, ); done(); }; @@ -752,7 +752,7 @@ async.each( bucket: 'bucket', outputUrlPrefix: 'output-url-prefix', }, - assert.ifError + assert.ifError, ); }, /Both `bucket` and `outputUrlPrefix` were provided\./); }); @@ -778,7 +778,7 @@ async.each( kinds: ['kind1', 'kind2'], entityFilter: {}, }, - assert.ifError + assert.ifError, ); }, /Both `entityFilter` and `kinds` were provided\./); }); @@ -791,7 +791,7 @@ async.each( datastore.request_ = (config: any) => { assert.deepStrictEqual( config.reqOpts.entityFilter.namespaceIds, - namespaces + namespaces, ); done(); }; @@ -807,7 +807,7 @@ async.each( namespaces: ['ns1', 'ns2'], entityFilter: {}, }, - assert.ifError + assert.ifError, ); }, /Both `entityFilter` and `namespaces` were provided\./); }); @@ -906,11 +906,11 @@ async.each( datastore.request_ = (config: any) => { assert.strictEqual( config.reqOpts.pageSize, - options.gaxOptions.pageSize + options.gaxOptions.pageSize, ); assert.strictEqual( config.reqOpts.pageToken, - options.gaxOptions.pageToken + options.gaxOptions.pageToken, ); done(); }; @@ -981,7 +981,7 @@ async.each( // eslint-disable-next-line @typescript-eslint/no-explicit-any datastore.request_ = (config: any) => { assert( - Object.keys(options.gaxOptions).every(k => !config.reqOpts[k]) + Object.keys(options.gaxOptions).every(k => !config.reqOpts[k]), ); done(); }; @@ -998,7 +998,7 @@ async.each( datastore.request_ = (config: any) => { assert.strictEqual( config.gaxOpts.autoPaginate, - options.autoPaginate + options.autoPaginate, ); done(); }; @@ -1039,7 +1039,7 @@ async.each( assert.strictEqual(nextQuery, null); assert.strictEqual(apiResp, apiResponse); done(); - } + }, ); }); @@ -1082,7 +1082,7 @@ async.each( assert.ifError(err); assert.deepStrictEqual(_nextQuery, nextQuery); done(); - } + }, ); }); }); @@ -1158,7 +1158,7 @@ async.each( file: 'file', inputUrl: 'gs://file', }, - assert.ifError + assert.ifError, ); }, /Both `file` and `inputUrl` were provided\./); }); @@ -1194,7 +1194,7 @@ async.each( datastore.request_ = (config: any) => { assert.strictEqual( config.reqOpts.inputUrl, - `gs://${file.bucket.name}/${file.name}` + `gs://${file.bucket.name}/${file.name}`, ); done(); }; @@ -1229,7 +1229,7 @@ async.each( kinds: ['kind1', 'kind2'], entityFilter: {}, }, - assert.ifError + assert.ifError, ); }, /Both `entityFilter` and `kinds` were provided\./); }); @@ -1242,7 +1242,7 @@ async.each( datastore.request_ = (config: any) => { assert.deepStrictEqual( config.reqOpts.entityFilter.namespaceIds, - namespaces + namespaces, ); done(); }; @@ -1258,7 +1258,7 @@ async.each( namespaces: ['ns1', 'ns2'], entityFilter: {}, }, - assert.ifError + assert.ifError, ); }, /Both `entityFilter` and `namespaces` were provided\./); }); @@ -1476,7 +1476,7 @@ async.each( {key, data: {k: 'v'}}, {key, data: {k: 'v'}}, ], - done + done, ); }); @@ -1508,7 +1508,7 @@ async.each( datastore.request_ = (config: RequestConfig, callback: Function) => { assert.deepStrictEqual( config.reqOpts!.mutations![0].upsert!.properties, - expectedProperties + expectedProperties, ); callback(); }; @@ -1540,7 +1540,7 @@ async.each( data: {}, }, gaxOptions, - assert.ifError + assert.ifError, ); }); @@ -1561,12 +1561,12 @@ async.each( }, () => { done('Should not reach callback'); - } + }, ); } catch (err: unknown) { assert.strictEqual( (err as {message: string}).message, - 'Unsupported field value, undefined, was provided.' + 'Unsupported field value, undefined, was provided.', ); done(); return; @@ -1591,14 +1591,14 @@ async.each( }, () => { done('Should not reach callback'); - } + }, ); } catch (err: unknown) { assert( [ "Cannot read properties of null (reading 'toString')", // Later Node versions "Cannot read property 'toString' of null", // Node 14 - ].includes((err as {message: string}).message) + ].includes((err as {message: string}).message), ); done(); return; @@ -1655,7 +1655,7 @@ async.each( {key, method: 'update', data: {k2: 'v2'}}, {key, method: 'upsert', data: {k3: 'v3'}}, ], - done + done, ); }); @@ -1669,7 +1669,7 @@ async.each( k: 'v', }, }, - assert.ifError + assert.ifError, ); }, /Method auto_insert_id not recognized/); }); @@ -1712,7 +1712,7 @@ async.each( assert.ifError(err); assert.strictEqual(mockCommitResponse, apiResponse); done(); - } + }, ); }); @@ -1736,7 +1736,7 @@ async.each( }, ], }, - assert.ifError + assert.ifError, ); }); @@ -1763,7 +1763,7 @@ async.each( }, ], }, - assert.ifError + assert.ifError, ); }); @@ -1837,7 +1837,7 @@ async.each( data, excludeFromIndexes: ['.*'], }, - assert.ifError + assert.ifError, ); }); @@ -1919,7 +1919,7 @@ async.each( 'metadata.longStringArray[].*', ], }, - assert.ifError + assert.ifError, ); }); @@ -1946,7 +1946,7 @@ async.each( }, ], }, - assert.ifError + assert.ifError, ); }); @@ -2009,12 +2009,12 @@ async.each( assert.strictEqual( (config.reqOpts!.mutations![0].upsert! as Entity) .excludeLargeProperties, - true + true, ); assert.deepStrictEqual( (config.reqOpts!.mutations![0].upsert! as Entity) .excludeFromIndexes, - excludeFromIndexes + excludeFromIndexes, ); done(); }; @@ -2025,7 +2025,7 @@ async.each( data, excludeLargeProperties: true, }, - assert.ifError + assert.ifError, ); }); @@ -2046,7 +2046,7 @@ async.each( assert.deepStrictEqual( config.reqOpts!.mutations![0].upsert!.properties!.name .excludeFromIndexes, - true + true, ); done(); }; @@ -2057,7 +2057,7 @@ async.each( data, excludeLargeProperties: true, }, - assert.ifError + assert.ifError, ); }); @@ -2109,7 +2109,7 @@ async.each( assert.strictEqual(keyProtos[1], response.mutationResults[1].key); done(); - } + }, ); }); @@ -2129,7 +2129,7 @@ async.each( assert.strictEqual( typeof datastore.requestCallbacks_[0], - 'function' + 'function', ); assert.strictEqual(typeof datastore.requests_[0], 'object'); }); @@ -2349,7 +2349,7 @@ async.each( (err: Error | null | undefined, urlSafeKey: string) => { assert.ifError(err); assert.strictEqual(urlSafeKey, base64EndocdedUrlSafeKey); - } + }, ); }); @@ -2370,7 +2370,7 @@ async.each( (err: Error | null | undefined, urlSafeKey: string) => { assert.ifError(err); assert.strictEqual(urlSafeKey, base64EndocdedUrlSafeKey); - } + }, ); }); @@ -2385,7 +2385,7 @@ async.each( (err: Error | null | undefined, urlSafeKey: string) => { assert.strictEqual(err, error); assert.strictEqual(urlSafeKey, undefined); - } + }, ); }); }); @@ -2495,7 +2495,7 @@ async.each( // Mock out the request function to compare config passed into it. datastore.request_ = ( config: RequestConfig, - callback: RequestCallback + callback: RequestCallback, ) => { try { assert.deepStrictEqual(config, expectedConfig); @@ -2510,13 +2510,13 @@ async.each( const key = datastore.key(['Post', 'Post1']); const entities = Object.assign( {key}, - onSaveTest.entitiesWithoutKey + onSaveTest.entitiesWithoutKey, ); const results = await datastore.save(entities); assert.deepStrictEqual(results, ['some-data']); } }); - } + }, ); }); }); @@ -2529,7 +2529,7 @@ async.each( }); assert.strictEqual( otherDatastore.getDatabaseId(), - SECOND_DATABASE_ID + SECOND_DATABASE_ID, ); }); }); @@ -2661,13 +2661,13 @@ async.each( // Mock out the request function to compare config passed into it. datastore.request_ = ( config: RequestConfig, - callback: RequestCallback + callback: RequestCallback, ) => { assert.deepStrictEqual(config.client, 'DatastoreClient'); assert.deepStrictEqual(config.method, 'runQuery'); assert.deepStrictEqual( config.reqOpts?.explainOptions, - modeOptions.expectedExplainOptions + modeOptions.expectedExplainOptions, ); callback( null, @@ -2678,8 +2678,8 @@ async.each( moreResults: 'NO_MORE_RESULTS', }, }, - modeOptions.explainMetrics - ) + modeOptions.explainMetrics, + ), ); }; const ancestor = datastore.key(['Book', 'GoT']); @@ -2688,28 +2688,28 @@ async.each( .hasAncestor(ancestor); const [entities, info] = await datastore.runQuery( q, - modeOptions.options + modeOptions.options, ); assert.deepStrictEqual(entities, []); assert.deepStrictEqual( info, Object.assign( {moreResults: 'NO_MORE_RESULTS'}, - modeOptions.expectedInfo - ) + modeOptions.expectedInfo, + ), ); }); it('should provide correct request/response data for runAggregationQuery', async () => { // Mock out the request function to compare config passed into it. datastore.request_ = ( config: RequestConfig, - callback: RequestCallback + callback: RequestCallback, ) => { assert.deepStrictEqual(config.client, 'DatastoreClient'); assert.deepStrictEqual(config.method, 'runAggregationQuery'); assert.deepStrictEqual( config.reqOpts?.explainOptions, - modeOptions.expectedExplainOptions + modeOptions.expectedExplainOptions, ); callback( null, @@ -2720,8 +2720,8 @@ async.each( moreResults: 'NO_MORE_RESULTS', }, }, - modeOptions.explainMetrics - ) + modeOptions.explainMetrics, + ), ); }; const ancestor = datastore.key(['Book', 'GoT']); @@ -2733,15 +2733,15 @@ async.each( .addAggregation(AggregateField.sum('appearances')); const [entities, info] = await datastore.runAggregationQuery( aggregate, - modeOptions.options + modeOptions.options, ); assert.deepStrictEqual(entities, []); assert.deepStrictEqual(info, modeOptions.expectedInfo); }); }); - } + }, ); }); }); - } + }, ); diff --git a/test/query.ts b/test/query.ts index a6d32f696..7238a4433 100644 --- a/test/query.ts +++ b/test/query.ts @@ -86,7 +86,7 @@ describe('Query', () => { { alias: 'alias1', count: {}, - } + }, ); }); it('should produce the right proto with a sum aggregation', () => { @@ -100,7 +100,7 @@ describe('Query', () => { name: 'property1', }, }, - } + }, ); }); it('should produce the right proto with an average aggregation', () => { @@ -114,7 +114,7 @@ describe('Query', () => { }, }, operator: 'avg', - } + }, ); }); }); @@ -126,21 +126,21 @@ describe('Query', () => { function compareAggregations( aggregateQuery: AggregateQuery, - aggregateFields: AggregateField[] + aggregateFields: AggregateField[], ) { const addAggregationsAggregate = generateAggregateQuery(); addAggregationsAggregate.addAggregations(aggregateFields); const addAggregationAggregate = generateAggregateQuery(); aggregateFields.forEach(aggregateField => - addAggregationAggregate.addAggregation(aggregateField) + addAggregationAggregate.addAggregation(aggregateField), ); assert.deepStrictEqual( aggregateQuery.aggregations, - addAggregationsAggregate.aggregations + addAggregationsAggregate.aggregations, ); assert.deepStrictEqual( aggregateQuery.aggregations, - addAggregationAggregate.aggregations + addAggregationAggregate.aggregations, ); assert.deepStrictEqual(aggregateQuery.aggregations, aggregateFields); } @@ -149,8 +149,8 @@ describe('Query', () => { compareAggregations( generateAggregateQuery().count('total1').count('total2'), ['total1', 'total2'].map(alias => - AggregateField.count().alias(alias) - ) + AggregateField.count().alias(alias), + ), ); }); it('should compare equivalent sum aggregation queries', () => { @@ -161,7 +161,7 @@ describe('Query', () => { [ AggregateField.sum('property1').alias('alias1'), AggregateField.sum('property2').alias('alias2'), - ] + ], ); }); it('should compare equivalent average aggregation queries', () => { @@ -172,7 +172,7 @@ describe('Query', () => { [ AggregateField.average('property1').alias('alias1'), AggregateField.average('property2').alias('alias2'), - ] + ], ); }); }); @@ -180,13 +180,16 @@ describe('Query', () => { it('should compare equivalent count aggregation queries', () => { compareAggregations( generateAggregateQuery().count().count(), - ['total1', 'total2'].map(() => AggregateField.count()) + ['total1', 'total2'].map(() => AggregateField.count()), ); }); it('should compare equivalent sum aggregation queries', () => { compareAggregations( generateAggregateQuery().sum('property1').sum('property2'), - [AggregateField.sum('property1'), AggregateField.sum('property2')] + [ + AggregateField.sum('property1'), + AggregateField.sum('property2'), + ], ); }); it('should compare equivalent average aggregation queries', () => { @@ -197,7 +200,7 @@ describe('Query', () => { [ AggregateField.average('property1'), AggregateField.average('property2'), - ] + ], ); }); }); @@ -210,7 +213,7 @@ describe('Query', () => { const onWarning = (warning: {message: unknown}) => { assert.strictEqual( warning.message, - 'Providing Filter objects like Composite Filter or Property Filter is recommended when using .filter' + 'Providing Filter objects like Composite Filter or Property Filter is recommended when using .filter', ); process.removeListener('warning', onWarning); done(); @@ -294,7 +297,7 @@ describe('Query', () => { const query = new Query(['kind1']).filter( 'count', ' < ', - 123 + 123, ); assert.strictEqual(query.filters[0].op, '<'); @@ -331,7 +334,7 @@ describe('Query', () => { it('should support filter with Filter', () => { const now = new Date(); const query = new Query(['kind1']).filter( - new PropertyFilter('date', '<=', now) + new PropertyFilter('date', '<=', now), ); const filter = query.entityFilters[0]; @@ -345,7 +348,7 @@ describe('Query', () => { or([ new PropertyFilter('date', '<=', now), new PropertyFilter('name', '=', 'Stephen'), - ]) + ]), ); const filter = query.entityFilters[0]; assert.strictEqual(filter.op, 'OR'); @@ -362,11 +365,11 @@ describe('Query', () => { it('should accept null as value', () => { assert.strictEqual( new Query(['kind1']).filter('status', null).filters.pop()?.val, - null + null, ); assert.strictEqual( new Query(['kind1']).filter('status', '=', null).filters.pop()?.val, - null + null, ); }); }); @@ -603,14 +606,14 @@ describe('Query', () => { dataClient['commit'] = ( request: any, options: any, - callback: (err?: unknown) => void + callback: (err?: unknown) => void, ) => { try { assert.strictEqual(request.databaseId, SECOND_DATABASE_ID); assert.strictEqual(request.projectId, projectId); assert.strictEqual( options.headers['google-cloud-resource-prefix'], - `projects/${projectId}` + `projects/${projectId}`, ); } catch (e) { callback(e); diff --git a/test/request.ts b/test/request.ts index 600421c16..48f582381 100644 --- a/test/request.ts +++ b/test/request.ts @@ -113,7 +113,7 @@ describe('Request', () => { assert.notStrictEqual(preparedEntityObject.data.nested, obj.data.nested); assert.deepStrictEqual( preparedEntityObject, - expectedPreparedEntityObject + expectedPreparedEntityObject, ); }); @@ -123,7 +123,7 @@ describe('Request', () => { const entityObject: any = {data: true}; entityObject[entity.KEY_SYMBOL] = key; const preparedEntityObject = Request.prepareEntityObject_( - entityObject + entityObject, ) as Any; assert.strictEqual(preparedEntityObject.key, key); assert.strictEqual(preparedEntityObject.data.data, entityObject.data); @@ -218,7 +218,7 @@ describe('Request', () => { assert.strictEqual(keys, null); assert.strictEqual(resp, API_RESPONSE); done(); - } + }, ); }); }); @@ -251,7 +251,7 @@ describe('Request', () => { assert.deepStrictEqual(keys, [key]); assert.strictEqual(resp, API_RESPONSE); done(); - } + }, ); }); }); @@ -284,7 +284,7 @@ describe('Request', () => { assert.strictEqual(config.method, 'lookup'); assert.deepStrictEqual( config.reqOpts!.keys[0], - entity.keyToKeyProto(key) + entity.keyToKeyProto(key), ); done(); }; @@ -390,7 +390,7 @@ describe('Request', () => { .on('error', (err: Error) => { assert.deepStrictEqual( err, - outOfBoundsError({integerValue: largeInt, propertyName}) + outOfBoundsError({integerValue: largeInt, propertyName}), ); setImmediate(() => { assert.strictEqual(stream.destroyed, true); @@ -637,7 +637,7 @@ describe('Request', () => { assert.ifError(err); assert.deepStrictEqual(resp, apiResponse); done(); - } + }, ); }); @@ -786,7 +786,7 @@ describe('Request', () => { request.createReadStream.getCall(0).args[1]; assert.strictEqual( typeof createReadStreamOptions.wrapNumbers, - 'boolean' + 'boolean', ); done(); }); @@ -808,14 +808,14 @@ describe('Request', () => { request.createReadStream.getCall(0).args[1]; assert.strictEqual( createReadStreamOptions.wrapNumbers, - integerTypeCastOptions + integerTypeCastOptions, ); assert.deepStrictEqual( createReadStreamOptions.wrapNumbers, - integerTypeCastOptions + integerTypeCastOptions, ); done(); - } + }, ); }); }); @@ -876,7 +876,7 @@ describe('Request', () => { assert.strictEqual(config.reqOpts!.query, queryProto); assert.strictEqual( config.reqOpts!.partitionId!.namespaceId, - query.namespace + query.namespace, ); assert.strictEqual(config.gaxOpts, undefined); @@ -988,7 +988,7 @@ describe('Request', () => { .on('error', (err: Error) => { assert.deepStrictEqual( err, - outOfBoundsError({integerValue: largeInt, propertyName}) + outOfBoundsError({integerValue: largeInt, propertyName}), ); setImmediate(() => { assert.strictEqual(stream.destroyed, true); @@ -1122,7 +1122,7 @@ describe('Request', () => { sandbox.stub(entity, 'formatArray').callsFake(array => { assert.strictEqual( array, - entityResultsPerApiCall[timesRequestCalled] + entityResultsPerApiCall[timesRequestCalled], ); return entityResultsPerApiCall[timesRequestCalled]; }); @@ -1151,7 +1151,7 @@ describe('Request', () => { FakeQuery.prototype.start = function (endCursor) { assert.strictEqual( endCursor, - apiResponse.batch.endCursor.toString('base64') + apiResponse.batch.endCursor.toString('base64'), ); startCalled = true; return this; @@ -1168,7 +1168,7 @@ describe('Request', () => { if (timesRequestCalled === 1) { assert.strictEqual( limit_, - entityResultsPerApiCall[1].length - query.limitVal + entityResultsPerApiCall[1].length - query.limitVal, ); } else { // Should restore the original limit. @@ -1340,7 +1340,7 @@ describe('Request', () => { assert.strictEqual(spy.args[0], query); assert.strictEqual(spy.args[1], options); done(); - } + }, ); }); @@ -1380,14 +1380,14 @@ describe('Request', () => { const runQueryOptions = request.runQueryStream.getCall(0).args[1]; assert.strictEqual( runQueryOptions.wrapNumbers, - integerTypeCastOptions + integerTypeCastOptions, ); assert.deepStrictEqual( runQueryOptions.wrapNumbers, - integerTypeCastOptions + integerTypeCastOptions, ); done(); - } + }, ); }); }); @@ -1494,7 +1494,7 @@ describe('Request', () => { transaction.save = (modifiedData: PrepareEntityObjectResponse) => { assert.deepStrictEqual( modifiedData.data, - Object.assign({}, entityObject, updatedEntityObject) + Object.assign({}, entityObject, updatedEntityObject), ); }; @@ -1517,7 +1517,7 @@ describe('Request', () => { transaction.modifiedEntities_.forEach((entity, index) => { assert.deepStrictEqual( entity.args[0].data, - Object.assign({}, entityObject, updatedEntityObject[index]) + Object.assign({}, entityObject, updatedEntityObject[index]), ); }); return [{}] as CommitResponse; @@ -1528,7 +1528,7 @@ describe('Request', () => { {key, data: updatedEntityObject[0]}, {key, data: updatedEntityObject[1]}, ], - done + done, ); }); @@ -1725,7 +1725,7 @@ describe('Request', () => { (err: Error, requestFn: Function) => { assert.ifError(err); requestFn(); - } + }, ); }); }); @@ -1755,7 +1755,7 @@ describe('Request', () => { (err: Error, requestFn: Function) => { assert.ifError(err); requestFn(); - } + }, ); }); @@ -1776,7 +1776,7 @@ describe('Request', () => { (err: Error, requestFn: Function) => { assert.ifError(err); requestFn(); - } + }, ); }); @@ -1790,7 +1790,7 @@ describe('Request', () => { lookup(reqOpts: RequestOptions) { assert.strictEqual( reqOpts.readOptions!.transaction, - TRANSACTION_ID + TRANSACTION_ID, ); done(); }, @@ -1801,7 +1801,7 @@ describe('Request', () => { (err: Error, requestFn: Function) => { assert.ifError(err); requestFn(); - } + }, ); }); @@ -1815,7 +1815,7 @@ describe('Request', () => { runQuery(reqOpts: RequestOptions) { assert.strictEqual( reqOpts.readOptions!.transaction, - TRANSACTION_ID + TRANSACTION_ID, ); done(); }, @@ -1826,7 +1826,7 @@ describe('Request', () => { (err: Error, requestFn: Function) => { assert.ifError(err); requestFn(); - } + }, ); }); diff --git a/test/transaction.ts b/test/transaction.ts index 965ee6b14..4da7bdb17 100644 --- a/test/transaction.ts +++ b/test/transaction.ts @@ -197,12 +197,12 @@ async.each( // This is useful for tests that need to know when the mocked function is called. callBackSignaler: ( callbackReached: GapicFunctionName, - request?: RequestType + request?: RequestType, ) => void = () => {}; constructor( err: Error | null = null, - resp: google.datastore.v1.IBeginTransactionResponse = testRunResp + resp: google.datastore.v1.IBeginTransactionResponse = testRunResp, ) { const namespace = 'run-without-mock'; const projectId = 'project-id'; @@ -223,7 +223,7 @@ async.each( // Datastore Gapic clients haven't been initialized yet, so we initialize them here. datastore.clients_.set( dataClientName, - new gapic.v1[dataClientName](options) + new gapic.v1[dataClientName](options), ); const dataClient = datastore.clients_.get(dataClientName); // Mock begin transaction @@ -241,13 +241,13 @@ async.each( | null | undefined, {} | null | undefined - > + >, ) => { // Calls a user provided function that will receive this string // Usually used to track when this code was reached relative to other code this.callBackSignaler( GapicFunctionName.BEGIN_TRANSACTION, - request + request, ); callback(err, resp); }; @@ -262,7 +262,7 @@ async.each( mockGapicFunction( functionName: GapicFunctionName, response: ResponseType, - error: Error | null + error: Error | null, ) { const dataClient = this.dataClient; // Check here that function hasn't been mocked out already @@ -286,7 +286,7 @@ async.each( ResponseType, RequestType | null | undefined, {} | null | undefined - > + >, ) => { this.callBackSignaler(functionName, request); callback(error, response); @@ -327,7 +327,7 @@ async.each( beforeEach(async () => { transactionWrapper = new MockedTransactionWrapper( new Error(testErrorMessage), - undefined + undefined, ); }); it('should send back the error when awaiting a promise', async () => { @@ -341,7 +341,7 @@ async.each( it('should send back the error when using a callback', done => { const commitCallback: CommitCallback = ( error: Error | null | undefined, - response?: google.datastore.v1.ICommitResponse + response?: google.datastore.v1.ICommitResponse, ) => { try { assert(error); @@ -382,7 +382,7 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.COMMIT, testCommitResp, - new Error(testErrorMessage) + new Error(testErrorMessage), ); }); @@ -398,7 +398,7 @@ async.each( it('should send back the error when using a callback', done => { const commitCallback: CommitCallback = ( error: Error | null | undefined, - response?: google.datastore.v1.ICommitResponse + response?: google.datastore.v1.ICommitResponse, ) => { try { assert(error); @@ -419,7 +419,7 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.COMMIT, testCommitResp, - null + null, ); }); it('should send back the response when awaiting a promise', async () => { @@ -431,7 +431,7 @@ async.each( it('should send back the response when using a callback', done => { const commitCallback: CommitCallback = ( error: Error | null | undefined, - response?: google.datastore.v1.ICommitResponse + response?: google.datastore.v1.ICommitResponse, ) => { try { assert.strictEqual(error, null); @@ -489,7 +489,7 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.RUN_AGGREGATION_QUERY, runAggregationQueryResp, - new Error(testErrorMessage) + new Error(testErrorMessage), ); }); @@ -505,7 +505,7 @@ async.each( it('should send back the error when using a callback', done => { const runAggregateQueryCallback: RequestCallback = ( error: Error | null | undefined, - response?: unknown + response?: unknown, ) => { try { assert(error); @@ -519,7 +519,7 @@ async.each( transaction.run(() => { transaction.runAggregationQuery( aggregate, - runAggregateQueryCallback + runAggregateQueryCallback, ); }); }); @@ -529,7 +529,7 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.RUN_AGGREGATION_QUERY, runAggregationQueryResp, - null + null, ); }); it('should send back the response when awaiting a promise', async () => { @@ -539,13 +539,13 @@ async.each( const [runAggregateQueryResults] = allResults; assert.deepStrictEqual( runAggregateQueryResults, - runAggregationQueryUserResp + runAggregationQueryUserResp, ); }); it('should send back the response when using a callback', done => { const runAggregateQueryCallback: CommitCallback = ( error: Error | null | undefined, - response?: unknown + response?: unknown, ) => { try { assert.strictEqual(error, null); @@ -558,7 +558,7 @@ async.each( transaction.run(() => { transaction.runAggregationQuery( aggregate, - runAggregateQueryCallback + runAggregateQueryCallback, ); }); }); @@ -594,7 +594,7 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.RUN_QUERY, runQueryResp, - new Error(testErrorMessage) + new Error(testErrorMessage), ); }); @@ -611,7 +611,7 @@ async.each( const callback: RunQueryCallback = ( error: Error | null | undefined, entities?: Entity[], - info?: RunQueryInfo + info?: RunQueryInfo, ) => { try { assert(error); @@ -633,7 +633,7 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.RUN_QUERY, runQueryResp, - null + null, ); }); it('should send back the response when awaiting a promise', async () => { @@ -646,7 +646,7 @@ async.each( const callback: RunQueryCallback = ( error: Error | null | undefined, entities?: Entity[], - info?: RunQueryInfo + info?: RunQueryInfo, ) => { try { assert.strictEqual(error, null); @@ -711,7 +711,7 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.LOOKUP, getResp, - new Error(testErrorMessage) + new Error(testErrorMessage), ); }); @@ -727,7 +727,7 @@ async.each( it('should send back the error when using a callback', done => { const callback: GetCallback = ( err?: Error | null, - entity?: Entities + entity?: Entities, ) => { try { assert(err); @@ -748,7 +748,7 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.LOOKUP, getResp, - null + null, ); }); it('should send back the response when awaiting a promise', async () => { @@ -760,7 +760,7 @@ async.each( it('should send back the response when using a callback', done => { const callback: GetCallback = ( err?: Error | null, - entity?: Entities + entity?: Entities, ) => { try { const result = entity[transactionWrapper.datastore.KEY]; @@ -938,12 +938,12 @@ async.each( try { assert.deepStrictEqual( this.eventOrder, - this.expectedEventOrder + this.expectedEventOrder, ); if (this.expectedRequests) { assert.deepStrictEqual( this.requests, - this.expectedRequests + this.expectedRequests, ); } this.#done(); @@ -960,14 +960,14 @@ async.each( expectedRequests?: { call: GapicFunctionName; request?: RequestType; - }[] + }[], ) { this.expectedEventOrder = expectedOrder; this.expectedRequests = expectedRequests; this.#done = done; transactionWrapper.callBackSignaler = ( call: GapicFunctionName, - request?: RequestType + request?: RequestType, ) => { try { this.requests.push({call, request}); @@ -1003,7 +1003,7 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.COMMIT, testCommitResp, - null + null, ); }); @@ -1017,7 +1017,7 @@ async.each( UserCodeEvent.RUN_CALLBACK, GapicFunctionName.COMMIT, UserCodeEvent.COMMIT_CALLBACK, - ] + ], ); transaction.run(tester.push(UserCodeEvent.RUN_CALLBACK)); transaction.commit(tester.push(UserCodeEvent.COMMIT_CALLBACK)); @@ -1032,7 +1032,7 @@ async.each( GapicFunctionName.BEGIN_TRANSACTION, GapicFunctionName.COMMIT, UserCodeEvent.COMMIT_CALLBACK, - ] + ], ); transaction.commit(tester.push(UserCodeEvent.COMMIT_CALLBACK)); tester.push(UserCodeEvent.CUSTOM_EVENT)(); @@ -1046,7 +1046,7 @@ async.each( GapicFunctionName.BEGIN_TRANSACTION, UserCodeEvent.RUN_CALLBACK, UserCodeEvent.RUN_CALLBACK, - ] + ], ); transaction.run(tester.push(UserCodeEvent.RUN_CALLBACK)); transaction.run(tester.push(UserCodeEvent.RUN_CALLBACK)); @@ -1062,7 +1062,7 @@ async.each( UserCodeEvent.RUN_CALLBACK, GapicFunctionName.COMMIT, UserCodeEvent.COMMIT_CALLBACK, - ] + ], ); transaction.commit(tester.push(UserCodeEvent.COMMIT_CALLBACK)); transaction.run(tester.push(UserCodeEvent.RUN_CALLBACK)); @@ -1076,22 +1076,22 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.COMMIT, testCommitResp, - null + null, ); transactionWrapper.mockGapicFunction( GapicFunctionName.LOOKUP, testLookupResp, - null + null, ); transactionWrapper.mockGapicFunction( GapicFunctionName.RUN_QUERY, testRunQueryResp, - null + null, ); transactionWrapper.mockGapicFunction( GapicFunctionName.RUN_AGGREGATION_QUERY, testRunAggregationQueryResp, - null + null, ); }); const beginTransactionRequest = { @@ -1181,7 +1181,7 @@ async.each( GapicFunctionName.COMMIT, UserCodeEvent.COMMIT_CALLBACK, ], - expectedRequests + expectedRequests, ); transaction.save({ key, @@ -1199,7 +1199,7 @@ async.each( GapicFunctionName.COMMIT, UserCodeEvent.COMMIT_CALLBACK, ], - expectedRequests + expectedRequests, ); transaction.save({ key, @@ -1241,7 +1241,7 @@ async.each( UserCodeEvent.GET_CALLBACK, UserCodeEvent.GET_CALLBACK, ], - expectedRequests + expectedRequests, ); transaction.get(key, tester.push(UserCodeEvent.GET_CALLBACK)); transaction.get(key, tester.push(UserCodeEvent.GET_CALLBACK)); @@ -1283,7 +1283,7 @@ async.each( UserCodeEvent.GET_CALLBACK, UserCodeEvent.GET_CALLBACK, ], - expectedRequests + expectedRequests, ); transaction.run(tester.push(UserCodeEvent.RUN_CALLBACK)); transaction.get(key, tester.push(UserCodeEvent.GET_CALLBACK)); @@ -1385,22 +1385,22 @@ async.each( transactionWrapper.mockGapicFunction( GapicFunctionName.RUN_AGGREGATION_QUERY, runAggregationQueryResp, - null + null, ); transactionWrapper.mockGapicFunction( GapicFunctionName.LOOKUP, getResp, - null + null, ); transactionWrapper.mockGapicFunction( GapicFunctionName.RUN_QUERY, runQueryResp, - null + null, ); transactionWrapper.mockGapicFunction( GapicFunctionName.COMMIT, testCommitResp, - null + null, ); }); describe('lookup, lookup, put, commit', () => { @@ -1410,13 +1410,13 @@ async.each( // It ensures the data that reaches the gapic layer is correct. transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType + request?: RequestType, ) => { try { switch (callbackReached) { case GapicFunctionName.BEGIN_TRANSACTION: throw Error( - 'BeginTransaction should not have been called' + 'BeginTransaction should not have been called', ); case GapicFunctionName.LOOKUP: { const lookupRequest = @@ -1444,18 +1444,18 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL' + 'TRANSACTIONAL', ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction + testRunResp.transaction, ); done(); break; } default: throw Error( - 'A gapic function was called that should not have been called' + 'A gapic function was called that should not have been called', ); } } catch (err: any) { @@ -1480,7 +1480,7 @@ async.each( // It ensures the data that reaches the gapic layer is correct. transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType + request?: RequestType, ) => { try { switch (callbackReached) { @@ -1504,11 +1504,11 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL' + 'TRANSACTIONAL', ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction + testRunResp.transaction, ); assert.strictEqual(beginCount, 1); done(); @@ -1516,7 +1516,7 @@ async.each( } default: throw Error( - 'A gapic function was called that should not have been called' + 'A gapic function was called that should not have been called', ); } } catch (err: any) { @@ -1543,13 +1543,13 @@ async.each( // It ensures the data that reaches the gapic layer is correct. transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType + request?: RequestType, ) => { try { switch (callbackReached) { case GapicFunctionName.BEGIN_TRANSACTION: throw Error( - 'BeginTransaction should not have been called' + 'BeginTransaction should not have been called', ); case GapicFunctionName.LOOKUP: { const lookupRequest = @@ -1573,18 +1573,18 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL' + 'TRANSACTIONAL', ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction + testRunResp.transaction, ); done(); break; } default: throw Error( - 'A gapic function was called that should not have been called' + 'A gapic function was called that should not have been called', ); } } catch (err: any) { @@ -1611,7 +1611,7 @@ async.each( // It ensures the data that reaches the gapic layer is correct. transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType + request?: RequestType, ) => { try { switch (callbackReached) { @@ -1643,11 +1643,11 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL' + 'TRANSACTIONAL', ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction + testRunResp.transaction, ); assert.strictEqual(beginCount, 1); done(); @@ -1655,7 +1655,7 @@ async.each( } default: throw Error( - 'A gapic function was called that should not have been called' + 'A gapic function was called that should not have been called', ); } } catch (err: any) { @@ -1684,13 +1684,13 @@ async.each( // It ensures the data that reaches the gapic layer is correct. transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType + request?: RequestType, ) => { try { switch (callbackReached) { case GapicFunctionName.BEGIN_TRANSACTION: throw Error( - 'BeginTransaction should not have been called' + 'BeginTransaction should not have been called', ); case GapicFunctionName.LOOKUP: { const lookupRequest = @@ -1708,7 +1708,7 @@ async.each( { newTransaction: {}, consistencyType: 'newTransaction', - } + }, ); break; } @@ -1717,18 +1717,18 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL' + 'TRANSACTIONAL', ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction + testRunResp.transaction, ); done(); break; } default: throw Error( - 'A gapic function was called that should not have been called' + 'A gapic function was called that should not have been called', ); } } catch (err: any) { @@ -1758,7 +1758,7 @@ async.each( // It ensures the data that reaches the gapic layer is correct. transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType + request?: RequestType, ) => { try { switch (callbackReached) { @@ -1784,7 +1784,7 @@ async.each( runAggregationQueryRequest.readOptions, { transaction: testRunResp.transaction, - } + }, ); break; } @@ -1793,11 +1793,11 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL' + 'TRANSACTIONAL', ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction + testRunResp.transaction, ); assert.strictEqual(beginCount, 1); done(); @@ -1805,7 +1805,7 @@ async.each( } default: throw Error( - 'A gapic function was called that should not have been called' + 'A gapic function was called that should not have been called', ); } } catch (err: any) { @@ -1837,13 +1837,13 @@ async.each( // It ensures the data that reaches the gapic layer is correct. transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType + request?: RequestType, ) => { try { switch (callbackReached) { case GapicFunctionName.BEGIN_TRANSACTION: throw Error( - 'BeginTransaction should not have been called' + 'BeginTransaction should not have been called', ); case GapicFunctionName.LOOKUP: { const lookupRequest = @@ -1859,18 +1859,18 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL' + 'TRANSACTIONAL', ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction + testRunResp.transaction, ); done(); break; } default: throw Error( - 'A gapic function was called that should not have been called' + 'A gapic function was called that should not have been called', ); } } catch (err: any) { @@ -1895,7 +1895,7 @@ async.each( // It ensures the data that reaches the gapic layer is correct. transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType + request?: RequestType, ) => { try { switch (callbackReached) { @@ -1919,11 +1919,11 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL' + 'TRANSACTIONAL', ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction + testRunResp.transaction, ); assert.strictEqual(beginCount, 1); done(); @@ -1931,7 +1931,7 @@ async.each( } default: throw Error( - 'A gapic function was called that should not have been called' + 'A gapic function was called that should not have been called', ); } } catch (err: any) { @@ -1959,7 +1959,7 @@ async.each( // It ensures the data that reaches the gapic layer is correct. transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType + request?: RequestType, ) => { try { switch (callbackReached) { @@ -1975,11 +1975,11 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL' + 'TRANSACTIONAL', ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction + testRunResp.transaction, ); assert.strictEqual(beginCount, 1); done(); @@ -1987,7 +1987,7 @@ async.each( } default: throw Error( - 'A gapic function was called that should not have been called' + 'A gapic function was called that should not have been called', ); } } catch (err: any) { @@ -2010,7 +2010,7 @@ async.each( let beginCount = 0; transactionWrapper.callBackSignaler = ( callbackReached: GapicFunctionName, - request?: RequestType + request?: RequestType, ) => { try { switch (callbackReached) { @@ -2034,11 +2034,11 @@ async.each( request as protos.google.datastore.v1.ICommitRequest; assert.deepStrictEqual( commitRequest.mode, - 'TRANSACTIONAL' + 'TRANSACTIONAL', ); assert.deepStrictEqual( commitRequest.transaction, - testRunResp.transaction + testRunResp.transaction, ); assert.strictEqual(beginCount, 1); done(); @@ -2046,7 +2046,7 @@ async.each( } default: throw Error( - 'A gapic function was called that should not have been called' + 'A gapic function was called that should not have been called', ); } } catch (err: any) { @@ -2097,7 +2097,7 @@ async.each( // Datastore Gapic clients haven't been initialized yet, so we initialize them here. datastore.clients_.set( dataClientName, - new gapic.v1[dataClientName](options) + new gapic.v1[dataClientName](options), ); dataClient = datastore.clients_.get(dataClientName); if (dataClient && dataClient.beginTransaction) { @@ -2124,7 +2124,7 @@ async.each( | null | undefined, {} | null | undefined - > + >, ) => { callback(err, testRunResp); }; @@ -2150,7 +2150,7 @@ async.each( const runCallback: RunCallback = ( error: Error | null, transaction: Transaction | null, - response?: google.datastore.v1.IBeginTransactionResponse + response?: google.datastore.v1.IBeginTransactionResponse, ) => { try { assert(error); @@ -2180,7 +2180,7 @@ async.each( const runCallback: RunCallback = ( error: Error | null, transaction: Transaction | null, - response?: google.datastore.v1.IBeginTransactionResponse + response?: google.datastore.v1.IBeginTransactionResponse, ) => { try { assert.strictEqual(error, null); @@ -2496,7 +2496,7 @@ async.each( // the rollback function to reach request_. transaction.request_ = ( config: RequestConfig, - callback: RequestCallback + callback: RequestCallback, ) => { callback(null, {transaction: Buffer.from(TRANSACTION_ID)}); }; @@ -2603,7 +2603,7 @@ async.each( transaction.request_ = (config: Any) => { assert.deepStrictEqual( config.reqOpts.transactionOptions.readOnly, - {} + {}, ); done(); }; @@ -2617,7 +2617,7 @@ async.each( transaction.request_ = config => { assert.deepStrictEqual( config.reqOpts!.transactionOptions!.readOnly, - {} + {}, ); done(); }; @@ -2637,7 +2637,7 @@ async.each( config.reqOpts!.transactionOptions!.readWrite, { previousTransaction: options.transactionId, - } + }, ); done(); }; @@ -2653,7 +2653,7 @@ async.each( config.reqOpts!.transactionOptions!.readWrite, { previousTransaction: transaction.id, - } + }, ); done(); }; @@ -2749,7 +2749,7 @@ async.each( transaction.save(entities); assert.strictEqual( transaction.modifiedEntities_.length, - entities.length + entities.length, ); transaction.modifiedEntities_.forEach((queuedEntity: Entity) => { assert.strictEqual(queuedEntity.method, 'save'); @@ -2855,7 +2855,7 @@ async.each( }); }); }); - } + }, ); describe('getTransactionRequest', () => {