@getenginex/sdk-igaming 0.7.0 → 0.8.1

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