httk.core.data_records¶
Stdlib-only records for one declared property value per entry.
Attributes¶
Classes¶
Store one canonical JSON value of one declared property. |
|
Logical entry family for served |
Module Contents¶
- httk.core.data_records.RECORDS_DEFINITION_ID = 'https://schemas.httk.org/defs/v0.1/entrytypes/records'[source]¶
- class httk.core.data_records.DataRecord[source]¶
Store one canonical JSON value of one declared property.
value_jsonis canonical JSON, with sorted object keys, compact separators, and no non-finite numeric values.valuedecodes it on access;value_numberexposes finite numeric values for numeric queries. The human-readable and immutable identifiers and timestamp metadata are excluded from content identity.product_ofnames the entries this value describes, asStrongLinkedges with the sameRunEdgescheme aRunuses: string(label, entry_type, entry_id)triples, part of the record’s content and therefore pinned to the exact entry revision. It is served forward as theproduct_ofrelationship and in reverse ashas_producton the target, and is searchable throughrecord.links.product_ofandtarget.links.has_product.- Parameters:
definition_id – The property definition IRI for the value.
name – The property name.
value_json – The canonical JSON representation of the value.
product_of – The entries this value is a product of, as labeled edges.
id – The human-readable entry id shared by all revisions; minted by the store when None.
immutable_id – The per-revision immutable id; minted by the store when None.
last_modified – The optional timezone-aware metadata timestamp.
- product_of: Annotated[tuple[httk.core.provenance.RunEdge, ...], StrongLink('product_of', reverse='has_product', role='subject')] = ()[source]¶
- last_modified: Annotated[datetime.datetime | None, IdentitySkip()] = None[source]¶
- property value_number: float | None[source]¶
The decoded numeric value, stored as a numeric SQL query column.
- classmethod from_value(definition_id, name, value, *, product_of=(), id=None, immutable_id=None, last_modified=None)[source]¶
Encode a value canonically and construct its data record.
- Parameters:
definition_id (str) – The property definition IRI for the value.
name (str) – The property name.
value (Any) – The JSON value to encode.
product_of (collections.abc.Iterable[httk.core.provenance.RunEdge | collections.abc.Mapping[str, Any]]) – The entries this value is a product of, as labeled edges.
id (str | None) – The human-readable entry id shared by all revisions; minted by the store when None.
immutable_id (str | None) – The per-revision immutable id; minted by the store when None.
last_modified (datetime.datetime | None) – The optional timezone-aware metadata timestamp.
- Returns:
A data record containing the canonical JSON value.
- Raises:
TypeError – If the value contains an unsupported object.
ValueError – If the value is circular or contains a non-finite number, or if
definition_idornameis invalid orlast_modifiedis not timezone-aware.
- Return type:
Self
- classmethod from_obj(obj)[source]¶
Coerce a mapping or existing record into a
DataRecord.- Parameters:
obj (DataRecord | Mapping[str, Any]) – A data record instance or field mapping.
- Returns:
The existing or newly constructed data record.
- Raises:
TypeError – If
objis neither a data record nor a mapping.ValueError – If the mapping has unknown or invalid fields.
- Return type:
Self