@actual-app/api 24.11.0 → 25.1.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.
Files changed (56) hide show
  1. package/@types/loot-core/client/state-types/app.d.ts +6 -1
  2. package/@types/loot-core/client/state-types/modals.d.ts +50 -0
  3. package/@types/loot-core/client/state-types/queries.d.ts +9 -10
  4. package/@types/loot-core/server/accounts/sync.d.ts +5 -0
  5. package/@types/loot-core/server/accounts/transaction-rules.d.ts +4 -3
  6. package/@types/loot-core/server/admin/app.d.ts +12 -0
  7. package/@types/loot-core/server/admin/types/handlers.d.ts +41 -0
  8. package/@types/loot-core/server/budget/actions.d.ts +1 -0
  9. package/@types/loot-core/server/budget/app.d.ts +1 -1
  10. package/@types/loot-core/server/budget/categoryTemplate.d.ts +47 -0
  11. package/@types/loot-core/server/budget/goalsSchedule.d.ts +8 -0
  12. package/@types/loot-core/server/budget/goaltemplates.d.ts +4 -0
  13. package/@types/loot-core/server/budget/types/handlers.d.ts +5 -0
  14. package/@types/loot-core/server/budget/types/templates.d.ts +7 -1
  15. package/@types/loot-core/server/cloud-storage.d.ts +9 -0
  16. package/@types/loot-core/server/db/index.d.ts +1 -0
  17. package/@types/loot-core/server/main-app.d.ts +1 -1
  18. package/@types/loot-core/server/post.d.ts +2 -0
  19. package/@types/loot-core/server/server-config.d.ts +1 -0
  20. package/@types/loot-core/server/tools/types/handlers.d.ts +3 -0
  21. package/@types/loot-core/server/util/budget-name.d.ts +6 -2
  22. package/@types/loot-core/shared/errors.d.ts +3 -0
  23. package/@types/loot-core/shared/months.d.ts +1 -1
  24. package/@types/loot-core/shared/query.d.ts +37 -22
  25. package/@types/loot-core/shared/rules.d.ts +2 -2
  26. package/@types/loot-core/shared/schedules.d.ts +4 -1
  27. package/@types/loot-core/shared/util.d.ts +7 -1
  28. package/@types/loot-core/types/budget.d.ts +1 -0
  29. package/@types/loot-core/types/file.d.ts +7 -0
  30. package/@types/loot-core/types/handlers.d.ts +2 -0
  31. package/@types/loot-core/types/models/bank-sync.d.ts +21 -0
  32. package/@types/loot-core/types/models/dashboard.d.ts +40 -1
  33. package/@types/loot-core/types/models/gocardless.d.ts +61 -0
  34. package/@types/loot-core/types/models/index.d.ts +2 -0
  35. package/@types/loot-core/types/models/openid.d.ts +7 -0
  36. package/@types/loot-core/types/models/rule.d.ts +8 -1
  37. package/@types/loot-core/types/models/schedule.d.ts +1 -1
  38. package/@types/loot-core/types/models/simplefin.d.ts +7 -0
  39. package/@types/loot-core/types/models/user.d.ts +26 -0
  40. package/@types/loot-core/types/models/userAccess.d.ts +9 -0
  41. package/@types/loot-core/types/prefs.d.ts +5 -3
  42. package/@types/loot-core/types/server-handlers.d.ts +103 -13
  43. package/dist/app/bundle.api.js +5384 -1958
  44. package/dist/methods.js +4 -1
  45. package/dist/migrations/1730744182000_fix_dashboard_table.sql +7 -0
  46. package/dist/package.json +2 -2
  47. package/package.json +2 -2
  48. package/@types/loot-core/server/budget/goals/goalsAverage.d.ts +0 -4
  49. package/@types/loot-core/server/budget/goals/goalsBy.d.ts +0 -5
  50. package/@types/loot-core/server/budget/goals/goalsCopy.d.ts +0 -7
  51. package/@types/loot-core/server/budget/goals/goalsPercentage.d.ts +0 -4
  52. package/@types/loot-core/server/budget/goals/goalsRemainder.d.ts +0 -8
  53. package/@types/loot-core/server/budget/goals/goalsSchedule.d.ts +0 -6
  54. package/@types/loot-core/server/budget/goals/goalsSimple.d.ts +0 -7
  55. package/@types/loot-core/server/budget/goals/goalsSpend.d.ts +0 -4
  56. package/@types/loot-core/server/budget/goals/goalsWeek.d.ts +0 -7
