@getenginex/sdk-igaming 0.0.0-stage → 0.6.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/CHANGELOG.md +179 -0
- package/LICENSE +202 -0
- package/README.md +110 -2
- package/dist/first-frame/index.cjs +136 -0
- package/dist/first-frame/index.cjs.map +1 -0
- package/dist/first-frame/index.d.cts +135 -0
- package/dist/first-frame/index.d.ts +135 -0
- package/dist/first-frame/index.js +134 -0
- package/dist/first-frame/index.js.map +1 -0
- package/dist/index.cjs +1046 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1588 -0
- package/dist/index.d.ts +1588 -0
- package/dist/index.js +1025 -0
- package/dist/index.js.map +1 -0
- package/dist/query/index.cjs +84 -0
- package/dist/query/index.cjs.map +1 -0
- package/dist/query/index.d.cts +103 -0
- package/dist/query/index.d.ts +103 -0
- package/dist/query/index.js +81 -0
- package/dist/query/index.js.map +1 -0
- package/dist/testing/index.cjs +743 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +75 -0
- package/dist/testing/index.d.ts +75 -0
- package/dist/testing/index.js +740 -0
- package/dist/testing/index.js.map +1 -0
- package/first-frame/package.json +5 -0
- package/package.json +159 -3
- package/query/package.json +5 -0
- package/testing/package.json +5 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1046 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var sdk = require('@getenginex/sdk');
|
|
4
|
+
var extension = require('@getenginex/sdk/extension');
|
|
5
|
+
var mini = require('zod/mini');
|
|
6
|
+
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var extension__namespace = /*#__PURE__*/_interopNamespace(extension);
|
|
26
|
+
|
|
27
|
+
// src/client.ts
|
|
28
|
+
function protoEnum(prefix) {
|
|
29
|
+
return mini.z.pipe(
|
|
30
|
+
mini.z.optional(mini.z.union([mini.z.string(), mini.z.number()])),
|
|
31
|
+
mini.z.transform((value) => {
|
|
32
|
+
if (value === void 0 || value === 0) return "unspecified";
|
|
33
|
+
if (typeof value === "number") return String(value);
|
|
34
|
+
return (value.startsWith(prefix) ? value.slice(prefix.length) : value).toLowerCase();
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
function minorUnits() {
|
|
39
|
+
return extension.moneyText();
|
|
40
|
+
}
|
|
41
|
+
function currencyOrEmpty() {
|
|
42
|
+
return extension.currencyCode({ allowEmpty: true });
|
|
43
|
+
}
|
|
44
|
+
var INTEGER_TEXT = "Expected an integer within the safe range of number";
|
|
45
|
+
function integerText() {
|
|
46
|
+
return mini.z.pipe(
|
|
47
|
+
mini.z.union([
|
|
48
|
+
mini.z.string().check(
|
|
49
|
+
mini.z.refine((value) => /^-?\d+$/.test(value) && Number.isSafeInteger(Number(value)), { message: INTEGER_TEXT })
|
|
50
|
+
),
|
|
51
|
+
mini.z.number().check(mini.z.refine((value) => Number.isSafeInteger(value), { message: INTEGER_TEXT }))
|
|
52
|
+
]),
|
|
53
|
+
mini.z.transform(Number)
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
function text() {
|
|
57
|
+
return mini.z._default(mini.z.string(), "");
|
|
58
|
+
}
|
|
59
|
+
function count() {
|
|
60
|
+
return mini.z._default(mini.z.number(), 0);
|
|
61
|
+
}
|
|
62
|
+
function list(item) {
|
|
63
|
+
return mini.z._default(mini.z.array(item), []);
|
|
64
|
+
}
|
|
65
|
+
function durationSeconds() {
|
|
66
|
+
return mini.z.pipe(
|
|
67
|
+
mini.z.string().check(mini.z.regex(/^-?\d+(\.\d+)?s$/, { message: 'Expected a protobuf duration, e.g. "86400s"' })),
|
|
68
|
+
mini.z.transform((value) => Number(value.slice(0, -1)))
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
var MAJOR_UNITS = "Expected a value in major units (a finite number) that fits in whole minor units";
|
|
72
|
+
function majorToMinorUnits(value) {
|
|
73
|
+
const minor = Math.sign(value) * Math.round(Math.abs(value) * 100);
|
|
74
|
+
return minor === 0 ? 0 : minor;
|
|
75
|
+
}
|
|
76
|
+
function majorUnits() {
|
|
77
|
+
return mini.z.pipe(
|
|
78
|
+
extension.strictValue(
|
|
79
|
+
(value) => typeof value === "number" && Number.isSafeInteger(majorToMinorUnits(value)),
|
|
80
|
+
MAJOR_UNITS
|
|
81
|
+
),
|
|
82
|
+
mini.z.transform((value) => majorToMinorUnits(value))
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/modules/bonus.ts
|
|
87
|
+
var campaignCurrency = () => mini.z._default(currencyOrEmpty(), "");
|
|
88
|
+
var money = () => extension.wire({ amount: mini.z._default(minorUnits(), 0), currency: campaignCurrency() });
|
|
89
|
+
var timeWindow = () => extension.wire({ starts_at: mini.z.optional(mini.z.string()), ends_at: mini.z.optional(mini.z.string()) });
|
|
90
|
+
var ratio = () => extension.wire({ decimal: mini.z.optional(mini.z.string()), basis_points: mini.z.optional(mini.z.number()), maximum_scale: count() });
|
|
91
|
+
var empty = () => extension.wire({});
|
|
92
|
+
var policy = (prefix) => extension.wire({ code: protoEnum(prefix), version: count() });
|
|
93
|
+
var casinoSelector = () => extension.wire({
|
|
94
|
+
provider_instance_id: text(),
|
|
95
|
+
software_ids: list(mini.z.string()),
|
|
96
|
+
game_ids: list(mini.z.string()),
|
|
97
|
+
category_codes: list(mini.z.string())
|
|
98
|
+
});
|
|
99
|
+
var sportsSelector = () => extension.wire({
|
|
100
|
+
sport_codes: list(mini.z.string()),
|
|
101
|
+
competition_ids: list(mini.z.string()),
|
|
102
|
+
event_ids: list(mini.z.string()),
|
|
103
|
+
market_codes: list(mini.z.string()),
|
|
104
|
+
live: mini.z.optional(mini.z.boolean()),
|
|
105
|
+
bet_types: list(protoEnum("SPORTS_BET_TYPE_"))
|
|
106
|
+
});
|
|
107
|
+
var qualification = () => extension.wire({
|
|
108
|
+
version: count(),
|
|
109
|
+
immediate: mini.z.optional(empty()),
|
|
110
|
+
user_event: mini.z.optional(
|
|
111
|
+
extension.wire({
|
|
112
|
+
event_code: text(),
|
|
113
|
+
event_version: count(),
|
|
114
|
+
source_authority: text(),
|
|
115
|
+
identity_fields: list(mini.z.string())
|
|
116
|
+
})
|
|
117
|
+
),
|
|
118
|
+
deposit_settled: mini.z.optional(
|
|
119
|
+
extension.wire({
|
|
120
|
+
currency: campaignCurrency(),
|
|
121
|
+
eligible_method_codes: list(mini.z.string()),
|
|
122
|
+
first_deposit_policy: protoEnum("FIRST_DEPOSIT_POLICY_"),
|
|
123
|
+
minimum_settled_net_amount: mini.z.optional(money()),
|
|
124
|
+
maximum_settled_net_amount: mini.z.optional(money()),
|
|
125
|
+
amount_basis: protoEnum("DEPOSIT_AMOUNT_BASIS_")
|
|
126
|
+
})
|
|
127
|
+
),
|
|
128
|
+
activity_aggregate: mini.z.optional(
|
|
129
|
+
extension.wire({
|
|
130
|
+
basis: protoEnum("BASIS_"),
|
|
131
|
+
product_scope: protoEnum("PRODUCT_SCOPE_"),
|
|
132
|
+
currency: campaignCurrency(),
|
|
133
|
+
window: mini.z.optional(durationSeconds()),
|
|
134
|
+
timezone: text(),
|
|
135
|
+
late_event_grace: mini.z.optional(durationSeconds()),
|
|
136
|
+
casino: mini.z.optional(casinoSelector()),
|
|
137
|
+
sportsbook: mini.z.optional(sportsSelector())
|
|
138
|
+
})
|
|
139
|
+
)
|
|
140
|
+
});
|
|
141
|
+
var validity = () => extension.wire({
|
|
142
|
+
no_expiry: mini.z.optional(empty()),
|
|
143
|
+
absolute_expiry: mini.z.optional(extension.wire({ expires_at: mini.z.optional(mini.z.string()) })),
|
|
144
|
+
duration_from_grant: mini.z.optional(extension.wire({ duration: mini.z.optional(durationSeconds()) }))
|
|
145
|
+
});
|
|
146
|
+
var rounding = () => protoEnum("ROUNDING_MODE_");
|
|
147
|
+
var proceedsClass = () => protoEnum("PROCEEDS_CLASS_");
|
|
148
|
+
var percent = () => extension.wire({
|
|
149
|
+
percentage: mini.z.optional(ratio()),
|
|
150
|
+
rounding: rounding(),
|
|
151
|
+
minimum_reward: mini.z.optional(money()),
|
|
152
|
+
maximum_reward: mini.z.optional(money())
|
|
153
|
+
});
|
|
154
|
+
var balanceCredit = () => extension.wire({
|
|
155
|
+
fixed_amount: mini.z.optional(extension.wire({ amount: mini.z.optional(money()) })),
|
|
156
|
+
percent_of_source_amount: mini.z.optional(percent()),
|
|
157
|
+
aggregate_rebate: mini.z.optional(
|
|
158
|
+
extension.wire({
|
|
159
|
+
percentage: mini.z.optional(ratio()),
|
|
160
|
+
rounding: rounding(),
|
|
161
|
+
minimum_basis: mini.z.optional(money()),
|
|
162
|
+
maximum_reward: mini.z.optional(money())
|
|
163
|
+
})
|
|
164
|
+
),
|
|
165
|
+
balance_class: protoEnum("BALANCE_CLASS_"),
|
|
166
|
+
proceeds_class: proceedsClass(),
|
|
167
|
+
validity: mini.z.optional(validity())
|
|
168
|
+
});
|
|
169
|
+
var maximumBet = () => extension.wire({ mode: protoEnum("MAXIMUM_BET_MODE_"), campaign_maximum: mini.z.optional(money()) });
|
|
170
|
+
var oddsPolicy = () => extension.wire({
|
|
171
|
+
mode: protoEnum("MODE_"),
|
|
172
|
+
minimum_total_odds_decimal: mini.z.optional(mini.z.string()),
|
|
173
|
+
minimum_odds_per_leg_decimal: mini.z.optional(mini.z.string()),
|
|
174
|
+
minimum_legs: mini.z.optional(mini.z.number()),
|
|
175
|
+
maximum_legs: mini.z.optional(mini.z.number())
|
|
176
|
+
});
|
|
177
|
+
var cashoutMode = () => protoEnum("RESTRICTED_CASHOUT_MODE_");
|
|
178
|
+
var usePolicy = () => extension.wire({
|
|
179
|
+
version: count(),
|
|
180
|
+
funds_consumption: mini.z.optional(policy("FUNDS_CONSUMPTION_POLICY_CODE_")),
|
|
181
|
+
casino: mini.z.optional(extension.wire({ allowed_scopes: list(casinoSelector()), maximum_bet: mini.z.optional(maximumBet()) })),
|
|
182
|
+
sportsbook: mini.z.optional(
|
|
183
|
+
extension.wire({
|
|
184
|
+
allowed_scopes: list(sportsSelector()),
|
|
185
|
+
excluded_scopes: list(sportsSelector()),
|
|
186
|
+
maximum_bet: mini.z.optional(maximumBet()),
|
|
187
|
+
funding_odds: mini.z.optional(oddsPolicy()),
|
|
188
|
+
cashout_mode: cashoutMode()
|
|
189
|
+
})
|
|
190
|
+
),
|
|
191
|
+
casino_and_sportsbook: mini.z.optional(
|
|
192
|
+
extension.wire({
|
|
193
|
+
allowed_casino_scopes: list(casinoSelector()),
|
|
194
|
+
allowed_sportsbook_scopes: list(sportsSelector()),
|
|
195
|
+
excluded_sportsbook_scopes: list(sportsSelector()),
|
|
196
|
+
maximum_casino_bet: mini.z.optional(maximumBet()),
|
|
197
|
+
maximum_sportsbook_bet: mini.z.optional(maximumBet()),
|
|
198
|
+
sportsbook_funding_odds: mini.z.optional(oddsPolicy()),
|
|
199
|
+
sportsbook_cashout_mode: cashoutMode()
|
|
200
|
+
})
|
|
201
|
+
),
|
|
202
|
+
payout_allocation: mini.z.optional(policy("PAYOUT_ALLOCATION_POLICY_CODE_"))
|
|
203
|
+
});
|
|
204
|
+
var wageringPolicy = () => extension.wire({
|
|
205
|
+
version: count(),
|
|
206
|
+
none: mini.z.optional(empty()),
|
|
207
|
+
multiplier: mini.z.optional(
|
|
208
|
+
extension.wire({
|
|
209
|
+
requirement_basis: protoEnum("REQUIREMENT_BASIS_"),
|
|
210
|
+
multiplier: mini.z.optional(ratio()),
|
|
211
|
+
contribution_rates: list(
|
|
212
|
+
extension.wire({
|
|
213
|
+
casino: mini.z.optional(casinoSelector()),
|
|
214
|
+
sportsbook: mini.z.optional(sportsSelector()),
|
|
215
|
+
rate: mini.z.optional(ratio())
|
|
216
|
+
})
|
|
217
|
+
),
|
|
218
|
+
deadline: mini.z.optional(validity()),
|
|
219
|
+
rounding: rounding(),
|
|
220
|
+
sportsbook_contribution_odds: mini.z.optional(oddsPolicy())
|
|
221
|
+
})
|
|
222
|
+
)
|
|
223
|
+
});
|
|
224
|
+
var stackingPolicy = () => extension.wire({
|
|
225
|
+
version: count(),
|
|
226
|
+
exclusive_in_group: mini.z.optional(extension.wire({ stacking_group_key: text() })),
|
|
227
|
+
multiple_in_group: mini.z.optional(extension.wire({ stacking_group_key: text(), maximum_active_per_player: count() }))
|
|
228
|
+
});
|
|
229
|
+
var reward = () => extension.wire({
|
|
230
|
+
reward_key: text(),
|
|
231
|
+
reward_kind: protoEnum("REWARD_KIND_"),
|
|
232
|
+
reward_kind_version: count(),
|
|
233
|
+
execution_profile_code: protoEnum("EXECUTION_PROFILE_CODE_"),
|
|
234
|
+
execution_profile_version: count(),
|
|
235
|
+
balance_credit: mini.z.optional(balanceCredit()),
|
|
236
|
+
provider_managed_balance: mini.z.optional(extension.wire({ provider_code: text() })),
|
|
237
|
+
casino_free_spins: mini.z.optional(
|
|
238
|
+
extension.wire({
|
|
239
|
+
provider_code: text(),
|
|
240
|
+
casino_scope: mini.z.optional(casinoSelector()),
|
|
241
|
+
quantity: count(),
|
|
242
|
+
denomination: mini.z.optional(money()),
|
|
243
|
+
currency: campaignCurrency(),
|
|
244
|
+
grant_window: mini.z.optional(timeWindow()),
|
|
245
|
+
proceeds_class: proceedsClass(),
|
|
246
|
+
maximum_winnings: mini.z.optional(money())
|
|
247
|
+
})
|
|
248
|
+
),
|
|
249
|
+
sports_bonus_bet: mini.z.optional(
|
|
250
|
+
extension.wire({
|
|
251
|
+
provider_code: text(),
|
|
252
|
+
sportsbook_scope: mini.z.optional(sportsSelector()),
|
|
253
|
+
amount: mini.z.optional(money()),
|
|
254
|
+
quantity: count(),
|
|
255
|
+
validity: mini.z.optional(validity())
|
|
256
|
+
})
|
|
257
|
+
),
|
|
258
|
+
sports_bet_coverage: mini.z.optional(
|
|
259
|
+
extension.wire({
|
|
260
|
+
provider_code: text(),
|
|
261
|
+
qualifying_bet_scope: mini.z.optional(sportsSelector()),
|
|
262
|
+
coverage_cap: mini.z.optional(money()),
|
|
263
|
+
validity: mini.z.optional(validity())
|
|
264
|
+
})
|
|
265
|
+
),
|
|
266
|
+
use_policy: mini.z.optional(usePolicy()),
|
|
267
|
+
wagering_policy: mini.z.optional(wageringPolicy()),
|
|
268
|
+
stacking_policy: mini.z.optional(stackingPolicy()),
|
|
269
|
+
restricted_position_selection_policy: mini.z.optional(
|
|
270
|
+
extension.wire({
|
|
271
|
+
version: count(),
|
|
272
|
+
priority_then_earliest_expiry: mini.z.optional(extension.wire({ selection_priority: mini.z.optional(mini.z.number()) }))
|
|
273
|
+
})
|
|
274
|
+
)
|
|
275
|
+
});
|
|
276
|
+
var localizedContent = () => extension.wire({ locale: text(), display_name: text(), description: text(), terms: text(), terms_revision: text() });
|
|
277
|
+
var content = () => extension.wire({ default_locale: text(), supported_locales: list(mini.z.string()), localized_content: list(localizedContent()) });
|
|
278
|
+
var offerSchema = /* @__PURE__ */ extension.lazy(
|
|
279
|
+
() => extension.wire({
|
|
280
|
+
campaign_id: text(),
|
|
281
|
+
campaign_version_id: text(),
|
|
282
|
+
publication_id: text(),
|
|
283
|
+
product_scope: protoEnum("PRODUCT_SCOPE_"),
|
|
284
|
+
timezone: text(),
|
|
285
|
+
enrollment_window: mini.z.optional(timeWindow()),
|
|
286
|
+
qualification_window: mini.z.optional(timeWindow()),
|
|
287
|
+
claim_window: mini.z.optional(timeWindow()),
|
|
288
|
+
entry_policy: mini.z.optional(policy("ENTRY_POLICY_CODE_")),
|
|
289
|
+
reward_claim_policy: mini.z.optional(policy("REWARD_CLAIM_POLICY_CODE_")),
|
|
290
|
+
qualification: mini.z.optional(qualification()),
|
|
291
|
+
reward: mini.z.optional(reward()),
|
|
292
|
+
publication_starts_at: mini.z.optional(mini.z.string()),
|
|
293
|
+
publication_ends_at: mini.z.optional(mini.z.string()),
|
|
294
|
+
content: mini.z.optional(content())
|
|
295
|
+
})
|
|
296
|
+
);
|
|
297
|
+
var participationSchema = /* @__PURE__ */ extension.lazy(
|
|
298
|
+
() => mini.z.pipe(
|
|
299
|
+
extension.wire({
|
|
300
|
+
id: text(),
|
|
301
|
+
campaign_id: text(),
|
|
302
|
+
campaign_version_id: text(),
|
|
303
|
+
reward_key: text(),
|
|
304
|
+
qualification_snapshot: mini.z.optional(qualification()),
|
|
305
|
+
// oneof `state`: only one of the cases is filled in.
|
|
306
|
+
enrolled: mini.z.optional(empty()),
|
|
307
|
+
qualifying: mini.z.optional(empty()),
|
|
308
|
+
qualified: mini.z.optional(extension.wire({ qualified_at: mini.z.optional(mini.z.string()) })),
|
|
309
|
+
reward_pending: mini.z.optional(empty()),
|
|
310
|
+
completed: mini.z.optional(extension.wire({ completed_at: mini.z.optional(mini.z.string()) })),
|
|
311
|
+
reward_failed: mini.z.optional(empty()),
|
|
312
|
+
expired: mini.z.optional(extension.wire({ expired_at: mini.z.optional(mini.z.string()) })),
|
|
313
|
+
cancelled: mini.z.optional(empty()),
|
|
314
|
+
snapshot: mini.z.optional(
|
|
315
|
+
extension.wire({
|
|
316
|
+
reward: mini.z.optional(reward()),
|
|
317
|
+
content: mini.z.optional(content()),
|
|
318
|
+
terms_acceptance: mini.z.optional(
|
|
319
|
+
extension.wire({
|
|
320
|
+
locale: text(),
|
|
321
|
+
terms_revision: text(),
|
|
322
|
+
terms_digest_sha256_hex: text(),
|
|
323
|
+
accepted_at: mini.z.optional(mini.z.string())
|
|
324
|
+
})
|
|
325
|
+
)
|
|
326
|
+
})
|
|
327
|
+
)
|
|
328
|
+
}),
|
|
329
|
+
// The oneof becomes `status` (+ the timestamp of the case); the oneof's keys are not passed on.
|
|
330
|
+
mini.z.transform(
|
|
331
|
+
({ enrolled, qualifying, qualified, rewardPending, completed, rewardFailed, expired, cancelled, ...rest }) => {
|
|
332
|
+
const out = { ...rest, status: "unspecified" };
|
|
333
|
+
if (enrolled) out.status = "enrolled";
|
|
334
|
+
else if (qualifying) out.status = "qualifying";
|
|
335
|
+
else if (qualified) {
|
|
336
|
+
out.status = "qualified";
|
|
337
|
+
if (qualified.qualifiedAt !== void 0) out.qualifiedAt = qualified.qualifiedAt;
|
|
338
|
+
} else if (rewardPending) out.status = "reward_pending";
|
|
339
|
+
else if (completed) {
|
|
340
|
+
out.status = "completed";
|
|
341
|
+
if (completed.completedAt !== void 0) out.completedAt = completed.completedAt;
|
|
342
|
+
} else if (rewardFailed) out.status = "reward_failed";
|
|
343
|
+
else if (expired) {
|
|
344
|
+
out.status = "expired";
|
|
345
|
+
if (expired.expiredAt !== void 0) out.expiredAt = expired.expiredAt;
|
|
346
|
+
} else if (cancelled) out.status = "cancelled";
|
|
347
|
+
return out;
|
|
348
|
+
}
|
|
349
|
+
)
|
|
350
|
+
)
|
|
351
|
+
);
|
|
352
|
+
var cursorPageSchema = (key, item) => extension.wire({ [key]: list(item), next_cursor: mini.z.optional(mini.z.string()) });
|
|
353
|
+
var offersPage = /* @__PURE__ */ extension.lazy(() => cursorPageSchema("offers", offerSchema()));
|
|
354
|
+
var participationsPage = /* @__PURE__ */ extension.lazy(() => cursorPageSchema("participations", participationSchema()));
|
|
355
|
+
var offerEnvelope = /* @__PURE__ */ extension.lazy(() => extension.wire({ offer: offerSchema() }));
|
|
356
|
+
var participationEnvelope = /* @__PURE__ */ extension.lazy(() => extension.wire({ participation: participationSchema() }));
|
|
357
|
+
var promoCodeOfferSchema = /* @__PURE__ */ extension.lazy(
|
|
358
|
+
() => extension.wire({ offer: offerSchema(), localized_content: localizedContent() })
|
|
359
|
+
);
|
|
360
|
+
function toCursorPage(key, data) {
|
|
361
|
+
const page = { items: data[key] };
|
|
362
|
+
if (data.nextCursor) page.nextCursor = data.nextCursor;
|
|
363
|
+
return page;
|
|
364
|
+
}
|
|
365
|
+
var terms = (acceptance) => acceptance && { locale: acceptance.locale, terms_revision: acceptance.termsRevision };
|
|
366
|
+
function createBonusApi(transport) {
|
|
367
|
+
const listPage = (path, key, schema, auth, input, options) => transport.request({
|
|
368
|
+
method: "GET",
|
|
369
|
+
path,
|
|
370
|
+
query: { page_size: input?.pageSize, cursor: input?.cursor },
|
|
371
|
+
auth,
|
|
372
|
+
schema,
|
|
373
|
+
options
|
|
374
|
+
}).then((data) => toCursorPage(key, data));
|
|
375
|
+
const participationCall = (path, body, options) => transport.request({
|
|
376
|
+
method: "POST",
|
|
377
|
+
path,
|
|
378
|
+
body,
|
|
379
|
+
auth: "required",
|
|
380
|
+
idempotent: true,
|
|
381
|
+
validation: "strict",
|
|
382
|
+
schema: participationEnvelope(),
|
|
383
|
+
options
|
|
384
|
+
}).then((data) => data.participation);
|
|
385
|
+
return {
|
|
386
|
+
listPublicOffers: (input, options) => listPage("/bonus-campaigns/public-offers", "offers", offersPage(), "none", input, options),
|
|
387
|
+
listOffers: (input, options) => listPage("/bonus-campaigns/offers", "offers", offersPage(), "required", input, options),
|
|
388
|
+
getOffer: ({ campaignId }, options) => transport.request({
|
|
389
|
+
method: "GET",
|
|
390
|
+
path: `/bonus-campaigns/offers/${encodeURIComponent(campaignId)}`,
|
|
391
|
+
auth: "required",
|
|
392
|
+
schema: offerEnvelope(),
|
|
393
|
+
options
|
|
394
|
+
}).then((data) => data.offer),
|
|
395
|
+
optIn: ({ campaignId, campaignVersionId, termsAcceptance }, options) => participationCall(
|
|
396
|
+
`/bonus-campaigns/offers/${encodeURIComponent(campaignId)}/opt-in`,
|
|
397
|
+
{ campaign_version_id: campaignVersionId, terms_acceptance: terms(termsAcceptance) },
|
|
398
|
+
options
|
|
399
|
+
),
|
|
400
|
+
claim: ({ participationId }, options) => participationCall(
|
|
401
|
+
`/bonus-campaigns/participations/${encodeURIComponent(participationId)}/claim`,
|
|
402
|
+
void 0,
|
|
403
|
+
options
|
|
404
|
+
),
|
|
405
|
+
resolvePromoCode: ({ code, locale }, options) => transport.request({
|
|
406
|
+
method: "POST",
|
|
407
|
+
path: "/bonus-campaigns/promo-codes/resolve",
|
|
408
|
+
body: { plaintext: code, locale },
|
|
409
|
+
auth: "required",
|
|
410
|
+
schema: promoCodeOfferSchema(),
|
|
411
|
+
options
|
|
412
|
+
}),
|
|
413
|
+
redeemPromoCode: ({ code, termsAcceptance }, options) => participationCall(
|
|
414
|
+
"/bonus-campaigns/promo-codes/redeem",
|
|
415
|
+
{ plaintext: code, terms_acceptance: terms(termsAcceptance) },
|
|
416
|
+
options
|
|
417
|
+
),
|
|
418
|
+
listParticipations: (input, options) => listPage(
|
|
419
|
+
"/bonus-campaigns/participations",
|
|
420
|
+
"participations",
|
|
421
|
+
participationsPage(),
|
|
422
|
+
"required",
|
|
423
|
+
input,
|
|
424
|
+
options
|
|
425
|
+
),
|
|
426
|
+
getParticipation: ({ participationId }, options) => transport.request({
|
|
427
|
+
method: "GET",
|
|
428
|
+
path: `/bonus-campaigns/participations/${encodeURIComponent(participationId)}`,
|
|
429
|
+
auth: "required",
|
|
430
|
+
schema: participationEnvelope(),
|
|
431
|
+
options
|
|
432
|
+
}).then((data) => data.participation)
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
var gameSchema = /* @__PURE__ */ extension.lazy(
|
|
436
|
+
() => extension.wire({
|
|
437
|
+
id: mini.z.string(),
|
|
438
|
+
name: mini.z.string(),
|
|
439
|
+
provider: mini.z.string(),
|
|
440
|
+
category: mini.z.string(),
|
|
441
|
+
type: mini.z.string(),
|
|
442
|
+
thumbnail: mini.z.string(),
|
|
443
|
+
is_new: mini.z.boolean(),
|
|
444
|
+
is_popular: mini.z.boolean(),
|
|
445
|
+
is_live: mini.z.boolean(),
|
|
446
|
+
demo_available: mini.z.boolean(),
|
|
447
|
+
rtp: mini.z.number(),
|
|
448
|
+
volatility: mini.z.string(),
|
|
449
|
+
priority: mini.z.number()
|
|
450
|
+
})
|
|
451
|
+
);
|
|
452
|
+
var categoriesSchema = /* @__PURE__ */ extension.lazy(
|
|
453
|
+
() => mini.z.array(
|
|
454
|
+
extension.wire({ slug: mini.z.string(), name: mini.z.string(), icon: mini.z.string(), game_count: mini.z.number(), priority: mini.z.number() })
|
|
455
|
+
)
|
|
456
|
+
);
|
|
457
|
+
var providersSchema = /* @__PURE__ */ extension.lazy(
|
|
458
|
+
() => mini.z.array(extension.wire({ id: mini.z.string(), name: mini.z.string(), game_count: mini.z.number() }))
|
|
459
|
+
);
|
|
460
|
+
var launchSchema = /* @__PURE__ */ extension.lazy(
|
|
461
|
+
() => mini.z.pipe(
|
|
462
|
+
extension.wire({
|
|
463
|
+
session_id: mini.z.string().check(mini.z.minLength(1)),
|
|
464
|
+
game_url: mini.z.string().check(mini.z.minLength(1)),
|
|
465
|
+
// Any text: a target the SDK does not know yet must not fail the (strict) launch.
|
|
466
|
+
launch_target: mini.z.optional(mini.z.string()),
|
|
467
|
+
provider_code: mini.z.optional(mini.z.string()),
|
|
468
|
+
expires_at: mini.z.optional(mini.z.string())
|
|
469
|
+
}),
|
|
470
|
+
// Without a target (an older gateway, or a custom mock), the launch keeps the behavior the SDK documented
|
|
471
|
+
// before the field existed: an iframe.
|
|
472
|
+
mini.z.transform(({ launchTarget, ...rest }) => ({ ...rest, launchTarget: launchTarget || "iframe" }))
|
|
473
|
+
)
|
|
474
|
+
);
|
|
475
|
+
var sessionSchema = /* @__PURE__ */ extension.lazy(
|
|
476
|
+
() => extension.wire({
|
|
477
|
+
id: mini.z.string(),
|
|
478
|
+
game_id: mini.z.string(),
|
|
479
|
+
game_name: mini.z.string(),
|
|
480
|
+
provider: mini.z.string(),
|
|
481
|
+
start_time: mini.z.string(),
|
|
482
|
+
total_bet: extension.money(),
|
|
483
|
+
total_win: extension.money(),
|
|
484
|
+
status: protoEnum("SESSION_STATUS_")
|
|
485
|
+
})
|
|
486
|
+
);
|
|
487
|
+
var transactionSchema = /* @__PURE__ */ extension.lazy(
|
|
488
|
+
() => extension.wire({
|
|
489
|
+
id: mini.z.string(),
|
|
490
|
+
game_id: mini.z.string(),
|
|
491
|
+
game_name: mini.z.string(),
|
|
492
|
+
round_id: mini.z.string(),
|
|
493
|
+
type: protoEnum("CASINO_TRANSACTION_TYPE_"),
|
|
494
|
+
amount: minorUnits(),
|
|
495
|
+
currency: extension.currencyCode(),
|
|
496
|
+
currency_decimal_places: extension.decimalPlaces(),
|
|
497
|
+
created_at: mini.z.string()
|
|
498
|
+
})
|
|
499
|
+
);
|
|
500
|
+
var winnersSchema = /* @__PURE__ */ extension.lazy(
|
|
501
|
+
() => mini.z.array(
|
|
502
|
+
extension.wire({
|
|
503
|
+
player: mini.z.string(),
|
|
504
|
+
amount: minorUnits(),
|
|
505
|
+
currency: extension.currencyCode(),
|
|
506
|
+
currency_decimal_places: extension.decimalPlaces(),
|
|
507
|
+
game_id: mini.z.string(),
|
|
508
|
+
game_name: mini.z.string(),
|
|
509
|
+
won_at: mini.z.string()
|
|
510
|
+
})
|
|
511
|
+
)
|
|
512
|
+
);
|
|
513
|
+
function createCasinoApi(transport) {
|
|
514
|
+
return {
|
|
515
|
+
listGames: (input, options) => transport.requestPage({
|
|
516
|
+
method: "GET",
|
|
517
|
+
path: "/games",
|
|
518
|
+
query: {
|
|
519
|
+
category: input?.category,
|
|
520
|
+
provider: input?.provider,
|
|
521
|
+
search: input?.search,
|
|
522
|
+
ids: input?.ids?.length ? input.ids.join(",") : void 0,
|
|
523
|
+
sort: input?.sort
|
|
524
|
+
},
|
|
525
|
+
page: input?.page,
|
|
526
|
+
perPage: input?.perPage,
|
|
527
|
+
perPageParam: "limit",
|
|
528
|
+
auth: "none",
|
|
529
|
+
item: gameSchema(),
|
|
530
|
+
options
|
|
531
|
+
}),
|
|
532
|
+
listCategories: (_params, options) => transport.request({ method: "GET", path: "/games/categories", schema: categoriesSchema(), options }),
|
|
533
|
+
listProviders: (_params, options) => transport.request({ method: "GET", path: "/games/providers", schema: providersSchema(), options }),
|
|
534
|
+
getGame: ({ gameId }, options) => transport.request({
|
|
535
|
+
method: "GET",
|
|
536
|
+
path: `/games/${encodeURIComponent(gameId)}`,
|
|
537
|
+
schema: gameSchema(),
|
|
538
|
+
options
|
|
539
|
+
}),
|
|
540
|
+
launchGame: ({ gameId, mode, isMobile, returnUrl, language }, options) => transport.request({
|
|
541
|
+
method: "POST",
|
|
542
|
+
path: `/games/${encodeURIComponent(gameId)}/launch`,
|
|
543
|
+
body: { is_demo: mode === "demo", is_mobile: isMobile === true, return_url: returnUrl, language },
|
|
544
|
+
auth: "required",
|
|
545
|
+
// The response carries the URL with the game session token: never through `warn` mode's recovery
|
|
546
|
+
// (which would deliver a raw field and the response to `onValidationIssue`).
|
|
547
|
+
validation: "strict",
|
|
548
|
+
schema: launchSchema(),
|
|
549
|
+
options
|
|
550
|
+
}),
|
|
551
|
+
listSessions: (input, options) => transport.requestPage({
|
|
552
|
+
method: "GET",
|
|
553
|
+
path: "/games/sessions",
|
|
554
|
+
page: input?.page,
|
|
555
|
+
perPage: input?.perPage,
|
|
556
|
+
perPageParam: "limit",
|
|
557
|
+
auth: "required",
|
|
558
|
+
item: sessionSchema(),
|
|
559
|
+
options
|
|
560
|
+
}),
|
|
561
|
+
getHistory: (input, options) => transport.requestPage({
|
|
562
|
+
method: "GET",
|
|
563
|
+
path: "/games/history",
|
|
564
|
+
page: input?.page,
|
|
565
|
+
perPage: input?.perPage,
|
|
566
|
+
perPageParam: "limit",
|
|
567
|
+
auth: "required",
|
|
568
|
+
item: transactionSchema(),
|
|
569
|
+
options
|
|
570
|
+
}),
|
|
571
|
+
getBiggestWinners: (input, options) => transport.request({
|
|
572
|
+
method: "GET",
|
|
573
|
+
path: "/games/biggest-winners",
|
|
574
|
+
query: { limit: input?.limit, days: input?.days },
|
|
575
|
+
auth: "required",
|
|
576
|
+
schema: winnersSchema(),
|
|
577
|
+
options
|
|
578
|
+
})
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// src/internal/input.ts
|
|
583
|
+
function rejectInput(transport, message, route) {
|
|
584
|
+
return Promise.reject(
|
|
585
|
+
transport.reportError({ code: "CONFIGURATION_ERROR", message, status: 0 }, { ...route, attempt: 0 })
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
function pageInputProblem(name, input) {
|
|
589
|
+
if (input === void 0) return void 0;
|
|
590
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) return `${name}: input must be an object.`;
|
|
591
|
+
const { page, perPage } = input;
|
|
592
|
+
if (page !== void 0 && (typeof page !== "number" || !Number.isSafeInteger(page) || page < 1))
|
|
593
|
+
return `${name}: page must be an integer \u2265 1.`;
|
|
594
|
+
if (perPage !== void 0 && (typeof perPage !== "number" || !Number.isInteger(perPage) || perPage < 1 || perPage > 100))
|
|
595
|
+
return `${name}: perPage must be an integer from 1 to 100.`;
|
|
596
|
+
return void 0;
|
|
597
|
+
}
|
|
598
|
+
function optionalTimestamp() {
|
|
599
|
+
return mini.z.pipe(
|
|
600
|
+
mini.z.nullish(mini.z.string().check(mini.z.refine((value) => value === "" || !Number.isNaN(Date.parse(value)), "invalid date"))),
|
|
601
|
+
mini.z.transform((value) => value == null || value === "" || Date.parse(value) === 0 ? null : value)
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
function optionalText() {
|
|
605
|
+
return mini.z.pipe(
|
|
606
|
+
mini.z.nullish(mini.z.string()),
|
|
607
|
+
mini.z.transform((value) => value == null || value === "" ? null : value)
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
function nullableList(item) {
|
|
611
|
+
return mini.z.pipe(
|
|
612
|
+
mini.z.nullish(mini.z.array(item)),
|
|
613
|
+
mini.z.transform((value) => value ?? [])
|
|
614
|
+
);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
// src/modules/loyalty.ts
|
|
618
|
+
var tierBenefits = () => mini.z.pipe(
|
|
619
|
+
mini.z.nullish(mini.z.string()),
|
|
620
|
+
mini.z.transform((text2, ctx) => {
|
|
621
|
+
if (text2 == null || text2.trim() === "") return null;
|
|
622
|
+
let parsed;
|
|
623
|
+
try {
|
|
624
|
+
parsed = JSON.parse(text2);
|
|
625
|
+
} catch {
|
|
626
|
+
parsed = void 0;
|
|
627
|
+
}
|
|
628
|
+
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed))
|
|
629
|
+
return parsed;
|
|
630
|
+
ctx.issues.push({ code: "custom", message: "tier_benefits_json is not a JSON object", input: void 0 });
|
|
631
|
+
return mini.z.NEVER;
|
|
632
|
+
})
|
|
633
|
+
);
|
|
634
|
+
var loyaltySchema = /* @__PURE__ */ extension.lazy(
|
|
635
|
+
() => mini.z.pipe(
|
|
636
|
+
extension.wire({
|
|
637
|
+
total_points_earned: integerText(),
|
|
638
|
+
current_points: integerText(),
|
|
639
|
+
points_redeemed: integerText(),
|
|
640
|
+
current_tier: optionalText(),
|
|
641
|
+
tier_points: integerText(),
|
|
642
|
+
lifetime_wagered: mini.z._default(minorUnits(), 0),
|
|
643
|
+
lifetime_deposited: mini.z._default(minorUnits(), 0),
|
|
644
|
+
tier_benefits_json: tierBenefits(),
|
|
645
|
+
tier_expires_at: optionalTimestamp()
|
|
646
|
+
}),
|
|
647
|
+
mini.z.transform(({ tierBenefitsJson, ...rest }) => {
|
|
648
|
+
const benefits = typeof tierBenefitsJson === "object" && tierBenefitsJson !== null && !Array.isArray(tierBenefitsJson) ? tierBenefitsJson : null;
|
|
649
|
+
return { ...rest, tierBenefits: benefits };
|
|
650
|
+
})
|
|
651
|
+
)
|
|
652
|
+
);
|
|
653
|
+
var redeemSchema = /* @__PURE__ */ extension.lazy(
|
|
654
|
+
() => mini.z.pipe(
|
|
655
|
+
extension.wire({
|
|
656
|
+
success: mini.z.optional(mini.z.boolean()),
|
|
657
|
+
message: mini.z.optional(mini.z.string()),
|
|
658
|
+
redeemed_points: integerText(),
|
|
659
|
+
value: mini.z.nullish(minorUnits()),
|
|
660
|
+
// Currency strict even in `'warn'`; absent, `null` and `''` still become `null`.
|
|
661
|
+
currency: mini.z.pipe(
|
|
662
|
+
mini.z.nullish(currencyOrEmpty()),
|
|
663
|
+
mini.z.transform((value) => value == null || value === "" ? null : value)
|
|
664
|
+
),
|
|
665
|
+
bonus_id: optionalText()
|
|
666
|
+
}),
|
|
667
|
+
mini.z.transform((data) => ({
|
|
668
|
+
success: data.success,
|
|
669
|
+
message: data.message,
|
|
670
|
+
redeemedPoints: data.redeemedPoints,
|
|
671
|
+
value: data.value ?? null,
|
|
672
|
+
currency: data.currency,
|
|
673
|
+
bonusId: data.bonusId
|
|
674
|
+
}))
|
|
675
|
+
)
|
|
676
|
+
);
|
|
677
|
+
var UNCONFIRMED_REDEEM = "loyalty.redeem: the gateway did not confirm the redemption.";
|
|
678
|
+
var REDEEM_ROUTE = { method: "POST", path: "/loyalty/redeem" };
|
|
679
|
+
function redeemInputProblem(input) {
|
|
680
|
+
if (typeof input !== "object" || input === null || Array.isArray(input))
|
|
681
|
+
return "loyalty.redeem: input must be an object { points, redemptionType }.";
|
|
682
|
+
const { points, redemptionType } = input;
|
|
683
|
+
if (typeof points !== "number" || !Number.isSafeInteger(points) || points <= 0)
|
|
684
|
+
return "loyalty.redeem: points must be an integer greater than 0.";
|
|
685
|
+
if (typeof redemptionType !== "string" || redemptionType.trim() === "")
|
|
686
|
+
return "loyalty.redeem: redemptionType must be non-empty text.";
|
|
687
|
+
return void 0;
|
|
688
|
+
}
|
|
689
|
+
function createLoyaltyApi(transport) {
|
|
690
|
+
return {
|
|
691
|
+
get: (_params, options) => transport.request({ method: "GET", path: "/loyalty", auth: "required", schema: loyaltySchema(), options }),
|
|
692
|
+
redeem: (input, options) => {
|
|
693
|
+
const problem = redeemInputProblem(input);
|
|
694
|
+
if (problem !== void 0) return rejectInput(transport, problem, REDEEM_ROUTE);
|
|
695
|
+
return transport.request({
|
|
696
|
+
...REDEEM_ROUTE,
|
|
697
|
+
body: { points: input.points, redemption_type: input.redemptionType },
|
|
698
|
+
auth: "required",
|
|
699
|
+
idempotent: true,
|
|
700
|
+
schema: redeemSchema(),
|
|
701
|
+
options
|
|
702
|
+
}).then(({ success, message, ...result }) => {
|
|
703
|
+
if (success === true) return result;
|
|
704
|
+
const text2 = typeof message === "string" && message !== "" ? message : UNCONFIRMED_REDEEM;
|
|
705
|
+
throw transport.reportError({ code: "UNKNOWN", message: text2, status: 200 }, REDEEM_ROUTE);
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
function openUnion(values) {
|
|
711
|
+
return mini.z.pipe(
|
|
712
|
+
mini.z.pipe(
|
|
713
|
+
mini.z.string(),
|
|
714
|
+
mini.z.transform((value) => value.toLowerCase())
|
|
715
|
+
),
|
|
716
|
+
mini.z.enum(values)
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
// src/modules/missions.ts
|
|
721
|
+
var MISSION_TYPES = ["daily", "weekly", "event", "permanent"];
|
|
722
|
+
var OBJECTIVE_TYPES = ["wager", "bet_count", "win_amount", "play_game", "deposit"];
|
|
723
|
+
var REWARD_TYPES = ["bonus", "free_spins", "points", "free_bet"];
|
|
724
|
+
var USER_MISSION_STATUSES = ["in_progress", "completed", "expired", "claimed"];
|
|
725
|
+
var missionSchema = /* @__PURE__ */ extension.lazy(
|
|
726
|
+
() => extension.wire({
|
|
727
|
+
id: mini.z.string(),
|
|
728
|
+
name: mini.z.string(),
|
|
729
|
+
description: mini.z._default(mini.z.string(), ""),
|
|
730
|
+
mission_type: openUnion(MISSION_TYPES),
|
|
731
|
+
objective_type: openUnion(OBJECTIVE_TYPES),
|
|
732
|
+
target_value: integerText(),
|
|
733
|
+
target_game_category: optionalText(),
|
|
734
|
+
target_games: nullableList(mini.z.string()),
|
|
735
|
+
reward_type: openUnion(REWARD_TYPES),
|
|
736
|
+
reward_value: minorUnits(),
|
|
737
|
+
valid_from: optionalTimestamp(),
|
|
738
|
+
valid_to: optionalTimestamp()
|
|
739
|
+
})
|
|
740
|
+
);
|
|
741
|
+
var userMissionsSchema = /* @__PURE__ */ extension.lazy(
|
|
742
|
+
() => mini.z.pipe(
|
|
743
|
+
extension.wire({
|
|
744
|
+
missions: nullableList(
|
|
745
|
+
extension.wire({
|
|
746
|
+
id: mini.z.string(),
|
|
747
|
+
mission_id: mini.z.string(),
|
|
748
|
+
mission_name: mini.z._default(mini.z.string(), ""),
|
|
749
|
+
current_progress: integerText(),
|
|
750
|
+
target_value: integerText(),
|
|
751
|
+
progress_percentage: mini.z.number(),
|
|
752
|
+
status: openUnion(USER_MISSION_STATUSES),
|
|
753
|
+
reward_type: openUnion(REWARD_TYPES),
|
|
754
|
+
reward_value: minorUnits(),
|
|
755
|
+
period_end: optionalTimestamp(),
|
|
756
|
+
completed_at: optionalTimestamp()
|
|
757
|
+
})
|
|
758
|
+
)
|
|
759
|
+
}),
|
|
760
|
+
mini.z.transform((data) => data.missions)
|
|
761
|
+
)
|
|
762
|
+
);
|
|
763
|
+
function createMissionsApi(transport) {
|
|
764
|
+
return {
|
|
765
|
+
list: (input, options) => {
|
|
766
|
+
const problem = pageInputProblem("missions.list", input);
|
|
767
|
+
if (problem !== void 0) return rejectInput(transport, problem, { method: "GET", path: "/missions" });
|
|
768
|
+
return transport.requestPage({
|
|
769
|
+
method: "GET",
|
|
770
|
+
path: "/missions",
|
|
771
|
+
page: input?.page,
|
|
772
|
+
perPage: input?.perPage,
|
|
773
|
+
perPageParam: "limit",
|
|
774
|
+
auth: "required",
|
|
775
|
+
item: missionSchema(),
|
|
776
|
+
options
|
|
777
|
+
});
|
|
778
|
+
},
|
|
779
|
+
listMine: (_params, options) => transport.request({
|
|
780
|
+
method: "GET",
|
|
781
|
+
path: "/my/missions",
|
|
782
|
+
auth: "required",
|
|
783
|
+
schema: userMissionsSchema(),
|
|
784
|
+
options
|
|
785
|
+
})
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
var STATUSES = ["pending", "qualified", "completed", "expired", "unspecified"];
|
|
789
|
+
var status = () => mini.z.pipe(protoEnum("REFERRAL_STATUS_"), mini.z.enum(STATUSES));
|
|
790
|
+
var DEFAULT_PER_PAGE = 20;
|
|
791
|
+
var count2 = () => mini.z._default(mini.z.number().check(mini.z.refine((value) => Number.isInteger(value) && value >= 0, "invalid counter")), 0);
|
|
792
|
+
var HISTORY_PATH = "/referrals/history";
|
|
793
|
+
var REGISTER_ROUTE = { method: "POST", path: "/referrals/register" };
|
|
794
|
+
function maskEmail(value) {
|
|
795
|
+
if (typeof value !== "string") return null;
|
|
796
|
+
const email = value.trim();
|
|
797
|
+
const parts = email.split("@");
|
|
798
|
+
if (parts.length !== 2 || /\s/.test(email)) return null;
|
|
799
|
+
const [local, domain] = parts;
|
|
800
|
+
if (local === "" || domain === "") return null;
|
|
801
|
+
const chars = Array.from(local);
|
|
802
|
+
return `${chars.length === 1 ? "*" : chars[0] + "*".repeat(chars.length - 1)}@${domain}`;
|
|
803
|
+
}
|
|
804
|
+
var infoSchema = /* @__PURE__ */ extension.lazy(
|
|
805
|
+
() => mini.z.pipe(
|
|
806
|
+
extension.wire({
|
|
807
|
+
referral_code: optionalText(),
|
|
808
|
+
referral_link: optionalText(),
|
|
809
|
+
total_referrals: count2(),
|
|
810
|
+
completed_referrals: count2(),
|
|
811
|
+
pending_referrals: count2(),
|
|
812
|
+
total_earned: majorUnits(),
|
|
813
|
+
bonus_per_referral: majorUnits(),
|
|
814
|
+
min_deposit: majorUnits()
|
|
815
|
+
}),
|
|
816
|
+
mini.z.transform(
|
|
817
|
+
({ referralCode, referralLink, ...rest }) => ({
|
|
818
|
+
code: referralCode,
|
|
819
|
+
link: referralLink,
|
|
820
|
+
...rest
|
|
821
|
+
})
|
|
822
|
+
)
|
|
823
|
+
)
|
|
824
|
+
);
|
|
825
|
+
var MinorAmount = class {
|
|
826
|
+
constructor(value) {
|
|
827
|
+
this.value = value;
|
|
828
|
+
}
|
|
829
|
+
value;
|
|
830
|
+
};
|
|
831
|
+
var minorAmount = () => mini.z.pipe(
|
|
832
|
+
majorUnits(),
|
|
833
|
+
mini.z.transform((value) => new MinorAmount(value))
|
|
834
|
+
);
|
|
835
|
+
var BUILT = /* @__PURE__ */ new WeakSet();
|
|
836
|
+
var referralSchema = /* @__PURE__ */ extension.lazy(
|
|
837
|
+
() => mini.z.pipe(
|
|
838
|
+
extension.wire({
|
|
839
|
+
id: mini.z.string(),
|
|
840
|
+
referee_id: mini.z.optional(mini.z.string()),
|
|
841
|
+
referee_email: mini.z.nullish(mini.z.string()),
|
|
842
|
+
referee_name: optionalText(),
|
|
843
|
+
referral_code: mini.z._default(mini.z.string(), ""),
|
|
844
|
+
status: status(),
|
|
845
|
+
referrer_bonus: minorAmount(),
|
|
846
|
+
referee_bonus: minorAmount(),
|
|
847
|
+
created_at: optionalTimestamp(),
|
|
848
|
+
completed_at: optionalTimestamp(),
|
|
849
|
+
expires_at: optionalTimestamp()
|
|
850
|
+
}),
|
|
851
|
+
mini.z.transform((r) => {
|
|
852
|
+
const referrerBonus = r.referrerBonus;
|
|
853
|
+
const refereeBonus = r.refereeBonus;
|
|
854
|
+
if (!(referrerBonus instanceof MinorAmount) || !(refereeBonus instanceof MinorAmount)) return null;
|
|
855
|
+
const item = {
|
|
856
|
+
id: r.id,
|
|
857
|
+
refereeName: r.refereeName,
|
|
858
|
+
refereeEmailMasked: maskEmail(r.refereeEmail),
|
|
859
|
+
code: r.referralCode,
|
|
860
|
+
status: r.status,
|
|
861
|
+
referrerBonus: referrerBonus.value,
|
|
862
|
+
refereeBonus: refereeBonus.value,
|
|
863
|
+
createdAt: r.createdAt,
|
|
864
|
+
completedAt: r.completedAt,
|
|
865
|
+
expiresAt: r.expiresAt
|
|
866
|
+
};
|
|
867
|
+
BUILT.add(item);
|
|
868
|
+
return item;
|
|
869
|
+
})
|
|
870
|
+
)
|
|
871
|
+
);
|
|
872
|
+
function rawReferral(value) {
|
|
873
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
874
|
+
const snake = {};
|
|
875
|
+
for (const [key, field] of Object.entries(value)) snake[key.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`)] = field;
|
|
876
|
+
const result = referralSchema().safeParse(snake);
|
|
877
|
+
return result.success ? result.data : null;
|
|
878
|
+
}
|
|
879
|
+
function historyItems(list2) {
|
|
880
|
+
if (!Array.isArray(list2)) return [];
|
|
881
|
+
const items = [];
|
|
882
|
+
for (const entry of list2) {
|
|
883
|
+
const item = typeof entry === "object" && entry !== null && BUILT.has(entry) ? entry : rawReferral(entry);
|
|
884
|
+
if (item !== null) items.push(item);
|
|
885
|
+
}
|
|
886
|
+
return items;
|
|
887
|
+
}
|
|
888
|
+
var reportedTotal = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : 0;
|
|
889
|
+
var historySchema = /* @__PURE__ */ extension.lazy(
|
|
890
|
+
() => extension.wire({
|
|
891
|
+
referrals: nullableList(referralSchema()),
|
|
892
|
+
completed_count: count2(),
|
|
893
|
+
total_earned: majorUnits(),
|
|
894
|
+
pagination: mini.z.optional(
|
|
895
|
+
extension.wire({
|
|
896
|
+
page: count2(),
|
|
897
|
+
page_size: count2(),
|
|
898
|
+
total_items: count2(),
|
|
899
|
+
total_pages: count2()
|
|
900
|
+
})
|
|
901
|
+
)
|
|
902
|
+
})
|
|
903
|
+
);
|
|
904
|
+
var registeredSchema = /* @__PURE__ */ extension.lazy(
|
|
905
|
+
() => mini.z.pipe(
|
|
906
|
+
extension.wire({
|
|
907
|
+
id: mini.z.string(),
|
|
908
|
+
referral_code: mini.z._default(mini.z.string(), ""),
|
|
909
|
+
status: status(),
|
|
910
|
+
referee_bonus: mini.z._default(majorUnits(), 0),
|
|
911
|
+
created_at: optionalTimestamp()
|
|
912
|
+
}),
|
|
913
|
+
mini.z.transform(
|
|
914
|
+
(r) => ({
|
|
915
|
+
id: r.id,
|
|
916
|
+
code: r.referralCode,
|
|
917
|
+
status: r.status,
|
|
918
|
+
refereeBonus: r.refereeBonus,
|
|
919
|
+
createdAt: r.createdAt
|
|
920
|
+
})
|
|
921
|
+
)
|
|
922
|
+
)
|
|
923
|
+
);
|
|
924
|
+
var positiveInt = (value, fallback) => typeof value === "number" && Number.isSafeInteger(value) && value >= 1 ? value : fallback;
|
|
925
|
+
function registerInputProblem(input) {
|
|
926
|
+
if (typeof input !== "object" || input === null || Array.isArray(input))
|
|
927
|
+
return "referrals.register: input must be an object { code }.";
|
|
928
|
+
const { code } = input;
|
|
929
|
+
if (typeof code !== "string" || code.trim() === "") return "referrals.register: code must be non-empty text.";
|
|
930
|
+
return void 0;
|
|
931
|
+
}
|
|
932
|
+
function createReferralsApi(transport) {
|
|
933
|
+
return {
|
|
934
|
+
get: (_params, options) => transport.request({ method: "GET", path: "/referrals", auth: "required", schema: infoSchema(), options }),
|
|
935
|
+
listHistory: (input, options) => {
|
|
936
|
+
const problem = pageInputProblem("referrals.listHistory", input);
|
|
937
|
+
if (problem !== void 0) return rejectInput(transport, problem, { method: "GET", path: HISTORY_PATH });
|
|
938
|
+
const requestedPage = input?.page;
|
|
939
|
+
const requestedPerPage = input?.perPage;
|
|
940
|
+
return transport.request({
|
|
941
|
+
method: "GET",
|
|
942
|
+
path: HISTORY_PATH,
|
|
943
|
+
query: { page: requestedPage, limit: requestedPerPage },
|
|
944
|
+
auth: "required",
|
|
945
|
+
schema: historySchema(),
|
|
946
|
+
options
|
|
947
|
+
}).then(({ referrals, completedCount, totalEarned, pagination }) => {
|
|
948
|
+
const items = historyItems(referrals);
|
|
949
|
+
const received = Array.isArray(referrals) ? referrals.length : 0;
|
|
950
|
+
const page = positiveInt(pagination?.page, requestedPage ?? 1);
|
|
951
|
+
const perPage = positiveInt(pagination?.pageSize, requestedPerPage ?? DEFAULT_PER_PAGE);
|
|
952
|
+
const seen = received > 0 ? (page - 1) * perPage + received : 0;
|
|
953
|
+
const totalItems = Math.max(reportedTotal(pagination?.totalItems), seen);
|
|
954
|
+
return {
|
|
955
|
+
items,
|
|
956
|
+
page,
|
|
957
|
+
perPage,
|
|
958
|
+
totalItems,
|
|
959
|
+
totalPages: totalItems > 0 ? Math.ceil(totalItems / perPage) : 0,
|
|
960
|
+
completedCount,
|
|
961
|
+
totalEarned
|
|
962
|
+
};
|
|
963
|
+
});
|
|
964
|
+
},
|
|
965
|
+
register: (input, options) => {
|
|
966
|
+
const problem = registerInputProblem(input);
|
|
967
|
+
if (problem !== void 0) return rejectInput(transport, problem, REGISTER_ROUTE);
|
|
968
|
+
return transport.request({
|
|
969
|
+
...REGISTER_ROUTE,
|
|
970
|
+
body: { referral_code: input.code.trim() },
|
|
971
|
+
auth: "required",
|
|
972
|
+
schema: registeredSchema(),
|
|
973
|
+
options
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
var HTTP_URL = "Expected an absolute http(s) URL";
|
|
979
|
+
var sessionSchema2 = /* @__PURE__ */ extension.lazy(
|
|
980
|
+
() => mini.z.pipe(
|
|
981
|
+
extension.wire({
|
|
982
|
+
// The separate token only exists on the wire: the schema declares it (strict contract) and the output drops it.
|
|
983
|
+
operator_token: mini.z.string(),
|
|
984
|
+
launch_url: mini.z.string().check(
|
|
985
|
+
mini.z.refine(
|
|
986
|
+
(value) => {
|
|
987
|
+
try {
|
|
988
|
+
const { protocol } = new URL(value);
|
|
989
|
+
return protocol === "https:" || protocol === "http:";
|
|
990
|
+
} catch {
|
|
991
|
+
return false;
|
|
992
|
+
}
|
|
993
|
+
},
|
|
994
|
+
{ message: HTTP_URL }
|
|
995
|
+
)
|
|
996
|
+
),
|
|
997
|
+
expires_in_seconds: mini.z.number().check(mini.z.refine((n) => Number.isFinite(n) && n > 0, { message: "Esperava > 0" }))
|
|
998
|
+
}),
|
|
999
|
+
// The clock is read when the response is interpreted (= moment of the response).
|
|
1000
|
+
mini.z.transform(({ launchUrl, expiresInSeconds }) => ({
|
|
1001
|
+
launchUrl,
|
|
1002
|
+
expiresInSeconds,
|
|
1003
|
+
expiresAt: Date.now() + expiresInSeconds * 1e3
|
|
1004
|
+
}))
|
|
1005
|
+
)
|
|
1006
|
+
);
|
|
1007
|
+
function createSportsbookApi(transport) {
|
|
1008
|
+
return {
|
|
1009
|
+
createSession: (_params, options) => transport.request({
|
|
1010
|
+
method: "GET",
|
|
1011
|
+
path: "/first/session",
|
|
1012
|
+
auth: "required",
|
|
1013
|
+
// The response carries the URL with the operator token: never through `warn` mode's recovery
|
|
1014
|
+
// (which would deliver a raw field and the response to `onValidationIssue`).
|
|
1015
|
+
validation: "strict",
|
|
1016
|
+
schema: sessionSchema2(),
|
|
1017
|
+
options
|
|
1018
|
+
})
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
// src/client.ts
|
|
1023
|
+
function createIgaming(client) {
|
|
1024
|
+
const transport = extension__namespace.getExtensionTransport(client);
|
|
1025
|
+
const igaming = {
|
|
1026
|
+
casino: createCasinoApi(transport),
|
|
1027
|
+
bonus: createBonusApi(transport),
|
|
1028
|
+
missions: createMissionsApi(transport),
|
|
1029
|
+
loyalty: createLoyaltyApi(transport),
|
|
1030
|
+
referrals: createReferralsApi(transport),
|
|
1031
|
+
sportsbook: createSportsbookApi(transport)
|
|
1032
|
+
};
|
|
1033
|
+
if (typeof extension__namespace.registerProductClient !== "function") {
|
|
1034
|
+
throw new sdk.EnginexError({
|
|
1035
|
+
code: "CONFIGURATION_ERROR",
|
|
1036
|
+
status: 0,
|
|
1037
|
+
message: `createIgaming requires @getenginex/sdk >=0.5.0 <1.0.0 (peer): update the installed core.`
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
extension__namespace.registerProductClient(igaming, client);
|
|
1041
|
+
return igaming;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
exports.createIgaming = createIgaming;
|
|
1045
|
+
//# sourceMappingURL=index.cjs.map
|
|
1046
|
+
//# sourceMappingURL=index.cjs.map
|