actionKeytextrequiredThe permission the action needs
Becomes the column action_key of approval_request.
A request for a person to approve one action of an agent, bound to a hash of its arguments, usable once
Model identityAgent. Written in commons/data/models/identity-agent/mod.ts:184. Identified by approvalRequestId.
actionKeytextrequiredThe permission the action needs
Becomes the column action_key of approval_request.
approvalRequestIdidentifierrequiredWhat identifies the request, made by the application
Becomes the column approval_request_id of approval_request.
approverRulecode of approverRulerequiredWho may approve
Becomes the column approver_rule of approval_request.
argsHashtextrequiredA hash of the arguments, so that an approval is for exactly this call
Becomes the column args_hash of approval_request.
consumedAtinstantoptionalWhen it was used
Becomes the column consumed_at of approval_request.
decidedAtinstantoptionalWhen it was decided
Becomes the column decided_at of approval_request.
decisionReasontextoptionalWhy it was decided so
Becomes the column decision_reason of approval_request.
expiresAtinstantrequiredWhen it stops being valid
Becomes the column expires_at of approval_request.
requestedAtinstantrequiredWhen it was asked for
Becomes the column requested_at of approval_request.
resourceIdtextoptionalThe resource it is about
Becomes the column resource_id of approval_request.
resourceTypetextoptionalThe kind of resource it is about
Becomes the column resource_type of approval_request.
riskLevelcode of riskLevelrequiredHow risky it is
Becomes the column risk_level of approval_request.
statuscode of approvalStatusrequiredWhere the request is
Becomes the column status of approval_request.
Annotations: quality.transitions={"allowed":{"pending":["approved","denied","expired","cancelled"],"approved":["consumed","expired","cancelled"],"denied":[],"expired":[],"cancelled":[],"cons...
summarytextrequiredWhat will happen, redacted
Becomes the column summary of approval_request.
agentoneThe agent that asks To principal. Written at commons/data/models/identity-agent/mod.ts:205
approverRoleoptionalThe role whose holders may approve, where the rule says so To accessRole. Written at commons/data/models/identity-agent/mod.ts:206
decidedByoptionalThe person who decided To principal. Written at commons/data/models/identity-agent/mod.ts:207
runoneThe run To agentRun. Written at commons/data/models/identity-agent/mod.ts:204
Projects to the table approval_request with the primary key approval_request_id.
| Column | Type | Null | Role | From |
|---|---|---|---|---|
action_key | text | false | attribute | approvalRequest.actionKey |
agent_principal_id | text | false | reference | approvalRequest.agent |
approval_request_id | text | false | attribute | approvalRequest.approvalRequestId |
approver_role_access_role_role_id | text | true | reference | approvalRequest.approverRole |
approver_rule | text | false | attribute | approvalRequest.approverRule |
args_hash | text | false | attribute | approvalRequest.argsHash |
consumed_at | timestamp | true | attribute | approvalRequest.consumedAt |
decided_at | timestamp | true | attribute | approvalRequest.decidedAt |
decided_by_principal_id | text | true | reference | approvalRequest.decidedBy |
decision_reason | text | true | attribute | approvalRequest.decisionReason |
expires_at | timestamp | false | attribute | approvalRequest.expiresAt |
requested_at | timestamp | false | attribute | approvalRequest.requestedAt |
resource_id | text | true | attribute | approvalRequest.resourceId |
resource_type | text | true | attribute | approvalRequest.resourceType |
risk_level | text | false | attribute | approvalRequest.riskLevel |
run_agent_run_run_id | text | false | reference | approvalRequest.run |
status | text | false | attribute | approvalRequest.status |
summary | text | false | attribute | approvalRequest.summary |
CREATE TABLE IF NOT EXISTS "approval_request" (
"approval_request_id" VARCHAR NOT NULL PRIMARY KEY,
"action_key" VARCHAR NOT NULL,
"resource_type" VARCHAR,
"resource_id" VARCHAR,
"args_hash" VARCHAR NOT NULL,
"summary" VARCHAR NOT NULL,
"risk_level" VARCHAR NOT NULL,
"approver_rule" VARCHAR NOT NULL,
"status" VARCHAR NOT NULL,
"requested_at" TIMESTAMPTZ NOT NULL,
"expires_at" TIMESTAMPTZ NOT NULL,
"decided_at" TIMESTAMPTZ,
"decision_reason" VARCHAR,
"consumed_at" TIMESTAMPTZ,
"run_agent_run_run_id" VARCHAR NOT NULL,
"agent_principal_id" VARCHAR NOT NULL,
"approver_role_access_role_role_id" VARCHAR,
"decided_by_principal_id" VARCHAR,
CONSTRAINT "approval_request_run_agent_run_run_id_fk" FOREIGN KEY ("run_agent_run_run_id") REFERENCES "agent_run" ("run_id"),
CONSTRAINT "approval_request_agent_principal_id_fk" FOREIGN KEY ("agent_principal_id") REFERENCES "principal" ("principal_id"),
CONSTRAINT "approval_request_approver_role_access_role_role_id_fk" FOREIGN KEY ("approver_role_access_role_role_id") REFERENCES "access_role" ("role_id"),
CONSTRAINT "approval_request_decided_by_principal_id_fk" FOREIGN KEY ("decided_by_principal_id") REFERENCES "principal" ("principal_id"),
CONSTRAINT "approval_request_risk_level_ck" CHECK ("risk_level" IN ('low', 'medium', 'high', 'critical')),
CONSTRAINT "approval_request_approver_rule_ck" CHECK ("approver_rule" IN ('owner', 'delegator', 'role_holder')),
CONSTRAINT "approval_request_status_ck" CHECK ("status" IN ('pending', 'approved', 'denied', 'expired', 'cancelled', 'consumed'))
);CREATE TABLE IF NOT EXISTS "approval_request" (
"approval_request_id" TEXT NOT NULL PRIMARY KEY,
"action_key" TEXT NOT NULL,
"resource_type" TEXT,
"resource_id" TEXT,
"args_hash" TEXT NOT NULL,
"summary" TEXT NOT NULL,
"risk_level" TEXT NOT NULL,
"approver_rule" TEXT NOT NULL,
"status" TEXT NOT NULL,
"requested_at" TIMESTAMPTZ NOT NULL,
"expires_at" TIMESTAMPTZ NOT NULL,
"decided_at" TIMESTAMPTZ,
"decision_reason" TEXT,
"consumed_at" TIMESTAMPTZ,
"run_agent_run_run_id" TEXT NOT NULL,
"agent_principal_id" TEXT NOT NULL,
"approver_role_access_role_role_id" TEXT,
"decided_by_principal_id" TEXT,
CONSTRAINT "approval_request_run_agent_run_run_id_fk" FOREIGN KEY ("run_agent_run_run_id") REFERENCES "agent_run" ("run_id"),
CONSTRAINT "approval_request_agent_principal_id_fk" FOREIGN KEY ("agent_principal_id") REFERENCES "principal" ("principal_id"),
CONSTRAINT "approval_request_approver_role_access_role_role_id_fk" FOREIGN KEY ("approver_role_access_role_role_id") REFERENCES "access_role" ("role_id"),
CONSTRAINT "approval_request_decided_by_principal_id_fk" FOREIGN KEY ("decided_by_principal_id") REFERENCES "principal" ("principal_id"),
CONSTRAINT "approval_request_risk_level_ck" CHECK ("risk_level" IN ('low', 'medium', 'high', 'critical')),
CONSTRAINT "approval_request_approver_rule_ck" CHECK ("approver_rule" IN ('owner', 'delegator', 'role_holder')),
CONSTRAINT "approval_request_status_ck" CHECK ("status" IN ('pending', 'approved', 'denied', 'expired', 'cancelled', 'consumed'))
);CREATE TABLE IF NOT EXISTS "approval_request" (
"approval_request_id" TEXT NOT NULL PRIMARY KEY,
"action_key" TEXT NOT NULL,
"resource_type" TEXT,
"resource_id" TEXT,
"args_hash" TEXT NOT NULL,
"summary" TEXT NOT NULL,
"risk_level" TEXT NOT NULL,
"approver_rule" TEXT NOT NULL,
"status" TEXT NOT NULL,
"requested_at" TEXT NOT NULL,
"expires_at" TEXT NOT NULL,
"decided_at" TEXT,
"decision_reason" TEXT,
"consumed_at" TEXT,
"run_agent_run_run_id" TEXT NOT NULL,
"agent_principal_id" TEXT NOT NULL,
"approver_role_access_role_role_id" TEXT,
"decided_by_principal_id" TEXT,
CONSTRAINT "approval_request_run_agent_run_run_id_fk" FOREIGN KEY ("run_agent_run_run_id") REFERENCES "agent_run" ("run_id"),
CONSTRAINT "approval_request_agent_principal_id_fk" FOREIGN KEY ("agent_principal_id") REFERENCES "principal" ("principal_id"),
CONSTRAINT "approval_request_approver_role_access_role_role_id_fk" FOREIGN KEY ("approver_role_access_role_role_id") REFERENCES "access_role" ("role_id"),
CONSTRAINT "approval_request_decided_by_principal_id_fk" FOREIGN KEY ("decided_by_principal_id") REFERENCES "principal" ("principal_id"),
CONSTRAINT "approval_request_risk_level_ck" CHECK ("risk_level" IN ('low', 'medium', 'high', 'critical')),
CONSTRAINT "approval_request_approver_rule_ck" CHECK ("approver_rule" IN ('owner', 'delegator', 'role_holder')),
CONSTRAINT "approval_request_status_ck" CHECK ("status" IN ('pending', 'approved', 'denied', 'expired', 'cancelled', 'consumed'))
);Read and written from TypeScript with the types the model gives: import { approvalRequest } from "@intellectual-frontiers/data/sql/typed/models". Generated in commons/data/sql/typed/models/identity-agent.auto.ts: do not edit.
import { from } from "@intellectual-frontiers/data/sql/typed";
import { approvalRequest } from "@intellectual-frontiers/data/sql/typed/models";
const rows = await from(approvalRequest).select((s) => ({ approvalRequestId: s.approvalRequest.approvalRequestId, actionKey: s.approvalRequest.actionKey })).run(runner);