Skip to main content

Terminal

Introduction

The Terminal entity represents an organization-scoped terminal or facility. Terminals can be associated with a port, searched by name/code/custom values, and soft-deleted without losing historical references.

Entity Structure

Property NameTypeRequiredDescription
TerminalIdintYesUnique terminal identifier
OrganizationIdintYesTenant scope
NamestringYesTerminal display name
Codestring?NoOrganization-specific terminal code
PortIdstring?NoOptional FK to Port (OrganizationId + PortId)
CustomValuesDictionary<string, object?>NoExtensible terminal metadata stored as JSONB
IsDeletedboolYesSoft delete flag; default false
CreatedDateTimeYesCreation timestamp
CreatedBystringYesCreating user ID
LastModifiedDateTimeYesLast update timestamp
LastModifiedBystringYesLast updating user ID

Relationships

RelationshipTypeDescription
PortPortOptional associated port
OrganizationOrganizationOwning organization
CreatedUserUserUser that created the terminal
UpdatedUserUserUser that last updated the terminal

Indexes and Uniqueness

Terminal codes are unique per organization only for active terminals:

UNIQUE (OrganizationId, Code)
WHERE Code IS NOT NULL AND IsDeleted = false

This means a soft-deleted terminal no longer blocks reuse of its Code, while active terminals still cannot duplicate a non-null code inside the same organization. CustomValues also has a JSONB GIN index for containment/search use cases.

GraphQL

Root queries:

  • getTerminal(organizationId, terminalId) — returns one terminal
  • getTerminals(organizationId, filter, search, orderBy) — paged list with projection, Lucene filtering, search, and sorting

Example:

query {
getTerminals(organizationId: 1, search: "LAX", take: 20) {
items {
terminalId
code
name
port { portId name }
}
}
}