From 9d36d59cbf6a8708578f8ac593b10c5567d1a607 Mon Sep 17 00:00:00 2001 From: Foxhoundn Date: Tue, 10 Dec 2024 16:07:34 +0100 Subject: [PATCH] Bump version to 0.4.9, enhance error handling in QorusRequest, and update IQorusAllowedValue to allow optional fields --- package.json | 2 +- src/QorusRequest.ts | 9 ++++++++- src/types/forms.ts | 5 +++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 3eee862..32ff943 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@qoretechnologies/ts-toolkit", - "version": "0.4.8", + "version": "0.4.9", "description": "Utility library to interact with Qorus Integration Engine & Qore Language", "keywords": [ "qoretechnologies", diff --git a/src/QorusRequest.ts b/src/QorusRequest.ts index c83657a..e6feae4 100644 --- a/src/QorusRequest.ts +++ b/src/QorusRequest.ts @@ -118,7 +118,14 @@ export class QorusRequest { throw new ErrorQorusRequest(text); } - const json = await promise.json(); + let json: any; + + // We need to turn the promise to json but if the response is empty we need to return an empty object + try { + json = await promise.json(); + } catch (error) { + json = {}; + } return { data: json }; } diff --git a/src/types/forms.ts b/src/types/forms.ts index 40b49fc..1591024 100644 --- a/src/types/forms.ts +++ b/src/types/forms.ts @@ -26,8 +26,8 @@ export interface IQorusFormFieldMessage { export interface IQorusAllowedValue { display_name: string; - short_desc: string; - desc: string; + short_desc?: string; + desc?: string; value: unknown; } @@ -45,6 +45,7 @@ export interface IQorusFormFieldSchema { sensitive?: boolean; allowed_values?: IQorusAllowedValue[]; + allowed_values_creatable?: boolean; allowed_schemes?: IQorusAllowedValue[]; arg_schema?: IQorusFormSchema;