Skip to content

Commit 7f3203a

Browse files
committed
Loosen attribute helpers to allow any attribute names
1 parent 5456eec commit 7f3203a

File tree

3 files changed

+5
-22
lines changed

3 files changed

+5
-22
lines changed

packages/app/src/providers/models.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import {
1111
type OnProgress,
1212
} from '@h5web/shared/react-suspense-fetch';
1313

14-
import { type NxAttribute } from '../vis-packs/nexus/models';
15-
1614
export type EntitiesStore = FetchStore<string, ProvidedEntity>;
1715
export type ValuesStore = FetchStore<ValuesStoreParams, unknown>;
1816
export type AttrValuesStore = FetchStore<Entity, AttributeValues>;
@@ -22,9 +20,6 @@ export interface ValuesStoreParams {
2220
selection?: string | undefined;
2321
}
2422

25-
export type ImageAttribute = 'CLASS' | 'IMAGE_SUBCLASS';
26-
export type AttrName = NxAttribute | ImageAttribute | '_FillValue';
27-
2823
export type ProgressCallback = (prog: number[]) => void;
2924

3025
export type Fetcher = (

packages/app/src/utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ import {
1414
type Value,
1515
} from '@h5web/shared/hdf5-models';
1616

17-
import { type AttrName, type AttrValuesStore } from './providers/models';
17+
import { type AttrValuesStore } from './providers/models';
1818

19-
export function hasAttribute(entity: Entity, attributeName: AttrName): boolean {
19+
export function hasAttribute(entity: Entity, attributeName: string): boolean {
2020
return entity.attributes.some((attr) => attr.name === attributeName);
2121
}
2222

2323
export function findAttribute(
2424
entity: Entity,
25-
attributeName: AttrName,
25+
attributeName: string,
2626
): Attribute | undefined {
2727
return entity.attributes.find((attr) => attr.name === attributeName);
2828
}
2929

3030
export function findScalarNumAttr(
3131
entity: Entity,
32-
attributeName: AttrName,
32+
attributeName: string,
3333
): Attribute<ScalarShape, NumericType> | undefined {
3434
const attr = findAttribute(entity, attributeName);
3535
return attr && hasScalarShape(attr) && hasNumericType(attr)
@@ -39,7 +39,7 @@ export function findScalarNumAttr(
3939

4040
export function findScalarStrAttr(
4141
entity: Entity,
42-
attributeName: AttrName,
42+
attributeName: string,
4343
): Attribute<ScalarShape, StringType> | undefined {
4444
const attr = findAttribute(entity, attributeName);
4545
return attr && hasScalarShape(attr) && hasStringType(attr) ? attr : undefined;

packages/app/src/vis-packs/nexus/models.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,6 @@ import {
1111
} from '@h5web/shared/hdf5-models';
1212
import { type AxisMapping } from '@h5web/shared/nexus-models';
1313

14-
export type NxAttribute =
15-
| 'NX_class'
16-
| 'signal'
17-
| 'interpretation'
18-
| 'axes'
19-
| 'default'
20-
| 'default_slice'
21-
| 'long_name'
22-
| 'units'
23-
| 'SILX_style'
24-
| 'auxiliary_signals';
25-
2614
export interface DatasetInfo {
2715
label: string;
2816
unit: string | undefined;

0 commit comments

Comments
 (0)