IF Commons GitHub

principal

conceptpersonal data

Anyone or anything that can be granted a role, own a key or act: a person, a machine, a device, an AI agent or a group

Model identity. Written in commons/data/models/identity/concepts.ts:36. Identified by principalId.

Governance: attributes

createdAtinstantrequired

When the principal was made

Becomes the column created_at of principal.

Written at commons/data/models/identity/concepts.ts:47

displayNametextoptionalpersonal data

The name the principal is shown by

Becomes the column display_name of principal.

Annotations: privacy.personal={"category":"Name","purposes":["show who did something"]}

Written at commons/data/models/identity/concepts.ts:41

kindcode of principalKindrequired

Whether the principal is a user, a machine, a device, an agent or a group

Becomes the column kind of principal.

Written at commons/data/models/identity/concepts.ts:40

principalIdidentifierrequired

What identifies the principal, made by the application

Becomes the column principal_id of principal.

Written at commons/data/models/identity/concepts.ts:39

statuscode of principalStatusrequired

Where the principal is in its life; making it disabled denies everything it could do, at once

Becomes the column status of principal.

Annotations: quality.transitions={"allowed":{"pending":["active","disabled","deleted"],"active":["suspended","disabled","deleted"],"suspended":["active","disabled","deleted"],"disabled":["ac...

Written at commons/data/models/identity/concepts.ts:42

statusChangedAtinstantrequired

When the principal's status last changed

Becomes the column status_changed_at of principal.

Written at commons/data/models/identity/concepts.ts:46

statusReasontextoptional

Why the principal is in the status it is in

Becomes the column status_reason of principal.

Written at commons/data/models/identity/concepts.ts:45

Governance: relationships

owneroptional

The person or group accountable for the principal; required of a machine, a device and an agent by the operation that makes them To principal. Written at commons/data/models/identity/concepts.ts:52

tenantoptional

The tenant that owns the principal; empty for a user who joins tenants by membership To tenant. Written at commons/data/models/identity/concepts.ts:51

Logical: the table

Projects to the table principal with the primary key principal_id.

ColumnTypeNullRoleFrom
created_attimestampfalseattributeprincipal.createdAt
display_nametexttrueattributeprincipal.displayName
kindtextfalseattributeprincipal.kind
owner_principal_idtexttruereferenceprincipal.owner
principal_idtextfalseattributeprincipal.principalId
statustextfalseattributeprincipal.status
status_changed_attimestampfalseattributeprincipal.statusChangedAt
status_reasontexttrueattributeprincipal.statusReason
tenant_idtexttruereferenceprincipal.tenant

Physical: SQL

CREATE TABLE IF NOT EXISTS "principal" (
    "principal_id" VARCHAR NOT NULL PRIMARY KEY,
    "kind" VARCHAR NOT NULL,
    "display_name" VARCHAR,
    "status" VARCHAR NOT NULL,
    "status_reason" VARCHAR,
    "status_changed_at" TIMESTAMPTZ NOT NULL,
    "created_at" TIMESTAMPTZ NOT NULL,
    "tenant_id" VARCHAR,
    "owner_principal_id" VARCHAR,
    CONSTRAINT "principal_tenant_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "tenant" ("tenant_id"),
    CONSTRAINT "principal_owner_principal_id_fk" FOREIGN KEY ("owner_principal_id") REFERENCES "principal" ("principal_id"),
    CONSTRAINT "principal_kind_ck" CHECK ("kind" IN ('user', 'machine', 'device', 'agent', 'group')),
    CONSTRAINT "principal_status_ck" CHECK ("status" IN ('pending', 'active', 'suspended', 'disabled', 'deleted')),
    CONSTRAINT "principal_principal_not_its_own_owner_ck" CHECK ("principal_id" <> "owner_principal_id")
);

Physical: the typed table

Read and written from TypeScript with the types the model gives: import { principal } from "@intellectual-frontiers/data/sql/typed/models". Generated in commons/data/sql/typed/models/identity.auto.ts: do not edit.

import { from } from "@intellectual-frontiers/data/sql/typed";
import { principal } from "@intellectual-frontiers/data/sql/typed/models";

const rows = await from(principal).select((s) => ({ principalId: s.principal.principalId, kind: s.principal.kind })).run(runner);

Titles, headings, exports, tables, columns and requirements. Esc closes.