@moneypot/hub 1.12.0-dev.3 → 1.12.0-dev.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.
package/README.md CHANGED
@@ -79,7 +79,7 @@ insert into hub.api_key default values returning key;
79
79
  ### 1.12.x
80
80
 
81
81
  - Added `hub.audit_log` table to track balance and bankroll changes.
82
- - Read more: <https://docs.moneypot.com/hub/balance-audit>
82
+ - Read more: <https://docs.moneypot.com/docs/controller-dev/audit-log>
83
83
  - Removed built-in hub faucet and old withdraw system.
84
84
 
85
85
  ### 1.11.x
@@ -156,3 +156,18 @@ export type DbOutcomeBet = {
156
156
  outcomes: DbOutcome[];
157
157
  outcome_idx: number;
158
158
  };
159
+ export type DbAuditLogRecord = {
160
+ id: string;
161
+ bankroll_id: string | null;
162
+ balance_id: string | null;
163
+ balance_old: number | null;
164
+ balance_new: number | null;
165
+ balance_delta: number | null;
166
+ bankroll_old: number | null;
167
+ bankroll_new: number | null;
168
+ bankroll_delta: number | null;
169
+ action: string;
170
+ metadata: Record<string, unknown> | null;
171
+ ref_type: string | null;
172
+ ref_id: string | null;
173
+ };
@@ -1,3 +1,4 @@
1
+
1
2
  create table hub.audit_log (
2
3
  id uuid primary key default hub_hidden.uuid_generate_v7(),
3
4
 
@@ -23,19 +24,31 @@ create table hub.audit_log (
23
24
  ref_type text null,
24
25
  ref_id text null, -- not a uuid since users might use it for their own non-uuid ids
25
26
 
26
- -- Ensure we have at least one type of change
27
- check (
28
- (balance_delta is not null) or
29
- (bankroll_delta is not null)
27
+ -- Ensure we have at least one type of change
28
+ CHECK (balance_id IS NOT NULL OR bankroll_id IS NOT NULL),
29
+
30
+ -- If balance_id is set, all balance columns must be filled
31
+ CHECK (
32
+ (balance_id IS NULL) OR
33
+ (balance_old IS NOT NULL AND balance_new IS NOT NULL AND balance_delta IS NOT NULL)
34
+ ),
35
+
36
+ -- If bankroll_id is set, all bankroll columns must be filled
37
+ CHECK (
38
+ (bankroll_id IS NULL) OR
39
+ (bankroll_old IS NOT NULL AND bankroll_new IS NOT NULL AND bankroll_delta IS NOT NULL)
30
40
  ),
31
- -- Ensure old/new/delta are all present or all null
32
- check (
33
- (balance_old is null) = (balance_new is null) AND
34
- (balance_old is null) = (balance_delta is null)
41
+
42
+ -- If balance_id is null, all balance columns must be null
43
+ CHECK (
44
+ (balance_id IS NOT NULL) OR
45
+ (balance_old IS NULL AND balance_new IS NULL AND balance_delta IS NULL)
35
46
  ),
36
- check (
37
- (bankroll_old is null) = (bankroll_new is null) AND
38
- (bankroll_old is null) = (bankroll_delta is null)
47
+
48
+ -- If bankroll_id is null, all bankroll columns must be null
49
+ CHECK (
50
+ (bankroll_id IS NOT NULL) OR
51
+ (bankroll_old IS NULL AND bankroll_new IS NULL AND bankroll_delta IS NULL)
39
52
  )
40
53
  );
41
54
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneypot/hub",
3
- "version": "1.12.0-dev.3",
3
+ "version": "1.12.0-dev.5",
4
4
  "author": "moneypot.com",
5
5
  "homepage": "https://moneypot.com/hub",
6
6
  "keywords": [