@item-enonic-types/global
Advanced tools
Comparing version 7.13.0 to 7.13.1
@@ -1,3 +0,6 @@ | ||
export interface Request { | ||
method: "GET" | "PUT" | "POST" | "DELETE" | "HEAD" | "PATCH" | "OPTIONS" | "TRACE" | "CONNECT"; | ||
type LooseAutocomplete<T extends string> = T | Omit<string, T>; | ||
type Unarray<T> = T extends Array<infer U> ? U : T extends ReadonlyArray<infer U> ? U : T; | ||
export type Request<Params extends Record<string, string | undefined> = Record<string, string>> = { | ||
method: string; | ||
scheme: string; | ||
@@ -16,21 +19,28 @@ host: string; | ||
body: string; | ||
params: { [key: string]: string | undefined }; | ||
params: Partial<Params>; | ||
headers: { [key: string]: string | undefined }; | ||
cookies: { [key: string]: string | undefined }; | ||
contentType: string; | ||
} | ||
}; | ||
export interface Response<ResponseBody = unknown> { | ||
status?: number; | ||
body?: ResponseBody; | ||
contentType?: "text/html" | "application/json" | "application/problem+json" | "text/xml" | "application/xml" | string; | ||
headers?: { [key: string]: string | undefined }; | ||
cookies?: { [key: string]: string | Cookie | undefined }; | ||
redirect?: string; | ||
postProcess?: boolean; | ||
pageContributions?: PageContributions; | ||
applyFilters?: boolean; | ||
} | ||
export type Response<ResponseBody = unknown> = Partial<{ | ||
status: number; | ||
body: ResponseBody; | ||
contentType: LooseAutocomplete< | ||
"text/html" | "application/json" | "application/problem+json" | "text/xml" | "application/xml" | ||
>; | ||
headers: { [key: string]: string | undefined }; | ||
cookies: { [key: string]: string | Cookie | undefined }; | ||
redirect: string; | ||
postProcess: boolean; | ||
pageContributions: { | ||
headBegin?: string | Array<string>; | ||
headEnd?: string | Array<string>; | ||
bodyBegin?: string | Array<string>; | ||
bodyEnd?: string | Array<string>; | ||
}; | ||
applyFilters: boolean; | ||
}>; | ||
export interface WebSocketResponse<WebSocketData = {}> { | ||
export type WebSocketResponse<WebSocketData = {}> = { | ||
webSocket: { | ||
@@ -40,5 +50,5 @@ data?: WebSocketData; | ||
}; | ||
} | ||
}; | ||
export interface MacroContext<Params = never> { | ||
export type MacroContext<Params extends Record<string, string> = Record<string, string>> = { | ||
name: string; | ||
@@ -49,3 +59,3 @@ body: string; | ||
request: Request; | ||
} | ||
}; | ||
@@ -55,3 +65,3 @@ /** | ||
*/ | ||
export interface ErrorRequest { | ||
export type ErrorRequest = { | ||
status: number; | ||
@@ -61,3 +71,3 @@ message: string; | ||
request: Request; | ||
} | ||
}; | ||
@@ -67,4 +77,14 @@ /** | ||
*/ | ||
export interface CustomSelectorServiceRequestParams { | ||
export type CustomSelectorServiceParams = { | ||
count: string; | ||
start: string; | ||
ids: string; | ||
query: string; | ||
}; | ||
/** | ||
* @deprecated Use `Partial<CustomSelectorServiceParams>` | ||
*/ | ||
export type CustomSelectorServiceRequestParams = { | ||
count: string; | ||
start?: string; | ||
@@ -75,13 +95,23 @@ ids?: string; | ||
[key: string]: string | undefined; | ||
} | ||
export type CustomSelectorServiceRequest = Omit<Request, "params"> & { | ||
params: CustomSelectorServiceRequestParams; | ||
}; | ||
export interface CustomSelectorServiceResponseBody { | ||
/** | ||
* @deprecated Use `Request<CustomSelectorServiceParams>` | ||
*/ | ||
export type CustomSelectorServiceRequest = Request<CustomSelectorServiceParams>; | ||
export type CustomSelectorServiceResponseBody = { | ||
total: number; | ||
count: number; | ||
hits: Array<CustomSelectorServiceResponseHit>; | ||
} | ||
hits: Array<{ | ||
id: string; | ||
displayName: string; | ||
description?: string; | ||
iconUrl?: string; | ||
icon?: { | ||
data: string; | ||
type: string; | ||
}; | ||
}>; | ||
}; | ||
@@ -93,14 +123,5 @@ /** | ||
export interface CustomSelectorServiceResponseHit { | ||
id: string; | ||
displayName: string; | ||
description?: string; | ||
iconUrl?: string; | ||
icon?: { | ||
data: string; | ||
type: string; | ||
}; | ||
} | ||
export type CustomSelectorServiceResponseHit = Unarray<CustomSelectorServiceResponseBody["hits"]>; | ||
interface AbstractWebSocketEvent<WebSocketData = {}> { | ||
type AbstractWebSocketEvent<WebSocketData> = { | ||
session: { | ||
@@ -112,22 +133,22 @@ id: string; | ||
data: WebSocketData; | ||
} | ||
}; | ||
export interface OpenWebSocketEvent<WebSocketData = {}> extends AbstractWebSocketEvent<WebSocketData> { | ||
export type OpenWebSocketEvent<WebSocketData = {}> = AbstractWebSocketEvent<WebSocketData> & { | ||
type: "open"; | ||
} | ||
}; | ||
export interface MessageWebSocketEvent<WebSocketData = {}> extends AbstractWebSocketEvent<WebSocketData> { | ||
export type MessageWebSocketEvent<WebSocketData = {}> = AbstractWebSocketEvent<WebSocketData> & { | ||
type: "message"; | ||
message: string; | ||
} | ||
}; | ||
export interface CloseWebSocketEvent<WebSocketData = {}> extends AbstractWebSocketEvent<WebSocketData> { | ||
export type CloseWebSocketEvent<WebSocketData = {}> = AbstractWebSocketEvent<WebSocketData> & { | ||
type: "close"; | ||
closeReason: number; | ||
} | ||
}; | ||
export interface ErrorWebSocketEvent<WebSocketData = {}> extends AbstractWebSocketEvent<WebSocketData> { | ||
export type ErrorWebSocketEvent<WebSocketData = {}> = AbstractWebSocketEvent<WebSocketData> & { | ||
type: "error"; | ||
error: string; | ||
} | ||
}; | ||
@@ -140,10 +161,3 @@ export type WebSocketEvent<WebSocketData = {}> = | ||
interface PageContributions { | ||
headBegin?: string | Array<string>; | ||
headEnd?: string | Array<string>; | ||
bodyBegin?: string | Array<string>; | ||
bodyEnd?: string | Array<string>; | ||
} | ||
interface Cookie { | ||
type Cookie = { | ||
value: string; | ||
@@ -156,4 +170,10 @@ path?: string; | ||
httpOnly?: boolean; | ||
} | ||
sameSite?: "Lax" | "Strict" | "None" | " "; | ||
}; | ||
export type AdminWidgetResponse = Response<`<widget>${string}</widget>` | `<widget class="error">${string}</widget>`>; | ||
export type AdminWidgetBody = `<widget>${string}</widget>` | `<widget class="error">${string}</widget>`; | ||
/** | ||
* @deprecated Use `Response<AdminWidgetBody>` instead. | ||
*/ | ||
export type AdminWidgetResponse = Response<AdminWidgetBody>; |
declare namespace XP { | ||
type Request = import("./controller").Request; | ||
type Request<Params extends Record<string, string | undefined> = Record<string, string>> = | ||
import("./controller").Request<Params>; | ||
type Response<ResponseBody = unknown> = import("./controller").Response<ResponseBody>; | ||
type Controller = <ResponseBody = unknown>(req: Request) => Response<ResponseBody>; | ||
type Controller = < | ||
Params extends Record<string, string | undefined> = Record<string, string>, | ||
ResponseBody = unknown, | ||
>( | ||
req: Request<Params>, | ||
) => Response<ResponseBody>; | ||
@@ -12,3 +18,4 @@ type WebSocketEvent<WebSocketData = {}> = import("./controller").WebSocketEvent<WebSocketData>; | ||
type MacroContext<Params = never> = import("./controller").MacroContext<Params>; | ||
type MacroContext<Params extends Record<string, string> = Record<string, string>> = | ||
import("./controller").MacroContext<Params>; | ||
@@ -31,6 +38,11 @@ /** | ||
*/ | ||
type CustomSelectorServiceParams = import("./controller").CustomSelectorServiceParams; | ||
/** | ||
* @deprecated Use `Partial<CustomSelectorServiceParams>` | ||
*/ | ||
type CustomSelectorServiceRequestParams = import("./controller").CustomSelectorServiceRequestParams; | ||
/** | ||
* This Request can be used by a Service that provides data to a CustomSelector input field | ||
* @deprecated Use `Request<CustomSelectorServiceParams>` | ||
*/ | ||
@@ -48,3 +60,6 @@ type CustomSelectorServiceRequest = import("./controller").CustomSelectorServiceRequest; | ||
/** | ||
* @deprecated Use `Response<AdminWidgetBody>` instead. | ||
*/ | ||
type AdminWidgetResponse = import("./controller").AdminWidgetResponse; | ||
} |
@@ -5,3 +5,3 @@ { | ||
"sideEffects": false, | ||
"version": "7.13.0", | ||
"version": "7.13.1", | ||
"description": "Global variables and functions type definition.", | ||
@@ -8,0 +8,0 @@ "typings": "index.d.ts", |
@@ -17,8 +17,6 @@ # Global types for Enonic XP | ||
- `XP.ErrorRequest` | ||
- `XP.CustomSelectorServiceRequest` | ||
- `XP.CustomSelectorServiceRequestParams` | ||
- `XP.CustomSelectorServiceParams` | ||
- `XP.Response` | ||
- `XP.WebSocketResponse` | ||
- `XP.CustomSelectorServiceResponse` | ||
- `XP.CustomSelectorServiceResponseHit` | ||
- `XP.CustomSelectorServiceResponseBody` | ||
- `XP.MacroContext` | ||
@@ -25,0 +23,0 @@ - `XP.WebSocketEvent` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8365
195
42