@glissandoo/lib 1.116.0 → 1.117.0
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/functions/event.d.ts +22 -0
- package/functions/eventPlayer.d.ts +2 -0
- package/functions/eventoPayout.d.ts +70 -0
- package/functions/eventoPayout.js +2 -0
- package/functions/groupModule.d.ts +13 -0
- package/functions/groupModule.js +2 -0
- package/functions/groupPayment.d.ts +62 -0
- package/functions/groupPayment.js +2 -0
- package/functions/groupPayoutRule.d.ts +18 -0
- package/functions/groupPayoutRule.js +2 -0
- package/functions/index.d.ts +12 -0
- package/functions/index.js +12 -0
- package/functions/regions.js +12 -0
- package/helpers/appScenes.d.ts +2 -0
- package/helpers/appScenes.js +2 -0
- package/helpers/currency.d.ts +4 -0
- package/helpers/currency.js +277 -0
- package/helpers/errors.d.ts +7 -1
- package/helpers/errors.js +6 -0
- package/helpers/paymentForecast.d.ts +37 -0
- package/helpers/paymentForecast.js +58 -0
- package/helpers/payoutRules.d.ts +45 -0
- package/helpers/payoutRules.js +166 -0
- package/lang/ca.json +6 -0
- package/lang/de.json +6 -0
- package/lang/en.json +6 -0
- package/lang/es.json +6 -0
- package/lang/eu.json +6 -0
- package/lang/fr.json +6 -0
- package/lang/gl.json +6 -0
- package/lang/it.json +6 -0
- package/lang/nl.json +6 -0
- package/lang/pt.json +6 -0
- package/models/Evento/Player/index.d.ts +1 -0
- package/models/Evento/Player/index.js +3 -0
- package/models/Evento/Player/types.d.ts +1 -0
- package/models/Evento/index.d.ts +2 -0
- package/models/Evento/index.js +6 -0
- package/models/Evento/types.d.ts +13 -1
- package/models/Evento/types.js +3 -0
- package/models/Group/Payment/index.d.ts +45 -0
- package/models/Group/Payment/index.js +110 -0
- package/models/Group/Payment/supabase.d.ts +16 -0
- package/models/Group/Payment/supabase.js +46 -0
- package/models/Group/Payment/types.d.ts +96 -0
- package/models/Group/Payment/types.js +26 -0
- package/models/Group/index.d.ts +8 -1
- package/models/Group/index.js +19 -0
- package/models/Group/types.d.ts +30 -0
- package/models/Group/types.js +14 -1
- package/models/Notification/types.d.ts +4 -1
- package/models/Notification/types.js +3 -0
- package/package.json +1 -1
- package/types/payoutRule.d.ts +126 -0
- package/types/payoutRule.js +34 -0
- package/types/payoutRule.ts +132 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { Timestamp } from '@google-cloud/firestore';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared types for the payout rules engine.
|
|
5
|
+
* Rules live at two levels:
|
|
6
|
+
* - Group level (templates, can be `pinned` to auto-apply to new events)
|
|
7
|
+
* - Event level (snapshot copied from the group when payout is initialized)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export enum PayoutRuleType {
|
|
11
|
+
EntityShare = 'entityShare',
|
|
12
|
+
DefaultExpense = 'defaultExpense',
|
|
13
|
+
PlayerMultiplier = 'playerMultiplier',
|
|
14
|
+
PlayerBonus = 'playerBonus',
|
|
15
|
+
PlayerFixed = 'playerFixed',
|
|
16
|
+
PlayerExclude = 'playerExclude',
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export enum PayoutRuleConditionOperator {
|
|
20
|
+
Eq = 'eq',
|
|
21
|
+
Neq = 'neq',
|
|
22
|
+
Gt = 'gt',
|
|
23
|
+
Gte = 'gte',
|
|
24
|
+
Lt = 'lt',
|
|
25
|
+
Lte = 'lte',
|
|
26
|
+
In = 'in',
|
|
27
|
+
Nin = 'nin',
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type PayoutRuleConditionFieldKind = 'mainInstrument' | 'isGuest' | `custom.${string}`;
|
|
31
|
+
|
|
32
|
+
export type PayoutRuleConditionValue = string | number | boolean | string[] | number[] | null;
|
|
33
|
+
|
|
34
|
+
export interface PayoutRuleCondition {
|
|
35
|
+
field: PayoutRuleConditionFieldKind;
|
|
36
|
+
operator: PayoutRuleConditionOperator;
|
|
37
|
+
value: PayoutRuleConditionValue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export enum PayoutRuleEntityShareMode {
|
|
41
|
+
Fixed = 'fixed',
|
|
42
|
+
Percentage = 'percentage',
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface PayoutRuleEntityShareEffect {
|
|
46
|
+
mode: PayoutRuleEntityShareMode;
|
|
47
|
+
value: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface PayoutRuleDefaultExpenseEffect {
|
|
51
|
+
concept: string;
|
|
52
|
+
amount: number;
|
|
53
|
+
/**
|
|
54
|
+
* `null` = expense remains general (reduces the shared pot).
|
|
55
|
+
* Future: could materialize per-attendee expenses.
|
|
56
|
+
*/
|
|
57
|
+
assignTo: null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface PayoutRulePlayerMultiplierEffect {
|
|
61
|
+
multiplier: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface PayoutRulePlayerBonusEffect {
|
|
65
|
+
amount: number;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface PayoutRulePlayerFixedEffect {
|
|
69
|
+
amount: number;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export type PayoutRulePlayerExcludeEffect = Record<string, never>;
|
|
73
|
+
|
|
74
|
+
export type PayoutRuleEffect =
|
|
75
|
+
| { type: PayoutRuleType.EntityShare; data: PayoutRuleEntityShareEffect }
|
|
76
|
+
| { type: PayoutRuleType.DefaultExpense; data: PayoutRuleDefaultExpenseEffect }
|
|
77
|
+
| { type: PayoutRuleType.PlayerMultiplier; data: PayoutRulePlayerMultiplierEffect }
|
|
78
|
+
| { type: PayoutRuleType.PlayerBonus; data: PayoutRulePlayerBonusEffect }
|
|
79
|
+
| { type: PayoutRuleType.PlayerFixed; data: PayoutRulePlayerFixedEffect }
|
|
80
|
+
| { type: PayoutRuleType.PlayerExclude; data: PayoutRulePlayerExcludeEffect };
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Common shape stored in both group templates and event snapshots.
|
|
84
|
+
*/
|
|
85
|
+
export interface PayoutRuleBaseData {
|
|
86
|
+
name: string;
|
|
87
|
+
description: string | null;
|
|
88
|
+
order: number;
|
|
89
|
+
conditions: PayoutRuleCondition[];
|
|
90
|
+
effect: PayoutRuleEffect;
|
|
91
|
+
createdAt: Timestamp;
|
|
92
|
+
createdBy: string;
|
|
93
|
+
editedAt: Timestamp | null;
|
|
94
|
+
editedBy: string | null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Helper used by the pure rules engine. Holds the minimal data
|
|
99
|
+
* required to evaluate conditions against a player.
|
|
100
|
+
*/
|
|
101
|
+
export interface PayoutRulePlayerInput {
|
|
102
|
+
id: string;
|
|
103
|
+
mainInstrument: string;
|
|
104
|
+
isGuest: boolean;
|
|
105
|
+
customFields: Record<string, string | number | boolean | null>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface GroupPayoutRuleEntry {
|
|
109
|
+
id: string;
|
|
110
|
+
name: string;
|
|
111
|
+
order: number;
|
|
112
|
+
pinned: boolean;
|
|
113
|
+
conditions: PayoutRuleCondition[];
|
|
114
|
+
effect: PayoutRuleEffect;
|
|
115
|
+
createdAt: Timestamp;
|
|
116
|
+
createdBy: string;
|
|
117
|
+
editedAt: Timestamp | null;
|
|
118
|
+
editedBy: string | null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface EventoPayoutRuleEntry {
|
|
122
|
+
id: string;
|
|
123
|
+
name: string;
|
|
124
|
+
order: number;
|
|
125
|
+
sourceGroupRuleId: string | null;
|
|
126
|
+
conditions: PayoutRuleCondition[];
|
|
127
|
+
effect: PayoutRuleEffect;
|
|
128
|
+
createdAt: Timestamp;
|
|
129
|
+
createdBy: string;
|
|
130
|
+
editedAt: Timestamp | null;
|
|
131
|
+
editedBy: string | null;
|
|
132
|
+
}
|