From 20bad0bb87a4e42c981128ca3354818ca919b437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?antoine=20beau=E1=B5=9B=E1=B5=83=E1=B4=B5=CB=A2=E2=81=BBla?= =?UTF-8?q?c=E1=B5=83=CB=A2=CB=A2=E1=B5=89?= Date: Tue, 2 Jan 2018 15:43:28 -0500 Subject: [PATCH] [@google-cloud/datastore]: Update definitions for v1.3 (#22504) --- .../google-cloud__datastore-tests.ts | 5 ++++ types/google-cloud__datastore/index.d.ts | 24 +++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/types/google-cloud__datastore/google-cloud__datastore-tests.ts b/types/google-cloud__datastore/google-cloud__datastore-tests.ts index 285cb1fb00..3093a8256a 100644 --- a/types/google-cloud__datastore/google-cloud__datastore-tests.ts +++ b/types/google-cloud__datastore/google-cloud__datastore-tests.ts @@ -35,12 +35,17 @@ ds.determineBaseUrl_('http://localhost:8081'); // Keys components creation: const dsInt: DatastoreInt = ds.int(42); +const isInt = ds.isInt(dsInt); const dsDouble: DatastoreDouble = ds.double('3.14'); +const isDouble = ds.isDouble(dsDouble); + const dsGeopoint: DatastoreGeopoint = ds.geoPoint({latitude: 0, longitude: 0}); +const isGeoPoint = ds.isGeoPoint(dsGeopoint); // Keys creation: const keyPath: DatastoreKeyPath = [kind, 'Google', 'Department', dsInt]; const key: DatastoreKey = ds.key(keyPath); +const isKey = ds.isKey(key); const ancestorKey: DatastoreKey = ds.key(['ParentCompany', 'Alphabet']); const keyWithOptions: DatastoreKey = ds.key({ namespace: 'special-namespace', diff --git a/types/google-cloud__datastore/index.d.ts b/types/google-cloud__datastore/index.d.ts index a8e64839e6..8c9cdd23c3 100644 --- a/types/google-cloud__datastore/index.d.ts +++ b/types/google-cloud__datastore/index.d.ts @@ -1,5 +1,5 @@ -// Type definitions for @google-cloud/datastore 1.1 -// Project: https://github.com/GoogleCloudPlatform/google-cloud-node/tree/master/packages/datastore +// Type definitions for @google-cloud/datastore 1.3 +// Project: https://github.com/googleapis/nodejs-datastore // Definitions by: Antoine Beauvais-Lacasse // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -20,7 +20,11 @@ declare module '@google-cloud/datastore' { DatastoreCoords, OneOrMany } from '@google-cloud/datastore/entity'; - import { DatastoreRequest as DatastoreRequest_, CommitCallback, CommitResult } from '@google-cloud/datastore/request'; + import { + DatastoreRequest as DatastoreRequest_, + CommitCallback, + CommitResult + } from '@google-cloud/datastore/request'; import { Query as DatastoreQuery, MoreResultsAfterCursor, @@ -51,12 +55,20 @@ declare module '@google-cloud/datastore' { int(value: string | number): DatastoreInt; + isInt(value: any): value is DatastoreInt; + double(value: string | number): DatastoreDouble; + isDouble(value: any): value is DatastoreDouble; + geoPoint(coordinates: DatastoreCoords): DatastoreGeopoint; + isGeoPoint(value: any): value is DatastoreGeopoint; + key(pathOrOptions: DatastoreKeyPath | DatastoreKeyOptions): DatastoreKey; + isKey(value: any): value is DatastoreKey; + determineBaseUrl_(customApiEndpoint?: string): void; } @@ -84,6 +96,7 @@ declare module '@google-cloud/datastore/entity' { interface DatastoreInt { value: string; } + interface DatastoreDouble { value: string; } @@ -92,6 +105,7 @@ declare module '@google-cloud/datastore/entity' { latitude: number; longitude: number; } + interface DatastoreGeopoint { value: DatastoreCoords; } @@ -297,6 +311,8 @@ declare module '@google-cloud/datastore/transaction' { type RollbackCallback = (err: Error, rollbackResponse: {}) => void; type RollbackResult = [{}]; - type TransactionCallback = (err: Error, tx: DatastoreTransaction, beginTxResponse: BeginTransactionResponse) => void; + type TransactionCallback = (err: Error, + tx: DatastoreTransaction, + beginTxResponse: BeginTransactionResponse) => void; type TransactionResult = [DatastoreTransaction, BeginTransactionResponse]; }