business-as-code
Version:
Primitives for expressing business logic and processes as code
157 lines • 4.69 kB
TypeScript
/**
* Objectives and Key Results (OKRs) management
*
* Uses org.ai OKR types for standardized OKR definitions across the ecosystem.
*/
import type { OKRDefinition, KeyResult } from './types.js';
import type { OKR as OrgOKR, KeyResult as OrgKeyResult, OKRStatus, KeyResultStatus } from 'org.ai';
export type { OrgOKR, OrgKeyResult, OKRStatus, KeyResultStatus };
/**
* Convert a business-as-code KeyResult to an org.ai KeyResult
*
* @param kr - Business key result
* @param id - Optional identifier
* @returns org.ai KeyResult object
*/
export declare function toOrgKeyResult(kr: KeyResult, id?: string): OrgKeyResult;
/**
* Convert an org.ai KeyResult to a business-as-code KeyResult
*
* @param kr - org.ai KeyResult object
* @returns Business key result
*/
export declare function fromOrgKeyResult(kr: OrgKeyResult): KeyResult;
/**
* Convert a business-as-code OKRDefinition to an org.ai OKR
*
* @param definition - Business OKR definition
* @param id - Optional unique identifier
* @returns org.ai OKR object
*/
export declare function toOrgOKR(definition: OKRDefinition, id?: string): OrgOKR;
/**
* Convert an org.ai OKR to a business-as-code OKRDefinition
*
* @param okr - org.ai OKR object
* @returns Business OKR definition
*/
export declare function fromOrgOKR(okr: OrgOKR): OKRDefinition;
/**
* Define Objectives and Key Results for goal tracking
*
* @example
* ```ts
* const quarterlyOKRs = okrs([
* {
* objective: 'Achieve Product-Market Fit',
* description: 'Validate that our product solves a real problem for customers',
* period: 'Q2 2024',
* owner: 'CEO',
* keyResults: [
* {
* description: 'Increase Net Promoter Score',
* metric: 'NPS',
* startValue: 40,
* targetValue: 60,
* currentValue: 52,
* unit: 'score',
* progress: 60,
* },
* {
* description: 'Reduce monthly churn rate',
* metric: 'Churn Rate',
* startValue: 8,
* targetValue: 4,
* currentValue: 5.5,
* unit: 'percent',
* progress: 62.5,
* },
* {
* description: 'Achieve customer retention',
* metric: 'Customers with 3+ months',
* startValue: 50,
* targetValue: 200,
* currentValue: 125,
* unit: 'customers',
* progress: 50,
* },
* ],
* status: 'on-track',
* confidence: 75,
* },
* ])
* ```
*/
export declare function okrs(definitions: OKRDefinition[]): OKRDefinition[];
/**
* Define a single OKR
*/
export declare function okr(definition: OKRDefinition): OKRDefinition;
/**
* Calculate key result progress
*/
export declare function calculateKeyResultProgress(kr: KeyResult): number;
/**
* Calculate overall OKR progress
*/
export declare function calculateOKRProgress(okr: OKRDefinition): number;
/**
* Calculate confidence score based on key results
*/
export declare function calculateConfidence(keyResults: KeyResult[]): number;
/**
* Update key result current value
*/
export declare function updateKeyResult(okr: OKRDefinition, krDescription: string, currentValue: number): OKRDefinition;
/**
* Check if key result is on track
*/
export declare function isKeyResultOnTrack(kr: KeyResult): boolean;
/**
* Check if OKR is on track
*/
export declare function isOKROnTrack(okr: OKRDefinition): boolean;
/**
* Get key results that are on track
*/
export declare function getKeyResultsOnTrack(okr: OKRDefinition): KeyResult[];
/**
* Get key results that are at risk
*/
export declare function getKeyResultsAtRisk(okr: OKRDefinition): KeyResult[];
/**
* Get OKRs by owner
*/
export declare function getOKRsByOwner(okrs: OKRDefinition[], owner: string): OKRDefinition[];
/**
* Get OKRs by period
*/
export declare function getOKRsByPeriod(okrs: OKRDefinition[], period: string): OKRDefinition[];
/**
* Get OKRs by status
*/
export declare function getOKRsByStatus(okrs: OKRDefinition[], status: OKRDefinition['status']): OKRDefinition[];
/**
* Calculate success rate across all OKRs
*/
export declare function calculateSuccessRate(okrs: OKRDefinition[]): number;
/**
* Format key result for display
*/
export declare function formatKeyResult(kr: KeyResult): string;
/**
* Compare OKR performance between periods
*/
export declare function compareOKRPerformance(current: OKRDefinition, previous: OKRDefinition): {
progressDelta: number;
confidenceDelta: number;
improved: boolean;
};
/**
* Validate OKR definitions
*/
export declare function validateOKRs(okrs: OKRDefinition[]): {
valid: boolean;
errors: string[];
};
//# sourceMappingURL=okrs.d.ts.map