IF Commons GitHub

relationTuple

concept

A fact of relationship-based access: this subject has this relation to this object, perhaps under a caveat and until a time

Model identityRebac. Written in commons/data/models/identity-rebac/mod.ts:31. Identified by relationTupleId.

Governance: attributes

caveattextoptional

The name of a caveat of the model that must hold

Becomes the column caveat of relation_tuple.

Written at commons/data/models/identity-rebac/mod.ts:42

caveatContextstructuredoptional

The values the caveat is given

Becomes the column caveat_context of relation_tuple.

Written at commons/data/models/identity-rebac/mod.ts:43

createdAtinstantrequired

When the fact was recorded

Becomes the column created_at of relation_tuple.

Written at commons/data/models/identity-rebac/mod.ts:45

expiresAtinstantoptional

When the fact stops holding

Becomes the column expires_at of relation_tuple.

Written at commons/data/models/identity-rebac/mod.ts:44

objectIdtextrequired

The object

Becomes the column object_id of relation_tuple.

Written at commons/data/models/identity-rebac/mod.ts:37

objectTypetextrequired

The kind of the object

Becomes the column object_type of relation_tuple.

Written at commons/data/models/identity-rebac/mod.ts:36

relationtextrequired

The relation

Becomes the column relation of relation_tuple.

Written at commons/data/models/identity-rebac/mod.ts:38

relationTupleIdidentifierrequired

What identifies the fact, made by the application

Becomes the column relation_tuple_id of relation_tuple.

Written at commons/data/models/identity-rebac/mod.ts:34

subjectIdtextrequired

The subject

Becomes the column subject_id of relation_tuple.

Written at commons/data/models/identity-rebac/mod.ts:40

subjectRelationtextoptional

The relation of the subject that is meant, where a set is

Becomes the column subject_relation of relation_tuple.

Written at commons/data/models/identity-rebac/mod.ts:41

subjectTypetextrequired

The kind of the subject: a kind of principal, or a kind of object

Becomes the column subject_type of relation_tuple.

Written at commons/data/models/identity-rebac/mod.ts:39

tupleKeytextrequired

A hash of the tenant, the object, the relation and the subject, unique, so that a fact is not recorded twice

Becomes the column tuple_key of relation_tuple.

Written at commons/data/models/identity-rebac/mod.ts:35

Governance: relationships

tenantone

The tenant the fact is in To tenant. Written at commons/data/models/identity-rebac/mod.ts:31

Logical: the table

Projects to the table relation_tuple with the primary key relation_tuple_id.

ColumnTypeNullRoleFrom
caveattexttrueattributerelationTuple.caveat
caveat_contextjsontrueattributerelationTuple.caveatContext
created_attimestampfalseattributerelationTuple.createdAt
expires_attimestamptrueattributerelationTuple.expiresAt
object_idtextfalseattributerelationTuple.objectId
object_typetextfalseattributerelationTuple.objectType
relationtextfalseattributerelationTuple.relation
relation_tuple_idtextfalseattributerelationTuple.relationTupleId
subject_idtextfalseattributerelationTuple.subjectId
subject_relationtexttrueattributerelationTuple.subjectRelation
subject_typetextfalseattributerelationTuple.subjectType
tenant_idtextfalsereferencerelationTuple.tenant
tuple_keytextfalseattributerelationTuple.tupleKey

Physical: SQL

CREATE TABLE IF NOT EXISTS "relation_tuple" (
    "relation_tuple_id" VARCHAR NOT NULL PRIMARY KEY,
    "tuple_key" VARCHAR NOT NULL,
    "object_type" VARCHAR NOT NULL,
    "object_id" VARCHAR NOT NULL,
    "relation" VARCHAR NOT NULL,
    "subject_type" VARCHAR NOT NULL,
    "subject_id" VARCHAR NOT NULL,
    "subject_relation" VARCHAR,
    "caveat" VARCHAR,
    "caveat_context" JSON,
    "expires_at" TIMESTAMPTZ,
    "created_at" TIMESTAMPTZ NOT NULL,
    "tenant_id" VARCHAR NOT NULL,
    CONSTRAINT "relation_tuple_tenant_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "tenant" ("tenant_id"),
    CONSTRAINT "relation_tuple_tuple_key_uq" UNIQUE ("tuple_key")
);

Physical: the typed table

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

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

const rows = await from(relationTuple).select((s) => ({ relationTupleId: s.relationTuple.relationTupleId, tupleKey: s.relationTuple.tupleKey })).run(runner);

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