@wealthfolio/addon-sdk 1.0.0 → 3.0.0

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.
@@ -0,0 +1,566 @@
1
+ /**
2
+ * Host API interface for addon development
3
+ * Provides comprehensive access to Wealthfolio functionality organized by domain
4
+ */
5
+ import type { EventCallback, UnlistenFn } from './types';
6
+ import type { Account, Activity, ActivityBulkMutationRequest, ActivityBulkMutationResult, ActivityCreate, ActivityDetails, ActivityImport, ActivitySearchResponse, ActivityUpdate, AccountValuation, ImportActivitiesResult, Asset, ContributionLimit, DepositsCalculation, ExchangeRate, Goal, GoalAllocation, Holding, ImportMappingData, IncomeSummary, MarketDataProviderInfo, NewContributionLimit, PerformanceMetrics, Quote, Settings, SimplePerformanceMetrics, SymbolSearchResult, UpdateAssetProfile } from './data-types';
7
+ export interface ActivitySearchFilters {
8
+ accountIds?: string | string[];
9
+ activityTypes?: string | string[];
10
+ symbol?: string;
11
+ }
12
+ export interface ActivitySort {
13
+ id: string;
14
+ desc?: boolean;
15
+ }
16
+ /**
17
+ * Account management APIs
18
+ */
19
+ export interface AccountsAPI {
20
+ /**
21
+ * Get all accounts
22
+ * @returns Promise resolving to array of accounts
23
+ */
24
+ getAll(): Promise<Account[]>;
25
+ /**
26
+ * Create a new account
27
+ * @param account New account data
28
+ * @returns Promise resolving to created account
29
+ */
30
+ create(account: unknown): Promise<Account>;
31
+ }
32
+ /**
33
+ * Portfolio and holdings APIs
34
+ */
35
+ export interface PortfolioAPI {
36
+ /**
37
+ * Get holdings for a specific account
38
+ * @param accountId Account identifier
39
+ * @returns Promise resolving to array of holdings
40
+ */
41
+ getHoldings(accountId: string): Promise<Holding[]>;
42
+ /**
43
+ * Get specific holding information
44
+ * @param accountId Account identifier
45
+ * @param assetId Asset identifier
46
+ * @returns Promise resolving to holding or null if not found
47
+ */
48
+ getHolding(accountId: string, assetId: string): Promise<Holding | null>;
49
+ /**
50
+ * Update portfolio calculations
51
+ * @returns Promise that resolves when update is complete
52
+ */
53
+ update(): Promise<void>;
54
+ /**
55
+ * Recalculate entire portfolio
56
+ * @returns Promise that resolves when recalculation is complete
57
+ */
58
+ recalculate(): Promise<void>;
59
+ /**
60
+ * Get income summary data
61
+ * @returns Promise resolving to array of income summaries
62
+ */
63
+ getIncomeSummary(): Promise<IncomeSummary[]>;
64
+ /**
65
+ * Get historical valuations
66
+ * @param accountId Optional account identifier
67
+ * @param startDate Optional start date
68
+ * @param endDate Optional end date
69
+ * @returns Promise resolving to array of account valuations
70
+ */
71
+ getHistoricalValuations(accountId?: string, startDate?: string, endDate?: string): Promise<AccountValuation[]>;
72
+ /**
73
+ * Get latest valuations for a set of accounts
74
+ * @param accountIds Array of account identifiers
75
+ * @returns Promise resolving to array of latest account valuations
76
+ */
77
+ getLatestValuations(accountIds: string[]): Promise<AccountValuation[]>;
78
+ }
79
+ /**
80
+ * Activity management APIs
81
+ */
82
+ export interface ActivitiesAPI {
83
+ /**
84
+ * Get activities, optionally filtered by account
85
+ * @param accountId Optional account identifier for filtering
86
+ * @returns Promise resolving to array of activity details
87
+ */
88
+ getAll(accountId?: string): Promise<ActivityDetails[]>;
89
+ /**
90
+ * Search activities with pagination and filters
91
+ * @param page Page number
92
+ * @param pageSize Number of items per page
93
+ * @param filters Filter criteria
94
+ * @param searchKeyword Search keyword
95
+ * @param sort Sort criteria
96
+ * @returns Promise resolving to search response
97
+ */
98
+ search(page: number, pageSize: number, filters: ActivitySearchFilters, searchKeyword: string, sort?: ActivitySort): Promise<ActivitySearchResponse>;
99
+ /**
100
+ * Create a new activity
101
+ * @param activity New activity data
102
+ * @returns Promise resolving to created activity
103
+ */
104
+ create(activity: ActivityCreate): Promise<Activity>;
105
+ /**
106
+ * Update an existing activity
107
+ * @param activity Updated activity data
108
+ * @returns Promise resolving to updated activity
109
+ */
110
+ update(activity: ActivityUpdate): Promise<Activity>;
111
+ /**
112
+ * Save multiple activities (create/update/delete) in a single request.
113
+ * @param request Bulk mutation payload
114
+ * @returns Promise resolving to detailed mutation result
115
+ */
116
+ saveMany(request: ActivityBulkMutationRequest): Promise<ActivityBulkMutationResult>;
117
+ /**
118
+ * Import activities from parsed data
119
+ * @param activities Array of activities to import
120
+ * @returns Promise resolving to import result with activities, run ID, and summary
121
+ */
122
+ import(activities: ActivityImport[]): Promise<ImportActivitiesResult>;
123
+ /**
124
+ * Check activities before import
125
+ * @param accountId Account identifier
126
+ * @param activities Array of activities to check
127
+ * @returns Promise resolving to validated activities
128
+ */
129
+ checkImport(accountId: string, activities: ActivityImport[]): Promise<ActivityImport[]>;
130
+ /**
131
+ * Get import mapping configuration for an account
132
+ * @param accountId Account identifier
133
+ * @returns Promise resolving to import mapping data
134
+ */
135
+ getImportMapping(accountId: string): Promise<ImportMappingData>;
136
+ /**
137
+ * Save import mapping configuration
138
+ * @param mapping Import mapping data to save
139
+ * @returns Promise resolving to saved mapping data
140
+ */
141
+ saveImportMapping(mapping: ImportMappingData): Promise<ImportMappingData>;
142
+ }
143
+ /**
144
+ * Market data and asset APIs
145
+ */
146
+ export interface MarketDataAPI {
147
+ /**
148
+ * Search for ticker symbols
149
+ * @param query Search query
150
+ * @returns Promise resolving to array of quote summaries
151
+ */
152
+ searchTicker(query: string): Promise<SymbolSearchResult[]>;
153
+ /**
154
+ * Synchronize historical quotes
155
+ * @returns Promise that resolves when sync is complete
156
+ */
157
+ syncHistory(): Promise<void>;
158
+ /**
159
+ * Synchronize market data for specific assets
160
+ * @param assetIds Array of asset identifiers to sync
161
+ * @param refetchAll Whether to refetch all data
162
+ * @param refetchRecentDays Optional number of recent days to refetch
163
+ * @returns Promise that resolves when sync is complete
164
+ */
165
+ sync(assetIds: string[], refetchAll: boolean, refetchRecentDays?: number): Promise<void>;
166
+ /**
167
+ * Get market data providers information
168
+ * @returns Promise resolving to array of provider info
169
+ */
170
+ getProviders(): Promise<MarketDataProviderInfo[]>;
171
+ }
172
+ /**
173
+ * Asset management APIs
174
+ */
175
+ export interface AssetsAPI {
176
+ /**
177
+ * Get asset profile information
178
+ * @param assetId Asset identifier
179
+ * @returns Promise resolving to asset profile
180
+ */
181
+ getProfile(assetId: string): Promise<Asset>;
182
+ /**
183
+ * Update asset profile information
184
+ * @param payload Updated asset profile data
185
+ * @returns Promise resolving to updated asset
186
+ */
187
+ updateProfile(payload: UpdateAssetProfile): Promise<Asset>;
188
+ /**
189
+ * Update asset quote mode (MARKET or MANUAL)
190
+ * @param assetId Asset identifier
191
+ * @param quoteMode New quote mode
192
+ * @returns Promise resolving to updated asset
193
+ */
194
+ updateQuoteMode(assetId: string, quoteMode: string): Promise<Asset>;
195
+ }
196
+ /**
197
+ * Quote management APIs
198
+ */
199
+ export interface QuotesAPI {
200
+ /**
201
+ * Update quote information
202
+ * @param assetId Asset identifier
203
+ * @param quote Updated quote data
204
+ * @returns Promise that resolves when update is complete
205
+ */
206
+ update(assetId: string, quote: Quote): Promise<void>;
207
+ /**
208
+ * Get quote history for an asset
209
+ * @param assetId Asset identifier
210
+ * @returns Promise resolving to array of quotes
211
+ */
212
+ getHistory(assetId: string): Promise<Quote[]>;
213
+ }
214
+ /**
215
+ * Performance calculation APIs
216
+ */
217
+ export interface PerformanceAPI {
218
+ /**
219
+ * Calculate performance history
220
+ * @param itemType Type of item ('account' or 'symbol')
221
+ * @param itemId Item identifier
222
+ * @param startDate Start date for calculation
223
+ * @param endDate End date for calculation
224
+ * @returns Promise resolving to performance metrics
225
+ */
226
+ calculateHistory(itemType: 'account' | 'symbol', itemId: string, startDate: string, endDate: string): Promise<PerformanceMetrics>;
227
+ /**
228
+ * Calculate performance summary
229
+ * @param args Performance calculation arguments
230
+ * @returns Promise resolving to performance metrics
231
+ */
232
+ calculateSummary(args: {
233
+ itemType: 'account' | 'symbol';
234
+ itemId: string;
235
+ startDate?: string | null;
236
+ endDate?: string | null;
237
+ }): Promise<PerformanceMetrics>;
238
+ /**
239
+ * Calculate simple performance for multiple accounts
240
+ * @param accountIds Array of account identifiers
241
+ * @returns Promise resolving to array of simple performance metrics
242
+ */
243
+ calculateAccountsSimple(accountIds: string[]): Promise<SimplePerformanceMetrics[]>;
244
+ }
245
+ /**
246
+ * Exchange rates APIs
247
+ */
248
+ export interface ExchangeRatesAPI {
249
+ /**
250
+ * Get all exchange rates
251
+ * @returns Promise resolving to array of exchange rates
252
+ */
253
+ getAll(): Promise<ExchangeRate[]>;
254
+ /**
255
+ * Update an existing exchange rate
256
+ * @param updatedRate Updated exchange rate data
257
+ * @returns Promise resolving to updated exchange rate
258
+ */
259
+ update(updatedRate: ExchangeRate): Promise<ExchangeRate>;
260
+ /**
261
+ * Add a new exchange rate
262
+ * @param newRate New exchange rate data (without ID)
263
+ * @returns Promise resolving to created exchange rate
264
+ */
265
+ add(newRate: Omit<ExchangeRate, 'id'>): Promise<ExchangeRate>;
266
+ }
267
+ /**
268
+ * Contribution limits APIs
269
+ */
270
+ export interface ContributionLimitsAPI {
271
+ /**
272
+ * Get all contribution limits
273
+ * @returns Promise resolving to array of contribution limits
274
+ */
275
+ getAll(): Promise<ContributionLimit[]>;
276
+ /**
277
+ * Create a new contribution limit
278
+ * @param newLimit New contribution limit data
279
+ * @returns Promise resolving to created contribution limit
280
+ */
281
+ create(newLimit: NewContributionLimit): Promise<ContributionLimit>;
282
+ /**
283
+ * Update an existing contribution limit
284
+ * @param id Contribution limit identifier
285
+ * @param updatedLimit Updated contribution limit data
286
+ * @returns Promise resolving to updated contribution limit
287
+ */
288
+ update(id: string, updatedLimit: NewContributionLimit): Promise<ContributionLimit>;
289
+ /**
290
+ * Calculate deposits for a specific contribution limit
291
+ * @param limitId Contribution limit identifier
292
+ * @returns Promise resolving to deposits calculation
293
+ */
294
+ calculateDeposits(limitId: string): Promise<DepositsCalculation>;
295
+ }
296
+ /**
297
+ * Goals management APIs
298
+ */
299
+ export interface GoalsAPI {
300
+ /**
301
+ * Get all goals
302
+ * @returns Promise resolving to array of goals
303
+ */
304
+ getAll(): Promise<Goal[]>;
305
+ /**
306
+ * Create a new goal
307
+ * @param goal New goal data
308
+ * @returns Promise resolving to created goal
309
+ */
310
+ create(goal: unknown): Promise<Goal>;
311
+ /**
312
+ * Update an existing goal
313
+ * @param goal Updated goal data
314
+ * @returns Promise resolving to updated goal
315
+ */
316
+ update(goal: Goal): Promise<Goal>;
317
+ /**
318
+ * Update goal allocations
319
+ * @param allocations Array of goal allocations
320
+ * @returns Promise that resolves when update is complete
321
+ */
322
+ updateAllocations(allocations: GoalAllocation[]): Promise<void>;
323
+ /**
324
+ * Get goal allocations
325
+ * @returns Promise resolving to array of goal allocations
326
+ */
327
+ getAllocations(): Promise<GoalAllocation[]>;
328
+ }
329
+ /**
330
+ * Application settings APIs
331
+ */
332
+ export interface SettingsAPI {
333
+ /**
334
+ * Get application settings
335
+ * @returns Promise resolving to settings
336
+ */
337
+ get(): Promise<Settings>;
338
+ /**
339
+ * Update application settings
340
+ * @param settingsUpdate Updated settings data
341
+ * @returns Promise resolving to updated settings
342
+ */
343
+ update(settingsUpdate: Settings): Promise<Settings>;
344
+ /**
345
+ * Create database backup
346
+ * @returns Promise resolving to backup file information
347
+ */
348
+ backupDatabase(): Promise<{
349
+ filename: string;
350
+ data: Uint8Array;
351
+ }>;
352
+ }
353
+ /**
354
+ * File operations APIs
355
+ */
356
+ export interface FilesAPI {
357
+ /**
358
+ * Open CSV file dialog
359
+ * @returns Promise resolving to file path(s) or null if cancelled
360
+ */
361
+ openCsvDialog(): Promise<null | string | string[]>;
362
+ /**
363
+ * Open file save dialog
364
+ * @param fileContent File content to save
365
+ * @param fileName Default file name
366
+ * @returns Promise resolving to save result
367
+ */
368
+ openSaveDialog(fileContent: Uint8Array | Blob | string, fileName: string): Promise<unknown>;
369
+ }
370
+ /**
371
+ * Secrets management APIs
372
+ * Provides secure storage for addon secrets using the system keyring
373
+ * Each addon can only access its own secrets
374
+ */
375
+ export interface SecretsAPI {
376
+ /**
377
+ * Store a secret value for this addon
378
+ * @param key Secret key identifier
379
+ * @param value Secret value to store
380
+ * @returns Promise that resolves when secret is stored
381
+ */
382
+ set(key: string, value: string): Promise<void>;
383
+ /**
384
+ * Retrieve a secret value for this addon
385
+ * @param key Secret key identifier
386
+ * @returns Promise resolving to secret value or null if not found
387
+ */
388
+ get(key: string): Promise<string | null>;
389
+ /**
390
+ * Delete a secret for this addon
391
+ * @param key Secret key identifier
392
+ * @returns Promise that resolves when secret is deleted
393
+ */
394
+ delete(key: string): Promise<void>;
395
+ }
396
+ /**
397
+ * Logger APIs
398
+ * Provides logging functionality with automatic addon prefix
399
+ * All log messages will be prefixed with the addon ID for easy identification
400
+ */
401
+ export interface LoggerAPI {
402
+ /**
403
+ * Log an error message
404
+ * @param message Error message to log
405
+ */
406
+ error(message: string): void;
407
+ /**
408
+ * Log an info message
409
+ * @param message Info message to log
410
+ */
411
+ info(message: string): void;
412
+ /**
413
+ * Log a warning message
414
+ * @param message Warning message to log
415
+ */
416
+ warn(message: string): void;
417
+ /**
418
+ * Log a trace message (for detailed debugging)
419
+ * @param message Trace message to log
420
+ */
421
+ trace(message: string): void;
422
+ /**
423
+ * Log a debug message
424
+ * @param message Debug message to log
425
+ */
426
+ debug(message: string): void;
427
+ }
428
+ /**
429
+ * Event listeners APIs
430
+ */
431
+ export interface EventsAPI {
432
+ /**
433
+ * Import file events
434
+ */
435
+ import: {
436
+ /**
437
+ * Listen for import file drop hover events
438
+ * @param handler Event handler
439
+ * @returns Promise resolving to unlisten function
440
+ */
441
+ onDropHover<T>(handler: EventCallback<T>): Promise<UnlistenFn>;
442
+ /**
443
+ * Listen for import file drop events
444
+ * @param handler Event handler
445
+ * @returns Promise resolving to unlisten function
446
+ */
447
+ onDrop<T>(handler: EventCallback<T>): Promise<UnlistenFn>;
448
+ /**
449
+ * Listen for import file drop cancelled events
450
+ * @param handler Event handler
451
+ * @returns Promise resolving to unlisten function
452
+ */
453
+ onDropCancelled<T>(handler: EventCallback<T>): Promise<UnlistenFn>;
454
+ };
455
+ /**
456
+ * Portfolio events
457
+ */
458
+ portfolio: {
459
+ /**
460
+ * Listen for portfolio update start events
461
+ * @param handler Event handler
462
+ * @returns Promise resolving to unlisten function
463
+ */
464
+ onUpdateStart<T>(handler: EventCallback<T>): Promise<UnlistenFn>;
465
+ /**
466
+ * Listen for portfolio update complete events
467
+ * @param handler Event handler
468
+ * @returns Promise resolving to unlisten function
469
+ */
470
+ onUpdateComplete<T>(handler: EventCallback<T>): Promise<UnlistenFn>;
471
+ /**
472
+ * Listen for portfolio update error events
473
+ * @param handler Event handler
474
+ * @returns Promise resolving to unlisten function
475
+ */
476
+ onUpdateError<T>(handler: EventCallback<T>): Promise<UnlistenFn>;
477
+ };
478
+ /**
479
+ * Market sync events
480
+ */
481
+ market: {
482
+ /**
483
+ * Listen for market sync start events
484
+ * @param handler Event handler
485
+ * @returns Promise resolving to unlisten function
486
+ */
487
+ onSyncStart<T>(handler: EventCallback<T>): Promise<UnlistenFn>;
488
+ /**
489
+ * Listen for market sync complete events
490
+ * @param handler Event handler
491
+ * @returns Promise resolving to unlisten function
492
+ */
493
+ onSyncComplete<T>(handler: EventCallback<T>): Promise<UnlistenFn>;
494
+ };
495
+ }
496
+ /**
497
+ * Navigation APIs
498
+ */
499
+ export interface NavigationAPI {
500
+ /**
501
+ * Navigate to a route in the application
502
+ * @param route The route path to navigate to
503
+ * @returns Promise that resolves when navigation is complete
504
+ */
505
+ navigate(route: string): Promise<void>;
506
+ }
507
+ /**
508
+ * Query management APIs for React Query integration
509
+ */
510
+ export interface QueryAPI {
511
+ /**
512
+ * Get the shared QueryClient instance from the main application
513
+ * @returns The shared QueryClient instance
514
+ */
515
+ getClient(): unknown;
516
+ /**
517
+ * Invalidate queries by key
518
+ * @param queryKey The query key to invalidate
519
+ */
520
+ invalidateQueries(queryKey: string | string[]): void;
521
+ /**
522
+ * Refetch queries by key
523
+ * @param queryKey The query key to refetch
524
+ */
525
+ refetchQueries(queryKey: string | string[]): void;
526
+ }
527
+ /**
528
+ * Comprehensive Host API interface providing access to all Wealthfolio functionality
529
+ * Organized by functional domains for better discoverability and maintainability
530
+ */
531
+ export interface HostAPI {
532
+ /** Account management operations */
533
+ accounts: AccountsAPI;
534
+ /** Portfolio and holdings operations */
535
+ portfolio: PortfolioAPI;
536
+ /** Activity management operations */
537
+ activities: ActivitiesAPI;
538
+ /** Market data operations */
539
+ market: MarketDataAPI;
540
+ /** Asset management operations */
541
+ assets: AssetsAPI;
542
+ /** Quote management operations */
543
+ quotes: QuotesAPI;
544
+ /** Performance calculation operations */
545
+ performance: PerformanceAPI;
546
+ /** Exchange rates operations */
547
+ exchangeRates: ExchangeRatesAPI;
548
+ /** Contribution limits operations */
549
+ contributionLimits: ContributionLimitsAPI;
550
+ /** Goals management operations */
551
+ goals: GoalsAPI;
552
+ /** Application settings operations */
553
+ settings: SettingsAPI;
554
+ /** File operations */
555
+ files: FilesAPI;
556
+ /** Secrets management */
557
+ secrets: SecretsAPI;
558
+ /** Logger operations */
559
+ logger: LoggerAPI;
560
+ /** Event listeners */
561
+ events: EventsAPI;
562
+ /** Navigation operations */
563
+ navigation: NavigationAPI;
564
+ /** React Query operations */
565
+ query: QueryAPI;
566
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @wealthfolio/addon-sdk
3
+ *
4
+ * TypeScript SDK for building Wealthfolio addons with enhanced functionality,
5
+ * type safety, and comprehensive permission management.
6
+ *
7
+ * @version 1.0.0
8
+ * @author Wealthfolio Team
9
+ * @license MIT
10
+ */
11
+ export type { AddonContext, AddonEnableFunction, EventCallback, RouteConfig, RouterManager, SidebarItemConfig, SidebarItemHandle, SidebarManager, UnlistenFn, } from './types';
12
+ export type { HostAPI, ActivitySearchFilters, ActivitySort } from './host-api';
13
+ export type { QueryClient } from '@tanstack/react-query';
14
+ export { QueryKeys } from './query-keys';
15
+ export type * from './data-types';
16
+ export type { AddonFile, AddonInstallResult, AddonManifest, AddonStoreListing, AddonUpdateCheckResult, AddonUpdateInfo, AddonValidationResult, DevelopmentManifest, ExtractedAddon, InstalledAddon, InstalledManifest, } from './manifest';
17
+ export { isInstalledManifest } from './manifest';
18
+ export type { FunctionPermission, Permission, PermissionCategory, RiskLevel, } from './permissions';
19
+ export { getFunctionRiskLevel, getPermissionCategoriesByRisk, getPermissionCategory, isPermissionRequired, PERMISSION_CATEGORIES, } from './permissions';
20
+ export { formatAddonSize, generateAddonId, isAddonManifest, isCompatibleVersion, validateManifest, } from './utils';
21
+ export { calculateGoalProgress } from './goal-progress';
22
+ /**
23
+ * React version guaranteed by the host application. Addons may assert against
24
+ * this at runtime if they rely on a particular React feature set.
25
+ */
26
+ export declare const ReactVersion = "19.1.1";
27
+ export declare const React: typeof import("react");
28
+ export declare const ReactDOM: typeof import("react-dom");
29
+ export { SDK_VERSION } from './version';