@stevenkellner/team-conduct-api 2.0.20 → 2.0.22

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.
@@ -14,7 +14,12 @@ export declare class FineAddFunction implements FirebaseFunction<FineAddFunction
14
14
  personId: string;
15
15
  fine: {
16
16
  id: Fine.Id.Flatten;
17
- payedState: import("../../types").PayedState;
17
+ payedState: {
18
+ type: "payed";
19
+ payedDate: import("@stevenkellner/typescript-common-functionality").UtcDate.Flatten;
20
+ } | {
21
+ type: "notPayed";
22
+ };
18
23
  date: import("@stevenkellner/typescript-common-functionality").UtcDate.Flatten;
19
24
  reason: string;
20
25
  amount: {
@@ -14,7 +14,12 @@ export declare class FineUpdateFunction implements FirebaseFunction<FineUpdateFu
14
14
  personId: string;
15
15
  fine: {
16
16
  id: Fine.Id.Flatten;
17
- payedState: import("../../types").PayedState;
17
+ payedState: {
18
+ type: "payed";
19
+ payedDate: import("@stevenkellner/typescript-common-functionality").UtcDate.Flatten;
20
+ } | {
21
+ type: "notPayed";
22
+ };
18
23
  date: import("@stevenkellner/typescript-common-functionality").UtcDate.Flatten;
19
24
  reason: string;
20
25
  amount: {
@@ -14,7 +14,7 @@ export declare class PersonAddFunction implements FirebaseFunction<PersonAddFunc
14
14
  id: string;
15
15
  properties: {
16
16
  firstName: string;
17
- lastName: string | null;
17
+ lastName: string;
18
18
  };
19
19
  }, PersonAddFunction.Parameters>;
20
20
  returnTypeBuilder: ValueTypeBuilder<void>;
@@ -14,7 +14,7 @@ export declare class PersonUpdateFunction implements FirebaseFunction<PersonUpda
14
14
  id: string;
15
15
  properties: {
16
16
  firstName: string;
17
- lastName: string | null;
17
+ lastName: string;
18
18
  };
19
19
  }, PersonUpdateFunction.Parameters>;
20
20
  returnTypeBuilder: ValueTypeBuilder<void>;
@@ -18,7 +18,7 @@ export declare class Fine implements Flattable<Fine.Flatten> {
18
18
  * Creates a new Fine instance.
19
19
  *
20
20
  * @param id - Unique identifier for the fine (GUID)
21
- * @param payedState - Payment status ('payed' or 'notPayed')
21
+ * @param payedState - Payment status (Payed with date, or NotPayed)
22
22
  * @param date - Date when the fine was issued
23
23
  * @param reason - Description or reason for the fine
24
24
  * @param amount - Monetary amount of the fine
@@ -251,7 +251,7 @@ export declare namespace Fine {
251
251
  */
252
252
  type Flatten = {
253
253
  id: Id.Flatten;
254
- payedState: PayedState;
254
+ payedState: PayedState.Flatten;
255
255
  date: UtcDate.Flatten;
256
256
  reason: string;
257
257
  amount: Amount.Flatten;
@@ -4,6 +4,7 @@ exports.Fine = void 0;
4
4
  const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
5
5
  const Money_1 = require("../Money");
6
6
  const Localization_1 = require("../localization/Localization");
7
+ const PayedState_1 = require("./PayedState");
7
8
  /**
8
9
  * Represents a fine assigned to a person in a team.
9
10
  *
@@ -19,7 +20,7 @@ class Fine {
19
20
  * Creates a new Fine instance.
20
21
  *
21
22
  * @param id - Unique identifier for the fine (GUID)
22
- * @param payedState - Payment status ('payed' or 'notPayed')
23
+ * @param payedState - Payment status (Payed with date, or NotPayed)
23
24
  * @param date - Date when the fine was issued
24
25
  * @param reason - Description or reason for the fine
25
26
  * @param amount - Monetary amount of the fine
@@ -37,7 +38,7 @@ class Fine {
37
38
  get flatten() {
38
39
  return {
39
40
  id: this.id.flatten,
40
- payedState: this.payedState,
41
+ payedState: this.payedState.flatten,
41
42
  date: this.date.flatten,
42
43
  reason: this.reason,
43
44
  amount: this.amount.flatten
@@ -307,7 +308,7 @@ exports.Fine = Fine;
307
308
  * @returns Fine instance
308
309
  */
309
310
  build(value) {
310
- return new Fine(Id.builder.build(value.id), value.payedState, typescript_common_functionality_1.UtcDate.builder.build(value.date), value.reason, Amount.builder.build(value.amount));
311
+ return new Fine(Id.builder.build(value.id), PayedState_1.PayedState.builder.build(value.payedState), typescript_common_functionality_1.UtcDate.builder.build(value.date), value.reason, Amount.builder.build(value.amount));
311
312
  }
312
313
  }
313
314
  Fine.TypeBuilder = TypeBuilder;
@@ -1,17 +1,58 @@
1
- import { ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
1
+ import { Flattable, ITypeBuilder, UtcDate } from '@stevenkellner/typescript-common-functionality';
2
2
  import { Locale } from '../localization/Locale';
3
- declare const payedStates: readonly ["payed", "notPayed"];
4
3
  /**
5
4
  * Represents the payment status of a fine.
6
5
  *
7
- * Can be either 'payed' (fine has been paid) or 'notPayed' (fine is unpaid).
6
+ * Can be either Payed (with the date it was paid) or NotPayed.
8
7
  */
9
- export type PayedState = typeof payedStates[number];
8
+ export type PayedState = PayedState.Payed | PayedState.NotPayed;
10
9
  export declare namespace PayedState {
11
10
  /**
12
- * Array containing all possible payment states.
11
+ * Represents a fine that has been paid, including the date of payment.
13
12
  */
14
- const all: readonly PayedState[];
13
+ class Payed implements Flattable<Payed.Flatten> {
14
+ payedDate: UtcDate;
15
+ readonly type: "payed";
16
+ constructor(payedDate: UtcDate);
17
+ get flatten(): Payed.Flatten;
18
+ }
19
+ namespace Payed {
20
+ type Flatten = {
21
+ type: 'payed';
22
+ payedDate: UtcDate.Flatten;
23
+ };
24
+ class TypeBuilder implements ITypeBuilder<Flatten, Payed> {
25
+ build(value: Flatten): Payed;
26
+ }
27
+ const builder: TypeBuilder;
28
+ }
29
+ /**
30
+ * Represents a fine that has not yet been paid.
31
+ */
32
+ class NotPayed implements Flattable<NotPayed.Flatten> {
33
+ readonly type: "notPayed";
34
+ get flatten(): NotPayed.Flatten;
35
+ }
36
+ namespace NotPayed {
37
+ type Flatten = {
38
+ type: 'notPayed';
39
+ };
40
+ class TypeBuilder implements ITypeBuilder<Flatten, NotPayed> {
41
+ build(_value: Flatten): NotPayed;
42
+ }
43
+ const builder: TypeBuilder;
44
+ }
45
+ /**
46
+ * Flattened representation of PayedState for serialization.
47
+ */
48
+ type Flatten = Payed.Flatten | NotPayed.Flatten;
49
+ /**
50
+ * Type builder for PayedState serialization/deserialization.
51
+ */
52
+ class TypeBuilder implements ITypeBuilder<Flatten, PayedState> {
53
+ build(value: Flatten): PayedState;
54
+ }
55
+ const builder: TypeBuilder;
15
56
  /**
16
57
  * Returns the localized display string for a payment state.
17
58
  *
@@ -21,15 +62,18 @@ export declare namespace PayedState {
21
62
  */
22
63
  function formatted(state: PayedState, locale: Locale): string;
23
64
  /**
24
- * Toggles the payment state between 'payed' and 'notPayed'.
65
+ * Toggles the payment state. Toggling to 'payed' uses the current date.
25
66
  *
26
67
  * @param state - The current payment state
27
68
  * @returns The toggled payment state
28
69
  */
29
70
  function toggled(state: PayedState): PayedState;
30
71
  /**
31
- * Type builder for PayedState serialization/deserialization.
72
+ * Creates a payed state with the given date.
73
+ */
74
+ function payed(payedDate: UtcDate): Payed;
75
+ /**
76
+ * Creates a notPayed state.
32
77
  */
33
- const builder: ValueTypeBuilder<"payed" | "notPayed">;
78
+ function notPayed(): NotPayed;
34
79
  }
35
- export {};
@@ -3,13 +3,69 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PayedState = void 0;
4
4
  const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
5
5
  const Localization_1 = require("../localization/Localization");
6
- const payedStates = ['payed', 'notPayed'];
7
6
  var PayedState;
8
7
  (function (PayedState) {
9
8
  /**
10
- * Array containing all possible payment states.
9
+ * Represents a fine that has been paid, including the date of payment.
11
10
  */
12
- PayedState.all = payedStates;
11
+ class Payed {
12
+ payedDate;
13
+ type = 'payed';
14
+ constructor(payedDate) {
15
+ this.payedDate = payedDate;
16
+ }
17
+ get flatten() {
18
+ return {
19
+ type: 'payed',
20
+ payedDate: this.payedDate.flatten
21
+ };
22
+ }
23
+ }
24
+ PayedState.Payed = Payed;
25
+ (function (Payed) {
26
+ class TypeBuilder {
27
+ build(value) {
28
+ return new Payed(typescript_common_functionality_1.UtcDate.builder.build(value.payedDate));
29
+ }
30
+ }
31
+ Payed.TypeBuilder = TypeBuilder;
32
+ Payed.builder = new TypeBuilder();
33
+ })(Payed = PayedState.Payed || (PayedState.Payed = {}));
34
+ /**
35
+ * Represents a fine that has not yet been paid.
36
+ */
37
+ class NotPayed {
38
+ type = 'notPayed';
39
+ get flatten() {
40
+ return { type: 'notPayed' };
41
+ }
42
+ }
43
+ PayedState.NotPayed = NotPayed;
44
+ (function (NotPayed) {
45
+ class TypeBuilder {
46
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
47
+ build(_value) {
48
+ return new NotPayed();
49
+ }
50
+ }
51
+ NotPayed.TypeBuilder = TypeBuilder;
52
+ NotPayed.builder = new TypeBuilder();
53
+ })(NotPayed = PayedState.NotPayed || (PayedState.NotPayed = {}));
54
+ /**
55
+ * Type builder for PayedState serialization/deserialization.
56
+ */
57
+ class TypeBuilder {
58
+ build(value) {
59
+ switch (value.type) {
60
+ case 'payed':
61
+ return Payed.builder.build(value);
62
+ case 'notPayed':
63
+ return NotPayed.builder.build(value);
64
+ }
65
+ }
66
+ }
67
+ PayedState.TypeBuilder = TypeBuilder;
68
+ PayedState.builder = new TypeBuilder();
13
69
  /**
14
70
  * Returns the localized display string for a payment state.
15
71
  *
@@ -18,26 +74,36 @@ var PayedState;
18
74
  * @returns Localized string representation of the payment state
19
75
  */
20
76
  function formatted(state, locale) {
21
- return Localization_1.Localization.shared(locale).payedState[state].value();
77
+ return Localization_1.Localization.shared(locale).payedState[state.type].value();
22
78
  }
23
79
  PayedState.formatted = formatted;
24
80
  /**
25
- * Toggles the payment state between 'payed' and 'notPayed'.
81
+ * Toggles the payment state. Toggling to 'payed' uses the current date.
26
82
  *
27
83
  * @param state - The current payment state
28
84
  * @returns The toggled payment state
29
85
  */
30
86
  function toggled(state) {
31
- switch (state) {
87
+ switch (state.type) {
32
88
  case 'payed':
33
- return 'notPayed';
89
+ return new NotPayed();
34
90
  case 'notPayed':
35
- return 'payed';
91
+ return new Payed(typescript_common_functionality_1.UtcDate.now);
36
92
  }
37
93
  }
38
94
  PayedState.toggled = toggled;
39
95
  /**
40
- * Type builder for PayedState serialization/deserialization.
96
+ * Creates a payed state with the given date.
41
97
  */
42
- PayedState.builder = new typescript_common_functionality_1.ValueTypeBuilder();
98
+ function payed(payedDate) {
99
+ return new Payed(payedDate);
100
+ }
101
+ PayedState.payed = payed;
102
+ /**
103
+ * Creates a notPayed state.
104
+ */
105
+ function notPayed() {
106
+ return new NotPayed();
107
+ }
108
+ PayedState.notPayed = notPayed;
43
109
  })(PayedState || (exports.PayedState = PayedState = {}));
@@ -6,14 +6,14 @@ import { Flattable, ITypeBuilder } from '@stevenkellner/typescript-common-functi
6
6
  */
7
7
  export declare class PersonProperties implements Flattable<PersonProperties.Flatten> {
8
8
  firstName: string;
9
- lastName: string | null;
9
+ lastName: string;
10
10
  /**
11
11
  * Creates new person properties.
12
12
  *
13
13
  * @param firstName - The first name of the person
14
14
  * @param lastName - The last name of the person (null if not provided)
15
15
  */
16
- constructor(firstName: string, lastName?: string | null);
16
+ constructor(firstName: string, lastName: string);
17
17
  /**
18
18
  * Gets the flattened representation of these properties for serialization.
19
19
  */
@@ -25,7 +25,7 @@ export declare namespace PersonProperties {
25
25
  */
26
26
  type Flatten = {
27
27
  firstName: string;
28
- lastName: string | null;
28
+ lastName: string;
29
29
  };
30
30
  /**
31
31
  * Builder for constructing PersonProperties from flattened data.
@@ -15,7 +15,7 @@ class PersonProperties {
15
15
  * @param firstName - The first name of the person
16
16
  * @param lastName - The last name of the person (null if not provided)
17
17
  */
18
- constructor(firstName, lastName = null) {
18
+ constructor(firstName, lastName) {
19
19
  this.firstName = firstName;
20
20
  this.lastName = lastName;
21
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stevenkellner/team-conduct-api",
3
- "version": "2.0.20",
3
+ "version": "2.0.22",
4
4
  "description": "Firebase API for Team Conduct",
5
5
  "license": "MIT",
6
6
  "author": "Steven Kellner",
@@ -16,7 +16,7 @@ export class Fine implements Flattable<Fine.Flatten> {
16
16
  * Creates a new Fine instance.
17
17
  *
18
18
  * @param id - Unique identifier for the fine (GUID)
19
- * @param payedState - Payment status ('payed' or 'notPayed')
19
+ * @param payedState - Payment status (Payed with date, or NotPayed)
20
20
  * @param date - Date when the fine was issued
21
21
  * @param reason - Description or reason for the fine
22
22
  * @param amount - Monetary amount of the fine
@@ -35,7 +35,7 @@ export class Fine implements Flattable<Fine.Flatten> {
35
35
  public get flatten(): Fine.Flatten {
36
36
  return {
37
37
  id: this.id.flatten,
38
- payedState: this.payedState,
38
+ payedState: this.payedState.flatten,
39
39
  date: this.date.flatten,
40
40
  reason: this.reason,
41
41
  amount: this.amount.flatten
@@ -364,7 +364,7 @@ export namespace Fine {
364
364
  */
365
365
  export type Flatten = {
366
366
  id: Id.Flatten,
367
- payedState: PayedState,
367
+ payedState: PayedState.Flatten,
368
368
  date: UtcDate.Flatten,
369
369
  reason: string,
370
370
  amount: Amount.Flatten
@@ -384,7 +384,7 @@ export namespace Fine {
384
384
  public build(value: Flatten): Fine {
385
385
  return new Fine(
386
386
  Id.builder.build(value.id),
387
- value.payedState,
387
+ PayedState.builder.build(value.payedState),
388
388
  UtcDate.builder.build(value.date),
389
389
  value.reason,
390
390
  Amount.builder.build(value.amount)
@@ -1,22 +1,101 @@
1
- import { ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
1
+ import { Flattable, ITypeBuilder, UtcDate } from '@stevenkellner/typescript-common-functionality';
2
2
  import { Localization } from '../localization/Localization';
3
3
  import { Locale } from '../localization/Locale';
4
4
 
5
- const payedStates = ['payed', 'notPayed'] as const;
6
-
7
5
  /**
8
6
  * Represents the payment status of a fine.
9
7
  *
10
- * Can be either 'payed' (fine has been paid) or 'notPayed' (fine is unpaid).
8
+ * Can be either Payed (with the date it was paid) or NotPayed.
11
9
  */
12
- export type PayedState = typeof payedStates[number];
10
+ export type PayedState =
11
+ | PayedState.Payed
12
+ | PayedState.NotPayed;
13
13
 
14
14
  export namespace PayedState {
15
15
 
16
16
  /**
17
- * Array containing all possible payment states.
17
+ * Represents a fine that has been paid, including the date of payment.
18
18
  */
19
- export const all: readonly PayedState[] = payedStates;
19
+ export class Payed implements Flattable<Payed.Flatten> {
20
+
21
+ public readonly type = 'payed' as const;
22
+
23
+ public constructor(
24
+ public payedDate: UtcDate
25
+ ) {}
26
+
27
+ public get flatten(): Payed.Flatten {
28
+ return {
29
+ type: 'payed',
30
+ payedDate: this.payedDate.flatten
31
+ };
32
+ }
33
+ }
34
+
35
+ export namespace Payed {
36
+
37
+ export type Flatten = {
38
+ type: 'payed',
39
+ payedDate: UtcDate.Flatten
40
+ };
41
+
42
+ export class TypeBuilder implements ITypeBuilder<Flatten, Payed> {
43
+ public build(value: Flatten): Payed {
44
+ return new Payed(UtcDate.builder.build(value.payedDate));
45
+ }
46
+ }
47
+
48
+ export const builder = new TypeBuilder();
49
+ }
50
+
51
+ /**
52
+ * Represents a fine that has not yet been paid.
53
+ */
54
+ export class NotPayed implements Flattable<NotPayed.Flatten> {
55
+
56
+ public readonly type = 'notPayed' as const;
57
+
58
+ public get flatten(): NotPayed.Flatten {
59
+ return { type: 'notPayed' };
60
+ }
61
+ }
62
+
63
+ export namespace NotPayed {
64
+
65
+ export type Flatten = {
66
+ type: 'notPayed'
67
+ };
68
+
69
+ export class TypeBuilder implements ITypeBuilder<Flatten, NotPayed> {
70
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
71
+ public build(_value: Flatten): NotPayed {
72
+ return new NotPayed();
73
+ }
74
+ }
75
+
76
+ export const builder = new TypeBuilder();
77
+ }
78
+
79
+ /**
80
+ * Flattened representation of PayedState for serialization.
81
+ */
82
+ export type Flatten = Payed.Flatten | NotPayed.Flatten;
83
+
84
+ /**
85
+ * Type builder for PayedState serialization/deserialization.
86
+ */
87
+ export class TypeBuilder implements ITypeBuilder<Flatten, PayedState> {
88
+ public build(value: Flatten): PayedState {
89
+ switch (value.type) {
90
+ case 'payed':
91
+ return Payed.builder.build(value);
92
+ case 'notPayed':
93
+ return NotPayed.builder.build(value);
94
+ }
95
+ }
96
+ }
97
+
98
+ export const builder = new TypeBuilder();
20
99
 
21
100
  /**
22
101
  * Returns the localized display string for a payment state.
@@ -26,26 +105,35 @@ export namespace PayedState {
26
105
  * @returns Localized string representation of the payment state
27
106
  */
28
107
  export function formatted(state: PayedState, locale: Locale): string {
29
- return Localization.shared(locale).payedState[state].value();
108
+ return Localization.shared(locale).payedState[state.type].value();
30
109
  }
31
110
 
32
111
  /**
33
- * Toggles the payment state between 'payed' and 'notPayed'.
112
+ * Toggles the payment state. Toggling to 'payed' uses the current date.
34
113
  *
35
114
  * @param state - The current payment state
36
115
  * @returns The toggled payment state
37
116
  */
38
117
  export function toggled(state: PayedState): PayedState {
39
- switch (state) {
118
+ switch (state.type) {
40
119
  case 'payed':
41
- return 'notPayed';
120
+ return new NotPayed();
42
121
  case 'notPayed':
43
- return 'payed';
122
+ return new Payed(UtcDate.now);
44
123
  }
45
124
  }
46
125
 
47
126
  /**
48
- * Type builder for PayedState serialization/deserialization.
127
+ * Creates a payed state with the given date.
49
128
  */
50
- export const builder = new ValueTypeBuilder<PayedState>();
129
+ export function payed(payedDate: UtcDate): Payed {
130
+ return new Payed(payedDate);
131
+ }
132
+
133
+ /**
134
+ * Creates a notPayed state.
135
+ */
136
+ export function notPayed(): NotPayed {
137
+ return new NotPayed();
138
+ }
51
139
  }
@@ -15,7 +15,7 @@ export class PersonProperties implements Flattable<PersonProperties.Flatten> {
15
15
  */
16
16
  constructor(
17
17
  public firstName: string,
18
- public lastName: string | null = null
18
+ public lastName: string
19
19
  ) {}
20
20
 
21
21
  /**
@@ -36,7 +36,7 @@ export namespace PersonProperties {
36
36
  */
37
37
  export type Flatten = {
38
38
  firstName: string;
39
- lastName: string | null;
39
+ lastName: string;
40
40
  }
41
41
 
42
42
  /**