5.0.6 • Published 6 months ago
@types/schwifty v5.0.6
Installation
npm install --save @types/schwifty
Summary
This package contains type definitions for schwifty (https://github.com/hapipal/schwifty).
Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/schwifty.
index.d.ts
// Type definitions for schwifty 5.0
// Project: https://github.com/hapipal/schwifty
// Definitions by: ozum <https://github.com/ozum>
// timcosta <https://github.com/timcosta>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
// 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/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;
static field(name: string): Joi.Schema;
static joiSchema: Joi.Schema;
}
export interface RegistrationOptions {
knex?: Knex | Knex.Config | undefined;
models?: ModelClass[] | string | undefined;
migrationsDir?: string | undefined;
teardownOnStop?: boolean | undefined;
migrateOnStart?: boolean | "latest" | "rollback" | undefined;
}
export function assertCompatible(
ModelA: typeof Model,
ModelB: typeof Model,
message?: string
): void | Error;
export const plugin: Plugin<RegistrationOptions>;
export interface RegisteredModels {
[key: string]: ModelClass;
}
/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Hapi Decorations +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
/**
* Merge decorations into hapi objects.
*/
declare module "@hapi/hapi" {
interface Server {
schwifty: (
config:
| ModelClass
| ModelClass[]
| {
knex: Knex | Knex.Config;
models: ModelClass[];
migrationsDir: string;
}
) => void;
knex: () => Knex;
models: (all?: boolean) => RegisteredModels;
}
interface Request {
knex: () => Knex;
models: (all?: boolean) => RegisteredModels;
}
interface ResponseToolkit {
knex: () => Knex;
models: (all?: boolean) => RegisteredModels;
}
}
Additional Details
- Last updated: Tue, 06 Jul 2021 16:34:20 GMT
- Dependencies: @types/objection, @types/joi, @types/hapi__hapi, @types/knex
- Global values: none