Skip to content
12 changes: 4 additions & 8 deletions enum/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,10 @@ export enum ElementSymbol {
* Periodic table blocks based on the orbital subshell being filled by the valence electrons.
*/
export enum ElementBlock {
/** Sharp orbital block containing groups 1 and 2, plus helium. */
S = 's',
/** Principal orbital block containing groups 13 to 18 (excluding helium). */
P = 'p',
/** Diffuse orbital block containing the transition metals (groups 3 to 12). */
D = 'd',
/** Fundamental orbital block containing lanthanoids and actinoids. */
F = 'f'
/** Sharp orbital block containing groups 1 and 2, plus helium. */ S = 's',
/** Principal orbital block containing groups 13 to 18 (excluding helium). */ P = 'p',
/** Diffuse orbital block containing the transition metals (groups 3 to 12). */ D = 'd',
/** Fundamental orbital block containing lanthanoids and actinoids. */ F = 'f'
};

/**
Expand Down
12 changes: 12 additions & 0 deletions enum/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ export enum UncertaintyType {
ASYMMETRICAL = 'asymmetrical'
};

/**
* High-level categorization of binary large objects.
*/
export enum BlobType {
/** Visual assets such as photographs, diagrams, or spectra. */
IMAGE = 'image',
/** Three-dimensional structural models (e.g., molecule, crystal). */
MODEL_3D = '3d',
/** Specialized scientific data formats or raw logs. */
DATA = 'data'
};

/**
* Classification of bibliographic references and data sources based on BibTeX.
*/
Expand Down
98 changes: 98 additions & 0 deletions types/abstract/blob.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**
* @file blob.ts
* @description Defines the core scientific blob representations for binary assets.
* This module handles multi-media assets, 3D structural models, and complex datasets
* stored as binary data within the database.
*/

import type { Brand, Expand } from 'devtypes/types/util';
import type { BlobType, D3Format, ImageFormat } from '../../enum/util';
import type { RefId } from './reference';
import type { Attribution, Factory } from './util';

/**
* Branded base attributes for all binary large objects.
* @template T The classification of the blob (Image, 3D Model, etc.).
*/
type BaseBlob< T extends BlobType > = Brand< {
/** The cryptographic hash (e.g., SHA-256) for data integrity. */
hash?: string;
/** The total size of the binary data in bytes. */
size?: number;
/** Legal and creative attribution for the binary asset. */
attribution?: Attribution;
/** Internal remarks or scientific context regarding the asset. */
note?: string;
/** Citations and verifiable sources for the binary content. */
references?: RefId[];
}, T, 'type', true >;

/**
* Represents a photographic or diagrammatic image asset.
*/
export type ImageBlob = Expand< BaseBlob< BlobType.IMAGE > & {
/** The raster or vector format of the image. */
format: ImageFormat;
/** The raw base64 encoded payload or internal data URI. */
data: string;
/** Physical width of the asset in pixels. */
width?: number;
/** Physical height of the asset in pixels. */
height?: number;
} >;

/**
* Represents a three-dimensional structural or molecular model.
*/
export type Model3DBlob = Expand< BaseBlob< BlobType.MODEL_3D > & {
/** The chemical or spatial data format (e.g., CIF, PDB). */
format: D3Format;
/** The structural data payload. */
data: string;
} >;

/**
* Represents a general-purpose scientific data blob.
*/
export type DataBlob = Expand< BaseBlob< BlobType.DATA > & {
/** The formal IANA media type (Mime-Type). */
mimeType: string;
/** The binary payload encoded as base64. */
data: string;
} >;

/**
* Union of all supported binary asset representations.
*/
export type Blob = ImageBlob | Model3DBlob | DataBlob;

/**
* Branded identifier for a specific binary asset.
*/
export type BlobId = Brand< string, 'blobId' >;

/**
* A registry collecting multiple binary scientific assets indexed by their unique IDs.
*/
export type BlobCollection = Record< BlobId, Blob >;

/**
* Factory type for defining binary assets in the database repository.
*
* @example
* ```typescript
* import type { BlobFactory } from '@pseinfo/database-schema/abstract/blob';
*
* export default ( {
* type: 'blob',
* blobId: 'XXXXXXX',
* data: {
* // ...
* }
* } ) as const satisfies BlobFactory;
* ```
*/
export type BlobFactory = Factory< 'blob', Blob, {
/** The unique, branded identifier for this binary asset. */
blobId: BlobId;
} >;
81 changes: 81 additions & 0 deletions types/abstract/meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* @file meta.ts
* @description Provides the structural definitions for the database root metadata
* and administrative statistics. This module enables tracking of repository-wide
* metrics, contributor impact, and schema versioning.
*/

import type { Expand } from 'devtypes/types/util';
import type { EntityType } from '../../enum/util';
import type { Collection, Distinct } from './collection';
import type { ISO8601Date } from './util';

/**
* Basic biographical and contact information for an individual or organization
* contributing to the scientific database.
*
* Will have GitHub username and public email or website if available.
*/
export interface Contributor {
/** The primary name or alias of the contributor. */
name: string;
/** The primary communication channel or professional URI for the contributor. */
contact?: string;
}

/**
* Root metadata structure for the entire scientific repository.
* Contains legal, versioning, and administrative information necessary for
* distribution and academic citation.
*/
export type DBMeta = Collection< {
/** The constant version of the database schema for structural compatibility. */
readonly schemaVersion: 1;
/** The MIT license for the database. */
readonly license: 'MIT';
/** The current semantic version of the data collection. */
version: Distinct< string >;
/** The unique repository revision or commit hash representing the data state. */
revision: Distinct< string >;
/** The official title of the data repository. */
title: Distinct< string >;
/** A concise abstract describing the scope and purpose of the database. */
description?: Distinct< string >;
/** ISO 8601 timestamp of the global database build or last verified modification. */
lastModified: Distinct< ISO8601Date >;
/** The collective list of all individuals who have contributed to the current database state. */
contributors: Distinct< Contributor[] >;
/** The permalink to the current version of the database. */
permalink: `https://github.com/pseinfo/database/releases/tag/v${string}`;
} >;

/**
* Detailed metrics regarding the distribution of scientific data, repository scale,
* and contributor activity. Designed for automated generation via repository scripts.
*/
export type DBStats = Collection< {
/** Total cumulative size in bytes. */
size: Distinct< number >;
/** Total number of data points in the database. */
count: Distinct< number >;
/** Total number of edits. */
edits: Distinct< number >;
/** Distribution metrics for each scientific entity type. */
entities: Distinct< {
[ E in EntityType ]: {
/** Count of discrete entities of this type. */
count: number;
/** Binary size of all entities of this type. */
bytes: number;
}
} >;
/** Analysis of contributor impact on the database content. */
contributors: Distinct< Expand< Contributor & {
/** ISO 8601 timestamp of the contributor's most recent valid commit. */
lastModified: ISO8601Date;
/** The count of edits made by the individual. */
edits: number;
/** The total volume of data (in bytes) introduced by this contributor. */
bytes: number;
} > [] >;
} >;
4 changes: 3 additions & 1 deletion types/abstract/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import type { ExtractFrom, RequireAtLeastOne, RequireExactlyOneFrom, StrictSubset } from 'devtypes/types/constraint';
import type { Brand, Expand } from 'devtypes/types/util';
import type { ReferenceType } from '../../enum/util';
import type { LangCode, ReferenceType } from '../../enum/util';
import type { Factory, ISO8601Date } from './util';

/**
Expand All @@ -21,6 +21,8 @@ type BaseReference< T extends ReferenceType > = Brand< {
url?: string;
/** Digital Object Identifier - the unique permanent identifier for scholarly work. */
doi?: string;
/** Language of the reference. */
language?: LangCode;
}, T, 'type', true >;

