@actual-app/api 6.9.0 → 6.10.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 (70) hide show
  1. package/@types/jest.config.d.ts +7 -7
  2. package/@types/loot-core/client/constants.d.ts +1 -0
  3. package/@types/loot-core/client/state-types/index.d.ts +1 -1
  4. package/@types/loot-core/client/state-types/modals.d.ts +18 -6
  5. package/@types/loot-core/client/state-types/notifications.d.ts +18 -1
  6. package/@types/loot-core/client/state-types/prefs.d.ts +9 -4
  7. package/@types/loot-core/server/accounts/parse-file.d.ts +1 -0
  8. package/@types/loot-core/server/accounts/rules.d.ts +2 -2
  9. package/@types/loot-core/server/accounts/sync.d.ts +2 -2
  10. package/@types/loot-core/server/accounts/transaction-rules.d.ts +1 -3
  11. package/@types/loot-core/server/accounts/transactions.d.ts +3 -5
  12. package/@types/loot-core/server/api-models.d.ts +6 -6
  13. package/@types/loot-core/server/aql/schema/index.d.ts +26 -3
  14. package/@types/loot-core/server/budget/statements.d.ts +9 -0
  15. package/@types/loot-core/server/budget/template-notes.d.ts +5 -0
  16. package/@types/loot-core/server/budget/types/templates.d.ts +82 -0
  17. package/@types/loot-core/server/cloud-storage.d.ts +0 -1
  18. package/@types/loot-core/server/dashboard/app.d.ts +12 -0
  19. package/@types/loot-core/server/dashboard/types/handlers.d.ts +24 -0
  20. package/@types/loot-core/server/db/index.d.ts +3 -2
  21. package/@types/loot-core/server/db/types.d.ts +9 -0
  22. package/@types/loot-core/server/encryption-internals.d.ts +0 -1
  23. package/@types/loot-core/server/encryption-internals.web.d.ts +0 -1
  24. package/@types/loot-core/server/encryption.d.ts +0 -1
  25. package/@types/loot-core/server/errors.d.ts +2 -0
  26. package/@types/loot-core/server/importers/actual.d.ts +0 -1
  27. package/@types/loot-core/server/importers/index.d.ts +0 -1
  28. package/@types/loot-core/server/importers/ynab4.d.ts +0 -1
  29. package/@types/loot-core/server/importers/ynab5.d.ts +0 -1
  30. package/@types/loot-core/server/main-app.d.ts +1 -1
  31. package/@types/loot-core/server/models.d.ts +4 -4
  32. package/@types/loot-core/server/prefs.d.ts +7 -2
  33. package/@types/loot-core/server/reports/app.d.ts +46 -0
  34. package/@types/loot-core/server/rules/types/handlers.d.ts +4 -6
  35. package/@types/loot-core/server/sync/make-test-message.d.ts +0 -1
  36. package/@types/loot-core/shared/dashboard.d.ts +2 -0
  37. package/@types/loot-core/shared/months.d.ts +7 -6
  38. package/@types/loot-core/shared/rules.d.ts +5 -1
  39. package/@types/loot-core/shared/schedules.d.ts +22 -22
  40. package/@types/loot-core/shared/transactions.d.ts +24 -73
  41. package/@types/loot-core/shared/util.d.ts +9 -12
  42. package/@types/loot-core/types/api-handlers.d.ts +14 -3
  43. package/@types/loot-core/types/handlers.d.ts +2 -0
  44. package/@types/loot-core/types/models/category-group.d.ts +6 -2
  45. package/@types/loot-core/types/models/category.d.ts +4 -2
  46. package/@types/loot-core/types/models/dashboard.d.ts +56 -0
  47. package/@types/loot-core/types/models/index.d.ts +1 -0
  48. package/@types/loot-core/types/models/payee.d.ts +5 -7
  49. package/@types/loot-core/types/models/reports.d.ts +2 -5
  50. package/@types/loot-core/types/models/rule.d.ts +100 -7
  51. package/@types/loot-core/types/models/transaction.d.ts +12 -25
  52. package/@types/loot-core/types/prefs.d.ts +44 -22
  53. package/@types/loot-core/types/server-handlers.d.ts +5 -7
  54. package/@types/loot-core/types/util.d.ts +4 -0
  55. package/@types/methods.d.ts +4 -11
  56. package/@types/migrations/1722717601000_reports_move_selected_categories.d.ts +1 -0
  57. package/@types/migrations/1722804019000_create_dashboard_table.d.ts +1 -0
  58. package/dist/app/bundle.api.js +4620 -1320
  59. package/dist/app/query.js +1 -2
  60. package/dist/index.js +3 -3
  61. package/dist/injected.js +2 -2
  62. package/dist/methods.js +53 -45
  63. package/dist/methods.test.js +8 -14
  64. package/dist/migrations/1632571489012_remove_cache.js +1 -1
  65. package/dist/migrations/1722717601000_reports_move_selected_categories.js +39 -0
  66. package/dist/migrations/1722804019000_create_dashboard_table.js +38 -0
  67. package/dist/package.json +2 -2
  68. package/dist/utils.js +2 -3
  69. package/dist/validateNodeVersion.js +1 -2
  70. package/package.json +2 -2
