@stevenkellner/team-conduct-api 1.0.3 → 1.0.5

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 (129) hide show
  1. package/lib/src/Firestore.d.ts +15 -0
  2. package/lib/src/Firestore.js +53 -0
  3. package/{src/FirestoreScheme.ts → lib/src/FirestoreScheme.d.ts} +12 -13
  4. package/lib/src/FirestoreScheme.js +2 -0
  5. package/lib/src/checkAuthentication.d.ts +2 -0
  6. package/lib/src/checkAuthentication.js +31 -0
  7. package/lib/src/firebase/FirebaseConfiguration.d.ts +15 -0
  8. package/lib/src/firebase/FirebaseConfiguration.js +28 -0
  9. package/{src/firebase/Messaging.ts → lib/src/firebase/Messaging.d.ts} +0 -3
  10. package/lib/src/firebase/Messaging.js +2 -0
  11. package/lib/src/firebase/index.js +18 -0
  12. package/lib/src/firebaseFunctionCreators.d.ts +50 -0
  13. package/lib/src/firebaseFunctionCreators.js +58 -0
  14. package/lib/src/functions/fine/add.d.ts +37 -0
  15. package/lib/src/functions/fine/add.js +71 -0
  16. package/lib/src/functions/fine/delete.d.ts +24 -0
  17. package/lib/src/functions/fine/delete.js +71 -0
  18. package/lib/src/functions/fine/update.d.ts +38 -0
  19. package/lib/src/functions/fine/update.js +73 -0
  20. package/lib/src/functions/fineTemplate/add.d.ts +32 -0
  21. package/lib/src/functions/fineTemplate/add.js +23 -0
  22. package/lib/src/functions/fineTemplate/delete.d.ts +17 -0
  23. package/lib/src/functions/fineTemplate/delete.js +23 -0
  24. package/lib/src/functions/fineTemplate/update.d.ts +32 -0
  25. package/lib/src/functions/fineTemplate/update.js +23 -0
  26. package/lib/src/functions/invitation/invite.d.ts +7 -0
  27. package/lib/src/functions/invitation/invite.js +23 -0
  28. package/lib/src/functions/invitation/register.d.ts +7 -0
  29. package/lib/src/functions/invitation/register.js +43 -0
  30. package/lib/src/functions/invitation/withdraw.d.ts +8 -0
  31. package/lib/src/functions/invitation/withdraw.js +21 -0
  32. package/lib/src/functions/notification/register.d.ts +19 -0
  33. package/lib/src/functions/notification/register.js +27 -0
  34. package/lib/src/functions/notification/subscribe.d.ts +19 -0
  35. package/lib/src/functions/notification/subscribe.js +26 -0
  36. package/lib/src/functions/paypalMe/edit.d.ts +17 -0
  37. package/lib/src/functions/paypalMe/edit.js +25 -0
  38. package/lib/src/functions/person/add.d.ts +22 -0
  39. package/lib/src/functions/person/add.js +24 -0
  40. package/lib/src/functions/person/delete.d.ts +17 -0
  41. package/lib/src/functions/person/delete.js +25 -0
  42. package/lib/src/functions/person/update.d.ts +22 -0
  43. package/lib/src/functions/person/update.js +25 -0
  44. package/lib/src/functions/team/new.d.ts +26 -0
  45. package/lib/src/functions/team/new.js +36 -0
  46. package/lib/src/functions/user/login.d.ts +8 -0
  47. package/lib/src/functions/user/login.js +21 -0
  48. package/lib/src/functions/user/roleEdit.d.ts +19 -0
  49. package/lib/src/functions/user/roleEdit.js +30 -0
  50. package/lib/src/pushNotification.d.ts +3 -0
  51. package/lib/src/pushNotification.js +35 -0
  52. package/lib/src/types/Configuration.d.ts +27 -0
  53. package/lib/src/types/Configuration.js +38 -0
  54. package/lib/src/types/Fine.d.ts +30 -0
  55. package/lib/src/types/Fine.js +42 -0
  56. package/lib/src/types/FineAmount.d.ts +51 -0
  57. package/lib/src/types/FineAmount.js +124 -0
  58. package/lib/src/types/FineTemplate.d.ts +28 -0
  59. package/lib/src/types/FineTemplate.js +40 -0
  60. package/lib/src/types/FineTemplateRepetition.d.ts +22 -0
  61. package/lib/src/types/FineTemplateRepetition.js +38 -0
  62. package/lib/src/types/Invitation.d.ts +25 -0
  63. package/lib/src/types/Invitation.js +42 -0
  64. package/lib/src/types/MoneyAmount.d.ts +17 -0
  65. package/lib/src/types/MoneyAmount.js +68 -0
  66. package/lib/src/types/NotificationProperties.d.ts +28 -0
  67. package/lib/src/types/NotificationProperties.js +50 -0
  68. package/lib/src/types/PayedState.d.ts +6 -0
  69. package/lib/src/types/PayedState.js +9 -0
  70. package/lib/src/types/Person.d.ts +29 -0
  71. package/lib/src/types/Person.js +41 -0
  72. package/lib/src/types/PersonPrivateProperties.d.ts +17 -0
  73. package/lib/src/types/PersonPrivateProperties.js +27 -0
  74. package/lib/src/types/PersonSignInProperties.d.ts +24 -0
  75. package/lib/src/types/PersonSignInProperties.js +36 -0
  76. package/lib/src/types/Team.d.ts +24 -0
  77. package/lib/src/types/Team.js +35 -0
  78. package/lib/src/types/User.d.ts +40 -0
  79. package/lib/src/types/User.js +58 -0
  80. package/lib/src/types/UserRole.d.ts +6 -0
  81. package/lib/src/types/UserRole.js +14 -0
  82. package/lib/src/types/index.js +31 -0
  83. package/lib/tsconfig.tsbuildinfo +1 -0
  84. package/package.json +4 -1
  85. package/eslint.config.js +0 -72
  86. package/src/Firestore.ts +0 -63
  87. package/src/checkAuthentication.ts +0 -36
  88. package/src/firebase/FirebaseConfiguration.ts +0 -39
  89. package/src/firebaseFunctionCreators.ts +0 -56
  90. package/src/functions/fine/add.ts +0 -54
  91. package/src/functions/fine/delete.ts +0 -54
  92. package/src/functions/fine/update.ts +0 -55
  93. package/src/functions/fineTemplate/add.ts +0 -34
  94. package/src/functions/fineTemplate/delete.ts +0 -34
  95. package/src/functions/fineTemplate/update.ts +0 -34
  96. package/src/functions/invitation/invite.ts +0 -28
  97. package/src/functions/invitation/register.ts +0 -54
  98. package/src/functions/invitation/withdraw.ts +0 -24
  99. package/src/functions/notification/register.ts +0 -39
  100. package/src/functions/notification/subscribe.ts +0 -38
  101. package/src/functions/paypalMe/edit.ts +0 -36
  102. package/src/functions/person/add.ts +0 -36
  103. package/src/functions/person/delete.ts +0 -37
  104. package/src/functions/person/update.ts +0 -37
  105. package/src/functions/team/new.ts +0 -54
  106. package/src/functions/user/login.ts +0 -25
  107. package/src/functions/user/roleEdit.ts +0 -44
  108. package/src/locales/de.json +0 -30
  109. package/src/locales/en.json +0 -30
  110. package/src/pushNotification.ts +0 -37
  111. package/src/types/Configuration.ts +0 -54
  112. package/src/types/Fine.ts +0 -59
  113. package/src/types/FineAmount.ts +0 -123
  114. package/src/types/FineTemplate.ts +0 -55
  115. package/src/types/FineTemplateRepetition.ts +0 -54
  116. package/src/types/Invitation.ts +0 -56
  117. package/src/types/MoneyAmount.ts +0 -41
  118. package/src/types/NotificationProperties.ts +0 -67
  119. package/src/types/PayedState.ts +0 -12
  120. package/src/types/Person.ts +0 -56
  121. package/src/types/PersonPrivateProperties.ts +0 -37
  122. package/src/types/PersonSignInProperties.ts +0 -42
  123. package/src/types/Team.ts +0 -49
  124. package/src/types/User.ts +0 -76
  125. package/src/types/UserRole.ts +0 -19
  126. package/tsconfig.json +0 -117
  127. /package/{index.ts → lib/index.d.ts} +0 -0
  128. /package/{src/firebase/index.ts → lib/src/firebase/index.d.ts} +0 -0
  129. /package/{src/types/index.ts → lib/src/types/index.d.ts} +0 -0