@@ -1,3 +1,4 @@
1
+ import type { AdminHandlers } from '../server/admin/types/handlers';
1
2
  import type { BudgetHandlers } from '../server/budget/types/handlers';
2
3
  import type { DashboardHandlers } from '../server/dashboard/types/handlers';
3
4
  import type { FiltersHandlers } from '../server/filters/types/handlers';
@@ -22,6 +23,7 @@ export interface Handlers
22
23
  ReportsHandlers,
23
24
  RulesHandlers,
24
25
  SchedulesHandlers,
26
+ AdminHandlers,
25
27
  ToolsHandlers {}
26
28
 
27
29
  export type HandlerFunctions = Handlers[keyof Handlers];
@@ -0,0 +1,21 @@
1
+ import {
2
+ GoCardlessAmount,
3
+ GoCardlessBalance,
4
+ GoCardlessTransaction,
5
+ } from './gocardless';
6
+
7
+ export type BankSyncBalance = GoCardlessBalance;
8
+ export type BankSyncAmount = GoCardlessAmount;
9
+ export type BankSyncTransaction = GoCardlessTransaction;
10
+
11
+ export type BankSyncResponse = {
12
+ transactions: {
13
+ all: BankSyncTransaction[];
14
+ booked: BankSyncTransaction[];
15
+ pending: BankSyncTransaction[];
16
+ };
17
+ balances: BankSyncBalance[];
18
+ startingBalance: number;
19
+ error_type: string;
20
+ error_code: string;
21
+ };
@@ -37,6 +37,7 @@ export type CashFlowWidget = AbstractWidget<
37
37
  conditions?: RuleConditionEntity[];
38
38
  conditionsOp?: 'and' | 'or';
39
39
  timeFrame?: TimeFrame;
40
+ showBalance?: boolean;
40
41
  } | null
41
42
  >;
42
43
  export type SpendingWidget = AbstractWidget<
@@ -64,7 +65,9 @@ type SpecializedWidget =
64
65
  | NetWorthWidget
65
66
  | CashFlowWidget
66
67
  | SpendingWidget
67
- | MarkdownWidget;
68
+ | MarkdownWidget
69
+ | SummaryWidget
70
+ | CalendarWidget;
68
71
  export type Widget = SpecializedWidget | CustomReportWidget;
69
72
  export type NewWidget = Omit<Widget, 'id' | 'tombstone'>;
70
73
 
@@ -87,3 +90,39 @@ export type ExportImportDashboard = {
87
90
  version: 1;
88
91
  widgets: ExportImportDashboardWidget[];
89
92
  };
