@sneat/dto 0.1.2 → 0.1.4

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 (89) hide show
  1. package/esm2022/index.js +2 -0
  2. package/esm2022/index.js.map +1 -0
  3. package/esm2022/lib/by-user.js +2 -0
  4. package/esm2022/lib/by-user.js.map +1 -0
  5. package/esm2022/lib/dto-app.js +2 -0
  6. package/esm2022/lib/dto-app.js.map +1 -0
  7. package/esm2022/lib/dto-brief.js +2 -0
  8. package/esm2022/lib/dto-brief.js.map +1 -0
  9. package/esm2022/lib/dto-commune.js +89 -0
  10. package/esm2022/lib/dto-commune.js.map +1 -0
  11. package/{src/lib/dto-constants.ts → esm2022/lib/dto-constants.js} +1 -0
  12. package/esm2022/lib/dto-constants.js.map +1 -0
  13. package/esm2022/lib/dto-models.js +23 -0
  14. package/esm2022/lib/dto-models.js.map +1 -0
  15. package/esm2022/lib/dto-pricing.js +2 -0
  16. package/esm2022/lib/dto-pricing.js.map +1 -0
  17. package/esm2022/lib/dto-team-brief.js +9 -0
  18. package/esm2022/lib/dto-team-brief.js.map +1 -0
  19. package/esm2022/lib/dto-team-info.js +4 -0
  20. package/esm2022/lib/dto-team-info.js.map +1 -0
  21. package/esm2022/lib/dto-team-meeting.js +2 -0
  22. package/esm2022/lib/dto-team-meeting.js.map +1 -0
  23. package/esm2022/lib/dto-team-metric.js +2 -0
  24. package/esm2022/lib/dto-team-metric.js.map +1 -0
  25. package/esm2022/lib/dto-team.js +2 -0
  26. package/esm2022/lib/dto-team.js.map +1 -0
  27. package/esm2022/lib/dto-user.js +33 -0
  28. package/esm2022/lib/dto-user.js.map +1 -0
  29. package/esm2022/lib/dto-with-modified.js +2 -0
  30. package/esm2022/lib/dto-with-modified.js.map +1 -0
  31. package/esm2022/lib/index.js +19 -0
  32. package/esm2022/lib/index.js.map +1 -0
  33. package/esm2022/lib/period.js +2 -0
  34. package/esm2022/lib/period.js.map +1 -0
  35. package/esm2022/lib/types.js +2 -0
  36. package/esm2022/lib/types.js.map +1 -0
  37. package/esm2022/lib/ui-state.js +2 -0
  38. package/esm2022/lib/ui-state.js.map +1 -0
  39. package/esm2022/lib/with-related.js +94 -0
  40. package/esm2022/lib/with-related.js.map +1 -0
  41. package/esm2022/sneat-dto.js +5 -0
  42. package/esm2022/sneat-dto.js.map +1 -0
  43. package/lib/by-user.d.ts +4 -0
  44. package/lib/dto-app.d.ts +6 -0
  45. package/{src/lib/dto-brief.ts → lib/dto-brief.d.ts} +2 -2
  46. package/lib/dto-commune.d.ts +53 -0
  47. package/lib/dto-constants.d.ts +2 -0
  48. package/lib/dto-models.d.ts +59 -0
  49. package/lib/dto-pricing.d.ts +5 -0
  50. package/lib/dto-team-brief.d.ts +9 -0
  51. package/lib/dto-team-info.d.ts +8 -0
  52. package/lib/dto-team-meeting.d.ts +6 -0
  53. package/lib/dto-team-metric.d.ts +20 -0
  54. package/lib/dto-team.d.ts +12 -0
  55. package/lib/dto-user.d.ts +31 -0
  56. package/lib/dto-with-modified.d.ts +26 -0
  57. package/lib/types.d.ts +7 -0
  58. package/lib/ui-state.d.ts +5 -0
  59. package/lib/with-related.d.ts +42 -0
  60. package/package.json +14 -2
  61. package/sneat-dto.d.ts +5 -0
  62. package/eslint.config.js +0 -7
  63. package/ng-package.json +0 -7
  64. package/project.json +0 -38
  65. package/src/lib/by-user.ts +0 -4
  66. package/src/lib/dto-app.ts +0 -9
  67. package/src/lib/dto-commune.ts +0 -158
  68. package/src/lib/dto-constants.spec.ts +0 -7
  69. package/src/lib/dto-models.ts +0 -105
  70. package/src/lib/dto-pricing.ts +0 -5
  71. package/src/lib/dto-team-brief.ts +0 -20
  72. package/src/lib/dto-team-info.ts +0 -15
  73. package/src/lib/dto-team-meeting.ts +0 -6
  74. package/src/lib/dto-team-metric.ts +0 -29
  75. package/src/lib/dto-team.ts +0 -27
  76. package/src/lib/dto-user.ts +0 -85
  77. package/src/lib/dto-with-modified.ts +0 -32
  78. package/src/lib/types.ts +0 -34
  79. package/src/lib/ui-state.ts +0 -5
  80. package/src/lib/with-related.ts +0 -180
  81. package/src/test-setup.ts +0 -1
  82. package/tsconfig.json +0 -13
  83. package/tsconfig.lib.json +0 -19
  84. package/tsconfig.lib.prod.json +0 -7
  85. package/tsconfig.spec.json +0 -31
  86. package/vite.config.mts +0 -10
  87. /package/{src/index.ts → index.d.ts} +0 -0
  88. /package/{src/lib/index.ts → lib/index.d.ts} +0 -0
  89. /package/{src/lib/period.ts → lib/period.d.ts} +0 -0