@@ -1,123 +0,0 @@
1
- import { Flattable, ITypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
- import { MoneyAmount } from './MoneyAmount';
3
- import * as i18n from 'i18n';
4
- import { Configuration } from './Configuration';
5
-
6
- export type FineAmount =
7
- | FineAmount.Money
8
- | FineAmount.Item;
9
-
10
- export namespace FineAmount {
11
-
12
- export class Money implements Flattable<Money.Flatten> {
13
-
14
- public constructor(
15
- public amount: MoneyAmount
16
- ) {}
17
-
18
- public formatted(configuration: Configuration): string {
19
- return this.amount.formatted(configuration.currency);
20
- }
21
-
22
- public get flatten(): Money.Flatten {
23
- return {
24
- type: 'money',
25
- amount: this.amount.flatten
26
- };
27
- }
28
- }
29
-
30
- export namespace Money {
31
-
32
- export type Flatten = {
33
- type: 'money',
34
- amount: MoneyAmount.Flatten
35
- }
36
-
37
- export class TypeBuilder implements ITypeBuilder<Flatten, Money> {
38
-
39
- public build(value: Flatten): Money {
40
- return new Money(MoneyAmount.builder.build(value.amount));
41
- }
42
- }
43
-
44
- export const builder = new TypeBuilder();
45
- }
46
-
47
- export class Item implements Flattable<Item.Flatten> {
48
-
49
- public constructor(
50
- public item: Item.Type,
51
- public count: number
52
- ) {}
53
-
54
- public formatted(configuration: Configuration): string {
55
- const numberFormat = Intl.NumberFormat(configuration.locale, {
56
- minimumFractionDigits: 0,
57
- maximumFractionDigits: 0
58
- });
59
- if (this.count === 1)
60
- return i18n.__(`FineAmount.Item.Type.${this.item}.singular`, numberFormat.format(this.count));
61
- return i18n.__(`FineAmount.Item.Type.${this.item}.plural`, numberFormat.format(this.count));
62
- }
63
-
64
- public get flatten(): Item.Flatten {
65
- return {
66
- type: 'item',
67
- item: this.item,
68
- count: this.count
69
- };
70
- }
71
- }
72
-
73
- export namespace Item {
74
-
75
- export type Type =
76
- | 'crateOfBeer';
77
-
78
- export namespace Type {
79
-
80
- export const all: Type[] = ['crateOfBeer'];
81
- }
82
-
83
- export type Flatten = {
84
- type: 'item',
85
- item: Item.Type,
86
- count: number
87
- }
88
-
89
- export class TypeBuilder implements ITypeBuilder<Flatten, Item> {
90
-
91
- public build(value: Flatten): Item {
92
- return new Item(value.item, value.count);
93
- }
94
- }
95
-
96
- export const builder = new TypeBuilder();
97
- }
98
-
99
-
100
- export function money(MoneyAmount: MoneyAmount): Money {
101
- return new Money(MoneyAmount);
102
- }
103
-
104
- export function item(item: Item.Type, count: number): Item {
105
- return new Item(item, count);
106
- }
107
-
108
- export type Flatten = Money.Flatten | Item.Flatten;
109
-
110
- export class TypeBuilder implements ITypeBuilder<Flatten, FineAmount> {
111
-
112
- public build(value: Flatten): FineAmount {
113
- switch (value.type) {
114
- case 'money':
115
- return Money.builder.build(value);
116
- case 'item':
117
- return Item.builder.build(value);
118
- }
119
- }
120
- }
121
-
122
- export const builder = new TypeBuilder();
123
- }
@@ -1,55 +0,0 @@
1
- import { Flattable, Guid, ITypeBuilder, Tagged } from '@stevenkellner/typescript-common-functionality';
2
- import { FineAmount } from './FineAmount';
3
- import { FineTemplateRepetition } from './FineTemplateRepetition';
4
-
5
- export class FineTemplate implements Flattable<FineTemplate.Flatten> {
6
-
7
- public constructor(
8
- public id: FineTemplate.Id,
9
- public reason: string,
10
- public amount: FineAmount,
11
- public repetition: FineTemplateRepetition | null
12
- ) {}
13
-
14
- public get flatten(): FineTemplate.Flatten {
15
- return {
16
- id: this.id.flatten,
17
- reason: this.reason,
18
- amount: this.amount.flatten,
19
- repetition: this.repetition === null ? null : this.repetition.flatten
20
- };
21
- }
22
- }
23
-
24
- export namespace FineTemplate {
25
-
26
- export type Id = Tagged<Guid, 'fineTemplate'>;
27
-
28
- export namespace Id {
29
-
30
- export type Flatten = string;
31
-
32
- export const builder = Tagged.builder('fineTemplate' as const, Guid.builder);
33
- }
34
-
35
- export type Flatten = {
36
- id: Id.Flatten,
37
- reason: string,
38
- amount: FineAmount.Flatten,
39
- repetition: FineTemplateRepetition.Flatten | null
40
- };
41
-
42
- export class TypeBuilder implements ITypeBuilder<Flatten, FineTemplate> {
43
-
44
- public build(value: Flatten): FineTemplate {
45
- return new FineTemplate(
46
- Id.builder.build(value.id),
47
- value.reason,
48
- FineAmount.builder.build(value.amount),
49
- value.repetition === null ? null : FineTemplateRepetition.builder.build(value.repetition)
50
- );
51
- }
52
- }
53
-
54
- export const builder = new TypeBuilder();
55
- }
@@ -1,54 +0,0 @@
1
- import { Flattable, ITypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
-
3
- export class FineTemplateRepetition implements Flattable<FineTemplateRepetition.Flatten> {
4
-
5
- public constructor(
6
- public item: FineTemplateRepetition.Item,
7
- public maxCount: number | null
8
- ) {}
9
-
10
- public get flatten(): FineTemplateRepetition.Flatten {
11
- return {
12
- item: this.item,
13
- maxCount: this.maxCount
14
- };
15
- }
16
- }
17
-
18
- export namespace FineTemplateRepetition {
19
-
20
- export type Item =
21
- | 'minute'
22
- | 'day'
23
- | 'item'
24
- | 'count';
25
-
26
- export namespace Item {
27
-
28
- export const all: Item[] = [
29
- 'minute',
30
- 'day',
31
- 'item',
32
- 'count'
33
- ];
34
-
35
- export const builder = new ValueTypeBuilder<Item>();
36
- }
37
-
38
- export type Flatten = {
39
- item: Item,
40
- maxCount: number | null
41
- }
42
-
43
- export class TypeBuilder implements ITypeBuilder<Flatten, FineTemplateRepetition> {
44
-
45
- public build(flatten: Flatten): FineTemplateRepetition {
46
- return new FineTemplateRepetition(
47
- flatten.item,
48
- flatten.maxCount
49
- );
50
- }
51
- }
52
-
53
- export const builder = new TypeBuilder();
54
- }
@@ -1,56 +0,0 @@
1
- import { BytesCoder, Flattable, ITypeBuilder, Sha512, Tagged, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
- import { Team } from './Team';
3
- import { Person } from './Person';
4
-
5
- export class Invitation implements Flattable<Invitation.Flatten> {
6
-
7
- constructor(
8
- public teamId: Team.Id,
9
- public personId: Person.Id
10
- ) {}
11
-
12
- public createId(): Invitation.Id {
13
- const hasher = new Sha512();
14
- const teamIdBytes = BytesCoder.fromUtf8(this.teamId.guidString);
15
- const personIdBytes = BytesCoder.fromUtf8(this.personId.guidString);
16
- const hashedInvitationBytes = hasher.hash(new Uint8Array([...teamIdBytes, ...personIdBytes]));
17
- const rawId = BytesCoder.toHex(hashedInvitationBytes).slice(0, 12);
18
- return new Tagged(rawId, 'invitation');
19
- }
20
-
21
- public get flatten(): Invitation.Flatten {
22
- return {
23
- teamId: this.teamId.flatten,
24
- personId: this.personId.flatten
25
- };
26
- }
27
- }
28
-
29
- export namespace Invitation {
30
-
31
- export type Id = Tagged<string, 'invitation'>;
32
-
33
- export namespace Id {
34
-
35
- export type Flatten = string;
36
-
37
- export const builder = Tagged.builder('invitation' as const, new ValueTypeBuilder<string>());
38
- }
39
-
40
- export type Flatten = {
41
- teamId: Team.Id.Flatten,
42
- personId: Person.Id.Flatten
43
- };
44
-
45
- export class TypeBuilder implements ITypeBuilder<Flatten, Invitation> {
46
-
47
- public build(value: Flatten): Invitation {
48
- return new Invitation(
49
- Team.Id.builder.build(value.teamId),
50
- Person.Id.builder.build(value.personId)
51
- );
52
- }
53
- }
54
-
55
- export const builder = new TypeBuilder();
56
- }
@@ -1,41 +0,0 @@
1
- import { Flattable, ITypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
- import * as i18n from 'i18n';
3
- import { Configuration } from './Configuration';
4
-
5
- export class MoneyAmount implements Flattable<MoneyAmount.Flatten> {
6
-
7
- public constructor(
8
- public value: number,
9
- public subunitValue: number
10
- ) {}
11
-
12
- public static zero(): MoneyAmount {
13
- return new MoneyAmount(0, 0);
14
- }
15
-
16
- public formatted(currency: Configuration.Currency): string {
17
- const numberFormat = Intl.NumberFormat(i18n.getLocale(), {
18
- style: 'currency',
19
- currency: currency
20
- });
21
- return numberFormat.format(this.value + this.subunitValue / 100);
22
- }
23
-
24
- public get flatten(): MoneyAmount.Flatten {
25
- return this.value + this.subunitValue / 100;
26
- }
27
- }
28
-
29
- export namespace MoneyAmount {
30
-
31
- export type Flatten = number;
32
-
33
- export class TypeBuilder implements ITypeBuilder<Flatten, MoneyAmount> {
34
-
35
- public build(value: Flatten): MoneyAmount {
36
- return new MoneyAmount(Math.floor(value), Math.round((value - Math.floor(value)) * 100));
37
- }
38
- }
39
-
40
- export const builder = new MoneyAmount.TypeBuilder();
41
- }
@@ -1,67 +0,0 @@
1
- import { BytesCoder, Dictionary, Flattable, ITypeBuilder, Sha512, Tagged, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
-
3
- export class NotificationProperties implements Flattable<NotificationProperties.Flatten> {
4
-
5
- public constructor(
6
- public tokens: Dictionary<NotificationProperties.TokenId, string> = new Dictionary(NotificationProperties.TokenId.builder),
7
- public subscriptions: NotificationProperties.Subscription[] = []
8
- ) {}
9
-
10
- public get flatten(): NotificationProperties.Flatten {
11
- return {
12
- tokens: this.tokens.flatten,
13
- subscriptions: this.subscriptions
14
- };
15
- }
16
- }
17
-
18
- export namespace NotificationProperties {
19
-
20
- export type TokenId = Tagged<string, 'notificationToken'>;
21
-
22
- export namespace TokenId {
23
-
24
- export function create(token: string): TokenId {
25
- const hasher = new Sha512();
26
- const tokenBytes = BytesCoder.fromUtf8(token);
27
- const tokenIdBytes = hasher.hash(tokenBytes);
28
- const tokenId = BytesCoder.toHex(tokenIdBytes);
29
- const rawId = tokenId.slice(0, 16);
30
- return new Tagged(rawId, 'notificationToken');
31
- }
32
-
33
- export type Flatten = string;
34
-
35
- export const builder = Tagged.builder('notificationToken' as const, new ValueTypeBuilder<string>());
36
- }
37
-
38
- export type Subscription =
39
- | 'new-fine'
40
- | 'fine-reminder'
41
- | 'fine-state-change';
42
-
43
- export namespace Subscription {
44
-
45
- export const all: Subscription[] = [
46
- 'new-fine',
47
- 'fine-reminder',
48
- 'fine-state-change'
49
- ]
50
-
51
- export const builder = new ValueTypeBuilder<Subscription>();
52
- }
53
-
54
- export type Flatten = {
55
- tokens: Dictionary.Flatten<string>,
56
- subscriptions: Subscription[]
57
- };
58
-
59
- export class TypeBuilder implements ITypeBuilder<Flatten, NotificationProperties> {
60
-
61
- public build(value: Flatten): NotificationProperties {
62
- return new NotificationProperties(Dictionary.builder(TokenId.builder, new ValueTypeBuilder<string>()).build(value.tokens), value.subscriptions);
63
- }
64
- }
65
-
66
- export const builder = new TypeBuilder();
67
- }
@@ -1,12 +0,0 @@
1
- import { ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
-
3
- export type PayedState =
4
- | 'payed'
5
- | 'notPayed';
6
-
7
- export namespace PayedState {
8
-
9
- export const all: PayedState[] = ['payed', 'notPayed'];
10
-
11
- export const builder = new ValueTypeBuilder<PayedState>();
12
- }
@@ -1,56 +0,0 @@
1
- import { PersonPrivateProperties } from './PersonPrivateProperties';
2
- import { PersonSignInProperties } from './PersonSignInProperties';
3
- import { Fine } from './Fine';
4
- import { Flattable, Guid, ITypeBuilder, Tagged } from '@stevenkellner/typescript-common-functionality';
5
-
6
- export class Person implements Flattable<Person.Flatten> {
7
-
8
- public constructor(
9
- public id: Person.Id,
10
- public properties: PersonPrivateProperties,
11
- public fineIds: Fine.Id[] = [],
12
- public signInProperties: PersonSignInProperties | null = null
13
- ) {}
14
-
15
- public get flatten(): Person.Flatten {
16
- return {
17
- id: this.id.flatten,
18
- properties: this.properties.flatten,
19
- fineIds: this.fineIds.map(fineId => fineId.flatten),
20
- signInProperties: this.signInProperties?.flatten ?? null
21
- };
22
- }
23
- }
24
-
25
- export namespace Person {
26
-
27
- export type Id = Tagged<Guid, 'person'>;
28
-
29
- export namespace Id {
30
-
31
- export type Flatten = string;
32
-
33
- export const builder = Tagged.builder('person' as const, Guid.builder);
34
- }
35
-
36
- export type Flatten = {
37
- id: Id.Flatten,
38
- properties: PersonPrivateProperties.Flatten,
39
- fineIds: Fine.Id.Flatten[],
40
- signInProperties: PersonSignInProperties.Flatten | null,
41
- }
42
-
43
- export class TypeBuilder implements ITypeBuilder<Flatten, Person> {
44
-
45
- public build(value: Flatten): Person {
46
- return new Person(
47
- Id.builder.build(value.id),
48
- PersonPrivateProperties.builder.build(value.properties),
49
- value.fineIds.map(fineId => Fine.Id.builder.build(fineId)),
50
- value.signInProperties ? PersonSignInProperties.builder.build(value.signInProperties) : null
51
- );
52
- }
53
- }
54
-
55
- export const builder = new TypeBuilder();
56
- }
@@ -1,37 +0,0 @@
1
- import { Flattable, ITypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
-
3
- export class PersonPrivateProperties implements Flattable<PersonPrivateProperties.Flatten> {
4
-
5
- constructor(
6
- public firstName: string,
7
- public lastName: string | null
8
- ) {}
9
-
10
- public get flatten(): PersonPrivateProperties.Flatten {
11
- return {
12
- firstName: this.firstName,
13
- lastName: this.lastName
14
- };
15
- }
16
- }
17
-
18
- export namespace PersonPrivateProperties {
19
-
20
- export type Flatten = {
21
- firstName: string;
22
- lastName: string | null;
23
- }
24
-
25
- export class TypeBuilder implements ITypeBuilder<Flatten, PersonPrivateProperties> {
26
-
27
- public build(value: Flatten): PersonPrivateProperties {
28
- return new PersonPrivateProperties(
29
- value.firstName,
30
- value.lastName
31
- );
32
- }
33
- }
34
-
35
- export const builder = new TypeBuilder();
36
- }
37
-
@@ -1,42 +0,0 @@
1
- import { Flattable, ITypeBuilder, UtcDate } from '@stevenkellner/typescript-common-functionality';
2
- import { NotificationProperties } from './NotificationProperties';
3
- import { User } from './User';
4
- import { UserRole } from './UserRole';
5
-
6
- export class PersonSignInProperties implements Flattable<PersonSignInProperties.Flatten> {
7
-
8
- public constructor(
9
- public userId: User.Id,
10
- public signInDate: UtcDate,
11
- public notificationProperties: NotificationProperties = new NotificationProperties(),
12
- public roles: UserRole[] = []
13
- ) {}
14
-
15
- public get flatten(): PersonSignInProperties.Flatten {
16
- return {
17
- userId: this.userId.flatten,
18
- signInDate: this.signInDate.flatten,
19
- notificationProperties: this.notificationProperties.flatten,
20
- roles: this.roles
21
- };
22
- }
23
- }
24
-
25
- export namespace PersonSignInProperties {
26
-
27
- export type Flatten = {
28
- userId: User.Id.Flatten
29
- signInDate: UtcDate.Flatten,
30
- notificationProperties: NotificationProperties.Flatten,
31
- roles: UserRole[]
32
- }
33
-
34
- export class TypeBuilder implements ITypeBuilder<Flatten, PersonSignInProperties> {
35
-
36
- public build(value: Flatten): PersonSignInProperties {
37
- return new PersonSignInProperties(User.Id.builder.build(value.userId), UtcDate.builder.build(value.signInDate), NotificationProperties.builder.build(value.notificationProperties), value.roles);
38
- }
39
- }
40
-
41
- export const builder = new TypeBuilder();
42
- }
package/src/types/Team.ts DELETED
@@ -1,49 +0,0 @@
1
- import { Flattable, Guid, ITypeBuilder, Tagged } from '@stevenkellner/typescript-common-functionality';
2
-
3
- export class Team implements Flattable<Team.Flatten> {
4
-
5
- public constructor(
6
- public id: Team.Id,
7
- public name: string,
8
- public paypalMeLink: string | null
9
- ) {}
10
-
11
- public get flatten(): Team.Flatten {
12
- return {
13
- id: this.id.flatten,
14
- name: this.name,
15
- paypalMeLink: this.paypalMeLink
16
- };
17
- }
18
- }
19
-
20
- export namespace Team {
21
-
22
- export type Id = Tagged<Guid, 'team'>;
23
-
24
- export namespace Id {
25
-
26
- export type Flatten = string;
27
-
28
- export const builder = Tagged.builder('team' as const, Guid.builder);
29
- }
30
-
31
- export type Flatten = {
32
- id: Id.Flatten,
33
- name: string,
34
- paypalMeLink: string | null
35
- }
36
-
37
- export class TypeBuilder implements ITypeBuilder<Flatten, Team> {
38
-
39
- public build(value: Flatten): Team {
40
- return new Team(
41
- Id.builder.build(value.id),
42
- value.name,
43
- value.paypalMeLink
44
- );
45
- }
46
- }
47
-
48
- export const builder = new TypeBuilder();
49
- }
package/src/types/User.ts DELETED
@@ -1,76 +0,0 @@
1
- import { Dictionary, Flattable, ITypeBuilder, Tagged, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
- import { Team } from './Team';
3
- import { Person } from './Person';
4
-
5
- export class User implements Flattable<User.Flatten> {
6
-
7
- public constructor(
8
- public id: User.Id,
9
- public teams: Dictionary<Team.Id, User.TeamProperties> = new Dictionary(Team.Id.builder)
10
- ) {}
11
-
12
- public get flatten(): User.Flatten {
13
- return {
14
- id: this.id.flatten,
15
- teams: this.teams.flatten
16
- };
17
- }
18
- }
19
-
20
- export namespace User {
21
-
22
- export type Id = Tagged<string, 'user'>;
23
-
24
- export namespace Id {
25
-
26
- export type Flatten = string;
27
-
28
- export const builder = Tagged.builder('user' as const, new ValueTypeBuilder<string>());
29
- }
30
-
31
- export class TeamProperties implements Flattable<TeamProperties.Flatten> {
32
-
33
- public constructor(
34
- public name: string,
35
- public personId: Person.Id
36
- ) {}
37
-
38
- public get flatten(): TeamProperties.Flatten {
39
- return {
40
- name: this.name,
41
- personId: this.personId.flatten
42
- };
43
- }
44
- }
45
-
46
- export namespace TeamProperties {
47
-
48
- export type Flatten = {
49
- name: string,
50
- personId: Person.Id.Flatten
51
- };
52
-
53
- export class TypeBuilder implements ITypeBuilder<Flatten, TeamProperties> {
54
-
55
- public build(value: Flatten): TeamProperties {
56
- return new TeamProperties(value.name, Person.Id.builder.build(value.personId));
57
- }
58
- }
59
-
60
- export const builder = new TypeBuilder();
61
- }
62
-
63
- export type Flatten = {
64
- id: Id.Flatten,
65
- teams: Dictionary.Flatten<TeamProperties>
66
- }
67
-
68
- export class TypeBuilder implements ITypeBuilder<Flatten, User> {
69
-
70
- public build(value: Flatten): User {
71
- return new User(Id.builder.build(value.id), Dictionary.builder(Team.Id.builder, User.TeamProperties.builder).build(value.teams));
72
- }
73
- }
74
-
75
- export const builder = new TypeBuilder();
76
- }
@@ -1,19 +0,0 @@
1
- import { ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
-
3
- export type UserRole =
4
- | 'person-manager'
5
- | 'fineTemplate-manager'
6
- | 'fine-manager'
7
- | 'team-manager';
8
-
9
- export namespace UserRole {
10
-
11
- export const all: UserRole[] = [
12
- 'person-manager',
13
- 'fineTemplate-manager',
14
- 'fine-manager',
15
- 'team-manager'
16
- ];
17
-
18
- export const builder = new ValueTypeBuilder<UserRole>();
19
- }