From 115a2c99023a30060145f88040d1c1a2a25c29fb Mon Sep 17 00:00:00 2001 From: blagoev Date: Tue, 12 Sep 2017 20:38:43 +0300 Subject: [PATCH] add deprecated warnings --- lib/index.d.ts | 20 +++++++++++++++++--- lib/user-methods.js | 12 ++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/index.d.ts b/lib/index.d.ts index 242174eb..5066dbb2 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -264,12 +264,25 @@ declare namespace Realm.Sync { readonly server: string; readonly token: string; static adminUser(adminToken: string, server?: string): User; - static login(server: string, username: string, password: string): Promise; + + /** + * @deprecated, to be removed in future versions + */ static login(server: string, username: string, password: string, callback: (error: any, user: User) => void): void; - static register(server: string, username: string, password: string): Promise; + static login(server: string, username: string, password: string): Promise; + + /** + * @deprecated, to be removed in future versions + */ static register(server: string, username: string, password: string, callback: (error: any, user: User) => void): void; - static registerWithProvider(server: string, options: { provider: string, providerToken: string, userInfo: any }): Promise; + static register(server: string, username: string, password: string): Promise; + + /** + * @deprecated, to be removed in versions + */ static registerWithProvider(server: string, options: { provider: string, providerToken: string, userInfo: any }, callback: (error: Error | null, user: User | null) => void): void; + static registerWithProvider(server: string, options: { provider: string, providerToken: string, userInfo: any }): Promise; + logout(): void; openManagementRealm(): Realm; retrieveAccount(provider: string, username: string): Promise; @@ -377,6 +390,7 @@ declare namespace Realm.Sync { function removeListener(regex: string, name: string, changeCallback: (changeEvent: ChangeEvent) => void): void; function setLogLevel(logLevel: 'all' | 'trace' | 'debug' | 'detail' | 'info' | 'warn' | 'error' | 'fatal' | 'off'): void; function setFeatureToken(token: string): void; + /** * @deprecated, to be removed in 2.0 */ diff --git a/lib/user-methods.js b/lib/user-methods.js index 16335c39..4035bc85 100644 --- a/lib/user-methods.js +++ b/lib/user-methods.js @@ -189,6 +189,10 @@ const staticMethods = { data: username }; + if (callback) { + const message = "register(..., callback) is now deprecated in favor of register(): Promise. This function argument will be removed in future versions."; + (console.warn || console.log).call(console, message); + } _authenticate(this, server, json, callback); }, @@ -201,6 +205,10 @@ const staticMethods = { data: username }; + if (callback) { + const message = "login(..., callback) is now deprecated in favor of login(): Promise. This function argument will be removed in future versions."; + (console.warn || console.log).call(console, message); + } _authenticate(this, server, json, callback); }, @@ -228,6 +236,10 @@ const staticMethods = { json.user_info = options.userInfo; } + if (callback) { + const message = "registerWithProvider(..., callback) is now deprecated in favor of registerWithProvider(): Promise. This function argument will be removed in future versions."; + (console.warn || console.log).call(console, message); + } _authenticate(this, server, json, callback); },