Skip to content

Identity

pipelines.enrichment.shared.identity

Summary

Entity identity helpers (port of domain/enrichment/entity/identity.py).

Functions

build_entity

1
2
3
4
5
build_entity(
    name: str,
    entity_type: str = "merchant",
    entity_logo: str | None = None,
) -> dict

Build the entity payload dict from name, type and logo.

Parameters:

Name Type Description Default
name str

Entity display name.

required
entity_type str

Entity type key, defaults to "merchant".

'merchant'
entity_logo str | None

Logo URL, or None.

None

Returns:

Name Type Description
dict dict

Entity payload with entity.id, entity.name, entity.type and entity.logo keys.

canonicalize_candidate

canonicalize_candidate(candidate: str | None) -> str | None

Canonicalize a candidate value via normalize_key.

Parameters:

Name Type Description Default
candidate str | None

Raw candidate, or None/empty.

required

Returns:

Type Description
str | None

str | None: The normalized candidate, or None when candidate is empty.

normalize_key

normalize_key(text: str | None) -> str | None

Normalize a key: NFKC, lowercase and stripped.

Parameters:

Name Type Description Default
text str | None

Raw key, or None.

required

Returns:

Type Description
str | None

str | None: The normalized key, or None when text is None.

to_entity_id

to_entity_id(name: str | None) -> str | None

Build the canonical snake-cased entity id from a name.

Parameters:

Name Type Description Default
name str | None

Raw entity name, or None/empty.

required

Returns:

Type Description
str | None

str | None: The snake-cased entity id, or None when name is empty.