@prismshadow/penguin-library-agent-api · library/agent-api/src/agent-api.ts:103

AgentApi

interface

No JSDoc comment in source yet.

API

@Interface()
export abstract class AgentApi {
  abstract get(projectId: string, agentId: string): AgentApiRow | null;
  abstract set(projectId: string, agentId: string, patch: AgentApiPatch, at: string): AgentApiRow;
  abstract enabledAgents(projectId: string): string[];
  abstract listKeys(projectId: string, agentId: string): AgentApiKeyRow[];
  abstract insertKey(row: AgentApiKeyRow & { tokenHash: string }): void;
  abstract findKeyByHash(tokenHash: string): AgentApiKeyRow | null;
  abstract touchKey(keyId: string, at: string): void;
  abstract deleteKey(projectId: string, agentId: string, keyId: string): boolean;
  abstract deleteByAgent(projectId: string, agentId: string): void;
  abstract deleteByProject(projectId: string): void;
}

Contract Topology

Static AST wiring across @Module / @Provide / @Use

Members (10)

get

get(projectId: string, agentId: string): AgentApiRow | null

The Agent's row; null = never configured, which reads as disabled, keyed, allow-all.

@paramprojectIdstring
@paramagentIdstring
@returnsAgentApiRow | null

set

set(projectId: string, agentId: string, patch: AgentApiPatch, at: string): AgentApiRow

Writes the patch over the stored row (or the defaults) and returns the row as stored.

@paramprojectIdstring
@paramagentIdstring
@parampatchAgentApiPatch
@paramatstring
@returnsAgentApiRow

enabledAgents

enabledAgents(projectId: string): string[]

The Project's Agents whose switch is on, in one query (the Agent list's apiEnabled).

@paramprojectIdstring
@returnsstring[]

listKeys

listKeys(projectId: string, agentId: string): AgentApiKeyRow[]

The Agent's keys, oldest first.

@paramprojectIdstring
@paramagentIdstring
@returnsAgentApiKeyRow[]

insertKey

insertKey(row: AgentApiKeyRow & { tokenHash: string }): void
@paramrowAgentApiKeyRow & { tokenHash: string }
@returnsvoid

findKeyByHash

findKeyByHash(tokenHash: string): AgentApiKeyRow | null

The key whose secret hashes to tokenHash; null when none does.

@paramtokenHashstring
@returnsAgentApiKeyRow | null

touchKey

touchKey(keyId: string, at: string): void
@paramkeyIdstring
@paramatstring
@returnsvoid

deleteKey

deleteKey(projectId: string, agentId: string, keyId: string): boolean

Hard delete; false when the Agent has no such key.

@paramprojectIdstring
@paramagentIdstring
@paramkeyIdstring
@returnsboolean

deleteByAgent

deleteByAgent(projectId: string, agentId: string): void

Drops the Agent's settings and keys (the Agent was deleted).

@paramprojectIdstring
@paramagentIdstring
@returnsvoid

deleteByProject

deleteByProject(projectId: string): void

Drops every settings row and key of the Project (the Project was deleted).

@paramprojectIdstring
@returnsvoid