Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.wellapp.ai/llms.txt

Use this file to discover all available pages before exploring further.

CompanyRelation models a directed link between two Company entities, capturing structural or commercial relationships (parent/subsidiary hierarchy, supplier chains, client networks). Each tuple records a source company, a target company, and the typed nature of the link. The entity is workspace-adjacent โ€” it is scoped through its Company endpoints rather than carrying a direct workspace FK. Soft-delete support is present via deleted_at; there is no updated_at column on this entity.
NamingValue
ObjectCompanyRelation
Resource type (JSON:API type)company_relation
Collection / records rootโ€” (not a records root)
REST base/v1/company-relations
Entity classCompanyRelation
Internal object. Not currently exposed on the public REST API. The operations below describe the intended contract.

API operations

OperationMethod & pathStatus
ListGET /v1/company-relations๐ŸŸก Planned
RetrieveGET /v1/company-relations/{id}๐ŸŸก Planned
CreatePOST /v1/company-relations๐ŸŸก Planned
UpdatePATCH /v1/company-relations/{id}๐ŸŸก Planned
DeleteDELETE /v1/company-relations/{id}๐ŸŸก Planned

Data model

Attributes

FieldTypeRequiredConstraintsAllowed valuesDescription
link_typeenum (link_type_enum โ€” native PostgreSQL enum)โœ… YesNOT NULL; native enum โ€” invalid values rejected at DB levelparent | supplier | clientClassifies the directed relationship from source_company to target_company. Stored as a native PostgreSQL enum core_api.link_type_enum.
created_at๐Ÿ”’ system โ€” Date (timestamptz)โœ… YesNOT NULL; immutable after insertโ€”Timestamp set once at row creation via MikroORM onCreate hook. No updated_at exists on this entity.
deleted_atDate | null (timestamptz)โšช NoNULLABLEโ€”Soft-delete sentinel. NULL means the relation is active; a non-null timestamp marks it as logically deleted. All queries must filter deleted_at IS NULL per platform convention.

Relationships

NameTypeRequiredDescription
source_companyto-one (ManyToOne)โœ… YesThe originating Company in the directed relationship (e.g. the subsidiary, the buyer, or the child entity). FK column: source_company_pk โ†’ core_api.companies.pk. A partial index on source_company_pk was added in Migration20260504120000 for hot-path query performance. Note: original migration used a typo column souce_company_pk; corrected to source_company_pk in Migration20251126135042.
target_companyto-one (ManyToOne)โœ… YesThe destination Company in the directed relationship (e.g. the parent, the supplier, or the client). FK column: target_company_pk โ†’ core_api.companies.pk. A partial index on target_company_pk was added in Migration20260504120000.

System-computed

  • created_at โ€” set to new Date() via MikroORM onCreate hook; never written by the caller
  • deleted_at โ€” set by soft-delete logic; never passed in on creation
  • pk โ€” auto-increment serial primary key, internal only; never exposed in the public API
  • source_company_pk / target_company_pk โ€” FK integers resolved from the ManyToOne relations; the public API surfaces these as relationship objects, not raw integers

Example

{
  "data": {
    "type": "company_relation",
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "attributes": {
      "link_type": "supplier",
      "created_at": "2025-09-12T08:30:00.000Z",
      "deleted_at": null
    },
    "relationships": {
      "source_company": {
        "data": { "type": "company", "id": "11111111-aaaa-bbbb-cccc-dddddddddddd" }
      },
      "target_company": {
        "data": { "type": "company", "id": "22222222-aaaa-bbbb-cccc-eeeeeeeeeeee" }
      }
    }
  }
}
Source: apps/api/src/database/entities/CompanyRelation.ts ยท domain: financial-graph ยท tier: Supporting