@mrck-labs/vanaheim-shared 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -0
- package/dist/constants/index.d.mts +42 -0
- package/dist/constants/index.d.ts +42 -0
- package/dist/constants/index.js +147 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/index.mjs +108 -0
- package/dist/constants/index.mjs.map +1 -0
- package/dist/database-BKc0Oj26.d.mts +240 -0
- package/dist/database-BKc0Oj26.d.ts +240 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +411 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +343 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types/index.d.mts +135 -0
- package/dist/types/index.d.ts +135 -0
- package/dist/types/index.js +39 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +12 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/utils/index.d.mts +159 -0
- package/dist/utils/index.d.ts +159 -0
- package/dist/utils/index.js +288 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +236 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
export { s as BankConnection, B as BankConnectionStatus, t as BankTransaction, k as ChatConversation, m as ChatMessage, C as ChatMessageRole, o as EFLink, u as ExchangeRate, a as Expense, E as ExpenseCategory, F as FocusCategory, h as FocusSession, j as FocusSessionFilters, g as FocusSessionStatus, d as Income, I as IncomeCategory, q as LieuDay, L as LieuDayType, l as NewChatConversation, n as NewChatMessage, p as NewEFLink, b as NewExpense, N as NewExpenseCategory, f as NewFocusCategory, i as NewFocusSession, e as NewIncome, c as NewIncomeCategory, r as NewLieuDay, S as Setting, T as TransactionType } from '../database-BKc0Oj26.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cursor Cloud API Types
|
|
5
|
+
*
|
|
6
|
+
* Types for interacting with Cursor's Cloud Agents API.
|
|
7
|
+
*/
|
|
8
|
+
type CloudAgentStatus = 'CREATING' | 'RUNNING' | 'FINISHED' | 'FAILED' | 'CANCELLED';
|
|
9
|
+
type CloudAgentModel = 'claude-4-opus-thinking' | 'claude-4.5-opus-high-thinking' | 'claude-4-sonnet-thinking' | 'o3';
|
|
10
|
+
interface CloudAgentSource {
|
|
11
|
+
repository: string;
|
|
12
|
+
ref: string;
|
|
13
|
+
}
|
|
14
|
+
interface CloudAgentTarget {
|
|
15
|
+
branchName?: string;
|
|
16
|
+
url?: string | null;
|
|
17
|
+
prUrl?: string | null;
|
|
18
|
+
autoCreatePr: boolean;
|
|
19
|
+
openAsCursorGithubApp?: boolean;
|
|
20
|
+
skipReviewerRequest?: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface CloudAgent {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string | null;
|
|
25
|
+
status: CloudAgentStatus;
|
|
26
|
+
source: CloudAgentSource;
|
|
27
|
+
target: CloudAgentTarget;
|
|
28
|
+
summary?: string | null;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
}
|
|
31
|
+
type CloudAgentMessageType = 'user_message' | 'assistant_message';
|
|
32
|
+
interface CloudAgentMessage {
|
|
33
|
+
id: string;
|
|
34
|
+
type: CloudAgentMessageType;
|
|
35
|
+
text: string;
|
|
36
|
+
createdAt?: string;
|
|
37
|
+
}
|
|
38
|
+
interface CloudAgentConversation {
|
|
39
|
+
id?: string;
|
|
40
|
+
agentId?: string;
|
|
41
|
+
messages: CloudAgentMessage[];
|
|
42
|
+
}
|
|
43
|
+
interface CloudAgentPrompt {
|
|
44
|
+
text: string;
|
|
45
|
+
images?: Array<{
|
|
46
|
+
data: string;
|
|
47
|
+
dimension: {
|
|
48
|
+
width: number;
|
|
49
|
+
height: number;
|
|
50
|
+
};
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
interface LaunchAgentRequest {
|
|
54
|
+
prompt: CloudAgentPrompt;
|
|
55
|
+
source: CloudAgentSource;
|
|
56
|
+
target?: {
|
|
57
|
+
autoCreatePr?: boolean;
|
|
58
|
+
branchName?: string;
|
|
59
|
+
openAsCursorGithubApp?: boolean;
|
|
60
|
+
skipReviewerRequest?: boolean;
|
|
61
|
+
};
|
|
62
|
+
model?: CloudAgentModel;
|
|
63
|
+
}
|
|
64
|
+
interface ListAgentsResponse {
|
|
65
|
+
agents: CloudAgent[];
|
|
66
|
+
nextCursor?: string;
|
|
67
|
+
hasMore?: boolean;
|
|
68
|
+
}
|
|
69
|
+
interface ModelsResponse {
|
|
70
|
+
models: string[];
|
|
71
|
+
}
|
|
72
|
+
interface ApiKeyInfo {
|
|
73
|
+
apiKeyName?: string;
|
|
74
|
+
email?: string;
|
|
75
|
+
userEmail?: string;
|
|
76
|
+
createdAt?: string;
|
|
77
|
+
usage?: {
|
|
78
|
+
current: number;
|
|
79
|
+
limit: number;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Linear API Types
|
|
85
|
+
*
|
|
86
|
+
* Types for interacting with Linear's GraphQL API.
|
|
87
|
+
*/
|
|
88
|
+
interface LinearUser {
|
|
89
|
+
id: string;
|
|
90
|
+
name: string;
|
|
91
|
+
email: string;
|
|
92
|
+
avatarUrl: string | null;
|
|
93
|
+
}
|
|
94
|
+
interface LinearProject {
|
|
95
|
+
id: string;
|
|
96
|
+
name: string;
|
|
97
|
+
color: string;
|
|
98
|
+
}
|
|
99
|
+
type LinearStateType = 'backlog' | 'unstarted' | 'started' | 'completed' | 'canceled';
|
|
100
|
+
interface LinearState {
|
|
101
|
+
id: string;
|
|
102
|
+
name: string;
|
|
103
|
+
color: string;
|
|
104
|
+
type: LinearStateType;
|
|
105
|
+
}
|
|
106
|
+
type LinearPriority = 0 | 1 | 2 | 3 | 4;
|
|
107
|
+
declare const LINEAR_PRIORITY_LABELS: Record<LinearPriority, string>;
|
|
108
|
+
interface LinearIssue {
|
|
109
|
+
id: string;
|
|
110
|
+
identifier: string;
|
|
111
|
+
title: string;
|
|
112
|
+
description: string | null;
|
|
113
|
+
priority: LinearPriority;
|
|
114
|
+
priorityLabel: string;
|
|
115
|
+
dueDate: string | null;
|
|
116
|
+
url: string;
|
|
117
|
+
state: LinearState | null;
|
|
118
|
+
project: LinearProject | null;
|
|
119
|
+
createdAt: string;
|
|
120
|
+
updatedAt: string;
|
|
121
|
+
}
|
|
122
|
+
interface IssueQueryOptions {
|
|
123
|
+
projectId?: string;
|
|
124
|
+
search?: string;
|
|
125
|
+
cursor?: string;
|
|
126
|
+
limit?: number;
|
|
127
|
+
}
|
|
128
|
+
interface PaginatedIssues {
|
|
129
|
+
issues: LinearIssue[];
|
|
130
|
+
hasNextPage: boolean;
|
|
131
|
+
endCursor: string | null;
|
|
132
|
+
totalCount: number;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export { type ApiKeyInfo, type CloudAgent, type CloudAgentConversation, type CloudAgentMessage, type CloudAgentMessageType, type CloudAgentModel, type CloudAgentPrompt, type CloudAgentSource, type CloudAgentStatus, type CloudAgentTarget, type IssueQueryOptions, LINEAR_PRIORITY_LABELS, type LaunchAgentRequest, type LinearIssue, type LinearPriority, type LinearProject, type LinearState, type LinearStateType, type LinearUser, type ListAgentsResponse, type ModelsResponse, type PaginatedIssues };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/types/index.ts
|
|
21
|
+
var types_exports = {};
|
|
22
|
+
__export(types_exports, {
|
|
23
|
+
LINEAR_PRIORITY_LABELS: () => LINEAR_PRIORITY_LABELS
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(types_exports);
|
|
26
|
+
|
|
27
|
+
// src/types/linear.ts
|
|
28
|
+
var LINEAR_PRIORITY_LABELS = {
|
|
29
|
+
0: "No priority",
|
|
30
|
+
1: "Urgent",
|
|
31
|
+
2: "High",
|
|
32
|
+
3: "Medium",
|
|
33
|
+
4: "Low"
|
|
34
|
+
};
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
LINEAR_PRIORITY_LABELS
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/index.ts","../../src/types/linear.ts"],"sourcesContent":["/**\n * Types Index\n *\n * Re-exports all shared types.\n */\n\n// Database types\nexport * from \"./database\";\n\n// API types\nexport * from \"./cursor-cloud\";\nexport * from \"./linear\";\n","/**\n * Linear API Types\n *\n * Types for interacting with Linear's GraphQL API.\n */\n\n// ============================================================================\n// User Types\n// ============================================================================\n\nexport interface LinearUser {\n id: string\n name: string\n email: string\n avatarUrl: string | null\n}\n\n// ============================================================================\n// Project Types\n// ============================================================================\n\nexport interface LinearProject {\n id: string\n name: string\n color: string\n}\n\n// ============================================================================\n// State Types\n// ============================================================================\n\nexport type LinearStateType =\n | 'backlog'\n | 'unstarted'\n | 'started'\n | 'completed'\n | 'canceled'\n\nexport interface LinearState {\n id: string\n name: string\n color: string\n type: LinearStateType\n}\n\n// ============================================================================\n// Issue Types\n// ============================================================================\n\nexport type LinearPriority = 0 | 1 | 2 | 3 | 4\n\nexport const LINEAR_PRIORITY_LABELS: Record<LinearPriority, string> = {\n 0: 'No priority',\n 1: 'Urgent',\n 2: 'High',\n 3: 'Medium',\n 4: 'Low',\n}\n\nexport interface LinearIssue {\n id: string\n identifier: string\n title: string\n description: string | null\n priority: LinearPriority\n priorityLabel: string\n dueDate: string | null\n url: string\n state: LinearState | null\n project: LinearProject | null\n createdAt: string\n updatedAt: string\n}\n\n// ============================================================================\n// Query Types\n// ============================================================================\n\nexport interface IssueQueryOptions {\n projectId?: string\n search?: string\n cursor?: string\n limit?: number\n}\n\nexport interface PaginatedIssues {\n issues: LinearIssue[]\n hasNextPage: boolean\n endCursor: string | null\n totalCount: number\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACmDO,IAAM,yBAAyD;AAAA,EACpE,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/linear.ts"],"sourcesContent":["/**\n * Linear API Types\n *\n * Types for interacting with Linear's GraphQL API.\n */\n\n// ============================================================================\n// User Types\n// ============================================================================\n\nexport interface LinearUser {\n id: string\n name: string\n email: string\n avatarUrl: string | null\n}\n\n// ============================================================================\n// Project Types\n// ============================================================================\n\nexport interface LinearProject {\n id: string\n name: string\n color: string\n}\n\n// ============================================================================\n// State Types\n// ============================================================================\n\nexport type LinearStateType =\n | 'backlog'\n | 'unstarted'\n | 'started'\n | 'completed'\n | 'canceled'\n\nexport interface LinearState {\n id: string\n name: string\n color: string\n type: LinearStateType\n}\n\n// ============================================================================\n// Issue Types\n// ============================================================================\n\nexport type LinearPriority = 0 | 1 | 2 | 3 | 4\n\nexport const LINEAR_PRIORITY_LABELS: Record<LinearPriority, string> = {\n 0: 'No priority',\n 1: 'Urgent',\n 2: 'High',\n 3: 'Medium',\n 4: 'Low',\n}\n\nexport interface LinearIssue {\n id: string\n identifier: string\n title: string\n description: string | null\n priority: LinearPriority\n priorityLabel: string\n dueDate: string | null\n url: string\n state: LinearState | null\n project: LinearProject | null\n createdAt: string\n updatedAt: string\n}\n\n// ============================================================================\n// Query Types\n// ============================================================================\n\nexport interface IssueQueryOptions {\n projectId?: string\n search?: string\n cursor?: string\n limit?: number\n}\n\nexport interface PaginatedIssues {\n issues: LinearIssue[]\n hasNextPage: boolean\n endCursor: string | null\n totalCount: number\n}\n\n"],"mappings":";AAmDO,IAAM,yBAAyD;AAAA,EACpE,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;","names":[]}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { a as Expense, d as Income } from '../database-BKc0Oj26.mjs';
|
|
2
|
+
import { Frequency } from '../constants/index.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Formatting Utilities
|
|
6
|
+
*
|
|
7
|
+
* Pure functions for formatting data.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Format seconds into MM:SS format
|
|
11
|
+
* @example formatTime(125) => "02:05"
|
|
12
|
+
*/
|
|
13
|
+
declare function formatTime(seconds: number): string;
|
|
14
|
+
/**
|
|
15
|
+
* Format seconds into human-readable total time
|
|
16
|
+
* @example formatTotalTime(3700) => "1h 1m"
|
|
17
|
+
* @example formatTotalTime(1800) => "30m"
|
|
18
|
+
*/
|
|
19
|
+
declare function formatTotalTime(seconds: number): string;
|
|
20
|
+
/**
|
|
21
|
+
* Format a number as currency
|
|
22
|
+
* @example formatCurrency(1234.56, 'CHF') => "CHF 1,234.56"
|
|
23
|
+
*/
|
|
24
|
+
declare function formatCurrency(amount: number, currency: string, locale?: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Format a date as relative time (e.g., "2h ago", "3d ago")
|
|
27
|
+
*/
|
|
28
|
+
declare function formatRelativeTime(dateStr: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Format a date string to a readable format
|
|
31
|
+
* @example formatDate('2024-01-15') => "Jan 15, 2024"
|
|
32
|
+
*/
|
|
33
|
+
declare function formatDate(dateStr: string, options?: Intl.DateTimeFormatOptions): string;
|
|
34
|
+
/**
|
|
35
|
+
* Format a due date with context (Today, Tomorrow, Overdue, etc.)
|
|
36
|
+
*/
|
|
37
|
+
declare function formatDueDate(dueDate: string | null): {
|
|
38
|
+
text: string;
|
|
39
|
+
isOverdue: boolean;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Truncate a string with ellipsis
|
|
43
|
+
* @example truncate("Hello World", 5) => "Hello..."
|
|
44
|
+
*/
|
|
45
|
+
declare function truncate(str: string, maxLength: number): string;
|
|
46
|
+
/**
|
|
47
|
+
* Extract repo name from GitHub URL
|
|
48
|
+
* @example getRepoName("https://github.com/owner/repo") => "owner/repo"
|
|
49
|
+
*/
|
|
50
|
+
declare function getRepoName(url: string): string;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* ID and Data Generators
|
|
54
|
+
*
|
|
55
|
+
* Pure functions for generating IDs and data.
|
|
56
|
+
*/
|
|
57
|
+
/**
|
|
58
|
+
* Generate a unique ID
|
|
59
|
+
* Uses crypto.randomUUID if available, falls back to timestamp-based ID
|
|
60
|
+
*
|
|
61
|
+
* Note: This works in both Node.js and browser environments.
|
|
62
|
+
* React Native needs the fallback since crypto.randomUUID isn't available.
|
|
63
|
+
*/
|
|
64
|
+
declare function generateId(): string;
|
|
65
|
+
/**
|
|
66
|
+
* Generate a short ID (timestamp + random)
|
|
67
|
+
* Format: {timestamp}-{random7chars}
|
|
68
|
+
* @example "1732547123456-k8f3j2m"
|
|
69
|
+
*/
|
|
70
|
+
declare function generateShortId(): string;
|
|
71
|
+
/**
|
|
72
|
+
* Generate a random color in hex format
|
|
73
|
+
*/
|
|
74
|
+
declare function generateRandomColor(): string;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Validation Utilities
|
|
78
|
+
*
|
|
79
|
+
* Pure functions for validating data.
|
|
80
|
+
*/
|
|
81
|
+
/**
|
|
82
|
+
* Check if a string is a valid email
|
|
83
|
+
*/
|
|
84
|
+
declare function isValidEmail(email: string): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Check if a string is a valid URL
|
|
87
|
+
*/
|
|
88
|
+
declare function isValidUrl(url: string): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Check if a string is a valid ISO date (YYYY-MM-DD)
|
|
91
|
+
*/
|
|
92
|
+
declare function isValidISODate(dateStr: string): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Check if a value is a valid currency code
|
|
95
|
+
*/
|
|
96
|
+
declare function isValidCurrency(currency: string): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Check if a value is a valid frequency
|
|
99
|
+
*/
|
|
100
|
+
declare function isValidFrequency(frequency: string): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Validate a positive number
|
|
103
|
+
*/
|
|
104
|
+
declare function isPositiveNumber(value: unknown): value is number;
|
|
105
|
+
/**
|
|
106
|
+
* Validate a non-empty string
|
|
107
|
+
*/
|
|
108
|
+
declare function isNonEmptyString(value: unknown): value is string;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Calculation Utilities
|
|
112
|
+
*
|
|
113
|
+
* Pure functions for business logic calculations.
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Convert an amount to yearly based on frequency
|
|
118
|
+
*/
|
|
119
|
+
declare function toYearlyAmount(amount: number, frequency: Frequency): number;
|
|
120
|
+
/**
|
|
121
|
+
* Convert an amount to monthly based on frequency
|
|
122
|
+
*/
|
|
123
|
+
declare function toMonthlyAmount(amount: number, frequency: Frequency): number;
|
|
124
|
+
/**
|
|
125
|
+
* Calculate total expenses (monthly)
|
|
126
|
+
*/
|
|
127
|
+
declare function calculateMonthlyExpenses(expenses: Expense[]): number;
|
|
128
|
+
/**
|
|
129
|
+
* Calculate total income (monthly)
|
|
130
|
+
*/
|
|
131
|
+
declare function calculateMonthlyIncome(incomes: Income[]): number;
|
|
132
|
+
/**
|
|
133
|
+
* Calculate savings (income - expenses)
|
|
134
|
+
*/
|
|
135
|
+
declare function calculateMonthlySavings(incomes: Income[], expenses: Expense[]): number;
|
|
136
|
+
/**
|
|
137
|
+
* Calculate savings rate as percentage
|
|
138
|
+
*/
|
|
139
|
+
declare function calculateSavingsRate(incomes: Income[], expenses: Expense[]): number;
|
|
140
|
+
/**
|
|
141
|
+
* Calculate lieu day balance
|
|
142
|
+
*/
|
|
143
|
+
declare function calculateLieuBalance(lieuDays: Array<{
|
|
144
|
+
type: 'earned' | 'used';
|
|
145
|
+
}>): number;
|
|
146
|
+
/**
|
|
147
|
+
* Calculate focus time stats for a period
|
|
148
|
+
*/
|
|
149
|
+
declare function calculateFocusStats(sessions: Array<{
|
|
150
|
+
actualSeconds: number;
|
|
151
|
+
status: string;
|
|
152
|
+
}>): {
|
|
153
|
+
totalSeconds: number;
|
|
154
|
+
completedCount: number;
|
|
155
|
+
abandonedCount: number;
|
|
156
|
+
completionRate: number;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export { calculateFocusStats, calculateLieuBalance, calculateMonthlyExpenses, calculateMonthlyIncome, calculateMonthlySavings, calculateSavingsRate, formatCurrency, formatDate, formatDueDate, formatRelativeTime, formatTime, formatTotalTime, generateId, generateRandomColor, generateShortId, getRepoName, isNonEmptyString, isPositiveNumber, isValidCurrency, isValidEmail, isValidFrequency, isValidISODate, isValidUrl, toMonthlyAmount, toYearlyAmount, truncate };
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { a as Expense, d as Income } from '../database-BKc0Oj26.js';
|
|
2
|
+
import { Frequency } from '../constants/index.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Formatting Utilities
|
|
6
|
+
*
|
|
7
|
+
* Pure functions for formatting data.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Format seconds into MM:SS format
|
|
11
|
+
* @example formatTime(125) => "02:05"
|
|
12
|
+
*/
|
|
13
|
+
declare function formatTime(seconds: number): string;
|
|
14
|
+
/**
|
|
15
|
+
* Format seconds into human-readable total time
|
|
16
|
+
* @example formatTotalTime(3700) => "1h 1m"
|
|
17
|
+
* @example formatTotalTime(1800) => "30m"
|
|
18
|
+
*/
|
|
19
|
+
declare function formatTotalTime(seconds: number): string;
|
|
20
|
+
/**
|
|
21
|
+
* Format a number as currency
|
|
22
|
+
* @example formatCurrency(1234.56, 'CHF') => "CHF 1,234.56"
|
|
23
|
+
*/
|
|
24
|
+
declare function formatCurrency(amount: number, currency: string, locale?: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Format a date as relative time (e.g., "2h ago", "3d ago")
|
|
27
|
+
*/
|
|
28
|
+
declare function formatRelativeTime(dateStr: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Format a date string to a readable format
|
|
31
|
+
* @example formatDate('2024-01-15') => "Jan 15, 2024"
|
|
32
|
+
*/
|
|
33
|
+
declare function formatDate(dateStr: string, options?: Intl.DateTimeFormatOptions): string;
|
|
34
|
+
/**
|
|
35
|
+
* Format a due date with context (Today, Tomorrow, Overdue, etc.)
|
|
36
|
+
*/
|
|
37
|
+
declare function formatDueDate(dueDate: string | null): {
|
|
38
|
+
text: string;
|
|
39
|
+
isOverdue: boolean;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Truncate a string with ellipsis
|
|
43
|
+
* @example truncate("Hello World", 5) => "Hello..."
|
|
44
|
+
*/
|
|
45
|
+
declare function truncate(str: string, maxLength: number): string;
|
|
46
|
+
/**
|
|
47
|
+
* Extract repo name from GitHub URL
|
|
48
|
+
* @example getRepoName("https://github.com/owner/repo") => "owner/repo"
|
|
49
|
+
*/
|
|
50
|
+
declare function getRepoName(url: string): string;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* ID and Data Generators
|
|
54
|
+
*
|
|
55
|
+
* Pure functions for generating IDs and data.
|
|
56
|
+
*/
|
|
57
|
+
/**
|
|
58
|
+
* Generate a unique ID
|
|
59
|
+
* Uses crypto.randomUUID if available, falls back to timestamp-based ID
|
|
60
|
+
*
|
|
61
|
+
* Note: This works in both Node.js and browser environments.
|
|
62
|
+
* React Native needs the fallback since crypto.randomUUID isn't available.
|
|
63
|
+
*/
|
|
64
|
+
declare function generateId(): string;
|
|
65
|
+
/**
|
|
66
|
+
* Generate a short ID (timestamp + random)
|
|
67
|
+
* Format: {timestamp}-{random7chars}
|
|
68
|
+
* @example "1732547123456-k8f3j2m"
|
|
69
|
+
*/
|
|
70
|
+
declare function generateShortId(): string;
|
|
71
|
+
/**
|
|
72
|
+
* Generate a random color in hex format
|
|
73
|
+
*/
|
|
74
|
+
declare function generateRandomColor(): string;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Validation Utilities
|
|
78
|
+
*
|
|
79
|
+
* Pure functions for validating data.
|
|
80
|
+
*/
|
|
81
|
+
/**
|
|
82
|
+
* Check if a string is a valid email
|
|
83
|
+
*/
|
|
84
|
+
declare function isValidEmail(email: string): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Check if a string is a valid URL
|
|
87
|
+
*/
|
|
88
|
+
declare function isValidUrl(url: string): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Check if a string is a valid ISO date (YYYY-MM-DD)
|
|
91
|
+
*/
|
|
92
|
+
declare function isValidISODate(dateStr: string): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Check if a value is a valid currency code
|
|
95
|
+
*/
|
|
96
|
+
declare function isValidCurrency(currency: string): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Check if a value is a valid frequency
|
|
99
|
+
*/
|
|
100
|
+
declare function isValidFrequency(frequency: string): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Validate a positive number
|
|
103
|
+
*/
|
|
104
|
+
declare function isPositiveNumber(value: unknown): value is number;
|
|
105
|
+
/**
|
|
106
|
+
* Validate a non-empty string
|
|
107
|
+
*/
|
|
108
|
+
declare function isNonEmptyString(value: unknown): value is string;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Calculation Utilities
|
|
112
|
+
*
|
|
113
|
+
* Pure functions for business logic calculations.
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Convert an amount to yearly based on frequency
|
|
118
|
+
*/
|
|
119
|
+
declare function toYearlyAmount(amount: number, frequency: Frequency): number;
|
|
120
|
+
/**
|
|
121
|
+
* Convert an amount to monthly based on frequency
|
|
122
|
+
*/
|
|
123
|
+
declare function toMonthlyAmount(amount: number, frequency: Frequency): number;
|
|
124
|
+
/**
|
|
125
|
+
* Calculate total expenses (monthly)
|
|
126
|
+
*/
|
|
127
|
+
declare function calculateMonthlyExpenses(expenses: Expense[]): number;
|
|
128
|
+
/**
|
|
129
|
+
* Calculate total income (monthly)
|
|
130
|
+
*/
|
|
131
|
+
declare function calculateMonthlyIncome(incomes: Income[]): number;
|
|
132
|
+
/**
|
|
133
|
+
* Calculate savings (income - expenses)
|
|
134
|
+
*/
|
|
135
|
+
declare function calculateMonthlySavings(incomes: Income[], expenses: Expense[]): number;
|
|
136
|
+
/**
|
|
137
|
+
* Calculate savings rate as percentage
|
|
138
|
+
*/
|
|
139
|
+
declare function calculateSavingsRate(incomes: Income[], expenses: Expense[]): number;
|
|
140
|
+
/**
|
|
141
|
+
* Calculate lieu day balance
|
|
142
|
+
*/
|
|
143
|
+
declare function calculateLieuBalance(lieuDays: Array<{
|
|
144
|
+
type: 'earned' | 'used';
|
|
145
|
+
}>): number;
|
|
146
|
+
/**
|
|
147
|
+
* Calculate focus time stats for a period
|
|
148
|
+
*/
|
|
149
|
+
declare function calculateFocusStats(sessions: Array<{
|
|
150
|
+
actualSeconds: number;
|
|
151
|
+
status: string;
|
|
152
|
+
}>): {
|
|
153
|
+
totalSeconds: number;
|
|
154
|
+
completedCount: number;
|
|
155
|
+
abandonedCount: number;
|
|
156
|
+
completionRate: number;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export { calculateFocusStats, calculateLieuBalance, calculateMonthlyExpenses, calculateMonthlyIncome, calculateMonthlySavings, calculateSavingsRate, formatCurrency, formatDate, formatDueDate, formatRelativeTime, formatTime, formatTotalTime, generateId, generateRandomColor, generateShortId, getRepoName, isNonEmptyString, isPositiveNumber, isValidCurrency, isValidEmail, isValidFrequency, isValidISODate, isValidUrl, toMonthlyAmount, toYearlyAmount, truncate };
|