93
+
94
+ export type SummaryWidget = AbstractWidget<
95
+ 'summary-card',
96
+ {
97
+ name?: string;
98
+ conditions?: RuleConditionEntity[];
99
+ conditionsOp?: 'and' | 'or';
100
+ timeFrame?: TimeFrame;
101
+ content?: string;
102
+ } | null
103
+ >;
104
+
105
+ export type BaseSummaryContent = {
106
+ type: 'sum' | 'avgPerMonth' | 'avgPerTransact';
107
+ fontSize?: number;
108
+ };
109
+
110
+ export type PercentageSummaryContent = {
111
+ type: 'percentage';
112
+ divisorConditions: RuleConditionEntity[];
113
+ divisorConditionsOp: 'and' | 'or';
114
+ divisorAllTimeDateRange?: boolean;
115
+ fontSize?: number;
116
+ };
117
+
118
+ export type SummaryContent = BaseSummaryContent | PercentageSummaryContent;
119
+
120
+ export type CalendarWidget = AbstractWidget<
121
+ 'calendar-card',
122
+ {
123
+ name?: string;
124
+ conditions?: RuleConditionEntity[];
125
+ conditionsOp?: 'and' | 'or';
126
+ timeFrame?: TimeFrame;
127
+ } | null
128
+ >;
@@ -12,3 +12,64 @@ export type GoCardlessInstitution = {
12
12
  logo: string;
13
13
  identification_codes: string[];
14
14
  };
15
+
16
+ export type GoCardlessBalance = {
17
+ balanceAmount: GoCardlessAmount;
18
+ balanceType:
19
+ | 'closingBooked'
20
+ | 'expected'
21
+ | 'forwardAvailable'
22
+ | 'interimAvailable'
23
+ | 'interimBooked'
24
+ | 'nonInvoiced'
25
+ | 'openingBooked';
26
+ creditLimitIncluded?: boolean;
27
+ lastChangeDateTime?: string;
28
+ lastCommittedTransaction?: string;
29
+ referenceDate?: string;
30
+ };
31
+
32
+ export type GoCardlessAmount = {
33
+ amount: string;
34
+ currency: string;
35
+ };
36
+
37
+ export type GoCardlessTransaction = {
38
+ additionalInformation?: string;
39
+ bookingStatus?: string;
40
+ balanceAfterTransaction?: Pick<
41
+ GoCardlessBalance,
42
+ 'balanceType' | 'balanceAmount'
43
+ >;
44
+ bankTransactionCode?: string;
45
+ bookingDate?: string;
46
+ bookingDateTime?: string;
47
+ checkId?: string;
48
+ creditorAccount?: string;
49
+ creditorAgent?: string;
50
+ creditorId?: string;
51
+ creditorName?: string;
52
+ currencyExchange?: string[];
53
+ debtorAccount?: {
54
+ iban: string;
55
+ };
56
+ debtorAgent?: string;
57
+ debtorName?: string;
58
+ endToEndId?: string;
59
+ entryReference?: string;
60
+ internalTransactionId?: string;
61
+ mandateId?: string;
62
+ merchantCategoryCode?: string;
63
+ proprietaryBankTransactionCode?: string;
64
+ purposeCode?: string;
65
+ remittanceInformationStructured?: string;
66
+ remittanceInformationStructuredArray?: string[];
67
+ remittanceInformationUnstructured?: string;
68
+ remittanceInformationUnstructuredArray?: string[];
69
+ transactionAmount: GoCardlessAmount;
70
+ transactionId?: string;
71
+ ultimateCreditor?: string;
72
+ ultimateDebtor?: string;
73
+ valueDate?: string;
74
+ valueDateTime?: string;
75
+ };
@@ -1,4 +1,5 @@
1
1
  export type * from './account';
2
+ export type * from './bank-sync';
2
3
  export type * from './category';
3
4
  export type * from './category-group';
4
5
  export type * from './dashboard';
@@ -11,3 +12,4 @@ export type * from './rule';
11
12
  export type * from './schedule';
12
13
  export type * from './transaction';
13
14
  export type * from './transaction-filter';
15
+ export type * from './user';
@@ -0,0 +1,7 @@
1
+ export type OpenIdConfig = {
2
+ selectedProvider: string;
3
+ issuer: string;
4
+ client_id: string;
5
+ client_secret: string;
6
+ server_hostname: string;
7
+ };
@@ -26,7 +26,10 @@ export type RuleConditionOp =
26
26
  | 'contains'
27
27
  | 'doesNotContain'
28
28
  | 'hasTags'
