From a6911b3ed6a6dabbaa055f74c7d3e12ce5214b2f Mon Sep 17 00:00:00 2001 From: Sebastian Frank Date: Wed, 7 Dec 2022 14:53:01 +0000 Subject: [PATCH] context.json package --- index.d.ts | 28 ++++++++++++++++++++++++++++ schemas/api-config/config.json | 9 +++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 3ece2df..6f0d4df 100644 --- a/index.d.ts +++ b/index.d.ts @@ -580,6 +580,31 @@ declare global { ): any } + interface CryptoPackage { + /** + * get hex of sha256 hash + * + * @param sata string + * + * @returns hex hash + */ + sha256(data: string): string + } + + interface JsonPackage { + /** + * parse json string to json + * @param str json string + */ + parse(str: string): any + + /** + * stringify json string + * @param json json object + */ + stringify(json: any): string + } + export interface HookContext extends GetHookData, GetHookGetOnlyData, @@ -588,6 +613,7 @@ declare global { request(): { method: string remoteAddr: string + clientIp(): string host: string url: string path: string @@ -616,6 +642,8 @@ declare global { xml: XmlPackage cookie: CookiePackage pdf: PdfPackage + crypto: CryptoPackage + json: JsonPackage } export interface HookException { diff --git a/schemas/api-config/config.json b/schemas/api-config/config.json index 8c32c5e..a535354 100644 --- a/schemas/api-config/config.json +++ b/schemas/api-config/config.json @@ -20,8 +20,13 @@ "additionalProperties": true, "properties": { "imageUrl": { - "type": "string", - "description": "project's teaser image url shown in admin ui" + "description": "project's teaser image url shown in admin ui", + "oneOf": [ + { "type": "string" }, + { + "$ref": "definitions.json#/definitions/evalObject" + } + ] } } },