Merge pull request #1807 from strongloop/fix/datasource-typings
Fix Promise/Callback variants in datasource types
This commit is contained in:
commit
c555dedfeb
|
@ -3,7 +3,7 @@
|
||||||
// This file is licensed under the MIT License.
|
// This file is licensed under the MIT License.
|
||||||
// License text available at https://opensource.org/licenses/MIT
|
// License text available at https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
import {AnyObject, Callback, Options, PromiseOrVoid} from './common';
|
import {AnyObject, Callback, Options} from './common';
|
||||||
import {Connector} from './connector';
|
import {Connector} from './connector';
|
||||||
import {
|
import {
|
||||||
ModelBaseClass,
|
ModelBaseClass,
|
||||||
|
@ -140,56 +140,138 @@ export declare class DataSource extends EventEmitter {
|
||||||
*/
|
*/
|
||||||
attach(modelClass: ModelBaseClass): ModelBaseClass;
|
attach(modelClass: ModelBaseClass): ModelBaseClass;
|
||||||
|
|
||||||
automigrate(models: string | string[], callback?: Callback): PromiseOrVoid;
|
automigrate(models: string | string[]): Promise<void>;
|
||||||
|
// legacy callback style
|
||||||
|
automigrate(models: string | string[], callback: Callback): void;
|
||||||
|
|
||||||
autoupdate(models: string | string[], callback?: Callback): PromiseOrVoid;
|
autoupdate(models: string | string[]): Promise<void>;
|
||||||
|
// legacy callback style
|
||||||
|
autoupdate(models: string | string[], callback: Callback): void;
|
||||||
|
|
||||||
discoverModelDefinitions(
|
discoverModelDefinitions(
|
||||||
options?: Options,
|
options?: Options,
|
||||||
callback?: Callback<ModelDefinition[]>,
|
): Promise<ModelDefinition[]>;
|
||||||
): PromiseOrVoid<ModelDefinition[]>;
|
// legacy callback style (no options)
|
||||||
|
discoverModelDefinitions(
|
||||||
|
callback: Callback<ModelDefinition[]>,
|
||||||
|
): void;
|
||||||
|
// legacy callback style (with options)
|
||||||
|
discoverModelDefinitions(
|
||||||
|
options: Options,
|
||||||
|
callback: Callback<ModelDefinition[]>,
|
||||||
|
): void;
|
||||||
|
|
||||||
discoverModelProperties(
|
discoverModelProperties(
|
||||||
modelName: string,
|
modelName: string,
|
||||||
options?: Options,
|
options?: Options,
|
||||||
callback?: Callback<PropertyDefinition[]>,
|
): Promise<PropertyDefinition[]>;
|
||||||
): PromiseOrVoid<PropertyDefinition[]>;
|
// legacy callback style (no options)
|
||||||
|
discoverModelProperties(
|
||||||
|
modelName: string,
|
||||||
|
callback: Callback<PropertyDefinition[]>,
|
||||||
|
): void;
|
||||||
|
// legacy callback style (with options)
|
||||||
|
discoverModelProperties(
|
||||||
|
modelName: string,
|
||||||
|
options: Options,
|
||||||
|
callback: Callback<PropertyDefinition[]>,
|
||||||
|
): void;
|
||||||
|
|
||||||
discoverPrimaryKeys(
|
discoverPrimaryKeys(
|
||||||
modelName: string,
|
modelName: string,
|
||||||
options?: Options,
|
options?: Options,
|
||||||
callback?: Callback<PropertyDefinition[]>,
|
): Promise<PropertyDefinition[]>;
|
||||||
): PromiseOrVoid<PropertyDefinition[]>;
|
// legacy callback style (no options)
|
||||||
|
discoverPrimaryKeys(
|
||||||
|
modelName: string,
|
||||||
|
callback: Callback<PropertyDefinition[]>,
|
||||||
|
): void;
|
||||||
|
// legacy callback style (with options)
|
||||||
|
discoverPrimaryKeys(
|
||||||
|
modelName: string,
|
||||||
|
options: Options,
|
||||||
|
callback: Callback<PropertyDefinition[]>,
|
||||||
|
): void;
|
||||||
|
|
||||||
discoverForeignKeys(
|
discoverForeignKeys(
|
||||||
modelName: string,
|
modelName: string,
|
||||||
options?: Options,
|
options?: Options,
|
||||||
callback?: Callback<PropertyDefinition[]>,
|
): Promise<PropertyDefinition[]>;
|
||||||
): PromiseOrVoid<PropertyDefinition[]>;
|
// legacy callback style (no options)
|
||||||
|
discoverForeignKeys(
|
||||||
|
modelName: string,
|
||||||
|
callback: Callback<PropertyDefinition[]>,
|
||||||
|
): void;
|
||||||
|
// legacy callback style (no options)
|
||||||
|
discoverForeignKeys(
|
||||||
|
modelName: string,
|
||||||
|
options: Options,
|
||||||
|
callback: Callback<PropertyDefinition[]>,
|
||||||
|
): void;
|
||||||
|
|
||||||
discoverExportedForeignKeys(
|
discoverExportedForeignKeys(
|
||||||
modelName: string,
|
modelName: string,
|
||||||
options?: Options,
|
options?: Options,
|
||||||
callback?: Callback<PropertyDefinition[]>,
|
): Promise<PropertyDefinition[]>;
|
||||||
): PromiseOrVoid<PropertyDefinition[]>;
|
// legacy callback style (no options)
|
||||||
|
discoverExportedForeignKeys(
|
||||||
|
modelName: string,
|
||||||
|
callback: Callback<PropertyDefinition[]>,
|
||||||
|
): void;
|
||||||
|
// legacy callback style (with options)
|
||||||
|
discoverExportedForeignKeys(
|
||||||
|
modelName: string,
|
||||||
|
options: Options,
|
||||||
|
callback: Callback<PropertyDefinition[]>,
|
||||||
|
): void;
|
||||||
|
|
||||||
discoverAndBuildModels(
|
discoverAndBuildModels(
|
||||||
modelName: string,
|
modelName: string,
|
||||||
options?: Options,
|
options?: Options,
|
||||||
callback?: Callback<{[name: string]: ModelBaseClass}>,
|
): Promise<{[name: string]: ModelBaseClass}>;
|
||||||
): PromiseOrVoid<{[name: string]: ModelBaseClass}>;
|
// legacy callback style (no options)
|
||||||
|
discoverAndBuildModels(
|
||||||
|
modelName: string,
|
||||||
|
callback: Callback<{[name: string]: ModelBaseClass}>,
|
||||||
|
): void;
|
||||||
|
// legacy callback style (with options)
|
||||||
|
discoverAndBuildModels(
|
||||||
|
modelName: string,
|
||||||
|
options: Options,
|
||||||
|
callback: Callback<{[name: string]: ModelBaseClass}>,
|
||||||
|
): void;
|
||||||
|
|
||||||
discoverSchema(
|
discoverSchema(
|
||||||
tableName: string,
|
tableName: string,
|
||||||
options?: Options,
|
options?: Options,
|
||||||
callback?: Callback<AnyObject>,
|
): Promise<AnyObject>;
|
||||||
): PromiseOrVoid<AnyObject>;
|
// legacy callback style (no options)
|
||||||
|
discoverSchema(
|
||||||
|
tableName: string,
|
||||||
|
callback: Callback<AnyObject>,
|
||||||
|
): void;
|
||||||
|
// legacy callback style (with options)
|
||||||
|
discoverSchema(
|
||||||
|
tableName: string,
|
||||||
|
options: Options,
|
||||||
|
callback: Callback<AnyObject>,
|
||||||
|
): void;
|
||||||
|
|
||||||
discoverSchemas(
|
discoverSchemas(
|
||||||
tableName: string,
|
tableName: string,
|
||||||
options?: Options,
|
options?: Options,
|
||||||
callback?: Callback<AnyObject[]>,
|
): Promise<AnyObject[]>;
|
||||||
): PromiseOrVoid<AnyObject[]>;
|
// legacy callback style (no options)
|
||||||
|
discoverSchemas(
|
||||||
|
tableName: string,
|
||||||
|
callback: Callback<AnyObject[]>,
|
||||||
|
): void;
|
||||||
|
// legacy callback style (with options)
|
||||||
|
discoverSchemas(
|
||||||
|
tableName: string,
|
||||||
|
options: Options,
|
||||||
|
callback: Callback<AnyObject[]>,
|
||||||
|
): void;
|
||||||
|
|
||||||
buildModelFromInstance(
|
buildModelFromInstance(
|
||||||
modelName: string,
|
modelName: string,
|
||||||
|
@ -197,9 +279,17 @@ export declare class DataSource extends EventEmitter {
|
||||||
options?: Options,
|
options?: Options,
|
||||||
): ModelBaseClass;
|
): ModelBaseClass;
|
||||||
|
|
||||||
connect(callback?: Callback): PromiseOrVoid;
|
connect(): Promise<void>;
|
||||||
disconnect(callback?: Callback): PromiseOrVoid;
|
// legacy callback style
|
||||||
ping(callback?: Callback): PromiseOrVoid;
|
connect(callback: Callback): void;
|
||||||
|
|
||||||
|
disconnect(): Promise<void>;
|
||||||
|
// legacy callback style
|
||||||
|
disconnect(callback: Callback): void;
|
||||||
|
|
||||||
|
ping(): Promise<void>;
|
||||||
|
// legacy callback style
|
||||||
|
ping(callback: Callback): void;
|
||||||
|
|
||||||
// Only promise variant, callback is intentionally not supported.
|
// Only promise variant, callback is intentionally not supported.
|
||||||
execute(
|
execute(
|
||||||
|
|
Loading…
Reference in New Issue