29
- | 'matches';
29
+ | 'and'
30
+ | 'matches'
31
+ | 'onBudget'
32
+ | 'offBudget';
30
33
 
31
34
  type FieldValueTypes = {
32
35
  account: string;
@@ -38,6 +41,8 @@ type FieldValueTypes = {
38
41
  payee_name: string;
39
42
  imported_payee: string;
40
43
  saved: string;
44
+ transfer: boolean;
45
+ parent: boolean;
41
46
  cleared: boolean;
42
47
  reconciled: boolean;
43
48
  };
@@ -73,6 +78,8 @@ export type RuleConditionEntity =
73
78
  | 'contains'
74
79
  | 'doesNotContain'
75
80
  | 'matches'
81
+ | 'onBudget'
82
+ | 'offBudget'
76
83
  >
77
84
  | BaseConditionEntity<
78
85
  'category',
@@ -32,7 +32,7 @@ export interface ScheduleEntity {
32
32
  // underlying rule
33
33
  _payee: PayeeEntity['id'];
34
34
  _account: AccountEntity['id'];
35
- _amount: unknown;
35
+ _amount: number | { num1: number; num2: number };
36
36
  _amountOp: string;
37
37
  _date: RecurConfig;
38
38
  _conditions: unknown;
@@ -1,3 +1,6 @@
1
+ import { AccountEntity } from './account';
2
+ import { BankSyncResponse } from './bank-sync';
3
+
1
4
  export type SimpleFinOrganization = {
2
5
  name: string;
3
6
  domain: string;
@@ -8,3 +11,7 @@ export type SimpleFinAccount = {
8
11
  name: string;
9
12
  org: SimpleFinOrganization;
10
13
  };
14
+
15
+ export interface SimpleFinBatchSyncResponse {
16
+ [accountId: AccountEntity['account_id']]: BankSyncResponse;
17
+ }
@@ -0,0 +1,26 @@
1
+ export interface NewUserEntity {
2
+ userName: string;
3
+ displayName: string;
4
+ role: string;
5
+ enabled: boolean;
6
+ }
7
+ export interface UserEntity extends NewUserEntity {
8
+ id: string;
9
+ owner: boolean;
10
+ }
11
+ export interface UserEntityDropdown {
12
+ userId: string;
13
+ userName: string;
14
+ displayName?: string;
15
+ }
16
+ export interface UserAvailable {
17
+ userId: string;
18
+ displayName?: string;
19
+ userName: string;
20
+ haveAccess?: number;
21
+ owner?: number;
22
+ }
23
+ export declare const PossibleRoles: {
24
+ ADMIN: string;
25
+ BASIC: string;
26
+ };
@@ -0,0 +1,9 @@
1
+ export interface NewUserAccessEntity {
2
+ fileId: string;
3
+ userId: string;
4
+ }
5
+ export interface UserAccessEntity extends NewUserAccessEntity {
6
+ displayName: string;
7
+ userName: string;
8
+ fileName: string;
9
+ }
@@ -1,9 +1,9 @@
1
1
  export type FeatureFlag =
2
- | 'dashboards'
3
- | 'reportBudget'
4
2
  | 'goalTemplatesEnabled'
5
3
  | 'actionTemplating'
6
- | 'upcomingLengthAdjustment';
4
+ | 'upcomingLengthAdjustment'
5
+ | 'contextMenus'
6
+ | 'openidAuth';
7
7
 
8
8
  /**
9
9
  * Cross-device preferences. These sync across devices when they are changed.
@@ -82,3 +82,5 @@ export type GlobalPrefs = Partial<{
82
82
  documentDir: string; // Electron only
83
83
  serverSelfSignedCert: string; // Electron only
84
84
  }>;
85
+
86
+ export type AuthMethods = 'password' | 'openid';
@@ -17,6 +17,7 @@ import {
17
17
  RuleEntity,
18
18
  PayeeEntity,
19
19
  } from './models';
20
+ import { OpenIdConfig } from './models/openid';
20
21
  import { GlobalPrefs, MetadataPrefs } from './prefs';
21
22
  import { Query } from './query';
22
23
  import { EmptyObject } from './util';
@@ -116,6 +117,7 @@ export interface ServerHandlers {
116
117
  }) => Promise<unknown>;
117
118
 
118
119
  'payees-check-orphaned': (arg: { ids }) => Promise<unknown>;
120
+ 'payees-get-orphaned': () => Promise<PayeeEntity[]>;
119
121
 
120
122
  'payees-get-rules': (arg: { id: string }) => Promise<RuleEntity[]>;
121
123
 
@@ -177,7 +179,7 @@ export interface ServerHandlers {
177
179
 
178
180
  'account-move': (arg: { id; targetId }) => Promise<unknown>;
179
181
 
180
- 'secret-set': (arg: { name: string; value: string }) => Promise<null>;
182
+ 'secret-set': (arg: { name: string; value: string | null }) => Promise<null>;
181
183
  'secret-check': (arg: string) => Promise<string | { error?: string }>;
182
184
 
183
185
  'gocardless-poll-web-token': (arg: {
@@ -193,6 +195,18 @@ export interface ServerHandlers {
193
195
 
194
196
  'simplefin-accounts': () => Promise<{ accounts: SimpleFinAccount[] }>;
195
197
 
198
+ 'simplefin-batch-sync': ({ ids }: { ids: string[] }) => Promise<
199
+ {
200
+ accountId: string;
201
+ res: {
202
+ errors;
203
+ newTransactions;
204
+ matchedTransactions;
205
+ updatedAccounts;
206
+ };
207
+ }[]
208
+ >;
209
+
196
210
  'gocardless-get-banks': (country: string) => Promise<{
197
211
  data: GoCardlessInstitution[];
198
212
  error?: { reason: string };
@@ -213,7 +227,7 @@ export interface ServerHandlers {
213
227
  | { error: 'failed' }
214
228
  >;
215
229
 
216
- 'accounts-bank-sync': (arg: { id?: string }) => Promise<{
230
+ 'accounts-bank-sync': (arg: { ids?: AccountEntity['id'][] }) => Promise<{
217
231
  errors;
218
232
  newTransactions;
219
233
  matchedTransactions;
@@ -256,27 +270,64 @@ export interface ServerHandlers {
256
270
 
257
271
  'get-did-bootstrap': () => Promise<boolean>;
258
272
 
259
- 'subscribe-needs-bootstrap': (args: {
260
- url;
261
- }) => Promise<
262
- { error: string } | { bootstrapped: unknown; hasServer: boolean }
273
+ 'subscribe-needs-bootstrap': (args: { url }) => Promise<
274
+ | { error: string }
275
+ | {
276
+ bootstrapped: boolean;
277
+ hasServer: false;
278
+ }
279
+ | {
280
+ bootstrapped: boolean;
281
+ hasServer: true;
282
+ availableLoginMethods: {
283
+ method: string;
284
+ displayName: string;
285
+ active: boolean;
286
+ }[];
287
+ multiuser: boolean;
288
+ }
263
289
  >;
264
290
 
265
- 'subscribe-bootstrap': (arg: { password }) => Promise<{ error?: string }>;
291
+ 'subscribe-get-login-methods': () => Promise<{
292
+ methods?: { method: string; displayName: string; active: boolean }[];
293
+ error?: string;
294
+ }>;
295
+
296
+ 'subscribe-bootstrap': (arg: {
297
+ password?: string;
298
+ openId?: OpenIdConfig;
299
+ }) => Promise<{ error?: string }>;
266
300
 
267
- 'subscribe-get-user': () => Promise<{ offline: boolean } | null>;
301
+ 'subscribe-get-user': () => Promise<{
302
+ offline: boolean;
303
+ userName?: string;
304
+ userId?: string;
305
+ displayName?: string;
306
+ permission?: string;
307
+ loginMethod?: string;
308
+ tokenExpired?: boolean;
309
+ } | null>;
268
310
 
269
311
  'subscribe-change-password': (arg: {
270
312
  password;
271
313
  }) => Promise<{ error?: string }>;
272
314
 
273
- 'subscribe-sign-in': (arg: {
274
- password;
275
- loginMethod?: string;
276
- }) => Promise<{ error?: string }>;
315
+ 'subscribe-sign-in': (
316
+ arg:
317
+ | {
318
+ password;
319
+ loginMethod?: string;
320
+ }
321
+ | {
322
+ return_url;
323
+ loginMethod?: 'openid';
324
+ },
325
+ ) => Promise<{ error?: string }>;
277
326
 
278
327
  'subscribe-sign-out': () => Promise<'ok'>;
279
328
 
329
+ 'subscribe-set-token': (arg: { token: string }) => Promise<void>;
330
+
280
331
  'get-server-version': () => Promise<{ error?: string } | { version: string }>;
281
332
 
282
333
  'get-server-url': () => Promise<string | null>;
@@ -291,10 +342,18 @@ export interface ServerHandlers {
291
342
  | { messages: Message[] }
292
343
  >;
293
344
 
345
+ 'validate-budget-name': (arg: {
346
+ name: string;
347
+ }) => Promise<{ valid: boolean; message?: string }>;
348
+
349
+ 'unique-budget-name': (arg: { name: string }) => Promise<string>;
350
+
294
351
  'get-budgets': () => Promise<Budget[]>;
295
352
 
296
353
  'get-remote-files': () => Promise<RemoteFile[]>;
297
354
 
355
+ 'get-user-file-info': (fileId: string) => Promise<RemoteFile | null>;
356
+
298
357
  'reset-budget-cache': () => Promise<unknown>;
299
358
 
300
359
  'upload-budget': (arg: { id }) => Promise<{ error?: string }>;
@@ -314,7 +373,24 @@ export interface ServerHandlers {
314
373
  'delete-budget': (arg: {
315
374
  id?: string;
316
375
  cloudFileId?: string;
317
- }) => Promise<'ok'>;
376
+ }) => Promise<'ok' | 'fail'>;
377
+
378
+ /**
379
+ * Duplicates a budget file.
380
+ * @param {Object} arg - The arguments for duplicating a budget.
381
+ * @param {string} [arg.id] - The ID of the local budget to duplicate.
382
+ * @param {string} [arg.cloudId] - The ID of the cloud-synced budget to duplicate.
383
+ * @param {string} arg.newName - The name for the duplicated budget.
384
+ * @param {boolean} [arg.cloudSync] - Whether to sync the duplicated budget to the cloud.
385
+ * @returns {Promise<string>} The ID of the newly created budget.
386
+ */
387
+ 'duplicate-budget': (arg: {
388
+ id?: string;
389
+ cloudId?: string;
390
+ newName: string;
391
+ cloudSync?: boolean;
392
+ open: 'none' | 'original' | 'copy';
393
+ }) => Promise<string>;
318
394
 
319
395
  'create-budget': (arg: {
320
396
  budgetName?;
@@ -344,4 +420,18 @@ export interface ServerHandlers {
344
420
  'get-last-opened-backup': () => Promise<string | null>;
345
421
 
346
422
  'app-focused': () => Promise<void>;
423
+
424
+ 'enable-openid': (arg: {
425
+ openId?: OpenIdConfig;
426
+ }) => Promise<{ error?: string }>;
427
+
428
+ 'enable-password': (arg: { password: string }) => Promise<{ error?: string }>;
429
+
430
+ 'get-openid-config': () => Promise<
431
+ | {
432
+ openId: OpenIdConfig;
433
+ }
434
+ | { error: string }
435
+ | null
436
+ >;
347
437
  }