From 978e014695481c2d770386d0996e004d3ab4e1e1 Mon Sep 17 00:00:00 2001 From: Pierre Cauchois Date: Wed, 28 Nov 2018 19:48:23 -0800 Subject: [PATCH] Fix a couple of typos that snuck in #434 --- common/core/src/promise_utils.ts | 2 -- provisioning/service/src/provisioningserviceclient.ts | 4 ++-- security/tpm/src/tpm_authentication_provider.ts | 10 +++++++--- service/src/job_client.ts | 2 +- service/src/registry.ts | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/common/core/src/promise_utils.ts b/common/core/src/promise_utils.ts index bdefcc3df..fa15ad790 100644 --- a/common/core/src/promise_utils.ts +++ b/common/core/src/promise_utils.ts @@ -69,8 +69,6 @@ export type HttpResponseCallback = TripleValueCallback; * const param = 42; * callbackToPromise((_callback) => foo(param, _callback)).then(result => { console.log(result); }, error => { console.error(error); }); */ -export function callbackToPromise(callBackOperation: (callback: Callback) => void, userCallback: Callback): void; -export function callbackToPromise(callBackOperation: (callback: Callback) => void): Promise; export function callbackToPromise(callBackOperation: (callback: Callback) => void, userCallback?: Callback): Promise | void { if (userCallback) { if (!(typeof userCallback === 'function')) { diff --git a/provisioning/service/src/provisioningserviceclient.ts b/provisioning/service/src/provisioningserviceclient.ts index 134cb5805..19f35db33 100644 --- a/provisioning/service/src/provisioningserviceclient.ts +++ b/provisioning/service/src/provisioningserviceclient.ts @@ -64,7 +64,7 @@ export class ProvisioningServiceClient { */ public deleteIndividualEnrollment(enrollmentOrId: string | IndividualEnrollment, etag: string, deleteCallback: ErrorCallback): void; public deleteIndividualEnrollment(enrollmentOrId: string | IndividualEnrollment, deleteCallback: ErrorCallback): void; - public deleteIndividualEnrollment(enrollmentOrId: string | IndividualEnrollment, etagOr: string): Promise; + public deleteIndividualEnrollment(enrollmentOrId: string | IndividualEnrollment, etag: string): Promise; public deleteIndividualEnrollment(enrollmentOrId: string | IndividualEnrollment): Promise; public deleteIndividualEnrollment(enrollmentOrId: string | IndividualEnrollment, etagOrCallback?: string | ErrorCallback, deleteCallback?: ErrorCallback): Promise | void { if (deleteCallback && !(typeof deleteCallback === 'function')) { @@ -254,7 +254,7 @@ export class ProvisioningServiceClient { */ public deleteDeviceRegistrationState(idOrRegistrationState: string | DeviceRegistrationState, etag: string, deleteCallback: ErrorCallback): void; public deleteDeviceRegistrationState(idOrRegistrationState: string | DeviceRegistrationState, deleteCallback: ErrorCallback): void; - public deleteDeviceRegistrationState(idOrRegistrationState: string | DeviceRegistrationState, etagOrCallback: string): Promise; + public deleteDeviceRegistrationState(idOrRegistrationState: string | DeviceRegistrationState, etag: string): Promise; public deleteDeviceRegistrationState(idOrRegistrationState: string | DeviceRegistrationState): Promise; public deleteDeviceRegistrationState(idOrRegistrationState: string | DeviceRegistrationState, etagOrCallback?: string | ErrorCallback, deleteCallback?: ErrorCallback): Promise | void { if (deleteCallback && !(typeof deleteCallback === 'function')) { diff --git a/security/tpm/src/tpm_authentication_provider.ts b/security/tpm/src/tpm_authentication_provider.ts index 988140f27..0bf8dcf37 100644 --- a/security/tpm/src/tpm_authentication_provider.ts +++ b/security/tpm/src/tpm_authentication_provider.ts @@ -3,7 +3,7 @@ const debug = dbg('azure-iot-device:TPMAuthenticationProvider'); import { EventEmitter } from 'events'; import * as machina from 'machina'; -import { AuthenticationType, SharedAccessSignature, errors, TransportConfig, AuthenticationProvider } from 'azure-iot-common'; +import { AuthenticationType, SharedAccessSignature, errors, TransportConfig, AuthenticationProvider, Callback, callbackToPromise } from 'azure-iot-common'; import { TpmSecurityClient } from './tpm'; /** @@ -106,8 +106,12 @@ export class TpmAuthenticationProvider extends EventEmitter implements Authentic }); } - getDeviceCredentials(callback: (err: Error, credentials?: TransportConfig) => void): void { - this._fsm.handle('getDeviceCredentials', callback); + getDeviceCredentials(): Promise; + getDeviceCredentials(callback: Callback): void; + getDeviceCredentials(callback?: Callback): void | Promise { + return callbackToPromise((_callback) => { + this._fsm.handle('getDeviceCredentials', _callback); + }, callback); } updateSharedAccessSignature(sharedAccessSignature: string): void { diff --git a/service/src/job_client.ts b/service/src/job_client.ts index fd5647cdf..36daed3e9 100644 --- a/service/src/job_client.ts +++ b/service/src/job_client.ts @@ -266,7 +266,7 @@ export class JobClient { scheduleTwinUpdate(jobId: string | number, queryCondition: string, patch: any, jobStartTime: Date, maxExecutionTimeInSeconds: number, done: TripleValueCallback): void; scheduleTwinUpdate(jobId: string | number, queryCondition: string, patch: any, jobStartTime: Date, done: TripleValueCallback): void; scheduleTwinUpdate(jobId: string | number, queryCondition: string, patch: any, done: TripleValueCallback): void; - scheduleTwinUpdate(jobId: string | number, queryCondition: string, patch: any, jobStartTime: Date, maxExecutionTimeInSeconds?: number | TripleValueCallback): Promise; + scheduleTwinUpdate(jobId: string | number, queryCondition: string, patch: any, jobStartTime: Date, maxExecutionTimeInSeconds?: number): Promise; scheduleTwinUpdate(jobId: string | number, queryCondition: string, patch: any, jobStartTime: Date): Promise; scheduleTwinUpdate(jobId: string | number, queryCondition: string, patch: any): Promise; scheduleTwinUpdate(jobId: string | number, queryCondition: string, patch: any, jobStartTime?: Date | TripleValueCallback, maxExecutionTimeInSeconds?: number | TripleValueCallback, done?: TripleValueCallback): Promise | void { diff --git a/service/src/registry.ts b/service/src/registry.ts index 2501173cf..d08104bb5 100644 --- a/service/src/registry.ts +++ b/service/src/registry.ts @@ -410,7 +410,7 @@ export class Registry { * an error happened, (null otherwise) and the job status that can be used to track progress of the devices export. * @returns {Promise | void} Promise if no callback function was passed, void otherwise. */ - exportDevicesToBlob(outputBlobContainerUri: string, excludeKeys: boolean, done: Callback): void; + exportDevicesToBlob(outputBlobContainerUri: string, excludeKeys: boolean, done: Callback): void; exportDevicesToBlob(outputBlobContainerUri: string, excludeKeys: boolean): Promise; exportDevicesToBlob(outputBlobContainerUri: string, excludeKeys: boolean, done?: Callback): Promise | void { return callbackToPromise((_callback) => {