@@ -25,12 +25,29 @@ export type RuleConditionOp =
25
25
  | 'lte'
26
26
  | 'contains'
27
27
  | 'doesNotContain'
28
+ | 'hasTags'
28
29
  | 'matches';
29
30
 
30
- export interface RuleConditionEntity {
31
- field?: string;
32
- op?: RuleConditionOp;
33
- value?: string | string[] | number | boolean;
31
+ type FieldValueTypes = {
32
+ account: string;
33
+ amount: number;
34
+ category: string;
35
+ date: string;
36
+ notes: string;
37
+ payee: string;
38
+ imported_payee: string;
39
+ saved: string;
40
+ };
41
+
42
+ type BaseConditionEntity<
43
+ Field extends keyof FieldValueTypes,
44
+ Op extends RuleConditionOp,
45
+ > = {
46
+ field: Field;
47
+ op: Op;
48
+ value: Op extends 'oneOf' | 'notOneOf'
49
+ ? Array<FieldValueTypes[Field]>
50
+ : FieldValueTypes[Field];
34
51
  options?: {
35
52
  inflow?: boolean;
36
53
  outflow?: boolean;
@@ -38,14 +55,80 @@ export interface RuleConditionEntity {
38
55
  year?: boolean;
39
56
  };
40
57
  conditionsOp?: string;
41
- type?: string;
58
+ type?: 'id' | 'boolean' | 'date' | 'number';
42
59
  customName?: string;
43
- }
60
+ };
61
+
62
+ export type RuleConditionEntity =
63
+ | BaseConditionEntity<
64
+ 'account',
65
+ | 'is'
66
+ | 'isNot'
67
+ | 'oneOf'
68
+ | 'notOneOf'
69
+ | 'contains'
70
+ | 'doesNotContain'
71
+ | 'matches'
72
+ >
73
+ | BaseConditionEntity<
74
+ 'category',
75
+ | 'is'
76
+ | 'isNot'
77
+ | 'oneOf'
78
+ | 'notOneOf'
79
+ | 'contains'
80
+ | 'doesNotContain'
81
+ | 'matches'
82
+ >
83
+ | BaseConditionEntity<
84
+ 'amount',
85
+ 'is' | 'isapprox' | 'isbetween' | 'gt' | 'gte' | 'lt' | 'lte'
86
+ >
87
+ | BaseConditionEntity<
88
+ 'date',
89
+ 'is' | 'isapprox' | 'isbetween' | 'gt' | 'gte' | 'lt' | 'lte'
90
+ >
91
+ | BaseConditionEntity<
92
+ 'notes',
93
+ | 'is'
94
+ | 'isNot'
95
+ | 'oneOf'
96
+ | 'notOneOf'
97
+ | 'contains'
98
+ | 'doesNotContain'
99
+ | 'matches'
100
+ | 'hasTags'
101
+ >
102
+ | BaseConditionEntity<
103
+ 'payee',
104
+ | 'is'
105
+ | 'isNot'
106
+ | 'oneOf'
107
+ | 'notOneOf'
108
+ | 'contains'
109
+ | 'doesNotContain'
110
+ | 'matches'
111
+ >
112
+ | BaseConditionEntity<
113
+ 'imported_payee',
114
+ | 'is'
115
+ | 'isNot'
116
+ | 'oneOf'
117
+ | 'notOneOf'
118
+ | 'contains'
119
+ | 'doesNotContain'
120
+ | 'matches'
121
+ >
122
+ | BaseConditionEntity<'saved', 'is'>
123
+ | BaseConditionEntity<'cleared', 'is'>
124
+ | BaseConditionEntity<'reconciled', 'is'>;
44
125
 
45
126
  export type RuleActionEntity =
46
127
  | SetRuleActionEntity
47
128
  | SetSplitAmountRuleActionEntity
48
- | LinkScheduleRuleActionEntity;
129
+ | LinkScheduleRuleActionEntity
130
+ | PrependNoteRuleActionEntity
131
+ | AppendNoteRuleActionEntity;
49
132
 
50
133
  export interface SetRuleActionEntity {
51
134
  field: string;
@@ -70,3 +153,13 @@ export interface LinkScheduleRuleActionEntity {
70
153
  op: 'link-schedule';
71
154
  value: ScheduleEntity;
72
155
  }
156
+
157
+ export interface PrependNoteRuleActionEntity {
158
+ op: 'prepend-notes';
159
+ value: string;
160
+ }
161
+
162
+ export interface AppendNoteRuleActionEntity {
163
+ op: 'append-notes';
164
+ value: string;
165
+ }
@@ -1,40 +1,27 @@
1
- import type { AccountEntity } from './account';
2
- import type { CategoryEntity } from './category';
3
- import type { PayeeEntity } from './payee';
4
- import type { ScheduleEntity } from './schedule';
1
+ import { AccountEntity } from './account';
2
+ import { CategoryEntity } from './category';
3
+ import { PayeeEntity } from './payee';
4
+ import { ScheduleEntity } from './schedule';
5
5
 
6
- export interface NewTransactionEntity {
7
- id?: string;
6
+ export interface TransactionEntity {
7
+ id: string;
8
8
  is_parent?: boolean;
9
9
  is_child?: boolean;
10
- parent_id?: string;
11
- account: string;
12
- category?: string;
10
+ parent_id?: TransactionEntity['id'];
11
+ account: AccountEntity['id'];
12
+ category?: CategoryEntity['id'];
13
13
  amount: number;
14
- payee?: string;
14
+ payee?: PayeeEntity['id'];
15
15
  notes?: string;
16
16
  date: string;
17
17
  imported_id?: string;
18
18
  imported_payee?: string;
19
19
  starting_balance_flag?: boolean;
20
- transfer_id?: string;
20
+ transfer_id?: TransactionEntity['id'];
21
21
  sort_order?: number;
22
22
  cleared?: boolean;
23
23
  reconciled?: boolean;
24
24
  tombstone?: boolean;
25
- schedule?: string;
26
- subtransactions?: Omit<NewTransactionEntity, 'account' | 'date'>[];
27
- }
28
-
29
- export interface TransactionEntity
30
- extends Omit<
31
- NewTransactionEntity,
32
- 'account' | 'category' | 'payee' | 'schedule' | 'subtransactions'
33
- > {
34
- id: string;
35
- account: AccountEntity;
36
- category?: CategoryEntity;
37
- payee?: PayeeEntity;
38
- schedule?: ScheduleEntity;
25
+ schedule?: ScheduleEntity['id'];
39
26
  subtransactions?: TransactionEntity[];
40
27
  }
@@ -3,13 +3,16 @@ import { type numberFormats } from '../shared/util';
3
3
  import { spendingReportTimeType } from './models/reports';
4
4
 
5
5
  export type FeatureFlag =
6
+ | 'dashboards'
6
7
  | 'reportBudget'
7
8
  | 'goalTemplatesEnabled'
8
9
  | 'spendingReport'
9
- | 'simpleFinSync'
10
- | 'iterableTopologicalSort';
10
+ | 'simpleFinSync';
11
11
 
12
- export type LocalPrefs = Partial<
12
+ /**
13
+ * Cross-device preferences. These sync across devices when they are changed.
14
+ */
15
+ export type SyncedPrefs = Partial<
13
16
  {
14
17
  firstDayOfWeekIdx: `${0 | 1 | 2 | 3 | 4 | 5 | 6}`;
15
18
  dateFormat:
@@ -21,34 +24,53 @@ export type LocalPrefs = Partial<
21
24
  numberFormat: (typeof numberFormats)[number]['value'];
22
25
  hideFraction: boolean;
23
26
  isPrivacyEnabled: boolean;
24
- budgetName: string;
25
- 'ui.showClosedAccounts': boolean;
26
- 'expand-splits': boolean;
27
27
  [key: `show-extra-balances-${string}`]: boolean;
28
28
  [key: `hide-cleared-${string}`]: boolean;
29
29
  [key: `hide-reconciled-${string}`]: boolean;
30
- 'budget.collapsed': string[];
31
- 'budget.summaryCollapsed': boolean;
32
- 'budget.showHiddenCategories': boolean;
33
- 'budget.startMonth': string;
34
30
  // TODO: pull from src/components/modals/ImportTransactions.js
35
31
  [key: `parse-date-${string}-${'csv' | 'qif'}`]: string;
36
32
  [key: `csv-mappings-${string}`]: string;
37
33
  [key: `csv-delimiter-${string}`]: ',' | ';' | '\t';
34
+ [key: `csv-skip-lines-${string}`]: number;
38
35
  [key: `csv-has-header-${string}`]: boolean;
39
36
  [key: `ofx-fallback-missing-payee-${string}`]: boolean;
40
37
  [key: `flip-amount-${string}-${'csv' | 'qif'}`]: boolean;
41
- 'flags.updateNotificationShownForVersion': string;
42
- id: string;
43
- lastUploaded: string;
44
- cloudFileId: string;
45
- groupId: string;
46
38
  budgetType: 'report' | 'rollover';
47
- encryptKeyId: string;
48
- lastSyncedTimestamp: string;
49
- userId: string;
50
- resetClock: boolean;
51
- lastScheduleRun: string;
39
+ } & Record<`flags.${FeatureFlag}`, boolean>
40
+ >;
41
+
42
+ /**
43
+ * Preferences that are stored in the `metadata.json` file along with the
44
+ * core database.
45
+ */
46
+ export type MetadataPrefs = Partial<{
47
+ budgetName: string;
48
+ id: string;
49
+ lastUploaded: string;
50
+ cloudFileId: string;
51
+ groupId: string;
52
+ encryptKeyId: string;
53
+ lastSyncedTimestamp: string;
54
+ resetClock: boolean;
55
+ lastScheduleRun: string;
56
+ userId: string; // TODO: delete this (unused)
57
+ }>;
58
+
59
+ /**
60
+ * Local preferences applicable to a single device. Stored in local storage.
61
+ * TODO: eventually `LocalPrefs` type should not use `SyncedPrefs` or `MetadataPrefs`;
62
+ * this is only a stop-gap solution.
63
+ */
64
+ export type LocalPrefs = SyncedPrefs &
65
+ MetadataPrefs &
66
+ Partial<{
67
+ 'ui.showClosedAccounts': boolean;
68
+ 'expand-splits': boolean;
69
+ 'budget.collapsed': string[];
70
+ 'budget.summaryCollapsed': boolean;
71
+ 'budget.showHiddenCategories': boolean;
72
+ 'budget.startMonth': string;
73
+ 'flags.updateNotificationShownForVersion': string;
52
74
  reportsViewLegend: boolean;
53
75
  reportsViewSummary: boolean;
54
76
  reportsViewLabel: boolean;
@@ -57,8 +79,7 @@ export type LocalPrefs = Partial<
57
79
  spendingReportCompare: spendingReportTimeType;
58
80
  sidebarWidth: number;
59
81
  'mobile.showSpentColumn': boolean;
60
- } & Record<`flags.${FeatureFlag}`, boolean>
61
- >;
82
+ }>;
62
83
 
63
84
  export type Theme = 'light' | 'dark' | 'auto' | 'midnight' | 'development';
64
85
  export type GlobalPrefs = Partial<{
@@ -67,4 +88,5 @@ export type GlobalPrefs = Partial<{
67
88
  keyId?: string;
68
89
  theme: Theme;
69
90
  documentDir: string; // Electron only
91
+ serverSelfSignedCert: string; // Electron only
70
92
  }>;
@@ -18,6 +18,7 @@ import {
18
18
  PayeeEntity,
19
19
  } from './models';
20
20
  import { GlobalPrefs, LocalPrefs } from './prefs';
21
+ import { Query } from './query';
21
22
  import { EmptyObject } from './util';
22
23
 
23
24
  export interface ServerHandlers {
@@ -28,11 +29,8 @@ export interface ServerHandlers {
28
29
  redo: () => Promise<void>;
29
30
 
30
31
  'transactions-batch-update': (
31
- arg: Omit<
32
- Parameters<typeof batchUpdateTransactions>[0],
33
- 'detectOrphanPayees'
34
- >,
35
- ) => Promise<Awaited<ReturnType<typeof batchUpdateTransactions>>>;
32
+ ...arg: Parameters<typeof batchUpdateTransactions>
33
+ ) => ReturnType<typeof batchUpdateTransactions>;
36
34
 
37
35
  'transaction-add': (transaction) => Promise<EmptyObject>;
38
36
 
@@ -111,7 +109,7 @@ export interface ServerHandlers {
111
109
 
112
110
  'payees-get-rule-counts': () => Promise<unknown>;
113
111
 
114
- 'payees-merge': (arg: { targetId; mergeIds }) => Promise<unknown>;
112
+ 'payees-merge': (arg: { targetId; mergeIds }) => Promise<void>;
115
113
 
116
114
  'payees-batch-change': (arg: {
117
115
  added?;
@@ -140,7 +138,7 @@ export interface ServerHandlers {
140
138
 
141
139
  'create-query': (arg: { sheetName; name; query }) => Promise<unknown>;
142
140
 
143
- query: (query) => Promise<{ data; dependencies }>;
141
+ query: (query: Query) => Promise<{ data: unknown; dependencies }>;
144
142
 
145
143
  'account-update': (arg: { id; name }) => Promise<unknown>;
146
144
 
@@ -3,3 +3,7 @@ export type EmptyObject = Record<never, never>;
3
3
  export type StripNever<T> = {
4
4
  [K in keyof T as T[K] extends never ? never : K]: T[K];
5
5
  };
6
+
7
+ export type EverythingButIdOptional<T> = { id: T['id'] } & Partial<
8
+ Omit<T, 'id'>
9
+ >;
@@ -49,16 +49,7 @@ export declare function updateTransaction(id: any, fields: any): Promise<import(
49
49
  id: any;
50
50
  category: any;
51
51
  })[]>;
52
- export declare function deleteTransaction(id: any): Promise<import("./loot-core/types/models").TransactionEntity[] | ({
53
- id: any;
54
- transfer_id: any;
55
- } | {
56
- id: any;
57
- payee: any;
58
- } | {
59
- id: any;
60
- category: any;
61
- })[]>;
52
+ export declare function deleteTransaction(id: any): Promise<any>;
62
53
  export declare function getAccounts(): Promise<import("./loot-core/server/api-models").APIAccountEntity[]>;
63
54
  export declare function createAccount(account: any, initialBalance?: any): Promise<string>;
64
55
  export declare function updateAccount(id: any, fields: any): Promise<void>;
@@ -86,4 +77,6 @@ export declare function getRules(): Promise<import("./loot-core/types/models").R
86
77
  export declare function getPayeeRules(id: any): Promise<import("./loot-core/types/models").RuleEntity[]>;
87
78
  export declare function createRule(rule: any): Promise<import("./loot-core/types/models").RuleEntity>;
88
79
  export declare function updateRule(rule: any): Promise<import("./loot-core/types/models").RuleEntity>;
89
- export declare function deleteRule(id: any): Promise<boolean>;
80
+ export declare function deleteRule(id: string): Promise<boolean>;
81
+ export declare function holdBudgetForNextMonth(month: any, amount: any): Promise<boolean>;
82
+ export declare function resetBudgetHold(month: any): Promise<void>;
@@ -0,0 +1 @@
1
+ export default function runMigration(db: any): Promise<void>;
@@ -0,0 +1 @@
1
+ export default function runMigration(db: any): Promise<void>;