diff --git a/docs/03-dictionaryReference.md b/docs/03-dictionaryReference.md index e65a7e32..31f5cd27 100644 --- a/docs/03-dictionaryReference.md +++ b/docs/03-dictionaryReference.md @@ -32,10 +32,11 @@ Optional components like descriptions, metadata, and references which can also b | Property | Type | Required | Description | Example | | ------------- | -------- | -------- | -------------------------------------- | ----------------------------------------- | -| `name` | `string` | ✓ | Display name of the dictionary | `"clinical_data_dictionary"` | +| `name` | `string` | ✓ | Name of the dictionary | `"clinical_data_dictionary"` | | `version` | `string` | ✓ | Semantic version (major.minor.patch) | `"1.2.0"` | | `schemas` | `Array` | ✓ | List of schema definitions (minimum 1) | See [Schema Structure](#schema-structure) | | `description` | `string` | ✗ | A human-readable description | `"Clinical trial data schemas"` | +| `displayName` | `string` | ✗ | Display name of the dictionary | `"Clinical Data Dictionary"` | | `meta` | `object` | ✗ | Any custom defined metadata fields | `{"author": "Clinical Data Team"}` | | `references` | `object` | ✗ | Reusable reference values | See [References](#references) | @@ -75,13 +76,13 @@ At the schema-level descriptions and metadata can also be optionally added. #### Schema Properties -| Property | Type | Required | Description | -| ------------- | -------- | -------- | ------------------------------------------------------------------ | -| `name` | `string` | ✓ | The schema identifier (no spaces or dots) | -| `displayName` | `string` | ✗ | A human-readable name for UI display. Can contain periods. | -| `fields` | `Array` | ✓ | List of field definitions, see [Field Structure](#field-structure) | -| `description` | `string` | ✗ | A human-readable description | -| `meta` | `object` | ✗ | Any custom defined metadata fields | +| Property | Type | Required | Description | +| ------------- | -------- | -------- | -------------------------------------------------------------------------------------------- | +| `name` | `string` | ✓ | The schema identifier. Typically a short name with no spaces. Cannot contain `.` characters. | +| `displayName` | `string` | ✗ | A human-readable name for UI display. No format restrictions. | +| `fields` | `Array` | ✓ | List of field definitions, see [Field Structure](#field-structure) | +| `description` | `string` | ✗ | A human-readable description | +| `meta` | `object` | ✗ | Any custom defined metadata fields | ## Field Structure @@ -140,17 +141,17 @@ The allowed values for `valueType` include: At the field-level the following properties can also be included: -| Property | Type | Required | Default | Description | -| -------------- | -------------- | -------- | ------- | -------------------------------------------------------------------------------------------------------- | -| `name` | `string` | ✓ | - | Field identifier (used as a column header) | -| `displayName` | `string` | ✗ | - | A human-readable name for UI display. Can contain periods. | -| `description` | `string` | ✗ | `""` | Human-readable description | -| `valueType` | `string` | ✓ | - | Data type: `string`, `integer`, `number`, `boolean` | -| `isArray` | `boolean` | ✗ | `false` | Whether field accepts multiple values | -| `delimiter` | `string` | ✗ | `","` | Separator for array values | -| `unique` | `boolean` | ✗ | `false` | Whether values must be unique across records | -| `restrictions` | `object/array` | ✗ | `{}` | Where the validation rules/logic for the field is defined, see [Field Restrictions](#field-restrictions) | -| `meta` | `object` | ✗ | `{}` | Any custom defined metadata fields | +| Property | Type | Required | Default | Description | +| -------------- | -------------- | -------- | ------- | ----------------------------------------------------------------------------------------------------------------- | +| `name` | `string` | ✓ | - | Field identifier (used as a column header). Typically a short name with no spaces. Cannot contain `.` characters. | +| `displayName` | `string` | ✗ | - | A human-readable name for UI display. Can contain periods. | +| `description` | `string` | ✗ | `""` | Human-readable description | +| `valueType` | `string` | ✓ | - | Data type: `string`, `integer`, `number`, `boolean` | +| `isArray` | `boolean` | ✗ | `false` | Whether field accepts multiple values | +| `delimiter` | `string` | ✗ | `","` | Separator for array values | +| `unique` | `boolean` | ✗ | `false` | Whether values must be unique across records | +| `restrictions` | `object/array` | ✗ | `{}` | Where the validation rules/logic for the field is defined, see [Field Restrictions](#field-restrictions) | +| `meta` | `object` | ✗ | `{}` | Any custom defined metadata fields | ### Display Name Example diff --git a/packages/dictionary/src/metaSchema/dictionarySchemas.ts b/packages/dictionary/src/metaSchema/dictionarySchemas.ts index ee58c609..d92ae164 100644 --- a/packages/dictionary/src/metaSchema/dictionarySchemas.ts +++ b/packages/dictionary/src/metaSchema/dictionarySchemas.ts @@ -32,20 +32,27 @@ import { } from './restrictionsSchemas'; /** - * String rules for all name fields used in dictionary, including Dictionary, Schema, and Fields. + * String rules for all name fields used in dictionary Schema, and Fields. * This validates the format of the string since names are not allowed to have `.` characters. * * Example Values: * - `donors` * - `primary-site` * - `maximumVelocity` - */ + * + * Note: This is not used for dictionary names, to support legacy dictionary data. + * */ export const NameValue = zod .string() .min(1, 'Name fields cannot be empty.') .regex(/^[^.]+$/, 'Name fields cannot have `.` characters.'); export type NameValue = zod.infer; +/** + * Common validation rules for `displayName` for all entities: Dictionary, Schema, and Field + */ +export const DisplayNameValue = zod.string().min(1).optional(); + // Meta accepts as values only strings, numbers, booleans, arrays of numbers or arrays of strings // Another Meta object can be nested inside a Meta property export const DictionaryMetaValue = zod.union([ @@ -180,9 +187,9 @@ export type AnyFieldRestrictions = zod.infer; export const SchemaFieldBase = zod .object({ name: NameValue, - displayName: zod.string().optional(), description: zod.string().optional(), delimiter: zod.string().min(1).optional(), + displayName: DisplayNameValue, isArray: zod.boolean().optional(), meta: DictionaryMeta.optional(), unique: zod.boolean().optional(), @@ -249,8 +256,8 @@ export type ForeignKeyRestriction = zod.infer; export const Schema = zod .object({ name: NameValue, - displayName: zod.string().optional(), description: zod.string().optional(), + displayName: DisplayNameValue, fields: zod.array(SchemaField).min(1), meta: DictionaryMeta.optional(), restrictions: zod @@ -329,6 +336,7 @@ export const DictionaryBase = zod .object({ name: zod.string().min(1), description: zod.string().optional(), + displayName: DisplayNameValue, meta: DictionaryMeta.optional(), references: References.optional(), schemas: zod.array(Schema).min(1), diff --git a/packages/ui/src/viewer-table/DictionaryHeader.tsx b/packages/ui/src/viewer-table/DictionaryHeader.tsx index 7f59aac7..18a83111 100644 --- a/packages/ui/src/viewer-table/DictionaryHeader.tsx +++ b/packages/ui/src/viewer-table/DictionaryHeader.tsx @@ -75,6 +75,7 @@ const DictionaryHeader = () => { const { loading } = dataContext; const { selectedDictionary } = stateContext; + const displayName = selectedDictionary?.displayName ?? selectedDictionary?.name; const version = selectedDictionary?.version; const description = selectedDictionary?.description; @@ -83,7 +84,7 @@ const DictionaryHeader = () => { } return (
-

{selectedDictionary?.name}

+

{displayName}

{description && (