DefinitelyTyped/types/schwifty/index.d.ts
segayuu 1a07f27101 [@types/Bluebird] Make iterative methods rigid types without type parameters. (#27216)
* Resolve bluebird(Array) method

* upgrade typescript version from bluebird-global

* move testfile
Reason: There are too many type definition files
  depending on jquery and it can not be managed.

* upgrade typescript version from bluebird require packages

* fix lint error: use-default-type-parameter
2018-07-12 09:23:46 -07:00

71 lines
2.1 KiB
TypeScript

// Type definitions for schwifty 4.0
// Project: https://github.com/hapipal/schwifty
// Definitions by: ozum <https://github.com/ozum>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// HELP NEEDED: If possible, find a better way to define Server.models, Request.models and ResponseToolkit.models
// They are dynamic types extended from SchwiftyModel.
import * as Objection from "objection";
import * as Joi from "joi";
import { Server, Request, ResponseToolkit, Plugin } from "hapi";
import * as Knex from "knex";
export type ModelClass = typeof Model | typeof Objection.Model;
export class Model extends Objection.Model {
static getJoiSchema(patch?: boolean): Joi.Schema;
joiSchema: Joi.Schema;
}
export interface RegistrationOptions {
knex?: Knex | Knex.Config;
models?: ModelClass[] | string;
migrationsDir?: string;
teardownOnStop?: boolean;
migrateOnStart?: boolean | "latest" | "rollback";
}
export function assertCompatible(
ModelA: typeof Model,
ModelB: typeof Model,
message?: string
): void | Error;
export const plugin: Plugin<RegistrationOptions>;
/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Hapi Decorations +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
/**
* Merge decorations into hapi objects.
*/
declare module "hapi" {
interface Server {
schwifty: (
config:
| ModelClass
| ModelClass[]
| {
knex: Knex | Knex.Config;
models: ModelClass[];
migrationsDir: string;
}
) => void;
knex: () => Knex;
models: (all?: boolean) => { [key: string]: typeof Model };
}
interface Request {
knex: () => Knex;
models: (all?: boolean) => { [key: string]: typeof Model };
}
interface ResponseToolkit {
knex: () => Knex;
models: (all?: boolean) => { [key: string]: typeof Model };
}
}