@sneat/extension-budgetus-contract 0.0.1 → 0.1.1
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.
package/README.md
ADDED
|
@@ -1,99 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
const BUDGETUS_SERVICE = new InjectionToken('BudgetusService');
|
|
4
|
+
|
|
5
|
+
class ListItemInfoModel {
|
|
6
|
+
static trackBy = (index, item) => !item
|
|
7
|
+
? index
|
|
8
|
+
: (!!item.id && `id:${item.id}`) ||
|
|
9
|
+
(item.subListId && `subList:${item.subListId}`) ||
|
|
10
|
+
item.title;
|
|
11
|
+
}
|
|
12
|
+
class ListItemModel {
|
|
13
|
+
static equalListItems(...items) {
|
|
14
|
+
const { id, title, subListId, category, subListType } = items[0];
|
|
15
|
+
return !items.some((item) => {
|
|
16
|
+
if (id) {
|
|
17
|
+
return item.id !== id;
|
|
18
|
+
}
|
|
19
|
+
return ((!!title && item.title !== title) ||
|
|
20
|
+
(!!subListId && item.subListId !== subListId) ||
|
|
21
|
+
(!!category && item.category !== category) ||
|
|
22
|
+
(!!subListType && item.subListType !== subListType));
|
|
23
|
+
});
|
|
24
|
+
}
|
|
8
25
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
26
|
+
|
|
27
|
+
var ListPage;
|
|
28
|
+
(function (ListPage) {
|
|
29
|
+
ListPage["list"] = "list";
|
|
30
|
+
})(ListPage || (ListPage = {}));
|
|
31
|
+
|
|
32
|
+
function getListShortUrlId(communeId, shortId, id) {
|
|
33
|
+
if (shortId) {
|
|
34
|
+
return `${communeId}-${shortId}`;
|
|
35
|
+
}
|
|
36
|
+
if (id) {
|
|
37
|
+
return id;
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
16
40
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
41
|
+
function isListInfoMatchesListDto(i, l) {
|
|
42
|
+
return ((!!i.id && i.id === l.id) ||
|
|
43
|
+
(i.type === l.dbo?.type && !!i.shortId && i.shortId === l.dbo?.shortId));
|
|
44
|
+
}
|
|
45
|
+
function createListInfoFromDto(dto, shortId) {
|
|
46
|
+
if (!dto.title) {
|
|
47
|
+
throw new Error('!title');
|
|
48
|
+
}
|
|
49
|
+
const listInfo = {
|
|
50
|
+
type: dto.type,
|
|
51
|
+
title: dto.title,
|
|
21
52
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
? p.amount.value > 0
|
|
31
|
-
: liabilitiesMode === 'incomes'
|
|
32
|
-
? p.amount.value < 0
|
|
33
|
-
: true) &&
|
|
34
|
-
(p.expenseQuantity || p.term)) || [];
|
|
35
|
-
if (prices.length) {
|
|
36
|
-
for (let priceIdx = 0; priceIdx < (prices.length || 0); priceIdx++) {
|
|
37
|
-
const price = prices[priceIdx];
|
|
38
|
-
hLiability = { ...hLiability, priceAmount: price.amount };
|
|
39
|
-
hLiability = processPrice(hLiability, slot, price, liabilities);
|
|
40
|
-
}
|
|
41
|
-
if (hLiabilityIndex >= 0) {
|
|
42
|
-
liabilities = {
|
|
43
|
-
...liabilities,
|
|
44
|
-
happenings: liabilities.happenings.map((h) => h.happening.id == hLiability.happening.id ? hLiability : h),
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
liabilities = {
|
|
49
|
-
...liabilities,
|
|
50
|
-
happenings: [...liabilities.happenings, hLiability],
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
+
if (shortId) {
|
|
54
|
+
listInfo.shortId = shortId;
|
|
55
|
+
}
|
|
56
|
+
if (dto.items && dto.items.length) {
|
|
57
|
+
listInfo.itemsCount = dto.items.length;
|
|
58
|
+
}
|
|
59
|
+
if (dto.emoji) {
|
|
60
|
+
listInfo.emoji = dto.emoji;
|
|
53
61
|
}
|
|
54
|
-
|
|
62
|
+
if (dto.restrictions) {
|
|
63
|
+
listInfo.restrictions = dto.restrictions;
|
|
64
|
+
}
|
|
65
|
+
if (dto.commune) {
|
|
66
|
+
listInfo.space = dto.commune;
|
|
67
|
+
}
|
|
68
|
+
return listInfo;
|
|
69
|
+
}
|
|
70
|
+
function monthISOOf(dateISO) {
|
|
71
|
+
return dateISO.slice(0, 7);
|
|
55
72
|
}
|
|
56
|
-
function
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
for (let wdIdx = 0; wdIdx < (slot?.weekdays?.length || 0); wdIdx++) {
|
|
60
|
-
let amountValue = happeningLiability.valuesByCurrency[price.amount.currency] || 0;
|
|
61
|
-
amountValue += price.amount.value;
|
|
62
|
-
happeningLiability = {
|
|
63
|
-
...happeningLiability,
|
|
64
|
-
valuesByCurrency: {
|
|
65
|
-
...happeningLiability?.valuesByCurrency,
|
|
66
|
-
[price.amount.currency]: amountValue,
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
const happeningContacts = happeningLiability.happening.brief?.related?.['contactus']?.['contacts'] || {};
|
|
70
|
-
Object.keys(happeningContacts).forEach((itemID) => {
|
|
71
|
-
let contactLiability = liabilities.contacts.find((c) => c.contact.id == itemID);
|
|
72
|
-
if (!contactLiability) {
|
|
73
|
-
contactLiability = {
|
|
74
|
-
contact: {
|
|
75
|
-
id: itemID,
|
|
76
|
-
space: happeningLiability.happening.space,
|
|
77
|
-
},
|
|
78
|
-
valuesByCurrency: {},
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
contactLiability.valuesByCurrency[price.amount.currency] =
|
|
82
|
-
(contactLiability.valuesByCurrency[price.amount.currency] || 0) +
|
|
83
|
-
price.amount.value;
|
|
84
|
-
liabilities = {
|
|
85
|
-
...liabilities,
|
|
86
|
-
contacts: [...liabilities.contacts, contactLiability],
|
|
87
|
-
};
|
|
88
|
-
});
|
|
89
|
-
}
|
|
73
|
+
function maskSurpriseLineItems(items, options) {
|
|
74
|
+
if (options?.reveal) {
|
|
75
|
+
return items;
|
|
90
76
|
}
|
|
91
|
-
return
|
|
77
|
+
return items.map((item) => item.isSurprise
|
|
78
|
+
? { ...item, title: '🎁 Hidden surprise', sourceRef: undefined }
|
|
79
|
+
: item);
|
|
92
80
|
}
|
|
93
81
|
|
|
94
82
|
/**
|
|
95
83
|
* Generated bundle index. Do not edit.
|
|
96
84
|
*/
|
|
97
85
|
|
|
98
|
-
export {
|
|
86
|
+
export { BUDGETUS_SERVICE, ListItemInfoModel, ListItemModel, ListPage, createListInfoFromDto, getListShortUrlId, isListInfoMatchesListDto, maskSurpriseLineItems, monthISOOf };
|
|
99
87
|
//# sourceMappingURL=sneat-extension-budgetus-contract.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sneat-extension-budgetus-contract.mjs","sources":["
|
|
1
|
+
{"version":3,"file":"sneat-extension-budgetus-contract.mjs","sources":["../../../../libs/budgetus/src/services.ts","../../../../libs/budgetus/src/models.ts","../../../../libs/budgetus/src/enums.ts","../../../../libs/budgetus/src/utils.ts","../../../../libs/budgetus/src/sneat-extension-budgetus-contract.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport {\n IListDbo,\n IListBrief,\n IListKey,\n IBudgetRollup,\n IBudgetOverridePatch,\n ListType,\n IListItemBrief,\n IListContext,\n ICreateListRequest,\n IListRequest,\n ICreateListItemsRequest,\n IListItemIDsRequest,\n IReorderListItemsRequest,\n IDeleteListItemsRequest,\n ISetListItemsIsComplete,\n IListItemsCommandParams,\n IListItemResult,\n} from './dto';\n\nexport interface GetOrCreateCommuneItemIds {\n id?: string;\n shortId?: string;\n communeShortId?: string;\n}\n\nexport interface IProgress {\n current: number;\n total: number;\n state?: string;\n}\n\nexport type ReorderListItemsWorker = (listDto: IListDbo) => void;\n\nexport interface IBudgetusService {\n createList(request: ICreateListRequest): Observable<IListContext>;\n deleteList(space: any, listId: string): Observable<void>;\n reorderListItems(request: IReorderListItemsRequest): Observable<void>;\n createListItems(params: IListItemsCommandParams): Observable<IListItemResult>;\n setListItemsIsCompleted(request: ISetListItemsIsComplete): Observable<void>;\n deleteListItems(request: IDeleteListItemsRequest): Observable<void>;\n getListById(space: any, listType: ListType, listID: string): Observable<IListContext>;\n watchBudget(spaceID: string): Observable<IBudgetRollup>;\n setOverride(spaceID: string, lineItemId: string, patch: IBudgetOverridePatch): Promise<void>;\n}\n\nexport const BUDGETUS_SERVICE = new InjectionToken<IBudgetusService>('BudgetusService');\n","import { IListItemBrief } from './dto/list-item';\n\nexport class ListItemInfoModel {\n static trackBy = (index: number, item: IListItemBrief | null | undefined): string | number | undefined =>\n !item\n ? index\n : (!!item.id && `id:${item.id}`) ||\n (item.subListId && `subList:${item.subListId}`) ||\n item.title;\n}\n\nexport class ListItemModel {\n static equalListItems(...items: IListItemBrief[]): boolean {\n const { id, title, subListId, category, subListType } = items[0];\n return !items.some((item) => {\n if (id) {\n return item.id !== id;\n }\n return (\n (!!title && item.title !== title) ||\n (!!subListId && item.subListId !== subListId) ||\n (!!category && item.category !== category) ||\n (!!subListType && item.subListType !== subListType)\n );\n });\n }\n}\n","import { EnumAsUnionOfKeys } from '@sneat/core';\n\nexport const enum ListPage {\n list = 'list',\n}\nexport type ListPages = EnumAsUnionOfKeys<typeof ListPage>;\n","import { IRecord } from '@sneat/data';\nimport { IListDbo, IListInfo } from './dto/list';\n\nexport function getListShortUrlId(communeId: string, shortId?: string, id?: string): string | undefined {\n if (shortId) {\n return `${communeId}-${shortId}`;\n }\n if (id) {\n return id;\n }\n return undefined;\n}\n\nexport function isListInfoMatchesListDto(i: IListInfo, l: IRecord<IListDbo>): boolean {\n return (\n (!!i.id && i.id === l.id) ||\n (i.type === l.dbo?.type && !!i.shortId && i.shortId === l.dbo?.shortId)\n );\n}\n\nexport function createListInfoFromDto(dto: IListDbo, shortId?: string): IListInfo {\n if (!dto.title) {\n throw new Error('!title');\n }\n const listInfo: IListInfo = {\n type: dto.type,\n title: dto.title,\n };\n if (shortId) {\n listInfo.shortId = shortId;\n }\n if (dto.items && dto.items.length) {\n listInfo.itemsCount = dto.items.length;\n }\n if (dto.emoji) {\n listInfo.emoji = dto.emoji;\n }\n if (dto.restrictions) {\n listInfo.restrictions = dto.restrictions;\n }\n if (dto.commune) {\n listInfo.space = dto.commune;\n }\n return listInfo;\n}\n\nexport function monthISOOf(dateISO: string): string {\n return dateISO.slice(0, 7);\n}\n\nexport function maskSurpriseLineItems(\n items: any[],\n options?: {\n reveal?: boolean;\n }\n): any[] {\n if (options?.reveal) {\n return items;\n }\n return items.map((item) =>\n item.isSurprise\n ? { ...item, title: '🎁 Hidden surprise', sourceRef: undefined }\n : item\n );\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;MAgDa,gBAAgB,GAAG,IAAI,cAAc,CAAmB,iBAAiB;;MC9CzE,iBAAiB,CAAA;IAC5B,OAAO,OAAO,GAAG,CAAC,KAAa,EAAE,IAAuC,KACtE,CAAC;AACC,UAAE;AACF,UAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAA,GAAA,EAAM,IAAI,CAAC,EAAE,EAAE;aAC5B,IAAI,CAAC,SAAS,IAAI,WAAW,IAAI,CAAC,SAAS,CAAA,CAAE,CAAC;YAC/C,IAAI,CAAC,KAAK;;MAGL,aAAa,CAAA;AACxB,IAAA,OAAO,cAAc,CAAC,GAAG,KAAuB,EAAA;AAC9C,QAAA,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;QAChE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,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.1.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@
|
|
9
|
-
"
|
|
10
|
-
"@sneat/
|
|
11
|
-
"@sneat/
|
|
8
|
+
"@angular/core": "^21.0.0",
|
|
9
|
+
"rxjs": "^7.0.0",
|
|
10
|
+
"@sneat/core": "^0.22.1",
|
|
11
|
+
"@sneat/data": "^0.22.1",
|
|
12
|
+
"@sneat/dto": "^0.22.1",
|
|
13
|
+
"@sneat/space-models": "^0.22.1",
|
|
12
14
|
"vitest": "^4.0.9"
|
|
13
15
|
},
|
|
14
16
|
"sideEffects": false,
|
|
@@ -1,29 +1,214 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { SneatRecordStatus, IWithSpaceIDs, IWithCreated, IWithRestrictions, IShortSpaceInfo } from '@sneat/dto';
|
|
2
|
+
import { ISpaceItemNavContext, ISpaceContext } from '@sneat/space-models';
|
|
3
|
+
import { InjectionToken } from '@angular/core';
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
5
|
+
import { EnumAsUnionOfKeys } from '@sneat/core';
|
|
6
|
+
import { IRecord } from '@sneat/data';
|
|
4
7
|
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
type ListType = 'buy' | 'watch' | 'cook' | 'do' | 'other' | 'recipes' | 'rsvp';
|
|
9
|
+
|
|
10
|
+
type ListStatus = SneatRecordStatus;
|
|
11
|
+
interface IQuantity {
|
|
12
|
+
value: number;
|
|
13
|
+
unit: string;
|
|
14
|
+
}
|
|
15
|
+
interface IListItemCommon {
|
|
16
|
+
subListId?: string;
|
|
17
|
+
subListType?: ListType;
|
|
18
|
+
quantity?: IQuantity;
|
|
19
|
+
category?: string;
|
|
20
|
+
title: string;
|
|
21
|
+
img?: string;
|
|
22
|
+
emoji?: string;
|
|
23
|
+
isDone?: boolean;
|
|
24
|
+
}
|
|
25
|
+
type IListItemBase = IListItemCommon;
|
|
26
|
+
type ListItemStatus = 'done' | 'active';
|
|
27
|
+
interface IListItemBrief extends IListItemBase {
|
|
28
|
+
id: string;
|
|
29
|
+
readonly created?: string;
|
|
30
|
+
readonly emoji?: string;
|
|
31
|
+
readonly status?: ListItemStatus;
|
|
32
|
+
readonly img?: string;
|
|
33
|
+
}
|
|
34
|
+
interface ListCounts {
|
|
35
|
+
active?: number;
|
|
36
|
+
completed?: number;
|
|
37
|
+
}
|
|
38
|
+
interface IListItemDbo extends IWithSpaceIDs, IListItemCommon {
|
|
39
|
+
listId?: string;
|
|
40
|
+
score?: number;
|
|
41
|
+
subListItems?: IListItemBrief[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface IListCommon {
|
|
45
|
+
title: string;
|
|
46
|
+
img?: string;
|
|
47
|
+
emoji?: string;
|
|
48
|
+
isDone?: boolean;
|
|
49
|
+
}
|
|
50
|
+
interface IListBase extends IListCommon, IWithSpaceIDs {
|
|
51
|
+
type: ListType;
|
|
52
|
+
shortId?: string;
|
|
53
|
+
status?: ListStatus;
|
|
54
|
+
}
|
|
55
|
+
interface IListDbo extends IListBase, IWithRestrictions, IWithCreated {
|
|
56
|
+
dtClosed?: number;
|
|
57
|
+
note?: string;
|
|
58
|
+
numberOf?: ListCounts;
|
|
59
|
+
items?: IListItemBrief[];
|
|
60
|
+
commune?: IShortSpaceInfo;
|
|
61
|
+
}
|
|
62
|
+
interface IListInfo extends IWithRestrictions {
|
|
63
|
+
parentListId?: string;
|
|
64
|
+
parentListType?: ListType;
|
|
65
|
+
type: ListType;
|
|
66
|
+
id?: string;
|
|
67
|
+
shortId?: string;
|
|
68
|
+
title?: string;
|
|
69
|
+
hidden?: boolean;
|
|
70
|
+
space?: IShortSpaceInfo;
|
|
71
|
+
emoji?: string;
|
|
72
|
+
img?: string;
|
|
73
|
+
note?: string;
|
|
74
|
+
itemsCount?: number;
|
|
75
|
+
}
|
|
76
|
+
interface IListBrief extends IListBase, IWithCreated {
|
|
77
|
+
emoji?: string;
|
|
78
|
+
}
|
|
79
|
+
interface IListKey {
|
|
80
|
+
id: string;
|
|
81
|
+
type: ListType;
|
|
82
|
+
}
|
|
83
|
+
interface IListGroup {
|
|
84
|
+
id: string;
|
|
85
|
+
title?: string;
|
|
86
|
+
type?: ListType;
|
|
87
|
+
emoji?: string;
|
|
88
|
+
lists?: IListInfo[];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface IBudgetusSpaceDbo {
|
|
92
|
+
listGroups?: any[];
|
|
93
|
+
}
|
|
94
|
+
interface IMoney {
|
|
95
|
+
currency: string;
|
|
96
|
+
value: number;
|
|
97
|
+
}
|
|
98
|
+
type BudgetLineSource = 'asset-renewal' | 'happening' | 'gift';
|
|
99
|
+
interface IBudgetLineItem {
|
|
100
|
+
id: string;
|
|
101
|
+
title: string;
|
|
102
|
+
dateISO: string;
|
|
103
|
+
amount: IMoney;
|
|
104
|
+
source: BudgetLineSource;
|
|
105
|
+
sourceRef?: string;
|
|
106
|
+
targetAmount?: IMoney;
|
|
107
|
+
isSurprise?: boolean;
|
|
108
|
+
}
|
|
109
|
+
interface IBudgetMonthGroup {
|
|
110
|
+
monthISO: string;
|
|
111
|
+
total: IMoney;
|
|
112
|
+
items: IBudgetLineItem[];
|
|
113
|
+
}
|
|
114
|
+
interface IBudgetRollup {
|
|
115
|
+
byMonth: IBudgetMonthGroup[];
|
|
116
|
+
annualTotal: IMoney;
|
|
117
|
+
mostExpensiveMonthISO: string;
|
|
11
118
|
}
|
|
12
|
-
interface
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
readonly happening: IHappeningContext;
|
|
119
|
+
interface IBudgetOverridePatch {
|
|
120
|
+
targetAmount?: IMoney;
|
|
121
|
+
isSurprise?: boolean;
|
|
16
122
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
123
|
+
|
|
124
|
+
interface IListContext extends ISpaceItemNavContext<IListBrief, any> {
|
|
125
|
+
type: ListType;
|
|
126
|
+
}
|
|
127
|
+
interface ICreateListRequest {
|
|
128
|
+
id?: string;
|
|
129
|
+
title: string;
|
|
130
|
+
type: ListType;
|
|
131
|
+
emoji?: string;
|
|
132
|
+
}
|
|
133
|
+
interface IListRequest {
|
|
134
|
+
readonly listID: string;
|
|
135
|
+
}
|
|
136
|
+
interface ICreateListItemRequest extends IListItemBrief {
|
|
137
|
+
id: string;
|
|
138
|
+
}
|
|
139
|
+
interface ICreateListItemsRequest extends IListRequest {
|
|
140
|
+
items: ICreateListItemRequest[];
|
|
141
|
+
}
|
|
142
|
+
interface IListItemRequest extends IListRequest {
|
|
143
|
+
itemID: string;
|
|
144
|
+
}
|
|
145
|
+
interface IListItemIDsRequest extends IListRequest {
|
|
146
|
+
readonly itemIDs: string[];
|
|
147
|
+
}
|
|
148
|
+
interface IReorderListItemsRequest extends IListItemIDsRequest {
|
|
149
|
+
toIndex: number;
|
|
150
|
+
}
|
|
151
|
+
type IDeleteListItemsRequest = IListItemIDsRequest;
|
|
152
|
+
interface ISetListItemsIsComplete extends IListItemIDsRequest {
|
|
153
|
+
isDone: boolean;
|
|
154
|
+
}
|
|
155
|
+
interface IListItemsCommandParams {
|
|
156
|
+
space: ISpaceContext;
|
|
157
|
+
list: IListContext;
|
|
158
|
+
items: IListItemBrief[];
|
|
20
159
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
160
|
+
interface IListItemResult {
|
|
161
|
+
message?: string;
|
|
162
|
+
changed?: boolean;
|
|
163
|
+
success: boolean;
|
|
164
|
+
listDto: any;
|
|
165
|
+
communeDto?: any;
|
|
166
|
+
listItemDto?: IListItemDbo;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
interface GetOrCreateCommuneItemIds {
|
|
170
|
+
id?: string;
|
|
171
|
+
shortId?: string;
|
|
172
|
+
communeShortId?: string;
|
|
173
|
+
}
|
|
174
|
+
interface IProgress {
|
|
175
|
+
current: number;
|
|
176
|
+
total: number;
|
|
177
|
+
state?: string;
|
|
178
|
+
}
|
|
179
|
+
type ReorderListItemsWorker = (listDto: IListDbo) => void;
|
|
180
|
+
interface IBudgetusService {
|
|
181
|
+
createList(request: ICreateListRequest): Observable<IListContext>;
|
|
182
|
+
deleteList(space: any, listId: string): Observable<void>;
|
|
183
|
+
reorderListItems(request: IReorderListItemsRequest): Observable<void>;
|
|
184
|
+
createListItems(params: IListItemsCommandParams): Observable<IListItemResult>;
|
|
185
|
+
setListItemsIsCompleted(request: ISetListItemsIsComplete): Observable<void>;
|
|
186
|
+
deleteListItems(request: IDeleteListItemsRequest): Observable<void>;
|
|
187
|
+
getListById(space: any, listType: ListType, listID: string): Observable<IListContext>;
|
|
188
|
+
watchBudget(spaceID: string): Observable<IBudgetRollup>;
|
|
189
|
+
setOverride(spaceID: string, lineItemId: string, patch: IBudgetOverridePatch): Promise<void>;
|
|
190
|
+
}
|
|
191
|
+
declare const BUDGETUS_SERVICE: InjectionToken<IBudgetusService>;
|
|
192
|
+
|
|
193
|
+
declare class ListItemInfoModel {
|
|
194
|
+
static trackBy: (index: number, item: IListItemBrief | null | undefined) => string | number | undefined;
|
|
195
|
+
}
|
|
196
|
+
declare class ListItemModel {
|
|
197
|
+
static equalListItems(...items: IListItemBrief[]): boolean;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
declare const enum ListPage {
|
|
201
|
+
list = "list"
|
|
24
202
|
}
|
|
203
|
+
type ListPages = EnumAsUnionOfKeys<typeof ListPage>;
|
|
25
204
|
|
|
26
|
-
declare function
|
|
205
|
+
declare function getListShortUrlId(communeId: string, shortId?: string, id?: string): string | undefined;
|
|
206
|
+
declare function isListInfoMatchesListDto(i: IListInfo, l: IRecord<IListDbo>): boolean;
|
|
207
|
+
declare function createListInfoFromDto(dto: IListDbo, shortId?: string): IListInfo;
|
|
208
|
+
declare function monthISOOf(dateISO: string): string;
|
|
209
|
+
declare function maskSurpriseLineItems(items: any[], options?: {
|
|
210
|
+
reveal?: boolean;
|
|
211
|
+
}): any[];
|
|
27
212
|
|
|
28
|
-
export {
|
|
29
|
-
export type {
|
|
213
|
+
export { BUDGETUS_SERVICE, ListItemInfoModel, ListItemModel, ListPage, createListInfoFromDto, getListShortUrlId, isListInfoMatchesListDto, maskSurpriseLineItems, monthISOOf };
|
|
214
|
+
export type { BudgetLineSource, GetOrCreateCommuneItemIds, IBudgetLineItem, IBudgetMonthGroup, IBudgetOverridePatch, IBudgetRollup, IBudgetusService, IBudgetusSpaceDbo, ICreateListItemRequest, ICreateListItemsRequest, ICreateListRequest, IDeleteListItemsRequest, IListBase, IListBrief, IListCommon, IListContext, IListDbo, IListGroup, IListInfo, IListItemBase, IListItemBrief, IListItemCommon, IListItemDbo, IListItemIDsRequest, IListItemRequest, IListItemResult, IListItemsCommandParams, IListKey, IListRequest, IMoney, IProgress, IQuantity, IReorderListItemsRequest, ISetListItemsIsComplete, ListCounts, ListItemStatus, ListPages, ListStatus, ListType, ReorderListItemsWorker };
|