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