@@ -0,0 +1,2 @@
1
+ export * from './lib';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/dto/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC","sourcesContent":["export * from './lib';\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=by-user.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"by-user.js","sourceRoot":"","sources":["../../../../../libs/dto/src/lib/by-user.ts"],"names":[],"mappings":"","sourcesContent":["export interface IByUser {\n uid: string;\n title?: string;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=dto-app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto-app.js","sourceRoot":"","sources":["../../../../../libs/dto/src/lib/dto-app.ts"],"names":[],"mappings":"","sourcesContent":["// import { IAuthStateRecord } from '../../auth/interfaces';\nimport { ITitledRecord } from './dto-models';\n\nexport interface DtoApp {\n /*extends IRecord*/ users?: ITitledRecord[];\n currentLanguage?: string;\n // authState?: IAuthStateRecord;\n isInDemoMode?: boolean;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=dto-brief.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto-brief.js","sourceRoot":"","sources":["../../../../../libs/dto/src/lib/dto-brief.ts"],"names":[],"mappings":"","sourcesContent":["export interface IWithIdAndTitle {\n id: string;\n title: string;\n}\n"]}
@@ -0,0 +1,89 @@
1
+ export function incrementNumberOf(dto, init, counter, v = 1) {
2
+ const current = ((dto.numberOf && dto.numberOf[counter]) ||
3
+ 0);
4
+ return {
5
+ ...dto,
6
+ numberOf: {
7
+ ...(dto.numberOf || init()),
8
+ [counter]: current + v,
9
+ },
10
+ };
11
+ }
12
+ export function newSpaceCounts(numberOf) {
13
+ numberOf = numberOf || {};
14
+ return {
15
+ activities: numberOf.activities || 0,
16
+ assets: numberOf.assets || 0,
17
+ assetGroups: numberOf.assetGroups || 0,
18
+ contacts: numberOf.contacts || 0,
19
+ documents: numberOf.documents || 0,
20
+ members: numberOf.members || 0,
21
+ memberGroups: numberOf.memberGroups || 0,
22
+ liabilities: numberOf.liabilities || 0,
23
+ overdues: numberOf.overdues || 0,
24
+ regularTasks: numberOf.regularTasks || 0,
25
+ todos: numberOf.todos || 0,
26
+ upcomings: numberOf.upcomings || 0,
27
+ };
28
+ }
29
+ export function isCommuneShouldHoldMembersInfo(type) {
30
+ return type === 'family' || type === 'cohabit';
31
+ }
32
+ // export function findCommuneMemberInfo(
33
+ // members: readonly ITeamMemberInfo[],
34
+ // member: { readonly id?: string; readonly userID?: string },
35
+ // ): ITeamMemberInfo | undefined {
36
+ // return (
37
+ // members &&
38
+ // members.find(
39
+ // (m) =>
40
+ // (m && !!m.id && m.id === member.id) ||
41
+ // (!!m.userID && m.userID === member.userID),
42
+ // )
43
+ // );
44
+ // }
45
+ export const personalCommuneIdPrefix = 'u_';
46
+ export function getUserPersonalCommuneID(userID) {
47
+ if (!userID) {
48
+ throw new Error('userID is required parameter');
49
+ }
50
+ return personalCommuneIdPrefix + userID;
51
+ }
52
+ export function isPersonalCommuneId(id) {
53
+ return !!id && id.startsWith(personalCommuneIdPrefix);
54
+ }
55
+ export function isUserPersonalCommune(communeID, userID) {
56
+ return !!userID && communeID === getUserPersonalCommuneID(userID);
57
+ }
58
+ // export const CommuneModel = {
59
+ // getListInfoByRealId: (dto: ITeamDto, listId: string) => {
60
+ // const result =
61
+ // dto.listGroups &&
62
+ // dto.listGroups
63
+ // .map((lg) => lg.lists && lg.lists.find((l) => l.id === listId))
64
+ // .find((l) => !!l);
65
+ // console.log(
66
+ // `CommuneModel.getListInfoByRealId(${listId})`,
67
+ // dto.listGroups,
68
+ // ' => ',
69
+ // result,
70
+ // );
71
+ // return result;
72
+ // },
73
+ //
74
+ // getListInfoByShortId: (dto: ICommuneDto, shortListId: string) => {
75
+ // console.log(
76
+ // `CommuneModel.getListInfoByShortId(${shortListId})`,
77
+ // dto.listGroups,
78
+ // );
79
+ // return (
80
+ // dto.listGroups &&
81
+ // dto.listGroups
82
+ // .map(
83
+ // (lg) => lg.lists && lg.lists.find((l) => l.shortId === shortListId),
84
+ // )
85
+ // .find((l) => !!l)
86
+ // );
87
+ // },
88
+ // };
89
+ //# sourceMappingURL=dto-commune.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto-commune.js","sourceRoot":"","sources":["../../../../../libs/dto/src/lib/dto-commune.ts"],"names":[],"mappings":"AA2CA,MAAM,UAAU,iBAAiB,CAG/B,GAAQ,EAAE,IAAoB,EAAE,OAAuB,EAAE,CAAC,GAAG,CAAC;IAC9D,MAAM,OAAO,GAAW,CAAC,CAAC,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC9D,CAAC,CAAsB,CAAC;IAC1B,OAAO;QACL,GAAG,GAAG;QACN,QAAQ,EAAE;YACR,GAAG,CAAC,GAAG,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;YAC3B,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,CAAC;SACvB;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,QAAsB;IACnD,QAAQ,GAAG,QAAQ,IAAI,EAAE,CAAC;IAC1B,OAAO;QACL,UAAU,EAAE,QAAQ,CAAC,UAAU,IAAI,CAAC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;AAED,MAAM,UAAU,qBAAqB,CACnC,SAAiB,EACjB,MAAe;IAEf,OAAO,CAAC,CAAC,MAAM,IAAI,SAAS,KAAK,wBAAwB,CAAC,MAAM,CAAC,CAAC;AACpE,CAAC;AAED,gCAAgC;AAChC,6DAA6D;AAC7D,mBAAmB;AACnB,uBAAuB;AACvB,oBAAoB;AACpB,sEAAsE;AACtE,yBAAyB;AACzB,iBAAiB;AACjB,oDAAoD;AACpD,qBAAqB;AACrB,aAAa;AACb,aAAa;AACb,OAAO;AACP,mBAAmB;AACnB,MAAM;AACN,EAAE;AACF,sEAAsE;AACtE,iBAAiB;AACjB,0DAA0D;AAC1D,qBAAqB;AACrB,OAAO;AACP,aAAa;AACb,uBAAuB;AACvB,oBAAoB;AACpB,YAAY;AACZ,4EAA4E;AAC5E,QAAQ;AACR,wBAAwB;AACxB,OAAO;AACP,MAAM;AACN,KAAK","sourcesContent":["import { IDemoRecord, ITitledRecord, ITotalsHolder } from './dto-models';\nimport { CommuneType, CountryId } from './types';\n\nexport const enum SpaceCounter {\n activities = 'activities',\n assets = 'assets',\n assetGroups = 'assetGroups',\n contacts = 'contacts',\n documents = 'documents',\n liabilities = 'liabilities',\n members = 'members',\n // membersByRole = 'membersByRole',\n memberGroups = 'memberGroups',\n overdues = 'overdues',\n pupils = 'pupils',\n regularTasks = 'regularTasks',\n staff = 'staff',\n todos = 'todos',\n upcomings = 'upcomings',\n}\n\n// type TeamCounters = {\n// \t[P in EnumAsUnionOfKeys<typeof TeamCounter>]: number;\n// };\n\nexport interface SpaceCounts {\n [SpaceCounter.activities]?: number;\n [SpaceCounter.assets]?: number;\n [SpaceCounter.assetGroups]?: number;\n [SpaceCounter.contacts]?: number;\n [SpaceCounter.documents]?: number;\n [SpaceCounter.regularTasks]?: number;\n [SpaceCounter.liabilities]?: number;\n [SpaceCounter.pupils]?: number;\n [SpaceCounter.staff]?: number;\n [SpaceCounter.members]?: number;\n [SpaceCounter.memberGroups]?: number;\n [SpaceCounter.overdues]?: number;\n [SpaceCounter.todos]?: number;\n [SpaceCounter.upcomings]?: number;\n // [CommuneCounter.membersByRole]?: { [role: string]: number }; this does not make sense here\n}\n\nexport function incrementNumberOf<\n NumberOf,\n Dbo extends { numberOf?: NumberOf },\n>(dto: Dbo, init: () => NumberOf, counter: keyof NumberOf, v = 1): Dbo {\n const current: number = ((dto.numberOf && dto.numberOf[counter]) ||\n 0) as unknown as number;\n return {\n ...dto,\n numberOf: {\n ...(dto.numberOf || init()),\n [counter]: current + v,\n },\n };\n}\n\nexport function newSpaceCounts(numberOf?: SpaceCounts): SpaceCounts {\n numberOf = numberOf || {};\n return {\n activities: numberOf.activities || 0,\n assets: numberOf.assets || 0,\n assetGroups: numberOf.assetGroups || 0,\n contacts: numberOf.contacts || 0,\n documents: numberOf.documents || 0,\n members: numberOf.members || 0,\n memberGroups: numberOf.memberGroups || 0,\n liabilities: numberOf.liabilities || 0,\n overdues: numberOf.overdues || 0,\n regularTasks: numberOf.regularTasks || 0,\n todos: numberOf.todos || 0,\n upcomings: numberOf.upcomings || 0,\n };\n}\n\nexport interface ICommuneDbo extends IDemoRecord, ITitledRecord, ITotalsHolder {\n readonly countryId?: CountryId;\n readonly type: CommuneType;\n readonly desc?: string;\n readonly userID: string;\n readonly order?: number;\n readonly numberOf?: SpaceCounts;\n readonly membersCountByRole?: Record<string, number>;\n readonly noContactRoles?: string[];\n // readonly groups?: ICommuneDtoMemberGroupInfo[];\n // readonly members?: readonly ITeamMemberInfo[];\n}\n\nexport function isCommuneShouldHoldMembersInfo(type: CommuneType): boolean {\n return type === 'family' || type === 'cohabit';\n}\n\n// export function findCommuneMemberInfo(\n// \tmembers: readonly ITeamMemberInfo[],\n// \tmember: { readonly id?: string; readonly userID?: string },\n// ): ITeamMemberInfo | undefined {\n// \treturn (\n// \t\tmembers &&\n// \t\tmembers.find(\n// \t\t\t(m) =>\n// \t\t\t\t(m && !!m.id && m.id === member.id) ||\n// \t\t\t\t(!!m.userID && m.userID === member.userID),\n// \t\t)\n// \t);\n// }\n\nexport const personalCommuneIdPrefix = 'u_';\n\nexport function getUserPersonalCommuneID(userID?: string): string {\n if (!userID) {\n throw new Error('userID is required parameter');\n }\n return personalCommuneIdPrefix + userID;\n}\n\nexport function isPersonalCommuneId(id: string): boolean {\n return !!id && id.startsWith(personalCommuneIdPrefix);\n}\n\nexport function isUserPersonalCommune(\n communeID: string,\n userID?: string,\n): boolean {\n return !!userID && communeID === getUserPersonalCommuneID(userID);\n}\n\n// export const CommuneModel = {\n// \tgetListInfoByRealId: (dto: ITeamDto, listId: string) => {\n// \t\tconst result =\n// \t\t\tdto.listGroups &&\n// \t\t\tdto.listGroups\n// \t\t\t\t.map((lg) => lg.lists && lg.lists.find((l) => l.id === listId))\n// \t\t\t\t.find((l) => !!l);\n// \t\tconsole.log(\n// \t\t\t`CommuneModel.getListInfoByRealId(${listId})`,\n// \t\t\tdto.listGroups,\n// \t\t\t' => ',\n// \t\t\tresult,\n// \t\t);\n// \t\treturn result;\n// \t},\n//\n// \tgetListInfoByShortId: (dto: ICommuneDto, shortListId: string) => {\n// \t\tconsole.log(\n// \t\t\t`CommuneModel.getListInfoByShortId(${shortListId})`,\n// \t\t\tdto.listGroups,\n// \t\t);\n// \t\treturn (\n// \t\t\tdto.listGroups &&\n// \t\t\tdto.listGroups\n// \t\t\t\t.map(\n// \t\t\t\t\t(lg) => lg.lists && lg.lists.find((l) => l.shortId === shortListId),\n// \t\t\t\t)\n// \t\t\t\t.find((l) => !!l)\n// \t\t);\n// \t},\n// };\n"]}
@@ -1,2 +1,3 @@
1
1
  export const CompoundIndexSeparator = ':';
2
2
  export const COMPLETED = true;
3
+ //# sourceMappingURL=dto-constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto-constants.js","sourceRoot":"","sources":["../../../../../libs/dto/src/lib/dto-constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAC1C,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC","sourcesContent":["export const CompoundIndexSeparator = ':';\nexport const COMPLETED = true;\n"]}
@@ -0,0 +1,23 @@
1
+ function newTotal() {
2
+ return { count: 0, day: 0, week: 0, month: 0, quarter: 0, year: 0 };
3
+ }
4
+ export function newTotals() {
5
+ // TODO: Rename to ITotalsDto
6
+ return { incomes: newTotal(), expenses: newTotal() };
7
+ }
8
+ export function zeroIfEmptyTotals(totals) {
9
+ const f = (t) => t
10
+ ? {
11
+ count: t.count || 0,
12
+ day: t.day || 0,
13
+ week: t.week || 0,
14
+ month: t.month || 0,
15
+ quarter: t.quarter || 0,
16
+ year: t.year || 0,
17
+ }
18
+ : newTotal();
19
+ totals.incomes = f(totals.incomes);
20
+ totals.expenses = f(totals.expenses);
21
+ return totals;
22
+ }
23
+ //# sourceMappingURL=dto-models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto-models.js","sourceRoot":"","sources":["../../../../../libs/dto/src/lib/dto-models.ts"],"names":[],"mappings":"AAwEA,SAAS,QAAQ;IACf,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,SAAS;IACvB,6BAA6B;IAC7B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAiB;IACjD,MAAM,CAAC,GAAG,CAAC,CAAY,EAAE,EAAE,CACzB,CAAC;QACC,CAAC,CAAC;YACE,KAAK,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC;YACnB,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;YACf,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC;YACjB,KAAK,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC;YACnB,OAAO,EAAE,CAAC,CAAC,OAAO,IAAI,CAAC;YACvB,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC;SAClB;QACH,CAAC,CAAC,QAAQ,EAAE,CAAC;IACjB,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACnC,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACrC,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { Restriction } from './types';\n\n// import {IPersonSize} from '../ui/dto-sizechart';\n\nexport interface ITitled {\n title: string;\n}\n\nexport interface ITitledRecord {\n id?: string;\n title?: string;\n}\n\nexport interface ITitledRecordInfo {\n id: string;\n title: string;\n}\n\n// | MemberRoleWork;\n\nexport interface DtoTotal {\n count: number;\n day?: number;\n week?: number;\n month?: number;\n quarter?: number;\n year?: number;\n}\n\nexport interface IDemoRecord {\n id?: string;\n isDemo?: boolean;\n isLocal?: boolean;\n}\n\nexport interface ITotalsHolder {\n totals?: DtoTotals;\n}\n\nexport interface DtoTotals {\n incomes?: DtoTotal;\n expenses?: DtoTotal;\n}\n\n// export interface Category extends ITitledRecord {\n// id: string;\n// }\n\nexport interface IWithSpaceIDs {\n spaceIDs?: string[];\n}\n\nexport interface IWithTag {\n tags?: string[];\n}\n\nexport interface IWithAssetIDs {\n assetIDs?: string[];\n}\n\nexport interface IWithMemberIDs {\n memberIDs?: string[];\n}\n\nexport interface IRealEstate {\n leaseExpires?: string;\n}\n\nexport interface IWithRestrictions {\n restrictions?: Restriction[];\n}\n\nfunction newTotal(): DtoTotal {\n return { count: 0, day: 0, week: 0, month: 0, quarter: 0, year: 0 };\n}\n\nexport function newTotals(): DtoTotals {\n // TODO: Rename to ITotalsDto\n return { incomes: newTotal(), expenses: newTotal() };\n}\n\nexport function zeroIfEmptyTotals(totals: DtoTotals): DtoTotals {\n const f = (t?: DtoTotal) =>\n t\n ? {\n count: t.count || 0,\n day: t.day || 0,\n week: t.week || 0,\n month: t.month || 0,\n quarter: t.quarter || 0,\n year: t.year || 0,\n }\n : newTotal();\n totals.incomes = f(totals.incomes);\n totals.expenses = f(totals.expenses);\n return totals;\n}\n\nexport interface IVerification {\n isVerified?: boolean;\n verification?: {\n confirmedBy?: string[]; // List of ID of users who confirmed validity of the member\n rejectedBy?: string[]; // List of ID of users who questions validity of the member\n };\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=dto-pricing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto-pricing.js","sourceRoot":"","sources":["../../../../../libs/dto/src/lib/dto-pricing.ts"],"names":[],"mappings":"","sourcesContent":["export interface IPrice {\n title?: string;\n amount: number;\n currency?: 'EUR' | 'RUB' | 'USD';\n}\n"]}
@@ -0,0 +1,9 @@
1
+ export const equalSpaceBriefs = (v1, v2) => {
2
+ if (v1 === v2)
3
+ return true;
4
+ return v1?.parentSpaceID === v2?.parentSpaceID && v1?.title === v2?.title;
5
+ };
6
+ export const isSpaceSupportsMemberGroups = (t) => {
7
+ return t === 'educator' || t === 'sport_club' || t === 'cohabit';
8
+ };
9
+ //# sourceMappingURL=dto-team-brief.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto-team-brief.js","sourceRoot":"","sources":["../../../../../libs/dto/src/lib/dto-team-brief.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,EAAmC,EACnC,EAAmC,EAC1B,EAAE;IACX,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAC3B,OAAO,EAAE,EAAE,aAAa,KAAK,EAAE,EAAE,aAAa,IAAI,EAAE,EAAE,KAAK,KAAK,EAAE,EAAE,KAAK,CAAC;AAC5E,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAY,EAAW,EAAE;IACnE,OAAO,CAAC,KAAK,UAAU,IAAI,CAAC,KAAK,YAAY,IAAI,CAAC,KAAK,SAAS,CAAC;AACnE,CAAC,CAAC","sourcesContent":["import { SpaceType } from '@sneat/core';\n\nexport interface ISpaceBrief {\n readonly title: string;\n readonly type: SpaceType;\n readonly parentSpaceID?: string;\n readonly roles?: string[];\n}\n\nexport const equalSpaceBriefs = (\n v1?: ISpaceBrief | null | undefined,\n v2?: ISpaceBrief | null | undefined,\n): boolean => {\n if (v1 === v2) return true;\n return v1?.parentSpaceID === v2?.parentSpaceID && v1?.title === v2?.title;\n};\n\nexport const isSpaceSupportsMemberGroups = (t: SpaceType): boolean => {\n return t === 'educator' || t === 'sport_club' || t === 'cohabit';\n};\n"]}
@@ -0,0 +1,4 @@
1
+ export function createShortCommuneInfoFromUserCommuneInfo(v) {
2
+ return { id: v.id, title: v.title, /*shortId: v.shortId,*/ type: v.type };
3
+ }
4
+ //# sourceMappingURL=dto-team-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto-team-info.js","sourceRoot":"","sources":["../../../../../libs/dto/src/lib/dto-team-info.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,yCAAyC,CACvD,CAAmB;IAEnB,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,uBAAuB,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAC5E,CAAC","sourcesContent":["import { SpaceType } from '@sneat/core';\nimport { IUserCommuneInfo } from './dto-user';\n\nexport interface IShortSpaceInfo {\n type: SpaceType;\n id?: string;\n // shortId?: CommuneShortId;\n title?: string;\n}\n\nexport function createShortCommuneInfoFromUserCommuneInfo(\n v: IUserCommuneInfo,\n): IShortSpaceInfo {\n return { id: v.id, title: v.title, /*shortId: v.shortId,*/ type: v.type };\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=dto-team-meeting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto-team-meeting.js","sourceRoot":"","sources":["../../../../../libs/dto/src/lib/dto-team-meeting.ts"],"names":[],"mappings":"","sourcesContent":["export interface IMeetingInfo {\n id: string;\n stage: string;\n started?: string;\n finished?: string;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=dto-team-metric.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto-team-metric.js","sourceRoot":"","sources":["../../../../../libs/dto/src/lib/dto-team-metric.ts"],"names":[],"mappings":"","sourcesContent":["export type MetricColor =\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'success'\n | 'danger'\n | 'warning';\n\nexport interface IBoolMetricVal {\n label: string;\n color: MetricColor;\n}\n\nexport interface IBoolMetric {\n true: IBoolMetricVal;\n false: IBoolMetricVal;\n}\n\nexport interface ISpaceMetric {\n id?: string;\n title: string;\n colorTrue?: MetricColor;\n colorFalse?: MetricColor;\n type: 'bool' | 'integer' | 'options';\n mode: 'personal' | 'team';\n bool?: IBoolMetric;\n min?: number;\n max?: number;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=dto-team.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto-team.js","sourceRoot":"","sources":["../../../../../libs/dto/src/lib/dto-team.ts"],"names":[],"mappings":"","sourcesContent":["import { ITotalsHolder } from './dto-models';\nimport { ISpaceBrief } from './dto-team-brief';\nimport { ISpaceMetric } from './dto-team-metric';\n\n// export interface ITeamMeetings {\n// \tscrum?: IMemberBrief;\n// \tretrospective?: IMeetingInfo;\n// }\n\nexport interface ISpaceDbo extends ISpaceBrief, ITotalsHolder {\n readonly countryID: string;\n readonly userIDs: string[];\n // readonly members?: IMemberBrief[];\n // readonly assets?: IAssetBrief[];\n // readonly contacts?: IContactBrief[];\n // readonly numberOf?: TeamCounts;\n // readonly recurringHappenings?: { [id: string]: IHappeningBrief }; // TODO: Move to ISchedulusTeamDto\n\n metrics: ISpaceMetric[];\n // active?: ITeamMeetings;\n // last?: ITeamMeetings;\n upcomingRetro?: {\n itemsByUserAndType?: Record<string, Record<string, number>>;\n };\n\n noContactRoles?: string[]; // lists roles that have no contacts. For example families that have no plumber contacts.\n}\n"]}
@@ -0,0 +1,33 @@
1
+ export function createUserCommuneInfoFromCommuneDto(communeDto, shortId) {
2
+ return {
3
+ id: communeDto.id,
4
+ shortId,
5
+ title: communeDto.title,
6
+ type: communeDto.type,
7
+ };
8
+ }
9
+ export function addCommuneToUserDto(userDto, communeInfo) {
10
+ const communes = userDto.communes || [];
11
+ if (communeInfo.id &&
12
+ communes.find((c) => !!c.id && !!communeInfo.id && c.id === communeInfo.id)) {
13
+ throw new Error(`Can't add commune with duplicate id: ${communeInfo.id}`);
14
+ }
15
+ return {
16
+ ...userDto,
17
+ communes: [...communes, communeInfo],
18
+ communesCount: communes.length + 1,
19
+ };
20
+ }
21
+ export class UserModel {
22
+ static getCommuneInfoByShortId(id, communes) {
23
+ return communes && communes.find((c) => c.shortId === id);
24
+ }
25
+ static getCommuneInfoById(id, communes) {
26
+ const ci = communes && communes.find((c) => c.shortId === id || c.id === id);
27
+ if (!ci && id === 'family') {
28
+ return { type: 'family', shortId: 'family', title: 'Family' };
29
+ }
30
+ return ci;
31
+ }
32
+ }
33
+ //# sourceMappingURL=dto-user.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto-user.js","sourceRoot":"","sources":["../../../../../libs/dto/src/lib/dto-user.ts"],"names":[],"mappings":"AAkBA,MAAM,UAAU,mCAAmC,CACjD,UAAuB,EACvB,OAAgB;IAEhB,OAAO;QACL,EAAE,EAAE,UAAU,CAAC,EAAE;QACjB,OAAO;QACP,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,IAAI,EAAE,UAAU,CAAC,IAAI;KACtB,CAAC;AACJ,CAAC;AAmBD,MAAM,UAAU,mBAAmB,CACjC,OAAiB,EACjB,WAA6B;IAE7B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;IACxC,IACE,WAAW,CAAC,EAAE;QACd,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,KAAK,WAAW,CAAC,EAAE,CAAC,EAC3E,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,wCAAwC,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO;QACL,GAAG,OAAO;QACV,QAAQ,EAAE,CAAC,GAAG,QAAQ,EAAE,WAAW,CAAC;QACpC,aAAa,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC;KACnC,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,SAAS;IACb,MAAM,CAAC,uBAAuB,CACnC,EAAU,EACV,QAAsC;QAEtC,OAAO,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC;IAC5D,CAAC;IAEM,MAAM,CAAC,kBAAkB,CAC9B,EAAU,EACV,QAAqC;QAErC,MAAM,EAAE,GACN,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,EAAE,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACpE,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,QAAQ,EAAE,CAAC;YAC3B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;QAChE,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF","sourcesContent":["// import { MemberRelationship } from './dto-member';\nimport { ITitledRecord } from './dto-models';\nimport { ICommuneDbo } from './dto-commune';\nimport { CommuneType, CountryId } from './types';\n\nexport interface IUserCommuneInfo {\n id?: string;\n shortId?: string;\n title?: string;\n type: CommuneType;\n // members?: {\n // \t[id: string]: {\n // \t\trelatedAs: MemberRelationship;\n // \t\t// title?: string;\n // \t};\n // };\n}\n\nexport function createUserCommuneInfoFromCommuneDto(\n communeDto: ICommuneDbo,\n shortId?: string,\n): IUserCommuneInfo {\n return {\n id: communeDto.id,\n shortId,\n title: communeDto.title,\n type: communeDto.type,\n };\n}\n\nexport interface IUserDbo extends ITitledRecord {\n countryIds?: CountryId[];\n created: {\n hostOrApp: string;\n at: string;\n };\n readonly communes?: readonly IUserCommuneInfo[]; // Returns real ID and Title, find by shortId\n communesCount?: number;\n isAnonymous: boolean;\n isDemo?: boolean;\n autogeneratedPassword?: string;\n emailVerified?: boolean;\n email?: string;\n emailOriginal?: string;\n gender?: 'male' | 'female' | 'undisclosed';\n}\n\nexport function addCommuneToUserDto(\n userDto: IUserDbo,\n communeInfo: IUserCommuneInfo,\n): IUserDbo {\n const communes = userDto.communes || [];\n if (\n communeInfo.id &&\n communes.find((c) => !!c.id && !!communeInfo.id && c.id === communeInfo.id)\n ) {\n throw new Error(`Can't add commune with duplicate id: ${communeInfo.id}`);\n }\n return {\n ...userDto,\n communes: [...communes, communeInfo],\n communesCount: communes.length + 1,\n };\n}\n\nexport class UserModel {\n public static getCommuneInfoByShortId(\n id: string,\n communes?: readonly IUserCommuneInfo[],\n ): IUserCommuneInfo | undefined {\n return communes && communes.find((c) => c.shortId === id);\n }\n\n public static getCommuneInfoById(\n id: string,\n communes: readonly IUserCommuneInfo[],\n ): IUserCommuneInfo | undefined {\n const ci =\n communes && communes.find((c) => c.shortId === id || c.id === id);\n if (!ci && id === 'family') {\n return { type: 'family', shortId: 'family', title: 'Family' };\n }\n return ci;\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export const emptyTimestamp = { seconds: 0, nanoseconds: 0 };
2
+ //# sourceMappingURL=dto-with-modified.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto-with-modified.js","sourceRoot":"","sources":["../../../../../libs/dto/src/lib/dto-with-modified.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,cAAc,GAAc,EAAE,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC","sourcesContent":["export interface timestamp {\n seconds: number;\n nanoseconds: number;\n}\nexport const emptyTimestamp: timestamp = { seconds: 0, nanoseconds: 0 };\n\nexport interface IWithCreatedShort {\n readonly at: string;\n readonly by: string;\n}\n\nexport interface IWithCreatedOn {\n readonly createdOn: string;\n}\n\nexport interface IWithCreated {\n readonly createdAt: timestamp;\n readonly createdBy: string;\n}\n\nexport interface IWithUpdated {\n readonly updatedAt: timestamp;\n readonly updatedBy: string;\n}\n\nexport interface IWithDeleted {\n readonly deletedAt?: timestamp;\n readonly deletedBy?: string;\n}\n\nexport interface IWithModified\n extends IWithCreated, IWithUpdated, IWithDeleted {}\n"]}
@@ -0,0 +1,19 @@
1
+ export * from './ui-state';
2
+ export * from './dto-app';
3
+ export * from './dto-brief';
4
+ export * from './dto-commune';
5
+ export * from './dto-constants';
6
+ export * from './dto-models';
7
+ export * from './dto-pricing';
8
+ export * from './dto-team';
9
+ export * from './dto-team-brief';
10
+ export * from './dto-team-info';
11
+ export * from './dto-team-meeting';
12
+ export * from './dto-team-metric';
13
+ export * from './dto-user';
14
+ export * from './dto-with-modified';
15
+ export * from './by-user';
16
+ export * from './types';
17
+ export * from './with-related';
18
+ export * from './period';
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/dto/src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC","sourcesContent":["export * from './ui-state';\nexport * from './dto-app';\nexport * from './dto-brief';\nexport * from './dto-commune';\nexport * from './dto-constants';\nexport * from './dto-models';\nexport * from './dto-pricing';\nexport * from './dto-team';\nexport * from './dto-team-brief';\nexport * from './dto-team-info';\nexport * from './dto-team-meeting';\nexport * from './dto-team-metric';\nexport * from './dto-user';\nexport * from './dto-with-modified';\nexport * from './by-user';\nexport * from './types';\nexport * from './with-related';\nexport * from './period';\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=period.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"period.js","sourceRoot":"","sources":["../../../../../libs/dto/src/lib/period.ts"],"names":[],"mappings":"","sourcesContent":["export type Period = 'day' | 'week' | 'month' | 'quarter' | 'year';\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../libs/dto/src/lib/types.ts"],"names":[],"mappings":"","sourcesContent":["import { SpaceType } from '@sneat/core';\n\nexport { SpaceMemberType } from '@sneat/auth-models';\n\nexport type Restriction = 'adults_only' | 'personal' | string;\n\nexport type SneatRecordStatus = 'active' | 'archived' | 'deleted';\n\nexport type CommuneType = SpaceType;\n\nexport type CountryId =\n | 'IE'\n | 'US'\n | 'UK'\n | 'RU'\n | 'FR'\n | 'ES'\n | 'AU'\n | 'ZA'\n | string;\n\nexport type CommuneItemCounter =\n | 'activities'\n | 'assets'\n | 'assetGroups'\n | 'contacts'\n | 'documents'\n | 'liabilities'\n | 'members'\n | 'memberGroups'\n | 'overdues'\n | 'regularTasks'\n | 'todos'\n | 'upcomings';\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ui-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui-state.js","sourceRoot":"","sources":["../../../../../libs/dto/src/lib/ui-state.ts"],"names":[],"mappings":"","sourcesContent":["export interface UiState {\n readonly isAdding?: boolean;\n readonly isDeleting?: boolean;\n readonly isReordering?: boolean;\n}\n"]}
@@ -0,0 +1,94 @@
1
+ export function getRelatedItems(moduleId, collectionId, related) {
2
+ return (related && related[moduleId]?.[collectionId]) || {};
3
+ }
4
+ export function validateRelated(related) {
5
+ if (!related) {
6
+ return;
7
+ }
8
+ Object.entries(related).forEach(([, collections]) => {
9
+ Object.entries(collections).forEach(([, items]) => {
10
+ if (!items) {
11
+ return;
12
+ }
13
+ Object.entries(items).forEach(([itemID]) => {
14
+ if (!itemID) {
15
+ throw new Error('ItemID is not set');
16
+ }
17
+ });
18
+ });
19
+ });
20
+ }
21
+ export const addRelatedItem = (related, key, rolesOfItem) => {
22
+ related = related || {};
23
+ let collectionRelated = related[key.module] || {};
24
+ let relatedItems = collectionRelated[key.collection] || {};
25
+ if (!hasRelated(related, key)) {
26
+ relatedItems = {
27
+ ...relatedItems,
28
+ [key.itemID]: { rolesOfItem },
29
+ };
30
+ collectionRelated = {
31
+ ...collectionRelated,
32
+ [key.collection]: relatedItems,
33
+ };
34
+ related = { ...related, [key.module]: collectionRelated };
35
+ }
36
+ return related;
37
+ };
38
+ export const removeRelatedItem = (related, key) => {
39
+ if (!related) {
40
+ return related;
41
+ }
42
+ let collectionRelated = related[key.module];
43
+ if (!collectionRelated) {
44
+ return related;
45
+ }
46
+ const relatedItems = collectionRelated[key.collection];
47
+ if (!relatedItems) {
48
+ return related;
49
+ }
50
+ if (hasRelated(related, key)) {
51
+ const collectionItems = { ...relatedItems };
52
+ delete collectionItems[key.itemID];
53
+ collectionRelated = {
54
+ ...collectionRelated,
55
+ [key.collection]: collectionItems,
56
+ };
57
+ related = { ...related, [key.module]: collectionRelated };
58
+ }
59
+ return related;
60
+ };
61
+ export const getLongRelatedItemID = (itemID, spaceID) => `${itemID}@${spaceID}`;
62
+ export const getRelatedItemByIDs = (relatedItems, itemID, spaceID) => relatedItems &&
63
+ (relatedItems[itemID] ||
64
+ (spaceID && relatedItems[getLongRelatedItemID(itemID, spaceID)]));
65
+ export const getRelatedItemByKey = (related, key) => {
66
+ const items = related?.[key.module]?.[key.collection];
67
+ const { itemID, spaceID } = key;
68
+ return getRelatedItemByIDs(items, itemID, spaceID);
69
+ };
70
+ export const getRelatedItemIDs = (related, module, collection, spaceID) => {
71
+ if (!related) {
72
+ return [];
73
+ }
74
+ // console.log('getRelatedItemIDs', module, collection, spaceID, related);
75
+ const collectionRelated = (related || {})[module] || {};
76
+ const relatedItems = collectionRelated[collection];
77
+ const keys = Object.keys(relatedItems);
78
+ return spaceID
79
+ ? keys.filter((k) => !k.includes('@') || k.endsWith(`@${spaceID}`))
80
+ : keys;
81
+ };
82
+ export const hasRelated = (related, key) => {
83
+ if (!related) {
84
+ return false;
85
+ }
86
+ const collectionRelated = (related || {})[key.module] || {};
87
+ const relatedItems = collectionRelated[key.collection];
88
+ return hasRelatedItem(relatedItems, key);
89
+ };
90
+ const hasRelatedItem = (relatedItems, itemKey) => {
91
+ const { itemID, spaceID } = itemKey;
92
+ return !!getRelatedItemByIDs(relatedItems, itemID, spaceID);
93
+ };
94
+ //# sourceMappingURL=with-related.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-related.js","sourceRoot":"","sources":["../../../../../libs/dto/src/lib/with-related.ts"],"names":[],"mappings":"AAuCA,MAAM,UAAU,eAAe,CAC7B,QAAgB,EAChB,YAAoB,EACpB,OAAyB;IAEzB,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,YAAY,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,KAAK,CAAC;IACf,CAAC;IACD,MAAM,iBAAiB,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC5D,MAAM,YAAY,GAAG,iBAAiB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACvD,OAAO,cAAc,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CACrB,YAA2B,EAC3B,OAAwB,EACf,EAAE;IACX,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACpC,OAAO,CAAC,CAAC,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC,CAAC","sourcesContent":["import { IWithCreatedShort } from './dto-with-modified';\n\nexport interface IRelatedItemKey {\n readonly itemID: string;\n readonly spaceID?: string;\n}\n\nexport interface ISpaceModuleItemRef {\n readonly module: string;\n readonly collection: string;\n readonly spaceID: string;\n readonly itemID: string;\n}\n\nexport interface IRelationshipRole {\n readonly created: IWithCreatedShort;\n}\n\nexport type WritableRelationshipRoles = Record<string, IRelationshipRole>;\n// {\n// \t// -readonly [K in keyof IRelationshipRoles]: IRelationshipRoles[K];\n// };\nexport type IRelationshipRoles = Readonly<WritableRelationshipRoles>;\n\nexport interface IRelatedItem {\n // readonly keys: readonly IRelatedItemKey[];\n readonly rolesOfItem?: IRelationshipRoles; // if related item is a child of the current record, then rolesOfItem = {\"child\": ...}\n readonly rolesToItem?: IRelationshipRoles; // if related item is a child of the current contact, then rolesToItem = {\"parent\": ...}\n}\n\nexport type IRelatedItems = Readonly<Record<string, IRelatedItem>>;\nexport type IRelatedCollections = Readonly<Record<string, IRelatedItems>>;\nexport type IRelatedModules = Readonly<Record<string, IRelatedCollections>>;\n\nexport interface IRelatedTo extends IWithRelatedOnly {\n readonly key: ISpaceModuleItemRef;\n readonly title: string; // pass empty string if you don't want to display name\n}\n\nexport function getRelatedItems(\n moduleId: string,\n collectionId: string,\n related?: IRelatedModules,\n): IRelatedItems {\n return (related && related[moduleId]?.[collectionId]) || {};\n}\n\nexport interface IWithRelatedOnly {\n readonly related?: IRelatedModules;\n}\n\nexport function validateRelated(related?: IRelatedModules): void {\n if (!related) {\n return;\n }\n Object.entries(related).forEach(([, collections]) => {\n Object.entries(collections).forEach(([, items]) => {\n if (!items) {\n return;\n }\n Object.entries(items).forEach(([itemID]) => {\n if (!itemID) {\n throw new Error('ItemID is not set');\n }\n });\n });\n });\n}\n\nexport interface IWithRelatedAndRelatedIDs extends IWithRelatedOnly {\n readonly relatedIDs?: readonly string[];\n}\n\nexport const addRelatedItem = (\n related: IRelatedModules | undefined,\n key: ISpaceModuleItemRef,\n rolesOfItem?: IRelationshipRoles,\n) => {\n related = related || {};\n let collectionRelated = related[key.module] || {};\n let relatedItems = collectionRelated[key.collection] || {};\n if (!hasRelated(related, key)) {\n relatedItems = {\n ...relatedItems,\n [key.itemID]: { rolesOfItem },\n };\n collectionRelated = {\n ...collectionRelated,\n [key.collection]: relatedItems,\n };\n related = { ...related, [key.module]: collectionRelated };\n }\n return related;\n};\n\nexport const removeRelatedItem = (\n related: IRelatedModules | undefined,\n key: ISpaceModuleItemRef,\n) => {\n if (!related) {\n return related;\n }\n let collectionRelated = related[key.module];\n if (!collectionRelated) {\n return related;\n }\n const relatedItems = collectionRelated[key.collection];\n if (!relatedItems) {\n return related;\n }\n if (hasRelated(related, key)) {\n const collectionItems = { ...relatedItems };\n delete collectionItems[key.itemID];\n collectionRelated = {\n ...collectionRelated,\n [key.collection]: collectionItems,\n };\n related = { ...related, [key.module]: collectionRelated };\n }\n return related;\n};\n\nexport const getLongRelatedItemID = (itemID: string, spaceID: string) =>\n `${itemID}@${spaceID}`;\n\nexport const getRelatedItemByIDs = (\n relatedItems: Readonly<Record<string, IRelatedItem>> | undefined,\n itemID: string,\n spaceID?: string,\n) =>\n relatedItems &&\n (relatedItems[itemID] ||\n (spaceID && relatedItems[getLongRelatedItemID(itemID, spaceID)]));\n\nexport const getRelatedItemByKey = (\n related: IRelatedModules | undefined,\n key: ISpaceModuleItemRef,\n): IRelatedItem | undefined => {\n const items = related?.[key.module]?.[key.collection];\n const { itemID, spaceID } = key;\n return getRelatedItemByIDs(items, itemID, spaceID);\n};\n\nexport const getRelatedItemIDs = (\n related: IRelatedModules | undefined,\n module: string,\n collection: string,\n spaceID?: string,\n): readonly string[] => {\n if (!related) {\n return [];\n }\n // console.log('getRelatedItemIDs', module, collection, spaceID, related);\n const collectionRelated = (related || {})[module] || {};\n const relatedItems = collectionRelated[collection];\n const keys = Object.keys(relatedItems);\n return spaceID\n ? keys.filter((k) => !k.includes('@') || k.endsWith(`@${spaceID}`))\n : keys;\n};\n\nexport const hasRelated = (\n related: IRelatedModules | undefined,\n key: ISpaceModuleItemRef,\n): boolean => {\n if (!related) {\n return false;\n }\n const collectionRelated = (related || {})[key.module] || {};\n const relatedItems = collectionRelated[key.collection];\n return hasRelatedItem(relatedItems, key);\n};\n\nconst hasRelatedItem = (\n relatedItems: IRelatedItems,\n itemKey: IRelatedItemKey,\n): boolean => {\n const { itemID, spaceID } = itemKey;\n return !!getRelatedItemByIDs(relatedItems, itemID, spaceID);\n};\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ export * from './index';
5
+ //# sourceMappingURL=sneat-dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sneat-dto.js","sourceRoot":"","sources":["../../../../libs/dto/src/sneat-dto.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC","sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"]}
@@ -0,0 +1,4 @@
1
+ export interface IByUser {
2
+ uid: string;
3
+ title?: string;
4
+ }
@@ -0,0 +1,6 @@
1
+ import { ITitledRecord } from './dto-models';
2
+ export interface DtoApp {
3
+ users?: ITitledRecord[];
4
+ currentLanguage?: string;
5
+ isInDemoMode?: boolean;
6
+ }
@@ -1,4 +1,4 @@
1
1
  export interface IWithIdAndTitle {
2
- id: string;
3
- title: string;
2
+ id: string;
3
+ title: string;
4
4
  }
@@ -0,0 +1,53 @@
1
+ import { IDemoRecord, ITitledRecord, ITotalsHolder } from './dto-models';
2
+ import { CommuneType, CountryId } from './types';
3
+ export declare const enum SpaceCounter {
4
+ activities = "activities",
5
+ assets = "assets",
6
+ assetGroups = "assetGroups",
7
+ contacts = "contacts",
8
+ documents = "documents",
9
+ liabilities = "liabilities",
10
+ members = "members",
11
+ memberGroups = "memberGroups",
12
+ overdues = "overdues",
13
+ pupils = "pupils",
14
+ regularTasks = "regularTasks",
15
+ staff = "staff",
16
+ todos = "todos",
17
+ upcomings = "upcomings"
18
+ }
19
+ export interface SpaceCounts {
20
+ [SpaceCounter.activities]?: number;
21
+ [SpaceCounter.assets]?: number;
22
+ [SpaceCounter.assetGroups]?: number;
23
+ [SpaceCounter.contacts]?: number;
24
+ [SpaceCounter.documents]?: number;
25
+ [SpaceCounter.regularTasks]?: number;
26
+ [SpaceCounter.liabilities]?: number;
27
+ [SpaceCounter.pupils]?: number;
28
+ [SpaceCounter.staff]?: number;
29
+ [SpaceCounter.members]?: number;
30
+ [SpaceCounter.memberGroups]?: number;
31
+ [SpaceCounter.overdues]?: number;
32
+ [SpaceCounter.todos]?: number;
33
+ [SpaceCounter.upcomings]?: number;
34
+ }
35
+ export declare function incrementNumberOf<NumberOf, Dbo extends {
36
+ numberOf?: NumberOf;
37
+ }>(dto: Dbo, init: () => NumberOf, counter: keyof NumberOf, v?: number): Dbo;
38
+ export declare function newSpaceCounts(numberOf?: SpaceCounts): SpaceCounts;
39
+ export interface ICommuneDbo extends IDemoRecord, ITitledRecord, ITotalsHolder {
40
+ readonly countryId?: CountryId;
41
+ readonly type: CommuneType;
42
+ readonly desc?: string;
43
+ readonly userID: string;
44
+ readonly order?: number;
45
+ readonly numberOf?: SpaceCounts;
46
+ readonly membersCountByRole?: Record<string, number>;
47
+ readonly noContactRoles?: string[];
48
+ }
49
+ export declare function isCommuneShouldHoldMembersInfo(type: CommuneType): boolean;
50
+ export declare const personalCommuneIdPrefix = "u_";
51
+ export declare function getUserPersonalCommuneID(userID?: string): string;
52
+ export declare function isPersonalCommuneId(id: string): boolean;
53
+ export declare function isUserPersonalCommune(communeID: string, userID?: string): boolean;
@@ -0,0 +1,2 @@
1
+ export declare const CompoundIndexSeparator = ":";
2
+ export declare const COMPLETED = true;
@@ -0,0 +1,59 @@
1
+ import { Restriction } from './types';
2
+ export interface ITitled {
3
+ title: string;
4
+ }
5
+ export interface ITitledRecord {
6
+ id?: string;
7
+ title?: string;
8
+ }
9
+ export interface ITitledRecordInfo {
10
+ id: string;
11
+ title: string;
12
+ }
13
+ export interface DtoTotal {
14
+ count: number;
15
+ day?: number;
16
+ week?: number;
17
+ month?: number;
18
+ quarter?: number;
19
+ year?: number;
20
+ }
21
+ export interface IDemoRecord {
22
+ id?: string;
23
+ isDemo?: boolean;
24
+ isLocal?: boolean;
25
+ }
26
+ export interface ITotalsHolder {
27
+ totals?: DtoTotals;
28
+ }
29
+ export interface DtoTotals {
30
+ incomes?: DtoTotal;
31
+ expenses?: DtoTotal;
32
+ }
33
+ export interface IWithSpaceIDs {
34
+ spaceIDs?: string[];
35
+ }
36
+ export interface IWithTag {
37
+ tags?: string[];
38
+ }
39
+ export interface IWithAssetIDs {
40
+ assetIDs?: string[];
41
+ }
42
+ export interface IWithMemberIDs {
43
+ memberIDs?: string[];
44
+ }
45
+ export interface IRealEstate {
46
+ leaseExpires?: string;
47
+ }
48
+ export interface IWithRestrictions {
49
+ restrictions?: Restriction[];
50
+ }
51
+ export declare function newTotals(): DtoTotals;
52
+ export declare function zeroIfEmptyTotals(totals: DtoTotals): DtoTotals;
53
+ export interface IVerification {
54
+ isVerified?: boolean;
55
+ verification?: {
56
+ confirmedBy?: string[];
57
+ rejectedBy?: string[];
58
+ };
59
+ }
@@ -0,0 +1,5 @@
1
+ export interface IPrice {
2
+ title?: string;
3
+ amount: number;
4
+ currency?: 'EUR' | 'RUB' | 'USD';
5
+ }