@stevenkellner/team-conduct-api 1.0.15 → 1.0.17

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.
@@ -45,6 +45,7 @@ export declare namespace FineAmount {
45
45
  }
46
46
  function money(MoneyAmount: MoneyAmount): Money;
47
47
  function item(item: Item.Type, count: number): Item;
48
+ function compare(lhs: FineAmount, rhs: FineAmount): 'less' | 'equal' | 'greater';
48
49
  type Flatten = Money.Flatten | Item.Flatten;
49
50
  class TypeBuilder implements ITypeBuilder<Flatten, FineAmount> {
50
51
  build(value: Flatten): FineAmount;
@@ -77,6 +77,25 @@ var FineAmount;
77
77
  return new Item(item, count);
78
78
  }
79
79
  FineAmount.item = item;
80
+ function compare(lhs, rhs) {
81
+ if (lhs instanceof Money) {
82
+ if (!(rhs instanceof Money))
83
+ return 'greater';
84
+ const lhsAmount = lhs.amount.completeValue;
85
+ const rhsAmount = rhs.amount.completeValue;
86
+ if (lhsAmount !== rhsAmount)
87
+ return lhsAmount < rhsAmount ? 'less' : 'greater';
88
+ }
89
+ if (lhs instanceof Item) {
90
+ if (!(rhs instanceof Item))
91
+ return 'less';
92
+ if (lhs.count === rhs.count)
93
+ return 'equal';
94
+ return lhs.count < rhs.count ? 'less' : 'greater';
95
+ }
96
+ return 'equal';
97
+ }
98
+ FineAmount.compare = compare;
80
99
  class TypeBuilder {
81
100
  build(value) {
82
101
  switch (value.type) {
@@ -9,6 +9,7 @@ export declare class Person implements Flattable<Person.Flatten> {
9
9
  signInProperties: PersonSignInProperties | null;
10
10
  constructor(id: Person.Id, properties: PersonPrivateProperties, fineIds?: Fine.Id[], signInProperties?: PersonSignInProperties | null);
11
11
  get flatten(): Person.Flatten;
12
+ get name(): string;
12
13
  }
13
14
  export declare namespace Person {
14
15
  type Id = Tagged<Guid, 'person'>;
@@ -24,6 +24,11 @@ class Person {
24
24
  signInProperties: this.signInProperties?.flatten ?? null
25
25
  };
26
26
  }
27
+ get name() {
28
+ if (this.properties.lastName === null)
29
+ return this.properties.firstName;
30
+ return `${this.properties.firstName} ${this.properties.lastName}`;
31
+ }
27
32
  }
28
33
  exports.Person = Person;
29
34
  (function (Person) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stevenkellner/team-conduct-api",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "Firebase API for Team Conduct",
5
5
  "license": "MIT",
6
6
  "author": "Steven Kellner",
@@ -107,6 +107,25 @@ export namespace FineAmount {
107
107
  return new Item(item, count);
108
108
  }
109
109
 
110
+ export function compare(lhs: FineAmount, rhs: FineAmount): 'less' | 'equal' | 'greater' {
111
+ if (lhs instanceof Money) {
112
+ if (!(rhs instanceof Money))
113
+ return 'greater';
114
+ const lhsAmount = lhs.amount.completeValue;
115
+ const rhsAmount = rhs.amount.completeValue;
116
+ if (lhsAmount !== rhsAmount)
117
+ return lhsAmount < rhsAmount ? 'less' : 'greater';
118
+ }
119
+ if (lhs instanceof Item) {
120
+ if (!(rhs instanceof Item))
121
+ return 'less';
122
+ if (lhs.count === rhs.count)
123
+ return 'equal';
124
+ return lhs.count < rhs.count ? 'less' : 'greater';
125
+ }
126
+ return 'equal';
127
+ }
128
+
110
129
  export type Flatten = Money.Flatten | Item.Flatten;
111
130
 
112
131
  export class TypeBuilder implements ITypeBuilder<Flatten, FineAmount> {
@@ -20,6 +20,12 @@ export class Person implements Flattable<Person.Flatten> {
20
20
  signInProperties: this.signInProperties?.flatten ?? null
21
21
  };
22
22
  }
23
+
24
+ public get name(): string {
25
+ if (this.properties.lastName === null)
26
+ return this.properties.firstName;
27
+ return `${this.properties.firstName} ${this.properties.lastName}`;
28
+ }
23
29
  }
24
30
 
25
31
  export namespace Person {