/**
Expand Down
17 changes: 12 additions & 5 deletions types/abstract/unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ export const ValidUnits = {
electricConductivity: { base: [ 'S/m', 'S/cm' ], prefixable: [ 'S/m' ] },
/** Electromagnetism: Electric Resistivity (Specific) */
electricResistivity: { base: [ 'Ω·m', 'Ω·cm' ], prefixable: [ 'Ω·m' ] },
/** Electromagnetism: Electric Capacitance */
capacitance: { base: [ 'F' ], prefixable: [ 'F' ] },
/** Electromagnetism: Electric Inductance */
inductance: { base: [ 'H' ], prefixable: [ 'H' ] },
/** Electromagnetism: Electric Dipole Moment */
dipoleMoment: { base: [ 'C·m', 'statC·cm', 'abC·cm' ], prefixable: [ 'C·m' ] },

Expand All @@ -147,9 +151,9 @@ export const ValidUnits = {
massMagneticSusceptibility: { base: [ 'cm[3]/g', 'm[3]/kg' ], prefixable: [] },

/** Photometry: Luminous Flux */
luminousFlux: { base: [ 'lm' ], prefixable: [] },
luminousFlux: { base: [ 'lm' ], prefixable: [ 'lm' ] },
/** Photometry: Illuminance */
illuminance: { base: [ 'lx', 'fc' ], prefixable: [] },
illuminance: { base: [ 'lx', 'fc' ], prefixable: [ 'lx' ] },

/** Acoustics: Speed of Sound */
soundSpeed: { base: [ 'm/s', 'km/h', 'ft/s' ], prefixable: [ 'm/s' ] },
Expand All @@ -166,10 +170,10 @@ export const ValidUnits = {
molarity: { base: [ 'M', 'mol/L' ], prefixable: [ 'mol/L' ] },
/** Chemistry: Molality (mol/kg) */
molality: { base: [ 'm', 'mol/kg' ], prefixable: [ 'mol/kg' ] },
/** Chemistry: Dimensionless Mole Fraction */
moleFraction: { base: [ '%', '‰', '*', 'ppm', 'ppb', 'ppt' ], prefixable: [] },
/** Chemistry: Molar Heat Capacity */
molarHeatCapacity: { base: [ 'J/(mol·K)', 'cal/(mol·K)' ], prefixable: [] },
/** Chemistry: Catalytic Activity */
catalyticActivity: { base: [ 'kat' ], prefixable: [ 'kat' ] },

/** Fluid Dynamics: Dynamic Viscosity */
dynamicViscosity: { base: [ 'Pa·s', 'cP', 'poise', 'mPa·s' ], prefixable: [] },
Expand All @@ -180,6 +184,8 @@ export const ValidUnits = {
activity: { base: [ 'Bq', 'Ci' ], prefixable: [ 'Bq', 'Ci' ] },
/** Nuclear: Absorbed Radiation Dose */
absorbedDose: { base: [ 'Gy', 'rad' ], prefixable: [ 'Gy' ] },
/** Nuclear: Equivalent Dose */
equivalentDose: { base: [ 'Sv', 'rem' ], prefixable: [ 'Sv' ] },

/** Magnetic Resonance: Gyromagnetic Ratio */
gyromagneticRatio: { base: [ 'rad/(s·T)' ] , prefixable: [] },
Expand All @@ -193,7 +199,8 @@ export const ValidUnits = {
/** General Physics: Geometric Area */
area: { base: [ 'm[2]', 'b' ], prefixable: [ 'm[2]' ] },
/** General Physics: Dimensionless Quantity */
quantity: { base: [ '*', '%', '‰', 'mol' ], prefixable: [] },
quantity: { base: [ '*', '%', '‰' ], prefixable: [] },

/** Economics: Monetary Currency */
currency: { base: [ 'USD', 'EUR', 'CHF' ], prefixable: [] }
} as const;
Expand Down
23 changes: 20 additions & 3 deletions types/abstract/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ import type { Collection, Distinct, Group } from '../abstract/collection';
/** Helper type for ISO 8601 date format. */
export type ISO8601Date = `${number}-${number}-${number}T${number}:${number}:${number}Z`;

/**
* Data model for legal and creative attribution of assets.
* Provides a standardized structure for handling authorship, licensing, and credits.
*/
export type Attribution = Group< {
/** The individual or organization primarily responsible for the creation of the asset. */
author?: Distinct< string >;
/** The legal license identifier or descriptive license name. */
license: Distinct< string >;
/** The mandatory attribution string required by the license or creator. */
credits: Distinct< string >;
/** The originating website, digital archive, or publication where the asset was sourced. */
source?: Distinct< string >;
/** The ISO 8601 date the asset was last accessed or verified. */
accessed?: Distinct< ISO8601Date >;
} >;

/**
* Defines the root metadata structure for the schema, supporting automated enrichment.
* This generic wrapper ensures that every high-level entity or collection can be tracked for
Expand All @@ -21,7 +38,7 @@ export type MetaData< T extends Collection< unknown > = Collection< unknown > >
/** Internal metadata object for administrative and scientific tracking. */
'@metadata': Distinct< {
/** The version of the schema used for this data object. */
schemaVersion: 1;
readonly schemaVersion: 1;
/** ISO 8601 timestamp of the last modification. */
lastModified: ISO8601Date;
/** Unique commit hash or version identifier representing the data source state. */
Expand Down Expand Up @@ -52,14 +69,14 @@ export type LangGroup< L extends LangCode = LangCode.ENGLISH, T = string > = Gro
* structure, identifiers, and underlying data collections are perfectly aligned.
*
* This enables strict template validation within the IDE and CI/CD pipelines when creating new
* entities (Elements, Nuclides, etc.) or registries (Units, References).
* entities (Elements, Nuclides, etc.) or registries (Units, References, Blobs).
*
* @template E The entity type or specialized registry category.
* @template C The raw scientific data collection associated with the entity.
* @template K A set of primary keys or identifiers that define the specific record (e.g., symbol, id).
*/
export type Factory<
E extends EntityType | 'unit' | 'ref',
E extends EntityType | 'unit' | 'ref' | 'blob',
C extends Collection< unknown >,
K extends Record< string, string | number >
> = Expand< Brand< K & { data: C }, E, 'type', true > >;
4 changes: 3 additions & 1 deletion types/abstract/value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ type BaseValue< T extends ValueType > = Brand< {
confidence?: ValueConfidence;
/** Experimental or statistical uncertainty associated with the value. */
uncertainty?: Uncertainty;
/** Contextual information or remarks regarding the specific value or measurement. */
/** Scientific context of the value. */
context?: string;
/** Notes or remarks regarding the value. */
note?: string;
}, T, 'type', true >;

Expand Down
Loading