@getenginex/sdk-igaming 0.7.0 → 0.8.1
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/CHANGELOG.md +22 -0
- package/dist/index.cjs +342 -396
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +124 -101
- package/dist/index.d.ts +124 -101
- package/dist/index.js +342 -397
- package/dist/index.js.map +1 -1
- package/dist/query/index.cjs +0 -1
- package/dist/query/index.cjs.map +1 -1
- package/dist/query/index.d.cts +3 -5
- package/dist/query/index.d.ts +3 -5
- package/dist/query/index.js +0 -1
- package/dist/query/index.js.map +1 -1
- package/dist/testing/index.cjs +35 -66
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +3 -4
- package/dist/testing/index.d.ts +3 -4
- package/dist/testing/index.js +36 -67
- package/dist/testing/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { EnginexError } from '@getenginex/sdk';
|
|
2
2
|
import * as extension from '@getenginex/sdk/extension';
|
|
3
|
-
import { lazy, wire, decimalPlaces, currencyCode, money as money$1,
|
|
4
|
-
import
|
|
3
|
+
import { lazy, wire, decimalPlaces, currencyCode, money as money$1, moneyText } from '@getenginex/sdk/extension';
|
|
4
|
+
import * as z2 from 'zod/mini';
|
|
5
5
|
|
|
6
6
|
// src/client.ts
|
|
7
7
|
function protoEnum(prefix) {
|
|
8
|
-
return
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
return z2.pipe(
|
|
9
|
+
z2.optional(z2.union([z2.string(), z2.number()])),
|
|
10
|
+
z2.transform((value) => {
|
|
11
11
|
if (value === void 0 || value === 0) return "unspecified";
|
|
12
12
|
if (typeof value === "number") return String(value);
|
|
13
13
|
return (value.startsWith(prefix) ? value.slice(prefix.length) : value).toLowerCase();
|
|
@@ -22,188 +22,174 @@ function currencyOrEmpty() {
|
|
|
22
22
|
}
|
|
23
23
|
var INTEGER_TEXT = "Expected an integer within the safe range of number";
|
|
24
24
|
function integerText() {
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
return z2.pipe(
|
|
26
|
+
z2.union([
|
|
27
|
+
z2.string().check(
|
|
28
|
+
z2.refine((value) => /^-?\d+$/.test(value) && Number.isSafeInteger(Number(value)), { message: INTEGER_TEXT })
|
|
29
29
|
),
|
|
30
|
-
|
|
30
|
+
z2.number().check(z2.refine((value) => Number.isSafeInteger(value), { message: INTEGER_TEXT }))
|
|
31
31
|
]),
|
|
32
|
-
|
|
32
|
+
z2.transform(Number)
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
35
|
function text() {
|
|
36
|
-
return
|
|
36
|
+
return z2._default(z2.string(), "");
|
|
37
37
|
}
|
|
38
38
|
function count() {
|
|
39
|
-
return
|
|
39
|
+
return z2._default(z2.number(), 0);
|
|
40
40
|
}
|
|
41
41
|
function list(item) {
|
|
42
|
-
return
|
|
42
|
+
return z2._default(z2.array(item), []);
|
|
43
43
|
}
|
|
44
44
|
function durationSeconds() {
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
var MAJOR_UNITS = "Expected a value in major units (a finite number) that fits in whole minor units";
|
|
51
|
-
function majorToMinorUnits(value) {
|
|
52
|
-
const minor = Math.sign(value) * Math.round(Math.abs(value) * 100);
|
|
53
|
-
return minor === 0 ? 0 : minor;
|
|
54
|
-
}
|
|
55
|
-
function majorUnits() {
|
|
56
|
-
return z.pipe(
|
|
57
|
-
strictValue(
|
|
58
|
-
(value) => typeof value === "number" && Number.isSafeInteger(majorToMinorUnits(value)),
|
|
59
|
-
MAJOR_UNITS
|
|
60
|
-
),
|
|
61
|
-
z.transform((value) => majorToMinorUnits(value))
|
|
45
|
+
return z2.pipe(
|
|
46
|
+
z2.string().check(z2.regex(/^-?\d+(\.\d+)?s$/, { message: 'Expected a protobuf duration, e.g. "86400s"' })),
|
|
47
|
+
z2.transform((value) => Number(value.slice(0, -1)))
|
|
62
48
|
);
|
|
63
49
|
}
|
|
64
50
|
|
|
65
51
|
// src/modules/bonus.ts
|
|
66
|
-
var campaignCurrency = () =>
|
|
67
|
-
var money = () => wire({ amount:
|
|
68
|
-
var timeWindow = () => wire({ starts_at:
|
|
69
|
-
var ratio = () => wire({ decimal:
|
|
52
|
+
var campaignCurrency = () => z2._default(currencyOrEmpty(), "");
|
|
53
|
+
var money = () => wire({ amount: z2._default(minorUnits(), 0), currency: campaignCurrency() });
|
|
54
|
+
var timeWindow = () => wire({ starts_at: z2.optional(z2.string()), ends_at: z2.optional(z2.string()) });
|
|
55
|
+
var ratio = () => wire({ decimal: z2.optional(z2.string()), basis_points: z2.optional(z2.number()), maximum_scale: count() });
|
|
70
56
|
var empty = () => wire({});
|
|
71
57
|
var policy = (prefix) => wire({ code: protoEnum(prefix), version: count() });
|
|
72
58
|
var casinoSelector = () => wire({
|
|
73
59
|
provider_instance_id: text(),
|
|
74
|
-
software_ids: list(
|
|
75
|
-
game_ids: list(
|
|
76
|
-
category_codes: list(
|
|
60
|
+
software_ids: list(z2.string()),
|
|
61
|
+
game_ids: list(z2.string()),
|
|
62
|
+
category_codes: list(z2.string())
|
|
77
63
|
});
|
|
78
64
|
var sportsSelector = () => wire({
|
|
79
|
-
sport_codes: list(
|
|
80
|
-
competition_ids: list(
|
|
81
|
-
event_ids: list(
|
|
82
|
-
market_codes: list(
|
|
83
|
-
live:
|
|
65
|
+
sport_codes: list(z2.string()),
|
|
66
|
+
competition_ids: list(z2.string()),
|
|
67
|
+
event_ids: list(z2.string()),
|
|
68
|
+
market_codes: list(z2.string()),
|
|
69
|
+
live: z2.optional(z2.boolean()),
|
|
84
70
|
bet_types: list(protoEnum("SPORTS_BET_TYPE_"))
|
|
85
71
|
});
|
|
86
72
|
var qualification = () => wire({
|
|
87
73
|
version: count(),
|
|
88
|
-
immediate:
|
|
89
|
-
user_event:
|
|
74
|
+
immediate: z2.optional(empty()),
|
|
75
|
+
user_event: z2.optional(
|
|
90
76
|
wire({
|
|
91
77
|
event_code: text(),
|
|
92
78
|
event_version: count(),
|
|
93
79
|
source_authority: text(),
|
|
94
|
-
identity_fields: list(
|
|
80
|
+
identity_fields: list(z2.string())
|
|
95
81
|
})
|
|
96
82
|
),
|
|
97
|
-
deposit_settled:
|
|
83
|
+
deposit_settled: z2.optional(
|
|
98
84
|
wire({
|
|
99
85
|
currency: campaignCurrency(),
|
|
100
|
-
eligible_method_codes: list(
|
|
86
|
+
eligible_method_codes: list(z2.string()),
|
|
101
87
|
first_deposit_policy: protoEnum("FIRST_DEPOSIT_POLICY_"),
|
|
102
|
-
minimum_settled_net_amount:
|
|
103
|
-
maximum_settled_net_amount:
|
|
88
|
+
minimum_settled_net_amount: z2.optional(money()),
|
|
89
|
+
maximum_settled_net_amount: z2.optional(money()),
|
|
104
90
|
amount_basis: protoEnum("DEPOSIT_AMOUNT_BASIS_")
|
|
105
91
|
})
|
|
106
92
|
),
|
|
107
|
-
activity_aggregate:
|
|
93
|
+
activity_aggregate: z2.optional(
|
|
108
94
|
wire({
|
|
109
95
|
basis: protoEnum("BASIS_"),
|
|
110
96
|
product_scope: protoEnum("PRODUCT_SCOPE_"),
|
|
111
97
|
currency: campaignCurrency(),
|
|
112
|
-
window:
|
|
98
|
+
window: z2.optional(durationSeconds()),
|
|
113
99
|
timezone: text(),
|
|
114
|
-
late_event_grace:
|
|
115
|
-
casino:
|
|
116
|
-
sportsbook:
|
|
100
|
+
late_event_grace: z2.optional(durationSeconds()),
|
|
101
|
+
casino: z2.optional(casinoSelector()),
|
|
102
|
+
sportsbook: z2.optional(sportsSelector())
|
|
117
103
|
})
|
|
118
104
|
)
|
|
119
105
|
});
|
|
120
106
|
var validity = () => wire({
|
|
121
|
-
no_expiry:
|
|
122
|
-
absolute_expiry:
|
|
123
|
-
duration_from_grant:
|
|
107
|
+
no_expiry: z2.optional(empty()),
|
|
108
|
+
absolute_expiry: z2.optional(wire({ expires_at: z2.optional(z2.string()) })),
|
|
109
|
+
duration_from_grant: z2.optional(wire({ duration: z2.optional(durationSeconds()) }))
|
|
124
110
|
});
|
|
125
111
|
var rounding = () => protoEnum("ROUNDING_MODE_");
|
|
126
112
|
var proceedsClass = () => protoEnum("PROCEEDS_CLASS_");
|
|
127
113
|
var percent = () => wire({
|
|
128
|
-
percentage:
|
|
114
|
+
percentage: z2.optional(ratio()),
|
|
129
115
|
rounding: rounding(),
|
|
130
|
-
minimum_reward:
|
|
131
|
-
maximum_reward:
|
|
116
|
+
minimum_reward: z2.optional(money()),
|
|
117
|
+
maximum_reward: z2.optional(money())
|
|
132
118
|
});
|
|
133
119
|
var balanceCredit = () => wire({
|
|
134
|
-
fixed_amount:
|
|
135
|
-
percent_of_source_amount:
|
|
136
|
-
aggregate_rebate:
|
|
120
|
+
fixed_amount: z2.optional(wire({ amount: z2.optional(money()) })),
|
|
121
|
+
percent_of_source_amount: z2.optional(percent()),
|
|
122
|
+
aggregate_rebate: z2.optional(
|
|
137
123
|
wire({
|
|
138
|
-
percentage:
|
|
124
|
+
percentage: z2.optional(ratio()),
|
|
139
125
|
rounding: rounding(),
|
|
140
|
-
minimum_basis:
|
|
141
|
-
maximum_reward:
|
|
126
|
+
minimum_basis: z2.optional(money()),
|
|
127
|
+
maximum_reward: z2.optional(money())
|
|
142
128
|
})
|
|
143
129
|
),
|
|
144
130
|
balance_class: protoEnum("BALANCE_CLASS_"),
|
|
145
131
|
proceeds_class: proceedsClass(),
|
|
146
|
-
validity:
|
|
132
|
+
validity: z2.optional(validity())
|
|
147
133
|
});
|
|
148
|
-
var maximumBet = () => wire({ mode: protoEnum("MAXIMUM_BET_MODE_"), campaign_maximum:
|
|
134
|
+
var maximumBet = () => wire({ mode: protoEnum("MAXIMUM_BET_MODE_"), campaign_maximum: z2.optional(money()) });
|
|
149
135
|
var oddsPolicy = () => wire({
|
|
150
136
|
mode: protoEnum("MODE_"),
|
|
151
|
-
minimum_total_odds_decimal:
|
|
152
|
-
minimum_odds_per_leg_decimal:
|
|
153
|
-
minimum_legs:
|
|
154
|
-
maximum_legs:
|
|
137
|
+
minimum_total_odds_decimal: z2.optional(z2.string()),
|
|
138
|
+
minimum_odds_per_leg_decimal: z2.optional(z2.string()),
|
|
139
|
+
minimum_legs: z2.optional(z2.number()),
|
|
140
|
+
maximum_legs: z2.optional(z2.number())
|
|
155
141
|
});
|
|
156
142
|
var cashoutMode = () => protoEnum("RESTRICTED_CASHOUT_MODE_");
|
|
157
143
|
var usePolicy = () => wire({
|
|
158
144
|
version: count(),
|
|
159
|
-
funds_consumption:
|
|
160
|
-
casino:
|
|
161
|
-
sportsbook:
|
|
145
|
+
funds_consumption: z2.optional(policy("FUNDS_CONSUMPTION_POLICY_CODE_")),
|
|
146
|
+
casino: z2.optional(wire({ allowed_scopes: list(casinoSelector()), maximum_bet: z2.optional(maximumBet()) })),
|
|
147
|
+
sportsbook: z2.optional(
|
|
162
148
|
wire({
|
|
163
149
|
allowed_scopes: list(sportsSelector()),
|
|
164
150
|
excluded_scopes: list(sportsSelector()),
|
|
165
|
-
maximum_bet:
|
|
166
|
-
funding_odds:
|
|
151
|
+
maximum_bet: z2.optional(maximumBet()),
|
|
152
|
+
funding_odds: z2.optional(oddsPolicy()),
|
|
167
153
|
cashout_mode: cashoutMode()
|
|
168
154
|
})
|
|
169
155
|
),
|
|
170
|
-
casino_and_sportsbook:
|
|
156
|
+
casino_and_sportsbook: z2.optional(
|
|
171
157
|
wire({
|
|
172
158
|
allowed_casino_scopes: list(casinoSelector()),
|
|
173
159
|
allowed_sportsbook_scopes: list(sportsSelector()),
|
|
174
160
|
excluded_sportsbook_scopes: list(sportsSelector()),
|
|
175
|
-
maximum_casino_bet:
|
|
176
|
-
maximum_sportsbook_bet:
|
|
177
|
-
sportsbook_funding_odds:
|
|
161
|
+
maximum_casino_bet: z2.optional(maximumBet()),
|
|
162
|
+
maximum_sportsbook_bet: z2.optional(maximumBet()),
|
|
163
|
+
sportsbook_funding_odds: z2.optional(oddsPolicy()),
|
|
178
164
|
sportsbook_cashout_mode: cashoutMode()
|
|
179
165
|
})
|
|
180
166
|
),
|
|
181
|
-
payout_allocation:
|
|
167
|
+
payout_allocation: z2.optional(policy("PAYOUT_ALLOCATION_POLICY_CODE_"))
|
|
182
168
|
});
|
|
183
169
|
var wageringPolicy = () => wire({
|
|
184
170
|
version: count(),
|
|
185
|
-
none:
|
|
186
|
-
multiplier:
|
|
171
|
+
none: z2.optional(empty()),
|
|
172
|
+
multiplier: z2.optional(
|
|
187
173
|
wire({
|
|
188
174
|
requirement_basis: protoEnum("REQUIREMENT_BASIS_"),
|
|
189
|
-
multiplier:
|
|
175
|
+
multiplier: z2.optional(ratio()),
|
|
190
176
|
contribution_rates: list(
|
|
191
177
|
wire({
|
|
192
|
-
casino:
|
|
193
|
-
sportsbook:
|
|
194
|
-
rate:
|
|
178
|
+
casino: z2.optional(casinoSelector()),
|
|
179
|
+
sportsbook: z2.optional(sportsSelector()),
|
|
180
|
+
rate: z2.optional(ratio())
|
|
195
181
|
})
|
|
196
182
|
),
|
|
197
|
-
deadline:
|
|
183
|
+
deadline: z2.optional(validity()),
|
|
198
184
|
rounding: rounding(),
|
|
199
|
-
sportsbook_contribution_odds:
|
|
185
|
+
sportsbook_contribution_odds: z2.optional(oddsPolicy())
|
|
200
186
|
})
|
|
201
187
|
)
|
|
202
188
|
});
|
|
203
189
|
var stackingPolicy = () => wire({
|
|
204
190
|
version: count(),
|
|
205
|
-
exclusive_in_group:
|
|
206
|
-
multiple_in_group:
|
|
191
|
+
exclusive_in_group: z2.optional(wire({ stacking_group_key: text() })),
|
|
192
|
+
multiple_in_group: z2.optional(wire({ stacking_group_key: text(), maximum_active_per_player: count() }))
|
|
207
193
|
});
|
|
208
194
|
var reward = () => wire({
|
|
209
195
|
reward_key: text(),
|
|
@@ -211,49 +197,49 @@ var reward = () => wire({
|
|
|
211
197
|
reward_kind_version: count(),
|
|
212
198
|
execution_profile_code: protoEnum("EXECUTION_PROFILE_CODE_"),
|
|
213
199
|
execution_profile_version: count(),
|
|
214
|
-
balance_credit:
|
|
215
|
-
provider_managed_balance:
|
|
216
|
-
casino_free_spins:
|
|
200
|
+
balance_credit: z2.optional(balanceCredit()),
|
|
201
|
+
provider_managed_balance: z2.optional(wire({ provider_code: text() })),
|
|
202
|
+
casino_free_spins: z2.optional(
|
|
217
203
|
wire({
|
|
218
204
|
provider_code: text(),
|
|
219
|
-
casino_scope:
|
|
205
|
+
casino_scope: z2.optional(casinoSelector()),
|
|
220
206
|
quantity: count(),
|
|
221
|
-
denomination:
|
|
207
|
+
denomination: z2.optional(money()),
|
|
222
208
|
currency: campaignCurrency(),
|
|
223
|
-
grant_window:
|
|
209
|
+
grant_window: z2.optional(timeWindow()),
|
|
224
210
|
proceeds_class: proceedsClass(),
|
|
225
|
-
maximum_winnings:
|
|
211
|
+
maximum_winnings: z2.optional(money())
|
|
226
212
|
})
|
|
227
213
|
),
|
|
228
|
-
sports_bonus_bet:
|
|
214
|
+
sports_bonus_bet: z2.optional(
|
|
229
215
|
wire({
|
|
230
216
|
provider_code: text(),
|
|
231
|
-
sportsbook_scope:
|
|
232
|
-
amount:
|
|
217
|
+
sportsbook_scope: z2.optional(sportsSelector()),
|
|
218
|
+
amount: z2.optional(money()),
|
|
233
219
|
quantity: count(),
|
|
234
|
-
validity:
|
|
220
|
+
validity: z2.optional(validity())
|
|
235
221
|
})
|
|
236
222
|
),
|
|
237
|
-
sports_bet_coverage:
|
|
223
|
+
sports_bet_coverage: z2.optional(
|
|
238
224
|
wire({
|
|
239
225
|
provider_code: text(),
|
|
240
|
-
qualifying_bet_scope:
|
|
241
|
-
coverage_cap:
|
|
242
|
-
validity:
|
|
226
|
+
qualifying_bet_scope: z2.optional(sportsSelector()),
|
|
227
|
+
coverage_cap: z2.optional(money()),
|
|
228
|
+
validity: z2.optional(validity())
|
|
243
229
|
})
|
|
244
230
|
),
|
|
245
|
-
use_policy:
|
|
246
|
-
wagering_policy:
|
|
247
|
-
stacking_policy:
|
|
248
|
-
restricted_position_selection_policy:
|
|
231
|
+
use_policy: z2.optional(usePolicy()),
|
|
232
|
+
wagering_policy: z2.optional(wageringPolicy()),
|
|
233
|
+
stacking_policy: z2.optional(stackingPolicy()),
|
|
234
|
+
restricted_position_selection_policy: z2.optional(
|
|
249
235
|
wire({
|
|
250
236
|
version: count(),
|
|
251
|
-
priority_then_earliest_expiry:
|
|
237
|
+
priority_then_earliest_expiry: z2.optional(wire({ selection_priority: z2.optional(z2.number()) }))
|
|
252
238
|
})
|
|
253
239
|
)
|
|
254
240
|
});
|
|
255
241
|
var localizedContent = () => wire({ locale: text(), display_name: text(), description: text(), terms: text(), terms_revision: text() });
|
|
256
|
-
var content = () => wire({ default_locale: text(), supported_locales: list(
|
|
242
|
+
var content = () => wire({ default_locale: text(), supported_locales: list(z2.string()), localized_content: list(localizedContent()) });
|
|
257
243
|
var offerSchema = /* @__PURE__ */ lazy(
|
|
258
244
|
() => wire({
|
|
259
245
|
campaign_id: text(),
|
|
@@ -261,33 +247,33 @@ var offerSchema = /* @__PURE__ */ lazy(
|
|
|
261
247
|
publication_id: text(),
|
|
262
248
|
product_scope: protoEnum("PRODUCT_SCOPE_"),
|
|
263
249
|
timezone: text(),
|
|
264
|
-
enrollment_window:
|
|
265
|
-
qualification_window:
|
|
266
|
-
claim_window:
|
|
267
|
-
entry_policy:
|
|
268
|
-
reward_claim_policy:
|
|
269
|
-
qualification:
|
|
270
|
-
reward:
|
|
271
|
-
publication_starts_at:
|
|
272
|
-
publication_ends_at:
|
|
273
|
-
content:
|
|
250
|
+
enrollment_window: z2.optional(timeWindow()),
|
|
251
|
+
qualification_window: z2.optional(timeWindow()),
|
|
252
|
+
claim_window: z2.optional(timeWindow()),
|
|
253
|
+
entry_policy: z2.optional(policy("ENTRY_POLICY_CODE_")),
|
|
254
|
+
reward_claim_policy: z2.optional(policy("REWARD_CLAIM_POLICY_CODE_")),
|
|
255
|
+
qualification: z2.optional(qualification()),
|
|
256
|
+
reward: z2.optional(reward()),
|
|
257
|
+
publication_starts_at: z2.optional(z2.string()),
|
|
258
|
+
publication_ends_at: z2.optional(z2.string()),
|
|
259
|
+
content: z2.optional(content())
|
|
274
260
|
})
|
|
275
261
|
);
|
|
276
262
|
function grantMoney(value, currency) {
|
|
277
263
|
return { amount: value?.amount ?? 0, currency: value?.currency || currency };
|
|
278
264
|
}
|
|
279
|
-
var rewardGrant = () =>
|
|
265
|
+
var rewardGrant = () => z2.pipe(
|
|
280
266
|
wire({
|
|
281
267
|
state: protoEnum("CAMPAIGN_PLAYER_REWARD_GRANT_STATE_"),
|
|
282
|
-
granted:
|
|
283
|
-
balance:
|
|
284
|
-
converted:
|
|
285
|
-
expires_at:
|
|
286
|
-
wagering:
|
|
287
|
-
wire({ required:
|
|
268
|
+
granted: z2.optional(money()),
|
|
269
|
+
balance: z2.optional(money()),
|
|
270
|
+
converted: z2.optional(money()),
|
|
271
|
+
expires_at: z2.optional(z2.string()),
|
|
272
|
+
wagering: z2.optional(
|
|
273
|
+
wire({ required: z2.optional(money()), accumulated: z2.optional(money()), completed_at: z2.optional(z2.string()) })
|
|
288
274
|
)
|
|
289
275
|
}),
|
|
290
|
-
|
|
276
|
+
z2.transform(({ state, granted, balance, converted, expiresAt, wagering }) => {
|
|
291
277
|
const currency = [granted, balance, converted, wagering?.required, wagering?.accumulated].find((m) => m?.currency)?.currency ?? "";
|
|
292
278
|
const out = {
|
|
293
279
|
state,
|
|
@@ -307,40 +293,40 @@ var rewardGrant = () => z.pipe(
|
|
|
307
293
|
})
|
|
308
294
|
);
|
|
309
295
|
var participationSchema = /* @__PURE__ */ lazy(
|
|
310
|
-
() =>
|
|
296
|
+
() => z2.pipe(
|
|
311
297
|
wire({
|
|
312
298
|
id: text(),
|
|
313
299
|
campaign_id: text(),
|
|
314
300
|
campaign_version_id: text(),
|
|
315
301
|
reward_key: text(),
|
|
316
|
-
qualification_snapshot:
|
|
302
|
+
qualification_snapshot: z2.optional(qualification()),
|
|
317
303
|
// oneof `state`: only one of the cases is filled in.
|
|
318
|
-
enrolled:
|
|
319
|
-
qualifying:
|
|
320
|
-
qualified:
|
|
321
|
-
reward_pending:
|
|
322
|
-
completed:
|
|
323
|
-
reward_failed:
|
|
324
|
-
expired:
|
|
325
|
-
cancelled:
|
|
326
|
-
reward_grant:
|
|
327
|
-
snapshot:
|
|
304
|
+
enrolled: z2.optional(empty()),
|
|
305
|
+
qualifying: z2.optional(empty()),
|
|
306
|
+
qualified: z2.optional(wire({ qualified_at: z2.optional(z2.string()) })),
|
|
307
|
+
reward_pending: z2.optional(empty()),
|
|
308
|
+
completed: z2.optional(wire({ completed_at: z2.optional(z2.string()) })),
|
|
309
|
+
reward_failed: z2.optional(empty()),
|
|
310
|
+
expired: z2.optional(wire({ expired_at: z2.optional(z2.string()) })),
|
|
311
|
+
cancelled: z2.optional(empty()),
|
|
312
|
+
reward_grant: z2.optional(rewardGrant()),
|
|
313
|
+
snapshot: z2.optional(
|
|
328
314
|
wire({
|
|
329
|
-
reward:
|
|
330
|
-
content:
|
|
331
|
-
terms_acceptance:
|
|
315
|
+
reward: z2.optional(reward()),
|
|
316
|
+
content: z2.optional(content()),
|
|
317
|
+
terms_acceptance: z2.optional(
|
|
332
318
|
wire({
|
|
333
319
|
locale: text(),
|
|
334
320
|
terms_revision: text(),
|
|
335
321
|
terms_digest_sha256_hex: text(),
|
|
336
|
-
accepted_at:
|
|
322
|
+
accepted_at: z2.optional(z2.string())
|
|
337
323
|
})
|
|
338
324
|
)
|
|
339
325
|
})
|
|
340
326
|
)
|
|
341
327
|
}),
|
|
342
328
|
// The oneof becomes `status` (+ the timestamp of the case); the oneof's keys are not passed on.
|
|
343
|
-
|
|
329
|
+
z2.transform(
|
|
344
330
|
({ enrolled, qualifying, qualified, rewardPending, completed, rewardFailed, expired, cancelled, ...rest }) => {
|
|
345
331
|
const out = { ...rest, status: "unspecified" };
|
|
346
332
|
if (enrolled) out.status = "enrolled";
|
|
@@ -362,7 +348,7 @@ var participationSchema = /* @__PURE__ */ lazy(
|
|
|
362
348
|
)
|
|
363
349
|
)
|
|
364
350
|
);
|
|
365
|
-
var cursorPageSchema = (key, item) => wire({ [key]: list(item), next_cursor:
|
|
351
|
+
var cursorPageSchema = (key, item) => wire({ [key]: list(item), next_cursor: z2.optional(z2.string()) });
|
|
366
352
|
var offersPage = /* @__PURE__ */ lazy(() => cursorPageSchema("offers", offerSchema()));
|
|
367
353
|
var participationsPage = /* @__PURE__ */ lazy(() => cursorPageSchema("participations", participationSchema()));
|
|
368
354
|
var offerEnvelope = /* @__PURE__ */ lazy(() => wire({ offer: offerSchema() }));
|
|
@@ -375,64 +361,64 @@ function toCursorPage(key, data) {
|
|
|
375
361
|
if (data.nextCursor) page.nextCursor = data.nextCursor;
|
|
376
362
|
return page;
|
|
377
363
|
}
|
|
378
|
-
var nullableDate = () =>
|
|
379
|
-
|
|
380
|
-
|
|
364
|
+
var nullableDate = () => z2.pipe(
|
|
365
|
+
z2.nullish(z2.string()),
|
|
366
|
+
z2.transform((value) => value ?? void 0)
|
|
381
367
|
);
|
|
382
368
|
function compact(value) {
|
|
383
369
|
return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== void 0));
|
|
384
370
|
}
|
|
385
371
|
var overviewSchema = /* @__PURE__ */ lazy(
|
|
386
|
-
() =>
|
|
372
|
+
() => z2.pipe(
|
|
387
373
|
wire({
|
|
388
374
|
currencies: list(
|
|
389
|
-
|
|
375
|
+
z2.pipe(
|
|
390
376
|
wire({
|
|
391
377
|
currency: currencyOrEmpty(),
|
|
392
|
-
decimal_places:
|
|
378
|
+
decimal_places: z2.number(),
|
|
393
379
|
restricted_total: minorUnits(),
|
|
394
380
|
expiring_7d: minorUnits(),
|
|
395
|
-
open_positions:
|
|
381
|
+
open_positions: z2.number(),
|
|
396
382
|
next_expires_at: nullableDate(),
|
|
397
383
|
converted: minorUnits(),
|
|
398
|
-
converted_campaigns:
|
|
384
|
+
converted_campaigns: z2.number()
|
|
399
385
|
}),
|
|
400
|
-
|
|
386
|
+
z2.transform(compact)
|
|
401
387
|
)
|
|
402
388
|
),
|
|
403
389
|
as_of: nullableDate()
|
|
404
390
|
}),
|
|
405
|
-
|
|
391
|
+
z2.transform(compact)
|
|
406
392
|
)
|
|
407
393
|
);
|
|
408
394
|
var positionsPage = /* @__PURE__ */ lazy(
|
|
409
395
|
() => wire({
|
|
410
396
|
rows: list(
|
|
411
|
-
|
|
397
|
+
z2.pipe(
|
|
412
398
|
wire({
|
|
413
|
-
position_id:
|
|
414
|
-
campaign_id:
|
|
399
|
+
position_id: z2.string(),
|
|
400
|
+
campaign_id: z2.string(),
|
|
415
401
|
currency: currencyOrEmpty(),
|
|
416
|
-
decimal_places:
|
|
402
|
+
decimal_places: z2.number(),
|
|
417
403
|
granted: minorUnits(),
|
|
418
404
|
restricted: minorUnits(),
|
|
419
405
|
converted: minorUnits(),
|
|
420
406
|
required: minorUnits(),
|
|
421
407
|
wagered: minorUnits(),
|
|
422
408
|
remaining: minorUnits(),
|
|
423
|
-
state:
|
|
409
|
+
state: z2.string(),
|
|
424
410
|
// The gateway answers `null` for an action it does not know; known ones are uppercase (`CONVERT`).
|
|
425
|
-
terminal_action:
|
|
426
|
-
|
|
427
|
-
|
|
411
|
+
terminal_action: z2.pipe(
|
|
412
|
+
z2.nullish(z2.string()),
|
|
413
|
+
z2.transform((value) => value ? value.toLowerCase() : void 0)
|
|
428
414
|
),
|
|
429
415
|
expires_at: nullableDate(),
|
|
430
416
|
created_at: nullableDate()
|
|
431
417
|
}),
|
|
432
|
-
|
|
418
|
+
z2.transform((row) => compact(row))
|
|
433
419
|
)
|
|
434
420
|
),
|
|
435
|
-
next_cursor:
|
|
421
|
+
next_cursor: z2.optional(z2.string())
|
|
436
422
|
})
|
|
437
423
|
);
|
|
438
424
|
var terms = (acceptance) => acceptance && { locale: acceptance.locale, terms_revision: acceptance.termsRevision };
|
|
@@ -526,51 +512,51 @@ function createBonusApi(transport) {
|
|
|
526
512
|
}
|
|
527
513
|
var gameSchema = /* @__PURE__ */ lazy(
|
|
528
514
|
() => wire({
|
|
529
|
-
id:
|
|
530
|
-
name:
|
|
531
|
-
provider:
|
|
532
|
-
category:
|
|
533
|
-
type:
|
|
534
|
-
thumbnail:
|
|
535
|
-
is_new:
|
|
536
|
-
is_popular:
|
|
537
|
-
is_live:
|
|
538
|
-
demo_available:
|
|
539
|
-
rtp:
|
|
540
|
-
volatility:
|
|
541
|
-
priority:
|
|
515
|
+
id: z2.string(),
|
|
516
|
+
name: z2.string(),
|
|
517
|
+
provider: z2.string(),
|
|
518
|
+
category: z2.string(),
|
|
519
|
+
type: z2.string(),
|
|
520
|
+
thumbnail: z2.string(),
|
|
521
|
+
is_new: z2.boolean(),
|
|
522
|
+
is_popular: z2.boolean(),
|
|
523
|
+
is_live: z2.boolean(),
|
|
524
|
+
demo_available: z2.boolean(),
|
|
525
|
+
rtp: z2.number(),
|
|
526
|
+
volatility: z2.string(),
|
|
527
|
+
priority: z2.number()
|
|
542
528
|
})
|
|
543
529
|
);
|
|
544
530
|
var categoriesSchema = /* @__PURE__ */ lazy(
|
|
545
|
-
() =>
|
|
546
|
-
wire({ slug:
|
|
531
|
+
() => z2.array(
|
|
532
|
+
wire({ slug: z2.string(), name: z2.string(), icon: z2.string(), game_count: z2.number(), priority: z2.number() })
|
|
547
533
|
)
|
|
548
534
|
);
|
|
549
535
|
var providersSchema = /* @__PURE__ */ lazy(
|
|
550
|
-
() =>
|
|
536
|
+
() => z2.array(wire({ id: z2.string(), name: z2.string(), game_count: z2.number() }))
|
|
551
537
|
);
|
|
552
538
|
var launchSchema = /* @__PURE__ */ lazy(
|
|
553
|
-
() =>
|
|
539
|
+
() => z2.pipe(
|
|
554
540
|
wire({
|
|
555
|
-
session_id:
|
|
556
|
-
game_url:
|
|
541
|
+
session_id: z2.string().check(z2.minLength(1)),
|
|
542
|
+
game_url: z2.string().check(z2.minLength(1)),
|
|
557
543
|
// Any text: a target the SDK does not know yet must not fail the (strict) launch.
|
|
558
|
-
launch_target:
|
|
559
|
-
provider_code:
|
|
560
|
-
expires_at:
|
|
544
|
+
launch_target: z2.optional(z2.string()),
|
|
545
|
+
provider_code: z2.optional(z2.string()),
|
|
546
|
+
expires_at: z2.optional(z2.string())
|
|
561
547
|
}),
|
|
562
548
|
// Without a target (an older gateway, or a custom mock), the launch keeps the behavior the SDK documented
|
|
563
549
|
// before the field existed: an iframe.
|
|
564
|
-
|
|
550
|
+
z2.transform(({ launchTarget, ...rest }) => ({ ...rest, launchTarget: launchTarget || "iframe" }))
|
|
565
551
|
)
|
|
566
552
|
);
|
|
567
553
|
var sessionSchema = /* @__PURE__ */ lazy(
|
|
568
554
|
() => wire({
|
|
569
|
-
id:
|
|
570
|
-
game_id:
|
|
571
|
-
game_name:
|
|
572
|
-
provider:
|
|
573
|
-
start_time:
|
|
555
|
+
id: z2.string(),
|
|
556
|
+
game_id: z2.string(),
|
|
557
|
+
game_name: z2.string(),
|
|
558
|
+
provider: z2.string(),
|
|
559
|
+
start_time: z2.string(),
|
|
574
560
|
total_bet: money$1(),
|
|
575
561
|
total_win: money$1(),
|
|
576
562
|
status: protoEnum("SESSION_STATUS_")
|
|
@@ -578,27 +564,27 @@ var sessionSchema = /* @__PURE__ */ lazy(
|
|
|
578
564
|
);
|
|
579
565
|
var transactionSchema = /* @__PURE__ */ lazy(
|
|
580
566
|
() => wire({
|
|
581
|
-
id:
|
|
582
|
-
game_id:
|
|
583
|
-
game_name:
|
|
584
|
-
round_id:
|
|
567
|
+
id: z2.string(),
|
|
568
|
+
game_id: z2.string(),
|
|
569
|
+
game_name: z2.string(),
|
|
570
|
+
round_id: z2.string(),
|
|
585
571
|
type: protoEnum("CASINO_TRANSACTION_TYPE_"),
|
|
586
572
|
amount: minorUnits(),
|
|
587
573
|
currency: currencyCode(),
|
|
588
574
|
currency_decimal_places: decimalPlaces(),
|
|
589
|
-
created_at:
|
|
575
|
+
created_at: z2.string()
|
|
590
576
|
})
|
|
591
577
|
);
|
|
592
578
|
var winnersSchema = /* @__PURE__ */ lazy(
|
|
593
|
-
() =>
|
|
579
|
+
() => z2.array(
|
|
594
580
|
wire({
|
|
595
|
-
player:
|
|
581
|
+
player: z2.string(),
|
|
596
582
|
amount: minorUnits(),
|
|
597
583
|
currency: currencyCode(),
|
|
598
584
|
currency_decimal_places: decimalPlaces(),
|
|
599
|
-
game_id:
|
|
600
|
-
game_name:
|
|
601
|
-
won_at:
|
|
585
|
+
game_id: z2.string(),
|
|
586
|
+
game_name: z2.string(),
|
|
587
|
+
won_at: z2.string()
|
|
602
588
|
})
|
|
603
589
|
)
|
|
604
590
|
);
|
|
@@ -688,28 +674,28 @@ function pageInputProblem(name, input) {
|
|
|
688
674
|
return void 0;
|
|
689
675
|
}
|
|
690
676
|
function optionalTimestamp() {
|
|
691
|
-
return
|
|
692
|
-
|
|
693
|
-
|
|
677
|
+
return z2.pipe(
|
|
678
|
+
z2.nullish(z2.string().check(z2.refine((value) => value === "" || !Number.isNaN(Date.parse(value)), "invalid date"))),
|
|
679
|
+
z2.transform((value) => value == null || value === "" || Date.parse(value) === 0 ? null : value)
|
|
694
680
|
);
|
|
695
681
|
}
|
|
696
682
|
function optionalText() {
|
|
697
|
-
return
|
|
698
|
-
|
|
699
|
-
|
|
683
|
+
return z2.pipe(
|
|
684
|
+
z2.nullish(z2.string()),
|
|
685
|
+
z2.transform((value) => value == null || value === "" ? null : value)
|
|
700
686
|
);
|
|
701
687
|
}
|
|
702
688
|
function nullableList(item) {
|
|
703
|
-
return
|
|
704
|
-
|
|
705
|
-
|
|
689
|
+
return z2.pipe(
|
|
690
|
+
z2.nullish(z2.array(item)),
|
|
691
|
+
z2.transform((value) => value ?? [])
|
|
706
692
|
);
|
|
707
693
|
}
|
|
708
694
|
|
|
709
695
|
// src/modules/loyalty.ts
|
|
710
|
-
var tierBenefits = () =>
|
|
711
|
-
|
|
712
|
-
|
|
696
|
+
var tierBenefits = () => z2.pipe(
|
|
697
|
+
z2.nullish(z2.string()),
|
|
698
|
+
z2.transform((text2, ctx) => {
|
|
713
699
|
if (text2 == null || text2.trim() === "") return null;
|
|
714
700
|
let parsed;
|
|
715
701
|
try {
|
|
@@ -720,43 +706,43 @@ var tierBenefits = () => z.pipe(
|
|
|
720
706
|
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed))
|
|
721
707
|
return parsed;
|
|
722
708
|
ctx.issues.push({ code: "custom", message: "tier_benefits_json is not a JSON object", input: void 0 });
|
|
723
|
-
return
|
|
709
|
+
return z2.NEVER;
|
|
724
710
|
})
|
|
725
711
|
);
|
|
726
712
|
var loyaltySchema = /* @__PURE__ */ lazy(
|
|
727
|
-
() =>
|
|
713
|
+
() => z2.pipe(
|
|
728
714
|
wire({
|
|
729
715
|
total_points_earned: integerText(),
|
|
730
716
|
current_points: integerText(),
|
|
731
717
|
points_redeemed: integerText(),
|
|
732
718
|
current_tier: optionalText(),
|
|
733
719
|
tier_points: integerText(),
|
|
734
|
-
lifetime_wagered:
|
|
735
|
-
lifetime_deposited:
|
|
720
|
+
lifetime_wagered: z2._default(minorUnits(), 0),
|
|
721
|
+
lifetime_deposited: z2._default(minorUnits(), 0),
|
|
736
722
|
tier_benefits_json: tierBenefits(),
|
|
737
723
|
tier_expires_at: optionalTimestamp()
|
|
738
724
|
}),
|
|
739
|
-
|
|
725
|
+
z2.transform(({ tierBenefitsJson, ...rest }) => {
|
|
740
726
|
const benefits = typeof tierBenefitsJson === "object" && tierBenefitsJson !== null && !Array.isArray(tierBenefitsJson) ? tierBenefitsJson : null;
|
|
741
727
|
return { ...rest, tierBenefits: benefits };
|
|
742
728
|
})
|
|
743
729
|
)
|
|
744
730
|
);
|
|
745
731
|
var redeemSchema = /* @__PURE__ */ lazy(
|
|
746
|
-
() =>
|
|
732
|
+
() => z2.pipe(
|
|
747
733
|
wire({
|
|
748
|
-
success:
|
|
749
|
-
message:
|
|
734
|
+
success: z2.optional(z2.boolean()),
|
|
735
|
+
message: z2.optional(z2.string()),
|
|
750
736
|
redeemed_points: integerText(),
|
|
751
|
-
value:
|
|
737
|
+
value: z2.nullish(minorUnits()),
|
|
752
738
|
// Currency strict even in `'warn'`; absent, `null` and `''` still become `null`.
|
|
753
|
-
currency:
|
|
754
|
-
|
|
755
|
-
|
|
739
|
+
currency: z2.pipe(
|
|
740
|
+
z2.nullish(currencyOrEmpty()),
|
|
741
|
+
z2.transform((value) => value == null || value === "" ? null : value)
|
|
756
742
|
),
|
|
757
743
|
bonus_id: optionalText()
|
|
758
744
|
}),
|
|
759
|
-
|
|
745
|
+
z2.transform((data) => ({
|
|
760
746
|
success: data.success,
|
|
761
747
|
message: data.message,
|
|
762
748
|
redeemedPoints: data.redeemedPoints,
|
|
@@ -800,12 +786,12 @@ function createLoyaltyApi(transport) {
|
|
|
800
786
|
};
|
|
801
787
|
}
|
|
802
788
|
function openUnion(values) {
|
|
803
|
-
return
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
789
|
+
return z2.pipe(
|
|
790
|
+
z2.pipe(
|
|
791
|
+
z2.string(),
|
|
792
|
+
z2.transform((value) => value.toLowerCase())
|
|
807
793
|
),
|
|
808
|
-
|
|
794
|
+
z2.enum(values)
|
|
809
795
|
);
|
|
810
796
|
}
|
|
811
797
|
|
|
@@ -816,14 +802,14 @@ var REWARD_TYPES = ["bonus", "free_spins", "points", "free_bet"];
|
|
|
816
802
|
var USER_MISSION_STATUSES = ["in_progress", "completed", "expired", "claimed"];
|
|
817
803
|
var missionSchema = /* @__PURE__ */ lazy(
|
|
818
804
|
() => wire({
|
|
819
|
-
id:
|
|
820
|
-
name:
|
|
821
|
-
description:
|
|
805
|
+
id: z2.string(),
|
|
806
|
+
name: z2.string(),
|
|
807
|
+
description: z2._default(z2.string(), ""),
|
|
822
808
|
mission_type: openUnion(MISSION_TYPES),
|
|
823
809
|
objective_type: openUnion(OBJECTIVE_TYPES),
|
|
824
810
|
target_value: integerText(),
|
|
825
811
|
target_game_category: optionalText(),
|
|
826
|
-
target_games: nullableList(
|
|
812
|
+
target_games: nullableList(z2.string()),
|
|
827
813
|
reward_type: openUnion(REWARD_TYPES),
|
|
828
814
|
reward_value: minorUnits(),
|
|
829
815
|
valid_from: optionalTimestamp(),
|
|
@@ -831,16 +817,16 @@ var missionSchema = /* @__PURE__ */ lazy(
|
|
|
831
817
|
})
|
|
832
818
|
);
|
|
833
819
|
var userMissionsSchema = /* @__PURE__ */ lazy(
|
|
834
|
-
() =>
|
|
820
|
+
() => z2.pipe(
|
|
835
821
|
wire({
|
|
836
822
|
missions: nullableList(
|
|
837
823
|
wire({
|
|
838
|
-
id:
|
|
839
|
-
mission_id:
|
|
840
|
-
mission_name:
|
|
824
|
+
id: z2.string(),
|
|
825
|
+
mission_id: z2.string(),
|
|
826
|
+
mission_name: z2._default(z2.string(), ""),
|
|
841
827
|
current_progress: integerText(),
|
|
842
828
|
target_value: integerText(),
|
|
843
|
-
progress_percentage:
|
|
829
|
+
progress_percentage: z2.number(),
|
|
844
830
|
status: openUnion(USER_MISSION_STATUSES),
|
|
845
831
|
reward_type: openUnion(REWARD_TYPES),
|
|
846
832
|
reward_value: minorUnits(),
|
|
@@ -849,7 +835,7 @@ var userMissionsSchema = /* @__PURE__ */ lazy(
|
|
|
849
835
|
})
|
|
850
836
|
)
|
|
851
837
|
}),
|
|
852
|
-
|
|
838
|
+
z2.transform((data) => data.missions)
|
|
853
839
|
)
|
|
854
840
|
);
|
|
855
841
|
function createMissionsApi(transport) {
|
|
@@ -877,150 +863,122 @@ function createMissionsApi(transport) {
|
|
|
877
863
|
})
|
|
878
864
|
};
|
|
879
865
|
}
|
|
880
|
-
var STATUSES = ["pending", "qualified", "completed", "expired", "unspecified"];
|
|
881
|
-
var status = () => z.pipe(protoEnum("REFERRAL_STATUS_"), z.enum(STATUSES));
|
|
882
866
|
var DEFAULT_PER_PAGE = 20;
|
|
883
|
-
var count2 = () => z._default(z.number().check(z.refine((value) => Number.isInteger(value) && value >= 0, "invalid counter")), 0);
|
|
884
867
|
var HISTORY_PATH = "/referrals/history";
|
|
885
|
-
var
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
868
|
+
var count2 = () => z2._default(z2.number().check(z2.refine((value) => Number.isSafeInteger(value) && value >= 0, "invalid counter")), 0);
|
|
869
|
+
var money3 = () => z2.pipe(
|
|
870
|
+
z2.nullish(wire({ minor_units: minorUnits(), currency: z2._default(currencyOrEmpty(), "") })),
|
|
871
|
+
z2.transform(
|
|
872
|
+
(value) => value == null ? null : { amount: value.minorUnits, currency: value.currency }
|
|
873
|
+
)
|
|
874
|
+
);
|
|
875
|
+
var rulesSchema = () => z2.pipe(
|
|
876
|
+
z2.nullish(
|
|
877
|
+
wire({
|
|
878
|
+
reward: money3(),
|
|
879
|
+
minimum_real_net_loss: money3(),
|
|
880
|
+
referee_window_days: count2(),
|
|
881
|
+
hold_hours: count2(),
|
|
882
|
+
wagering_multiplier: z2._default(z2.string(), ""),
|
|
883
|
+
maximum_conversion: money3()
|
|
884
|
+
})
|
|
885
|
+
),
|
|
886
|
+
z2.transform((rules) => {
|
|
887
|
+
if (rules == null || rules.reward === null || rules.minimumRealNetLoss === null) return null;
|
|
888
|
+
return {
|
|
889
|
+
reward: rules.reward,
|
|
890
|
+
minimumRealNetLoss: rules.minimumRealNetLoss,
|
|
891
|
+
refereeWindowDays: rules.refereeWindowDays,
|
|
892
|
+
holdHours: rules.holdHours,
|
|
893
|
+
wageringMultiplier: rules.wageringMultiplier,
|
|
894
|
+
maximumConversion: rules.maximumConversion
|
|
895
|
+
};
|
|
896
|
+
})
|
|
897
|
+
);
|
|
896
898
|
var infoSchema = /* @__PURE__ */ lazy(
|
|
897
|
-
() =>
|
|
899
|
+
() => z2.pipe(
|
|
898
900
|
wire({
|
|
901
|
+
enabled: z2._default(z2.boolean(), false),
|
|
899
902
|
referral_code: optionalText(),
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
903
|
+
rules: rulesSchema(),
|
|
904
|
+
totals: z2._default(
|
|
905
|
+
wire({
|
|
906
|
+
registered: count2(),
|
|
907
|
+
deposited: count2(),
|
|
908
|
+
in_hold: count2(),
|
|
909
|
+
paid: count2(),
|
|
910
|
+
not_eligible: count2(),
|
|
911
|
+
expired: count2(),
|
|
912
|
+
cancelled: count2()
|
|
913
|
+
}),
|
|
914
|
+
{ registered: 0, deposited: 0, inHold: 0, paid: 0, notEligible: 0, expired: 0, cancelled: 0 }
|
|
915
|
+
)
|
|
907
916
|
}),
|
|
908
|
-
|
|
909
|
-
({ referralCode,
|
|
910
|
-
code: referralCode,
|
|
911
|
-
link: referralLink,
|
|
912
|
-
...rest
|
|
913
|
-
})
|
|
917
|
+
z2.transform(
|
|
918
|
+
({ enabled, referralCode, rules, totals }) => ({ enabled, code: referralCode, rules, totals })
|
|
914
919
|
)
|
|
915
920
|
)
|
|
916
921
|
);
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
var minorAmount = () => z.pipe(
|
|
924
|
-
majorUnits(),
|
|
925
|
-
z.transform((value) => new MinorAmount(value))
|
|
926
|
-
);
|
|
927
|
-
var BUILT = /* @__PURE__ */ new WeakSet();
|
|
928
|
-
var referralSchema = /* @__PURE__ */ lazy(
|
|
929
|
-
() => z.pipe(
|
|
922
|
+
function remainingOf(target, loss) {
|
|
923
|
+
const missing = BigInt(target.amount) - BigInt(loss.amount);
|
|
924
|
+
return { amount: missing > 0n ? Number(missing) : 0, currency: target.currency };
|
|
925
|
+
}
|
|
926
|
+
var progressSchema = () => z2.pipe(
|
|
927
|
+
z2.nullish(
|
|
930
928
|
wire({
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
referral_code: z._default(z.string(), ""),
|
|
936
|
-
status: status(),
|
|
937
|
-
referrer_bonus: minorAmount(),
|
|
938
|
-
referee_bonus: minorAmount(),
|
|
939
|
-
created_at: optionalTimestamp(),
|
|
940
|
-
completed_at: optionalTimestamp(),
|
|
941
|
-
expires_at: optionalTimestamp()
|
|
942
|
-
}),
|
|
943
|
-
z.transform((r) => {
|
|
944
|
-
const referrerBonus = r.referrerBonus;
|
|
945
|
-
const refereeBonus = r.refereeBonus;
|
|
946
|
-
if (!(referrerBonus instanceof MinorAmount) || !(refereeBonus instanceof MinorAmount)) return null;
|
|
947
|
-
const item = {
|
|
948
|
-
id: r.id,
|
|
949
|
-
refereeName: r.refereeName,
|
|
950
|
-
refereeEmailMasked: maskEmail(r.refereeEmail),
|
|
951
|
-
code: r.referralCode,
|
|
952
|
-
status: r.status,
|
|
953
|
-
referrerBonus: referrerBonus.value,
|
|
954
|
-
refereeBonus: refereeBonus.value,
|
|
955
|
-
createdAt: r.createdAt,
|
|
956
|
-
completedAt: r.completedAt,
|
|
957
|
-
expiresAt: r.expiresAt
|
|
958
|
-
};
|
|
959
|
-
BUILT.add(item);
|
|
960
|
-
return item;
|
|
929
|
+
deposit_done: z2._default(z2.boolean(), false),
|
|
930
|
+
real_net_loss: money3(),
|
|
931
|
+
target: money3(),
|
|
932
|
+
remaining: money3()
|
|
961
933
|
})
|
|
962
|
-
)
|
|
934
|
+
),
|
|
935
|
+
z2.transform((progress) => {
|
|
936
|
+
if (progress == null || progress.target === null) return null;
|
|
937
|
+
const { target } = progress;
|
|
938
|
+
const realNetLoss = progress.realNetLoss ?? { amount: 0, currency: target.currency };
|
|
939
|
+
return {
|
|
940
|
+
depositDone: progress.depositDone,
|
|
941
|
+
realNetLoss,
|
|
942
|
+
target,
|
|
943
|
+
remaining: progress.remaining ?? remainingOf(target, realNetLoss)
|
|
944
|
+
};
|
|
945
|
+
})
|
|
963
946
|
);
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
const result = referralSchema().safeParse(snake);
|
|
969
|
-
return result.success ? result.data : null;
|
|
970
|
-
}
|
|
971
|
-
function historyItems(list2) {
|
|
972
|
-
if (!Array.isArray(list2)) return [];
|
|
973
|
-
const items = [];
|
|
974
|
-
for (const entry of list2) {
|
|
975
|
-
const item = typeof entry === "object" && entry !== null && BUILT.has(entry) ? entry : rawReferral(entry);
|
|
976
|
-
if (item !== null) items.push(item);
|
|
977
|
-
}
|
|
978
|
-
return items;
|
|
947
|
+
var LEGACY_STATUS = { COMPLETED: "paid", EXPIRED: "expired", PENDING: "registered" };
|
|
948
|
+
function statusOf(playerStatus, legacy) {
|
|
949
|
+
if (playerStatus !== null) return playerStatus.replace(/^CAMPAIGN_REFERRAL_STATUS_/, "").toLowerCase();
|
|
950
|
+
return LEGACY_STATUS[(legacy ?? "").toUpperCase()] ?? "registered";
|
|
979
951
|
}
|
|
980
|
-
var
|
|
952
|
+
var referralSchema = () => z2.pipe(
|
|
953
|
+
wire({
|
|
954
|
+
id: z2.string(),
|
|
955
|
+
referee_name: optionalText(),
|
|
956
|
+
status: optionalText(),
|
|
957
|
+
player_status: optionalText(),
|
|
958
|
+
created_at: optionalTimestamp(),
|
|
959
|
+
deadline_at: optionalTimestamp(),
|
|
960
|
+
progress: progressSchema()
|
|
961
|
+
}),
|
|
962
|
+
z2.transform(
|
|
963
|
+
(r) => ({
|
|
964
|
+
id: r.id,
|
|
965
|
+
refereeName: r.refereeName,
|
|
966
|
+
status: statusOf(r.playerStatus, r.status),
|
|
967
|
+
createdAt: r.createdAt,
|
|
968
|
+
deadlineAt: r.deadlineAt,
|
|
969
|
+
progress: r.progress
|
|
970
|
+
})
|
|
971
|
+
)
|
|
972
|
+
);
|
|
981
973
|
var historySchema = /* @__PURE__ */ lazy(
|
|
982
974
|
() => wire({
|
|
975
|
+
referral_code: optionalText(),
|
|
983
976
|
referrals: nullableList(referralSchema()),
|
|
984
|
-
|
|
985
|
-
total_earned: majorUnits(),
|
|
986
|
-
pagination: z.optional(
|
|
987
|
-
wire({
|
|
988
|
-
page: count2(),
|
|
989
|
-
page_size: count2(),
|
|
990
|
-
total_items: count2(),
|
|
991
|
-
total_pages: count2()
|
|
992
|
-
})
|
|
993
|
-
)
|
|
977
|
+
pagination: z2.optional(wire({ page: count2(), limit: count2(), total_items: count2() }))
|
|
994
978
|
})
|
|
995
979
|
);
|
|
996
|
-
var registeredSchema = /* @__PURE__ */ lazy(
|
|
997
|
-
() => z.pipe(
|
|
998
|
-
wire({
|
|
999
|
-
id: z.string(),
|
|
1000
|
-
referral_code: z._default(z.string(), ""),
|
|
1001
|
-
status: status(),
|
|
1002
|
-
referee_bonus: z._default(majorUnits(), 0),
|
|
1003
|
-
created_at: optionalTimestamp()
|
|
1004
|
-
}),
|
|
1005
|
-
z.transform(
|
|
1006
|
-
(r) => ({
|
|
1007
|
-
id: r.id,
|
|
1008
|
-
code: r.referralCode,
|
|
1009
|
-
status: r.status,
|
|
1010
|
-
refereeBonus: r.refereeBonus,
|
|
1011
|
-
createdAt: r.createdAt
|
|
1012
|
-
})
|
|
1013
|
-
)
|
|
1014
|
-
)
|
|
1015
|
-
);
|
|
1016
980
|
var positiveInt = (value, fallback) => typeof value === "number" && Number.isSafeInteger(value) && value >= 1 ? value : fallback;
|
|
1017
|
-
|
|
1018
|
-
if (typeof input !== "object" || input === null || Array.isArray(input))
|
|
1019
|
-
return "referrals.register: input must be an object { code }.";
|
|
1020
|
-
const { code } = input;
|
|
1021
|
-
if (typeof code !== "string" || code.trim() === "") return "referrals.register: code must be non-empty text.";
|
|
1022
|
-
return void 0;
|
|
1023
|
-
}
|
|
981
|
+
var reportedTotal = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : 0;
|
|
1024
982
|
function createReferralsApi(transport) {
|
|
1025
983
|
return {
|
|
1026
984
|
get: (_params, options) => transport.request({ method: "GET", path: "/referrals", auth: "required", schema: infoSchema(), options }),
|
|
@@ -1036,12 +994,11 @@ function createReferralsApi(transport) {
|
|
|
1036
994
|
auth: "required",
|
|
1037
995
|
schema: historySchema(),
|
|
1038
996
|
options
|
|
1039
|
-
}).then(({
|
|
1040
|
-
const items =
|
|
1041
|
-
const received = Array.isArray(referrals) ? referrals.length : 0;
|
|
997
|
+
}).then(({ referralCode, referrals, pagination }) => {
|
|
998
|
+
const items = Array.isArray(referrals) ? referrals : [];
|
|
1042
999
|
const page = positiveInt(pagination?.page, requestedPage ?? 1);
|
|
1043
|
-
const perPage = positiveInt(pagination?.
|
|
1044
|
-
const seen =
|
|
1000
|
+
const perPage = positiveInt(pagination?.limit, requestedPerPage ?? DEFAULT_PER_PAGE);
|
|
1001
|
+
const seen = items.length > 0 ? (page - 1) * perPage + items.length : 0;
|
|
1045
1002
|
const totalItems = Math.max(reportedTotal(pagination?.totalItems), seen);
|
|
1046
1003
|
return {
|
|
1047
1004
|
items,
|
|
@@ -1049,32 +1006,20 @@ function createReferralsApi(transport) {
|
|
|
1049
1006
|
perPage,
|
|
1050
1007
|
totalItems,
|
|
1051
1008
|
totalPages: totalItems > 0 ? Math.ceil(totalItems / perPage) : 0,
|
|
1052
|
-
|
|
1053
|
-
totalEarned
|
|
1009
|
+
code: referralCode
|
|
1054
1010
|
};
|
|
1055
1011
|
});
|
|
1056
|
-
},
|
|
1057
|
-
register: (input, options) => {
|
|
1058
|
-
const problem = registerInputProblem(input);
|
|
1059
|
-
if (problem !== void 0) return rejectInput(transport, problem, REGISTER_ROUTE);
|
|
1060
|
-
return transport.request({
|
|
1061
|
-
...REGISTER_ROUTE,
|
|
1062
|
-
body: { referral_code: input.code.trim() },
|
|
1063
|
-
auth: "required",
|
|
1064
|
-
schema: registeredSchema(),
|
|
1065
|
-
options
|
|
1066
|
-
});
|
|
1067
1012
|
}
|
|
1068
1013
|
};
|
|
1069
1014
|
}
|
|
1070
1015
|
var HTTP_URL = "Expected an absolute http(s) URL";
|
|
1071
1016
|
var sessionSchema2 = /* @__PURE__ */ lazy(
|
|
1072
|
-
() =>
|
|
1017
|
+
() => z2.pipe(
|
|
1073
1018
|
wire({
|
|
1074
1019
|
// The separate token only exists on the wire: the schema declares it (strict contract) and the output drops it.
|
|
1075
|
-
operator_token:
|
|
1076
|
-
launch_url:
|
|
1077
|
-
|
|
1020
|
+
operator_token: z2.string(),
|
|
1021
|
+
launch_url: z2.string().check(
|
|
1022
|
+
z2.refine(
|
|
1078
1023
|
(value) => {
|
|
1079
1024
|
try {
|
|
1080
1025
|
const { protocol } = new URL(value);
|
|
@@ -1086,10 +1031,10 @@ var sessionSchema2 = /* @__PURE__ */ lazy(
|
|
|
1086
1031
|
{ message: HTTP_URL }
|
|
1087
1032
|
)
|
|
1088
1033
|
),
|
|
1089
|
-
expires_in_seconds:
|
|
1034
|
+
expires_in_seconds: z2.number().check(z2.refine((n) => Number.isFinite(n) && n > 0, { message: "Esperava > 0" }))
|
|
1090
1035
|
}),
|
|
1091
1036
|
// The clock is read when the response is interpreted (= moment of the response).
|
|
1092
|
-
|
|
1037
|
+
z2.transform(({ launchUrl, expiresInSeconds }) => ({
|
|
1093
1038
|
launchUrl,
|
|
1094
1039
|
expiresInSeconds,
|
|
1095
1040
|
expiresAt: Date.now() + expiresInSeconds * 1e3
|