From e21939c68fa41b4e5fa3c6a02779a41548ea6255 Mon Sep 17 00:00:00 2001 From: Axel Bocciarelli Date: Tue, 10 Sep 2024 11:05:10 +0200 Subject: [PATCH] Parse metadata of committed datatypes with h5grove --- packages/app/src/providers/h5grove/models.ts | 17 ++++++++++------- packages/app/src/providers/h5grove/utils.ts | 15 +++++++++++++-- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/packages/app/src/providers/h5grove/models.ts b/packages/app/src/providers/h5grove/models.ts index b47ea5222..1afd4710d 100644 --- a/packages/app/src/providers/h5grove/models.ts +++ b/packages/app/src/providers/h5grove/models.ts @@ -1,8 +1,4 @@ -import type { - AttributeValues, - EntityKind, - Filter, -} from '@h5web/shared/hdf5-models'; +import type { AttributeValues, Filter } from '@h5web/shared/hdf5-models'; export type H5GroveEntityResponse = H5GroveEntity; export type H5GroveDataResponse = unknown; @@ -16,6 +12,7 @@ export interface H5GroveErrorResponse { export type H5GroveEntity = | H5GroveGroup | H5GroveDataset + | H5GroveDatatype | H5GroveSoftLink | H5GroveExternalLink; @@ -25,13 +22,13 @@ export interface H5GroveBaseEntity { } export interface H5GroveGroup extends H5GroveBaseEntity { - kind: EntityKind.Group; + kind: 'group'; children?: H5GroveEntity[]; attributes: H5GroveAttribute[]; } export interface H5GroveDataset extends H5GroveBaseEntity { - kind: EntityKind.Dataset; + kind: 'dataset'; shape: number[]; type: H5GroveType; chunks: number[] | null; @@ -39,6 +36,12 @@ export interface H5GroveDataset extends H5GroveBaseEntity { attributes: H5GroveAttribute[]; } +export interface H5GroveDatatype extends H5GroveBaseEntity { + kind: 'datatype'; + type: H5GroveType; + attributes: H5GroveAttribute[]; +} + export interface H5GroveSoftLink extends H5GroveBaseEntity { kind: 'soft_link'; target_path: string; diff --git a/packages/app/src/providers/h5grove/utils.ts b/packages/app/src/providers/h5grove/utils.ts index 94e87e016..3a6e98f6b 100644 --- a/packages/app/src/providers/h5grove/utils.ts +++ b/packages/app/src/providers/h5grove/utils.ts @@ -52,7 +52,7 @@ export function parseEntity( const { name } = h5gEntity; const baseEntity = { name, path }; - if (h5gEntity.kind === EntityKind.Group) { + if (h5gEntity.kind === 'group') { const { children = [], attributes: attrsMetadata } = h5gEntity; const attributes = parseAttributes(attrsMetadata); const baseGroup: Group = { @@ -74,7 +74,7 @@ export function parseEntity( }; } - if (h5gEntity.kind === EntityKind.Dataset) { + if (h5gEntity.kind === 'dataset') { const { attributes: attrsMetadata, type, @@ -94,6 +94,17 @@ export function parseEntity( }; } + if (h5gEntity.kind === 'datatype') { + const { attributes: attrsMetadata, type } = h5gEntity; + return { + ...baseEntity, + kind: EntityKind.Datatype, + type: parseDType(type), + rawType: type, + attributes: parseAttributes(attrsMetadata), + }; + } + if (h5gEntity.kind === 'soft_link') { const { target_path } = h5gEntity; return {