chore: Typescript database models (#2886)

closes #2798
This commit is contained in:
Tom Moor
2022-01-06 18:24:28 -08:00
committed by GitHub
parent d3cbf250e6
commit b20a341f0c
207 changed files with 5624 additions and 5315 deletions

View File

@@ -1,4 +1,6 @@
declare module "cancan" {
import { Model } from "sequelize-typescript";
namespace CanCan {
interface Option {
instanceOf?: ((instance: any, model: any) => boolean) | undefined;
@@ -9,20 +11,42 @@ declare module "cancan" {
class CanCan {
constructor(options?: CanCan.Option);
allow<T>(
model: any,
allow<
T extends new (...args: any) => any,
U extends new (...args: any) => any
>(
model: U,
actions: string | ReadonlyArray<string>,
targets: T | ReadonlyArray<T> | string | ReadonlyArray<string>,
condition?:
| object
| ((performer: any, target: any, options?: any) => boolean)
| ((
performer: InstanceType<U>,
target: InstanceType<T> | null,
options?: any
) => boolean)
): void;
can(performer: any, action: string, target: any, options?: any): boolean;
can(
performer: Model,
action: string,
target: Model | null | undefined,
options?: any
): boolean;
cannot(performer: any, action: string, target: any, options?: any): boolean;
cannot(
performer: Model,
action: string,
target: Model | null | undefined,
options?: any
): boolean;
authorize(performer: any, action: string, target: any, options?: any): void;
authorize(
performer: Model,
action: string,
target: Model | null | undefined,
options?: any
): asserts target;
abilities: {
model: any;

33
server/typings/index.d.ts vendored Normal file
View File

@@ -0,0 +1,33 @@
declare module "slate-md-serializer";
declare module "sequelize-encrypted";
declare module "styled-components-breakpoint";
declare module "formidable/lib/file";
declare module "socket.io-client";
declare module "@tommoor/remove-markdown" {
export default function removeMarkdown(
text: string,
options?: {
stripHTML: boolean;
}
): string;
}
declare module "socket.io-redis" {
import { Redis } from "ioredis";
type Config = {
pubClient: Redis;
subClient: Redis;
};
const socketRedisAdapter: (config: Config) => void;
export = socketRedisAdapter;
}
declare module "oy-vey";

28
server/typings/socketio-auth.d.ts vendored Normal file
View File

@@ -0,0 +1,28 @@
declare module "socketio-auth" {
import IO from "socket.io";
type AuthenticatedSocket = IO.Socket & {
client: IO.Client & {
user: any;
};
};
type AuthenticateCallback = (
socket: AuthenticatedSocket,
data: { token: string },
callback: (err: Error | null, allow: boolean) => void
) => Promise<void>;
type PostAuthenticateCallback = (
socket: AuthenticatedSocket
) => Promise<void>;
type AuthenticationConfig = {
authenticate: AuthenticateCallback;
postAuthenticate: PostAuthenticateCallback;
};
const SocketAuth: (io: IO.Server, config: AuthenticationConfig) => void;
export = SocketAuth;
}