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