diff --git a/packages/zapp/console/src/components/Literals/DeprecatedLiteralMapViewer.tsx b/packages/zapp/console/src/components/Literals/DeprecatedLiteralMapViewer.tsx index 5e594c635..f8ec614bb 100644 --- a/packages/zapp/console/src/components/Literals/DeprecatedLiteralMapViewer.tsx +++ b/packages/zapp/console/src/components/Literals/DeprecatedLiteralMapViewer.tsx @@ -16,7 +16,7 @@ export const NoDataIsAvailable = () => { }; /** Renders a LiteralMap as a formatted object */ -export const LiteralMapViewer: React.FC<{ +export const DeprecatedLiteralMapViewer: React.FC<{ className?: string; map: LiteralMap | null; showBrackets?: boolean; diff --git a/packages/zapp/console/src/components/Literals/helpers.ts b/packages/zapp/console/src/components/Literals/helpers.ts index b8e253c10..b49a02a56 100644 --- a/packages/zapp/console/src/components/Literals/helpers.ts +++ b/packages/zapp/console/src/components/Literals/helpers.ts @@ -10,9 +10,15 @@ import { SchemaColumnType, } from 'models/Common/types'; +const DEFAULT_UNSUPPORTED = 'This type is not yet supported'; + // PRIMITIVE function processPrimitive(primitive: Core.IPrimitive) { - const type = (primitive as Core.Primitive).value!; + const type = (primitive as Core.Primitive).value; + if (!type) { + return DEFAULT_UNSUPPORTED; + } + switch (type) { case 'datetime': return formatDateUTC(timestampToDate(primitive.datetime!)); @@ -24,7 +30,6 @@ function processPrimitive(primitive: Core.IPrimitive) { case 'boolean': case 'floatValue': return primitive[type]; - case 'stringValue': default: return `${primitive[type]}`; } @@ -38,7 +43,9 @@ const dimensionalityStrings: Record = { function processBlobType(blobType: Core.IBlobType, typePrefix: string = '') { const formatString = blobType && blobType.format ? ` (${blobType.format})` : ''; - const typeString = `${dimensionalityStrings[blobType!.dimensionality!]}${formatString}`; + const typeString = blobType.dimensionality + ? `${dimensionalityStrings[blobType.dimensionality]}${formatString}` + : 'unknown'; return `${typePrefix}${typeString} blob`; } @@ -46,8 +53,12 @@ function processBlobType(blobType: Core.IBlobType, typePrefix: string = '') { function processBlob(blob: Core.IBlob | Core.Blob) { const type = blob?.metadata?.type; + if (!type) { + return DEFAULT_UNSUPPORTED; + } + return { - type: processBlobType(type!), + type: processBlobType(type), uri: blob.uri, }; } @@ -109,11 +120,11 @@ function processNone(none?: Core.IVoid) { // TODO: FC#450 ass support for union types function processUnionType(union: Core.IUnionType, shortString = false) { - return 'This type is not yet supported'; + return DEFAULT_UNSUPPORTED; } function processUnion(union: Core.IUnion) { - return 'This type is not yet supported'; + return DEFAULT_UNSUPPORTED; } /* eslint-enable @typescript-eslint/no-unused-vars */ @@ -217,7 +228,7 @@ function processLiteralType(literalType: Core.ILiteralType) { case 'unionType': return processUnionType(literalType?.unionType!, true); default: - return 'This type is not yet supported'; + return DEFAULT_UNSUPPORTED; } } @@ -282,7 +293,7 @@ function processScalar(scalar: Core.Scalar | Core.IScalar) { case 'union': return processUnion(value as Core.IUnion); default: - return 'This type is not yet supported'; + return DEFAULT_UNSUPPORTED; } }