enonic-types
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -1,2 +0,3 @@ | ||
export declare interface Request { | ||
import { XOR } from "./types"; | ||
export interface Request { | ||
readonly method: "GET" | "PUT" | "POST" | "DELETE"; | ||
@@ -21,7 +22,8 @@ readonly scheme: string; | ||
}; | ||
readonly webSocket?: boolean; | ||
} | ||
export declare type ResponseType = string | object | Array<any> | ReadonlyArray<any>; | ||
export declare interface Response { | ||
export interface HttpResponse<A> { | ||
readonly status?: number; | ||
readonly body?: ResponseType; | ||
readonly body?: A | ResponseType; | ||
readonly contentType?: string; | ||
@@ -39,2 +41,9 @@ readonly headers?: { | ||
} | ||
export interface WebSocketResponse<A = {}> { | ||
readonly webSocket: { | ||
readonly data?: A; | ||
readonly subProtocols?: ReadonlyArray<string>; | ||
}; | ||
} | ||
export declare type Response<A = {}> = XOR<HttpResponse<A>, WebSocketResponse<A>>; | ||
export interface MacroContext<A = never> { | ||
@@ -112,1 +121,23 @@ readonly name: string; | ||
} | ||
interface AbstractWebSocketEvent<A = {}> { | ||
readonly session: { | ||
readonly id: string; | ||
readonly path: string; | ||
readonly params: Record<string, string>; | ||
}; | ||
readonly data: A; | ||
} | ||
declare type WebSocketType = { | ||
readonly type: 'open'; | ||
} | { | ||
readonly type: 'message'; | ||
readonly message: string; | ||
} | { | ||
readonly type: 'error'; | ||
readonly error: string; | ||
} | { | ||
readonly type: 'close'; | ||
readonly closeReason: number; | ||
}; | ||
export declare type WebSocketEvent<A = {}> = AbstractWebSocketEvent<A> & WebSocketType; | ||
export {}; |
{ | ||
"name": "enonic-types", | ||
"sideEffects": false, | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "TypeScript types for Enonic XP", | ||
@@ -27,5 +27,5 @@ "typings": "index.d.ts", | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^4.8.2", | ||
"@typescript-eslint/parser": "^4.8.2", | ||
"eslint": "^7.14.0", | ||
"@typescript-eslint/eslint-plugin": "^4.9.1", | ||
"@typescript-eslint/parser": "^4.9.1", | ||
"eslint": "^7.15.0", | ||
"rimraf": "^3.0.2", | ||
@@ -32,0 +32,0 @@ "typescript": "^4.1.2" |
77822
2295