@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
@@ -1,4 +1,50 @@
1
+ import { type CustomReportData, type CustomReportEntity } from '../../types/models';
1
2
  import { ReportsHandlers } from './types/handlers';
3
+ export declare const reportModel: {
4
+ validate(report: Omit<CustomReportEntity, "tombstone">, { update }?: {
5
+ update?: boolean;
6
+ }): Omit<CustomReportEntity, "tombstone">;
7
+ toJS(row: CustomReportData): {
8
+ id: string;
9
+ name: string;
10
+ startDate: string;
11
+ endDate: string;
12
+ isDateStatic: boolean;
13
+ dateRange: string;
14
+ mode: string;
15
+ groupBy: string;
16
+ interval: string;
17
+ balanceType: string;
18
+ showEmpty: boolean;
19
+ showOffBudget: boolean;
20
+ showHiddenCategories: boolean;
21
+ showUncategorized: boolean;
22
+ includeCurrentInterval: boolean;
23
+ graphType: string;
24
+ conditions: import("../../types/models").RuleConditionEntity[];
25
+ conditionsOp: "and" | "or";
26
+ };
27
+ fromJS(report: CustomReportEntity): {
28
+ id: string;
29
+ name: string;
30
+ start_date: string;
31
+ end_date: string;
32
+ date_static: number;
33
+ date_range: string;
34
+ mode: string;
35
+ group_by: string;
36
+ interval: string;
37
+ balance_type: string;
38
+ show_empty: number;
39
+ show_offbudget: number;
40
+ show_hidden: number;
41
+ show_uncategorized: number;
42
+ include_current: number;
43
+ graph_type: string;
44
+ conditions: import("../../types/models").RuleConditionEntity[];
45
+ conditions_op: "and" | "or";
46
+ };
47
+ };
2
48
  export declare const app: {
3
49
  events: any;
4
50
  handlers: ReportsHandlers;
@@ -10,13 +10,11 @@ export interface RulesHandlers {
10
10
  }>;
11
11
  'rule-add': (rule: Omit<RuleEntity, 'id'>) => Promise<{
12
12
  error: ValidationError;
13
- } | {
14
- id: string;
15
- }>;
16
- 'rule-update': (rule: Partial<RuleEntity>) => Promise<{
13
+ } | RuleEntity>;
14
+ 'rule-update': <PartialRule extends Partial<Omit<RuleEntity, 'id'>> & Pick<RuleEntity, 'id'>>(rule: PartialRule) => Promise<{
17
15
  error: ValidationError;
18
- } | object>;
19
- 'rule-delete': (rule: Required<RuleEntity>) => Promise<false | void>;
16
+ } | PartialRule>;
17
+ 'rule-delete': (id: string) => Promise<boolean>;
20
18
  'rule-delete-all': (ids: string[]) => Promise<{
21
19
  someDeletionsFailed: boolean;
22
20
  }>;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  export declare function makeTestMessage(keyId: any): Promise<{
3
2
  value: Buffer;
4
3
  meta: {
@@ -0,0 +1,2 @@
1
+ import { type NewWidget } from '../types/models';
2
+ export declare const DEFAULT_DASHBOARD_STATE: NewWidget[];
@@ -1,13 +1,13 @@
1
- import { type LocalPrefs } from '../types/prefs';
1
+ import { type SyncedPrefs } from '../types/prefs';
2
2
  type DateLike = string | Date;
3
3
  export declare function _parse(value: DateLike): Date;
4
4
  export declare const parseDate: typeof _parse;
5
5
  export declare function yearFromDate(date: DateLike): string;
6
6
  export declare function monthFromDate(date: DateLike): string;
7
- export declare function weekFromDate(date: DateLike, firstDayOfWeekIdx: LocalPrefs['firstDayOfWeekIdx']): string;
7
+ export declare function weekFromDate(date: DateLike, firstDayOfWeekIdx: SyncedPrefs['firstDayOfWeekIdx']): string;
8
8
  export declare function dayFromDate(date: DateLike): string;
9
9
  export declare function currentMonth(): string;
10
- export declare function currentWeek(firstDayOfWeekIdx?: LocalPrefs['firstDayOfWeekIdx']): string;
10
+ export declare function currentWeek(firstDayOfWeekIdx?: SyncedPrefs['firstDayOfWeekIdx']): string;
11
11
  export declare function currentYear(): string;
12
12
  export declare function currentDate(): Date;
13
13
  export declare function currentDay(): string;
@@ -26,14 +26,15 @@ export declare function addDays(day: DateLike, n: number): string;
26
26
  export declare function subDays(day: DateLike, n: number): string;
27
27
  export declare function isBefore(month1: DateLike, month2: DateLike): boolean;
28
28
  export declare function isAfter(month1: DateLike, month2: DateLike): boolean;
29
+ export declare function isCurrentMonth(month: DateLike): boolean;
29
30
  export declare function bounds(month: DateLike): {
30
31
  start: number;
31
32
  end: number;
32
33
  };
33
34
  export declare function _yearRange(start: DateLike, end: DateLike, inclusive?: boolean): string[];
34
35
  export declare function yearRangeInclusive(start: DateLike, end: DateLike): string[];
35
- export declare function _weekRange(start: DateLike, end: DateLike, inclusive?: boolean, firstDayOfWeekIdx?: LocalPrefs['firstDayOfWeekIdx']): string[];
36
- export declare function weekRangeInclusive(start: DateLike, end: DateLike, firstDayOfWeekIdx?: LocalPrefs['firstDayOfWeekIdx']): string[];
36
+ export declare function _weekRange(start: DateLike, end: DateLike, inclusive?: boolean, firstDayOfWeekIdx?: SyncedPrefs['firstDayOfWeekIdx']): string[];
37
+ export declare function weekRangeInclusive(start: DateLike, end: DateLike, firstDayOfWeekIdx?: SyncedPrefs['firstDayOfWeekIdx']): string[];
37
38
  export declare function _range(start: DateLike, end: DateLike, inclusive?: boolean): string[];
38
39
  export declare function range(start: DateLike, end: DateLike): string[];
39
40
  export declare function rangeInclusive(start: DateLike, end: DateLike): string[];
@@ -46,7 +47,7 @@ export declare function getYear(month: string): string;
46
47
  export declare function getMonth(day: string): string;
47
48
  export declare function getDay(day: string): number;
48
49
  export declare function getMonthEnd(day: string): string;
49
- export declare function getWeekEnd(date: DateLike, firstDayOfWeekIdx?: LocalPrefs['firstDayOfWeekIdx']): string;
50
+ export declare function getWeekEnd(date: DateLike, firstDayOfWeekIdx?: SyncedPrefs['firstDayOfWeekIdx']): string;
50
51
  export declare function getYearStart(month: string): string;
51
52
  export declare function getYearEnd(month: string): string;
52
53
  export declare function sheetForMonth(month: string): string;
@@ -15,6 +15,10 @@ export declare const TYPE_INFO: {
15
15
  ops: string[];
16
16
  nullable: boolean;
17
17
  };
18
+ imported_payee: {
19
+ ops: string[];
20
+ nullable: boolean;
21
+ };
18
22
  number: {
19
23
  ops: string[];
20
24
  nullable: boolean;
@@ -31,7 +35,7 @@ export declare const ALLOCATION_METHODS: {
31
35
  remainder: string;
32
36
  };
33
37
  export declare function mapField(field: any, opts?: any): any;
34
- export declare function friendlyOp(op: any, type?: any): "" | "is" | "contains" | "matches" | "one of" | "not one of" | "is not" | "is approx" | "is between" | "does not contain" | "is after" | "is greater than" | "is after or equals" | "is greater than or equals" | "is before" | "is less than" | "is before or equals" | "is less than or equals" | "is true" | "is false" | "set" | "allocate" | "link schedule" | "and" | "or";
38
+ export declare function friendlyOp(op: any, type?: any): "" | "is" | "contains" | "matches" | "one of" | "not one of" | "is not" | "is approx" | "is between" | "has tag(s)" | "does not contain" | "is after" | "is greater than" | "is after or equals" | "is greater than or equals" | "is before" | "is less than" | "is before or equals" | "is less than or equals" | "is true" | "is false" | "set" | "allocate" | "link schedule" | "prepend to notes" | "append to notes" | "and" | "or";
35
39
  export declare function deserializeField(field: any): {
36
40
  field: string;
37
41
  options: {
@@ -4,34 +4,34 @@ export declare function getHasTransactionsQuery(schedules: any): import("./query
4
4
  export declare function getRecurringDescription(config: any, dateFormat: any): string;
5
5
  export declare function recurConfigToRSchedule(config: any): IRuleOptions[] | ({
6
6
  byDayOfMonth: any;
7
- start: import("@rschedule/core").DateInput;
8
- end?: import("@rschedule/core").DateInput;
9
- duration?: number;
10
- count?: number;
7
+ start: import("@rschedule/core").RuleOption.Start;
8
+ end?: import("@rschedule/core").RuleOption.End;
9
+ duration?: import("@rschedule/core").RuleOption.Duration;
10
+ count?: import("@rschedule/core").RuleOption.Count;
11
11
  frequency: import("@rschedule/core").RuleOption.Frequency;
12
- interval?: number;
13
- weekStart?: import("@rschedule/core").DateAdapter.Weekday;
12
+ interval?: import("@rschedule/core").RuleOption.Interval;
13
+ weekStart?: import("@rschedule/core").RuleOption.WeekStart;
14
14
  byDayOfWeek?: import("@rschedule/core").RuleOption.ByDayOfWeek[];
15
- byHourOfDay?: import("@rschedule/core").DateAdapter.Hour[];
16
- byMillisecondOfSecond?: number[];
17
- byMinuteOfHour?: import("@rschedule/core").DateAdapter.Minute[];
18
- byMonthOfYear?: import("@rschedule/core").DateAdapter.Month[];
19
- bySecondOfMinute?: import("@rschedule/core").DateAdapter.Minute[];
15
+ byHourOfDay?: import("@rschedule/core").RuleOption.ByHourOfDay[];
16
+ byMillisecondOfSecond?: import("@rschedule/core").RuleOption.ByMillisecondOfSecond[];
17
+ byMinuteOfHour?: import("@rschedule/core").RuleOption.ByMinuteOfHour[];
18
+ byMonthOfYear?: import("@rschedule/core").RuleOption.ByMonthOfYear[];
19
+ bySecondOfMinute?: import("@rschedule/core").RuleOption.BySecondOfMinute[];
20
20
  } | {
21
21
  byDayOfWeek: any;
22
- start: import("@rschedule/core").DateInput;
23
- end?: import("@rschedule/core").DateInput;
24
- duration?: number;
25
- count?: number;
22
+ start: import("@rschedule/core").RuleOption.Start;
23
+ end?: import("@rschedule/core").RuleOption.End;
24
+ duration?: import("@rschedule/core").RuleOption.Duration;
25
+ count?: import("@rschedule/core").RuleOption.Count;
26
26
  frequency: import("@rschedule/core").RuleOption.Frequency;
27
- interval?: number;
28
- weekStart?: import("@rschedule/core").DateAdapter.Weekday;
27
+ interval?: import("@rschedule/core").RuleOption.Interval;
28
+ weekStart?: import("@rschedule/core").RuleOption.WeekStart;
29
29
  byDayOfMonth?: import("@rschedule/core").RuleOption.ByDayOfMonth[];
30
- byHourOfDay?: import("@rschedule/core").DateAdapter.Hour[];
31
- byMillisecondOfSecond?: number[];
32
- byMinuteOfHour?: import("@rschedule/core").DateAdapter.Minute[];
33
- byMonthOfYear?: import("@rschedule/core").DateAdapter.Month[];
34
- bySecondOfMinute?: import("@rschedule/core").DateAdapter.Minute[];
30
+ byHourOfDay?: import("@rschedule/core").RuleOption.ByHourOfDay[];
31
+ byMillisecondOfSecond?: import("@rschedule/core").RuleOption.ByMillisecondOfSecond[];
32
+ byMinuteOfHour?: import("@rschedule/core").RuleOption.ByMinuteOfHour[];
33
+ byMonthOfYear?: import("@rschedule/core").RuleOption.ByMonthOfYear[];
34
+ bySecondOfMinute?: import("@rschedule/core").RuleOption.BySecondOfMinute[];
35
35
  })[];
36
36
  export declare function extractScheduleConds(conditions: any): {
37
37
  payee: any;
@@ -1,5 +1,5 @@
1
- import { type TransactionEntity, type NewTransactionEntity } from '../types/models';
2
- import { applyChanges } from './util';
1
+ import { type TransactionEntity } from '../types/models';
2
+ import { diffItems, applyChanges } from './util';
3
3
  interface TransactionEntityWithError extends TransactionEntity {
4
4
  error: ReturnType<typeof SplitTransactionError> | null;
5
5
  _deleted?: boolean;
@@ -11,7 +11,7 @@ declare function SplitTransactionError(total: number, parent: TransactionEntity)
11
11
  version: number;
12
12
  difference: number;
13
13
  };
14
- type GenericTransactionEntity = NewTransactionEntity | TransactionEntity | TransactionEntityWithError;
14
+ type GenericTransactionEntity = TransactionEntity | TransactionEntityWithError;
15
15
  export declare function makeChild<T extends GenericTransactionEntity>(parent: T, data?: object): T;
16
16
  export declare function recalculateSplit(trans: TransactionEntity): TransactionEntityWithError;
17
17
  export declare function ungroupTransactions(transactions: TransactionEntity[]): TransactionEntity[];
@@ -19,98 +19,49 @@ export declare function groupTransaction(split: TransactionEntity[]): Transactio
19
19
  export declare function ungroupTransaction(split: TransactionEntity | null): TransactionEntity[];
20
20
  export declare function applyTransactionDiff(groupedTrans: Parameters<typeof ungroupTransaction>[0], diff: Parameters<typeof applyChanges>[0]): TransactionEntity;
21
21
  export declare function addSplitTransaction(transactions: TransactionEntity[], id: string): {
22
- data: any[];
23
- diff: {
24
- deleted: any[];
25
- updated: any[];
26
- };
27
- newTransaction?: undefined;
28
- } | {
29
22
  data: TransactionEntity[];
30
- newTransaction: TransactionEntityWithError | TransactionEntity;
31
- diff: any;
23
+ newTransaction: TransactionEntity | TransactionEntityWithError | null;
24
+ diff: ReturnType<typeof diffItems<TransactionEntity>>;
32
25
  };
33
26
  export declare function updateTransaction(transactions: TransactionEntity[], transaction: TransactionEntity): {
34
- data: any[];
35
- diff: {
36
- deleted: any[];
37
- updated: any[];
38
- };
39
- newTransaction?: undefined;
40
- } | {
41
27
  data: TransactionEntity[];
42
- newTransaction: TransactionEntityWithError | TransactionEntity;
43
- diff: any;
28
+ newTransaction: TransactionEntity | TransactionEntityWithError | null;
29
+ diff: ReturnType<typeof diffItems<TransactionEntity>>;
44
30
  };
45
31
  export declare function deleteTransaction(transactions: TransactionEntity[], id: string): {
46
- data: any[];
47
- diff: {
48
- deleted: any[];
49
- updated: any[];
50
- };
51
- newTransaction?: undefined;
52
- } | {
53
32
  data: TransactionEntity[];
54
- newTransaction: TransactionEntityWithError | TransactionEntity;
55
- diff: any;
33
+ newTransaction: TransactionEntity | TransactionEntityWithError | null;
34
+ diff: ReturnType<typeof diffItems<TransactionEntity>>;
56
35
  };
57
36
  export declare function splitTransaction(transactions: TransactionEntity[], id: string, createSubtransactions?: (parentTransaction: TransactionEntity) => TransactionEntity[]): {
58
- data: any[];
59
- diff: {
60
- deleted: any[];
61
- updated: any[];
62
- };
63
- newTransaction?: undefined;
64
- } | {
65
37
  data: TransactionEntity[];
66
- newTransaction: TransactionEntityWithError | TransactionEntity;
67
- diff: any;
38
+ newTransaction: TransactionEntity | TransactionEntityWithError | null;
39
+ diff: ReturnType<typeof diffItems<TransactionEntity>>;
68
40
  };
69
- export declare function realizeTempTransactions(transactions: TransactionEntity[]): {
70
- id: string;
71
- account: import("../types/models").AccountEntity;
72
- category?: import("../types/models").CategoryEntity;
73
- payee?: import("../types/models").PayeeEntity;
74
- schedule?: import("../types/models").ScheduleEntity;
75
- subtransactions?: TransactionEntity[];
76
- imported_payee?: string;
77
- date: string;
78
- notes?: string;
79
- amount: number;
80
- cleared?: boolean;
81
- reconciled?: boolean;
82
- is_parent?: boolean;
83
- is_child?: boolean;
84
- parent_id?: string;
85
- imported_id?: string;
86
- starting_balance_flag?: boolean;
87
- transfer_id?: string;
88
- sort_order?: number;
89
- tombstone?: boolean;
90
- }[];
41
+ export declare function realizeTempTransactions(transactions: TransactionEntity[]): TransactionEntity[];
91
42
  export declare function makeAsNonChildTransactions(childTransactionsToUpdate: TransactionEntity[], transactions: TransactionEntity[]): {
92
43
  updated: TransactionEntity[];
93
44
  deleted: {
94
45
  amount: number;
95
46
  id: string;
96
- account: import("../types/models").AccountEntity;
97
- category?: import("../types/models").CategoryEntity;
98
- payee?: import("../types/models").PayeeEntity;
99
- schedule?: import("../types/models").ScheduleEntity;
100
- subtransactions?: TransactionEntity[];
101
- imported_payee?: string;
102
- date: string;
103
- notes?: string;
104
- cleared?: boolean;
105
- reconciled?: boolean;
106
47
  is_parent?: boolean;
107
48
  is_child?: boolean;
108
- parent_id?: string;
49
+ parent_id?: TransactionEntity["id"];
50
+ account: import("../types/models").AccountEntity["id"];
51
+ category?: import("../types/models").CategoryEntity["id"];
52
+ payee?: import("../types/models").PayeeEntity["id"];
53
+ notes?: string;
54
+ date: string;
109
55
  imported_id?: string;
56
+ imported_payee?: string;
110
57
  starting_balance_flag?: boolean;
111
- transfer_id?: string;
58
+ transfer_id?: TransactionEntity["id"];
112
59
  sort_order?: number;
60
+ cleared?: boolean;
61
+ reconciled?: boolean;
113
62
  tombstone?: boolean;
63
+ schedule?: import("../types/models").ScheduleEntity["id"];
64
+ subtransactions?: TransactionEntity[];
114
65
  }[];
115
66
  };
116
67
  export {};
@@ -3,24 +3,21 @@ export declare function getChangedValues<T extends {
3
3
  id?: string;
4
4
  }>(obj1: T, obj2: T): Partial<T>;
5
5
  export declare function hasFieldsChanged<T extends object>(obj1: T, obj2: T, fields: Array<keyof T>): boolean;
6
+ export type Diff<T extends {
7
+ id: string;
8
+ }> = {
9
+ added: T[];
10
+ updated: Partial<T>[];
11
+ deleted: Partial<T>[];
12
+ };
6
13
  export declare function applyChanges<T extends {
7
14
  id: string;
8
- }>(changes: {
9
- added?: T[];
10
- updated?: T[];
11
- deleted?: T[];
12
- }, items: T[]): T[];
15
+ }>(changes: Diff<T>, items: T[]): T[];
13
16
  export declare function partitionByField<T, K extends keyof T>(data: T[], field: K): Map<any, any>;
14
17
  export declare function groupBy<T, K extends keyof T>(data: T[], field: K): Map<T[K], T[]>;
15
18
  export declare function diffItems<T extends {
16
19
  id: string;
17
- }>(items: T[], newItems: T[]): {
18
- added: T[];
19
- updated: Partial<T>[];
20
- deleted: {
21
- id: string;
22
- }[];
23
- };
20
+ }>(items: T[], newItems: T[]): Diff<T>;
24
21
  export declare function groupById<T extends {
25
22
  id: string;
26
23
  }>(data: T[]): {
@@ -63,13 +63,24 @@ export interface ApiHandlers {
63
63
  flag: boolean;
64
64
  }) => Promise<void>;
65
65
 
66
+ 'api/budget-hold-for-next-month': (arg: {
67
+ month: string;
68
+ amount: number;
69
+ }) => Promise<boolean>;
70
+
71
+ 'api/budget-reset-hold': (arg: { month: string }) => Promise<void>;
72
+
66
73
  'api/transactions-export': (arg: {
67
74
  transactions;
68
75
  categoryGroups;
69
76
  payees;
70
77
  }) => Promise<unknown>;
71
78
 
72
- 'api/transactions-import': (arg: { accountId; transactions }) => Promise<{
79
+ 'api/transactions-import': (arg: {
80
+ accountId;
81
+ transactions;
82
+ isPreview?;
83
+ }) => Promise<{
73
84
  errors?: { message: string }[];
74
85
  added;
75
86
  updated;
@@ -95,7 +106,7 @@ export interface ApiHandlers {
95
106
 
96
107
  'api/transaction-delete': (arg: {
97
108
  id;
98
- }) => Promise<Awaited<ReturnType<typeof batchUpdateTransactions>>['updated']>;
109
+ }) => Promise<Awaited<ReturnType<typeof batchUpdateTransactions>>['deleted']>;
99
110
 
100
111
  'api/sync': () => Promise<void>;
101
112
 
@@ -169,5 +180,5 @@ export interface ApiHandlers {
169
180
 
170
181
  'api/rule-update': (arg: { rule: RuleEntity }) => Promise<RuleEntity>;
171
182
 
172
- 'api/rule-delete': (arg: { id: string }) => Promise<boolean>;
183
+ 'api/rule-delete': (id: string) => Promise<boolean>;
173
184
  }
@@ -1,4 +1,5 @@
1
1
  import type { BudgetHandlers } from '../server/budget/types/handlers';
2
+ import type { DashboardHandlers } from '../server/dashboard/types/handlers';
2
3
  import type { FiltersHandlers } from '../server/filters/types/handlers';
3
4
  import type { NotesHandlers } from '../server/notes/types/handlers';
4
5
  import type { ReportsHandlers } from '../server/reports/types/handlers';
@@ -13,6 +14,7 @@ export interface Handlers
13
14
  extends ServerHandlers,
14
15
  ApiHandlers,
15
16
  BudgetHandlers,
17
+ DashboardHandlers,
16
18
  FiltersHandlers,
17
19
  NotesHandlers,
18
20
  ReportsHandlers,
@@ -1,11 +1,15 @@
1
1
  import { CategoryEntity } from './category';
2
2
 
3
- export interface CategoryGroupEntity {
4
- id?: string;
3
+ export interface NewCategoryGroupEntity {
5
4
  name: string;
6
5
  is_income?: boolean;
7
6
  sort_order?: number;
8
7
  tombstone?: boolean;
9
8
  hidden?: boolean;
9
+ categories?: Omit<CategoryEntity, 'id'>[];
10
+ }
11
+
12
+ export interface CategoryGroupEntity extends NewCategoryGroupEntity {
13
+ id: string;
10
14
  categories?: CategoryEntity[];
11
15
  }
@@ -1,8 +1,10 @@
1
+ import { CategoryGroupEntity } from './category-group';
2
+
1
3
  export interface CategoryEntity {
2
- id?: string;
4
+ id: string;
3
5
  name: string;
4
6
  is_income?: boolean;
5
- cat_group?: string;
7
+ cat_group?: CategoryGroupEntity['id'];
6
8
  sort_order?: number;
7
9
  tombstone?: boolean;
8
10
  hidden?: boolean;
@@ -0,0 +1,56 @@
1
+ import { type CustomReportEntity } from './reports';
2
+
3
+ type AbstractWidget<
4
+ T extends string,
5
+ Meta extends Record<string, unknown> = null,
6
+ > = {
7
+ id: string;
8
+ type: T;
9
+ x: number;
10
+ y: number;
11
+ width: number;
12
+ height: number;
13
+ meta: Meta;
14
+ tombstone: boolean;
15
+ };
16
+
17
+ export type NetWorthWidget = AbstractWidget<
18
+ 'net-worth-card',
19
+ { name?: string } | null
20
+ >;
21
+ export type CashFlowWidget = AbstractWidget<
22
+ 'cash-flow-card',
23
+ { name?: string } | null
24
+ >;
25
+ export type SpendingWidget = AbstractWidget<
26
+ 'spending-card',
27
+ { name?: string } | null
28
+ >;
29
+ export type CustomReportWidget = AbstractWidget<
30
+ 'custom-report',
31
+ { id: string }
32
+ >;
33
+
34
+ type SpecializedWidget = NetWorthWidget | CashFlowWidget | SpendingWidget;
35
+ export type Widget = SpecializedWidget | CustomReportWidget;
36
+ export type NewWidget = Omit<Widget, 'id' | 'tombstone'>;
37
+
38
+ // Exported/imported (json) widget definition
39
+ export type ExportImportCustomReportWidget = Omit<
40
+ CustomReportWidget,
41
+ 'id' | 'meta' | 'tombstone'
42
+ > & {
43
+ meta: Omit<CustomReportEntity, 'tombstone'>;
44
+ };
45
+ export type ExportImportDashboardWidget = Omit<
46
+ ExportImportCustomReportWidget | SpecializedWidget,
47
+ 'tombstone'
48
+ >;
49
+
50
+ export type ExportImportDashboard = {
51
+ // Dashboard exports can be versioned; currently we support
52
+ // only a single version, but lets account for multiple
53
+ // future versions
54
+ version: 1;
55
+ widgets: ExportImportDashboardWidget[];
56
+ };
@@ -1,6 +1,7 @@
1
1
  export type * from './account';
2
2
  export type * from './category';
3
3
  export type * from './category-group';
4
+ export type * from './dashboard';
4
5
  export type * from './gocardless';
5
6
  export type * from './simplefin';
6
7
  export type * from './note';
@@ -1,11 +1,9 @@
1
- export interface NewPayeeEntity {
2
- id?: string;
1
+ import { AccountEntity } from './account';
2
+
3
+ export interface PayeeEntity {
4
+ id: string;
3
5
  name: string;
4
- transfer_acct?: string;
6
+ transfer_acct?: AccountEntity['id'];
5
7
  favorite?: boolean;
6
8
  tombstone?: boolean;
7
9
  }
8
-
9
- export interface PayeeEntity extends NewPayeeEntity {
10
- id: string;
11
- }
@@ -1,4 +1,3 @@
1
- import { CategoryEntity } from './category';
2
1
  import { type RuleConditionEntity } from './rule';
3
2
 
4
3
  export interface CustomReportEntity {
@@ -17,10 +16,9 @@ export interface CustomReportEntity {
17
16
  showHiddenCategories: boolean;
18
17
  includeCurrentInterval: boolean;
19
18
  showUncategorized: boolean;
20
- selectedCategories?: CategoryEntity[];
21
19
  graphType: string;
22
20
  conditions?: RuleConditionEntity[];
23
- conditionsOp: string;
21
+ conditionsOp: 'and' | 'or';
24
22
  data?: GroupedEntity;
25
23
  tombstone?: boolean;
26
24
  }
@@ -140,10 +138,9 @@ export interface CustomReportData {
140
138
  show_hidden: number;
141
139
  include_current: number;
142
140
  show_uncategorized: number;
143
- selected_categories?: CategoryEntity[];
144
141
  graph_type: string;
145
142
  conditions?: RuleConditionEntity[];
146
- conditions_op: string;
143
+ conditions_op: 'and' | 'or';
147
144
  metadata?: GroupedEntity;
148
145
  interval: string;
149
146
  color_scheme?: string;