createdAtinstantrequiredWhen the principal was made
Becomes the column created_at of principal.
Written at commons/data/models/identity/concepts.ts:47
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.
createdAtinstantrequiredWhen the principal was made
Becomes the column created_at of principal.
Written at commons/data/models/identity/concepts.ts:47
displayNametextoptionalpersonal dataThe 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 principalKindrequiredWhether 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
principalIdidentifierrequiredWhat 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 principalStatusrequiredWhere 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
statusChangedAtinstantrequiredWhen the principal's status last changed
Becomes the column status_changed_at of principal.
Written at commons/data/models/identity/concepts.ts:46
statusReasontextoptionalWhy 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
owneroptionalThe 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
tenantoptionalThe 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
Projects to the table principal with the primary key principal_id.
| Column | Type | Null | Role | From |
|---|---|---|---|---|
created_at | timestamp | false | attribute | principal.createdAt |
display_name | text | true | attribute | principal.displayName |
kind | text | false | attribute | principal.kind |
owner_principal_id | text | true | reference | principal.owner |
principal_id | text | false | attribute | principal.principalId |
status | text | false | attribute | principal.status |
status_changed_at | timestamp | false | attribute | principal.statusChangedAt |
status_reason | text | true | attribute | principal.statusReason |
tenant_id | text | true | reference | principal.tenant |
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")
);CREATE TABLE IF NOT EXISTS "principal" (
"principal_id" TEXT NOT NULL PRIMARY KEY,
"kind" TEXT NOT NULL,
"display_name" TEXT,
"status" TEXT NOT NULL,
"status_reason" TEXT,
"status_changed_at" TIMESTAMPTZ NOT NULL,
"created_at" TIMESTAMPTZ NOT NULL,
"tenant_id" TEXT,
"owner_principal_id" TEXT,
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")
);CREATE TABLE IF NOT EXISTS "principal" (
"principal_id" TEXT NOT NULL PRIMARY KEY,
"kind" TEXT NOT NULL,
"display_name" TEXT,
"status" TEXT NOT NULL,
"status_reason" TEXT,
"status_changed_at" TEXT NOT NULL,
"created_at" TEXT NOT NULL,
"tenant_id" TEXT,
"owner_principal_id" TEXT,
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")
);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);