TealTiger Playground API Reference
Complete reference for all service classes, data models, and interfaces in the TealTiger Playground enterprise platform.
Source: playground/src/services/ and playground/src/types/
Authentication
AuthenticationService
src/services/AuthenticationService.ts — Handles GitHub OAuth via Supabase Auth.
| Method | Signature | Description |
|---|
signInWithGitHub | () => Promise<void> | Initiates GitHub OAuth flow |
handleCallback | () => Promise<AuthUser> | Handles OAuth callback, creates/updates user profile |
signOut | () => Promise<void> | Signs out user and clears session |
getCurrentUser | () => Promise<AuthUser | null> | Returns current authenticated user |
syncOrganizations | (userId: string) => Promise<void> | Syncs GitHub org memberships |
SessionManager
src/services/SessionManager.ts — Session persistence with automatic token refresh.
| Method | Signature | Description |
|---|
persistSession | (session: Session) => Promise<void> | Stores session in localStorage |
restoreSession | () => Promise<Session | null> | Restores session, refreshes if expired |
clearSession | () => Promise<void> | Removes session from all storage |
setupAutoRefresh | (session: Session) => () => void | Auto-refresh before expiry |
Workspace Management
WorkspaceService
src/services/WorkspaceService.ts — Team workspaces with role-based permissions.
| Method | Description |
|---|
createWorkspace(name, ownerId) | Creates workspace, adds owner as member |
inviteMember(workspaceId, emailOrUsername, role, invitedBy) | Invites user by email or GitHub username |
removeMember(workspaceId, memberId) | Removes a member |
updateMemberRole(workspaceId, memberId, newRole) | Changes a member’s role |
listWorkspaces(userId) | Lists all workspaces the user belongs to |
checkPermission(workspaceId, userId, action) | Checks if user has permission |
Policy Management
PolicyRegistryService
src/services/PolicyRegistryService.ts — Central policy registry with semantic versioning.
| Method | Description |
|---|
createPolicy(input) | Creates policy in Draft state with version 1.0.0 |
saveVersion(input) | Saves new version (major/minor/patch bump) |
revertToVersion(policyId, versionId, userId) | Reverts to a previous version |
searchPolicies(input) | Searches by name, tag, author, or category |
branchPolicy(input) | Creates a branch for experimental changes |
PolicyDiffService
src/services/PolicyDiffService.ts — Diffs between policy versions.
| Method | Description |
|---|
calculateDiff(oldVersion, newVersion) | Line-by-line diff |
exportUnifiedDiff(diff) | Unified format with +/- indicators |
exportHtmlDiff(diff) | Syntax-highlighted HTML |
PolicyTemplateService
src/services/PolicyTemplateService.ts — 15+ enterprise policy templates.
| Method | Description |
|---|
listTemplates() | Returns all templates |
getTemplatesByCategory(category) | Filters by category |
searchTemplates(query) | Searches by name, description, or tags |
customizeTemplate(templateId, parameters) | Applies parameters, returns code |
validateParameters(templateId, parameters) | Validates against template schema |
PolicyImpactAnalysisService
src/services/PolicyImpactAnalysisService.ts — Impact analysis comparing versions.
| Method | Description |
|---|
analyzeImpact(policyId, oldVersionId, newVersionId) | Full impact analysis |
compareResults(oldResults, newResults) | Detects decision (±any), cost (±10%), latency (±20%) changes |
filterBySeverity(scenarios, severity) | Filter by breaking/warning/info |
exportImpactReport(analysis, format) | Export as CSV or PDF |
Collaboration
CollaborationService
Inline code comments with threading, mentions, and version persistence.
| Method | Description |
|---|
addComment(input) | Comment on a specific line |
addReply(input) | Threaded reply |
resolveComment(commentId) | Mark as resolved |
filterComments(policyId, filters) | Filter by author, status, date |
RealtimeCollaborationService
Real-time sync via Supabase channels with offline support.
| Method | Description |
|---|
subscribeToPolicyChanges(policyId, callback) | Live policy edits |
subscribeToComments(policyId, callback) | Live comment updates |
broadcastPresence(workspaceId, userId) | Active editing presence |
syncOfflineChanges(changes) | Sync queued offline changes |
Governance
GovernanceService
src/services/GovernanceService.ts — Policy approval workflow: Draft → Review → Approved → Production.
| Method | Description |
|---|
promotePolicy(input) | Promotes to next state, validates transitions |
requestApproval(input) | Sends approval requests to approvers |
approvePolicy(input) | Records approval with comment |
rejectPolicy(input) | Records rejection with reason |
getApprovalStatus(policyId) | Current approval status and canPromote flag |
emergencyBypass(input) | Emergency promotion bypassing approvals |
checkAutoApproval(policyId, oldCode, newCode) | Checks auto-approval eligibility |
Compliance & Audit
ComplianceService
Maps policies to frameworks (OWASP, NIST, SOC2, ISO 27001, GDPR).
| Method | Description |
|---|
mapPolicyToRequirement(input) | Map policy to framework requirement |
calculateCoverage(workspaceId, frameworkId) | Coverage percentage |
getUnmappedRequirements(workspaceId, frameworkId) | Gap identification |
loadCustomFramework(workspaceId, framework) | Load custom JSON framework |
exportMappings(input) | Export as CSV or JSON |
AuditTrailService
Immutable, append-only audit log with redaction and tamper detection.
| Method | Description |
|---|
logEvent(...) | Log audit event with auto-redaction |
filterEvents(workspaceId, filters, options) | Filter by date, actor, action, resource |
exportCSV/JSON/PDF(workspaceId, filters) | Export in three formats |
signExport(data) | SHA-256 signature for tamper detection |
verifySignature(data, signature) | Verify export integrity |
Enterprise Features
RBACSimulatorService
| Method | Description |
|---|
defineRole(workspaceId, role) | Create custom role |
simulateWithRole(policyId, versionId, role, scenario) | Simulate with role context |
simulateAcrossRoles(policyId, versionId, roles, scenario) | Multi-role parallel simulation |
compareRoleResults(results) | Highlight decision/reason/timing differences |
EnvironmentService
Manages deployment environments (Development, Staging, Production).
| Method | Description |
|---|
createEnvironment(input) | Create environment with config |
promotePolicy(input) | Promote policy to environment |
rollback(environmentId, policyId) | Rollback to previous version |
CICDIntegrationService
| Method | Description |
|---|
generateWorkflow(config) | Generate GitHub Actions YAML |
validateSyntax(code) | Validate policy syntax |
runTestSuite(policyId, versionId, scenarios) | Run test suite |
generateCoverageReport(testRunResult) | Coverage report |
postPRComment(repoOwner, repoName, prNumber, results) | Post PR comment |
Data Models
Core Types
// Authentication
interface AuthUser {
id: string; githubId: string; username: string;
email: string; avatarUrl: string; organizations: GitHubOrganization[];
}
// Workspace
enum WorkspaceRole { Owner = 'owner', Editor = 'editor', Viewer = 'viewer' }
// Policy
enum PolicyState { Draft = 'draft', Review = 'review', Approved = 'approved', Production = 'production' }
// Audit
type AuditAction = 'policy_created' | 'policy_updated' | 'policy_deleted'
| 'policy_approved' | 'policy_rejected' | 'policy_deployed' | 'policy_evaluated'
| 'member_added' | 'member_removed' | 'member_role_changed'
| 'workspace_settings_changed' | 'auth_login' | 'auth_logout' | 'emergency_bypass';
Error Handling
All services follow a consistent error pattern with typed error interfaces.
| Code | Service | Description |
|---|
SUPABASE_NOT_CONFIGURED | All | Environment variables not set |
APPROVAL_REQUIRED | Governance | Approvals needed for promotion |
INVALID_TRANSITION | Governance | Invalid state transition |
EDIT_BLOCKED | Governance | Cannot edit Approved/Production policies |
PERMISSION_DENIED | Workspace | User lacks required role |
DUPLICATE_NAME | PolicyRegistry | Policy name already exists |
TypeDoc Generation
Generate HTML API docs from source:
cd playground
npm run docs:api
Outputs to playground/docs/typedoc/. Configured in playground/typedoc.json.