@getenginex/sdk-igaming 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ function minorUnits() {
20
20
  function currencyOrEmpty() {
21
21
  return currencyCode({ allowEmpty: true });
22
22
  }
23
- var INTEGER_TEXT = "Esperava um inteiro dentro da faixa segura do number";
23
+ var INTEGER_TEXT = "Expected an integer within the safe range of number";
24
24
  function integerText() {
25
25
  return z.pipe(
26
26
  z.union([
@@ -43,11 +43,11 @@ function list(item) {
43
43
  }
44
44
  function durationSeconds() {
45
45
  return z.pipe(
46
- z.string().check(z.regex(/^-?\d+(\.\d+)?s$/, { message: 'Esperava uma dura\xE7\xE3o do protobuf, ex.: "86400s"' })),
46
+ z.string().check(z.regex(/^-?\d+(\.\d+)?s$/, { message: 'Expected a protobuf duration, e.g. "86400s"' })),
47
47
  z.transform((value) => Number(value.slice(0, -1)))
48
48
  );
49
49
  }
50
- var MAJOR_UNITS = "Esperava um valor em unidade maior (n\xFAmero finito) que caiba em unidades menores inteiras";
50
+ var MAJOR_UNITS = "Expected a value in major units (a finite number) that fits in whole minor units";
51
51
  function majorToMinorUnits(value) {
52
52
  const minor = Math.sign(value) * Math.round(Math.abs(value) * 100);
53
53
  return minor === 0 ? 0 : minor;
@@ -281,7 +281,7 @@ var participationSchema = /* @__PURE__ */ lazy(
281
281
  campaign_version_id: text(),
282
282
  reward_key: text(),
283
283
  qualification_snapshot: z.optional(qualification()),
284
- // oneof `state`: só um dos casos vem preenchido.
284
+ // oneof `state`: only one of the cases is filled in.
285
285
  enrolled: z.optional(empty()),
286
286
  qualifying: z.optional(empty()),
287
287
  qualified: z.optional(wire({ qualified_at: z.optional(z.string()) })),
@@ -305,7 +305,7 @@ var participationSchema = /* @__PURE__ */ lazy(
305
305
  })
306
306
  )
307
307
  }),
308
- // O oneof vira `status` (+ o timestamp do caso); as chaves do oneof não passam adiante.
308
+ // The oneof becomes `status` (+ the timestamp of the case); the oneof's keys are not passed on.
309
309
  z.transform(
310
310
  ({ enrolled, qualifying, qualified, rewardPending, completed, rewardFailed, expired, cancelled, ...rest }) => {
311
311
  const out = { ...rest, status: "unspecified" };
@@ -437,7 +437,19 @@ var providersSchema = /* @__PURE__ */ lazy(
437
437
  () => z.array(wire({ id: z.string(), name: z.string(), game_count: z.number() }))
438
438
  );
439
439
  var launchSchema = /* @__PURE__ */ lazy(
440
- () => wire({ session_id: z.string().check(z.minLength(1)), game_url: z.string().check(z.minLength(1)) })
440
+ () => z.pipe(
441
+ wire({
442
+ session_id: z.string().check(z.minLength(1)),
443
+ game_url: z.string().check(z.minLength(1)),
444
+ // Any text: a target the SDK does not know yet must not fail the (strict) launch.
445
+ launch_target: z.optional(z.string()),
446
+ provider_code: z.optional(z.string()),
447
+ expires_at: z.optional(z.string())
448
+ }),
449
+ // Without a target (an older gateway, or a custom mock), the launch keeps the behavior the SDK documented
450
+ // before the field existed: an iframe.
451
+ z.transform(({ launchTarget, ...rest }) => ({ ...rest, launchTarget: launchTarget || "iframe" }))
452
+ )
441
453
  );
442
454
  var sessionSchema = /* @__PURE__ */ lazy(
443
455
  () => wire({
@@ -509,8 +521,8 @@ function createCasinoApi(transport) {
509
521
  path: `/games/${encodeURIComponent(gameId)}/launch`,
510
522
  body: { is_demo: mode === "demo", is_mobile: isMobile === true, return_url: returnUrl, language },
511
523
  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`).
524
+ // The response carries the URL with the game session token: never through `warn` mode's recovery
525
+ // (which would deliver a raw field and the response to `onValidationIssue`).
514
526
  validation: "strict",
515
527
  schema: launchSchema(),
516
528
  options
@@ -554,18 +566,17 @@ function rejectInput(transport, message, route) {
554
566
  }
555
567
  function pageInputProblem(name, input) {
556
568
  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.`;
569
+ if (typeof input !== "object" || input === null || Array.isArray(input)) return `${name}: input must be an object.`;
559
570
  const { page, perPage } = input;
560
571
  if (page !== void 0 && (typeof page !== "number" || !Number.isSafeInteger(page) || page < 1))
561
- return `${name}: page precisa ser um inteiro \u2265 1.`;
572
+ return `${name}: page must be an integer \u2265 1.`;
562
573
  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.`;
574
+ return `${name}: perPage must be an integer from 1 to 100.`;
564
575
  return void 0;
565
576
  }
566
577
  function optionalTimestamp() {
567
578
  return z.pipe(
568
- z.nullish(z.string().check(z.refine((value) => value === "" || !Number.isNaN(Date.parse(value)), "data inv\xE1lida"))),
579
+ z.nullish(z.string().check(z.refine((value) => value === "" || !Number.isNaN(Date.parse(value)), "invalid date"))),
569
580
  z.transform((value) => value == null || value === "" || Date.parse(value) === 0 ? null : value)
570
581
  );
571
582
  }
@@ -595,7 +606,7 @@ var tierBenefits = () => z.pipe(
595
606
  }
596
607
  if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed))
597
608
  return parsed;
598
- ctx.issues.push({ code: "custom", message: "tier_benefits_json n\xE3o \xE9 um objeto JSON", input: void 0 });
609
+ ctx.issues.push({ code: "custom", message: "tier_benefits_json is not a JSON object", input: void 0 });
599
610
  return z.NEVER;
600
611
  })
601
612
  );
@@ -625,7 +636,7 @@ var redeemSchema = /* @__PURE__ */ lazy(
625
636
  message: z.optional(z.string()),
626
637
  redeemed_points: integerText(),
627
638
  value: z.nullish(minorUnits()),
628
- // Moeda estrita mesmo no `'warn'`; ausente, `null` e `''` continuam virando `null`.
639
+ // Currency strict even in `'warn'`; absent, `null` and `''` still become `null`.
629
640
  currency: z.pipe(
630
641
  z.nullish(currencyOrEmpty()),
631
642
  z.transform((value) => value == null || value === "" ? null : value)
@@ -642,16 +653,16 @@ var redeemSchema = /* @__PURE__ */ lazy(
642
653
  }))
643
654
  )
644
655
  );
645
- var UNCONFIRMED_REDEEM = "loyalty.redeem: o gateway n\xE3o confirmou o resgate.";
656
+ var UNCONFIRMED_REDEEM = "loyalty.redeem: the gateway did not confirm the redemption.";
646
657
  var REDEEM_ROUTE = { method: "POST", path: "/loyalty/redeem" };
647
658
  function redeemInputProblem(input) {
648
659
  if (typeof input !== "object" || input === null || Array.isArray(input))
649
- return "loyalty.redeem: o input precisa ser um objeto { points, redemptionType }.";
660
+ return "loyalty.redeem: input must be an object { points, redemptionType }.";
650
661
  const { points, redemptionType } = input;
651
662
  if (typeof points !== "number" || !Number.isSafeInteger(points) || points <= 0)
652
- return "loyalty.redeem: points precisa ser um inteiro maior que 0.";
663
+ return "loyalty.redeem: points must be an integer greater than 0.";
653
664
  if (typeof redemptionType !== "string" || redemptionType.trim() === "")
654
- return "loyalty.redeem: redemptionType precisa ser um texto n\xE3o vazio.";
665
+ return "loyalty.redeem: redemptionType must be non-empty text.";
655
666
  return void 0;
656
667
  }
657
668
  function createLoyaltyApi(transport) {
@@ -756,7 +767,7 @@ function createMissionsApi(transport) {
756
767
  var STATUSES = ["pending", "qualified", "completed", "expired", "unspecified"];
757
768
  var status = () => z.pipe(protoEnum("REFERRAL_STATUS_"), z.enum(STATUSES));
758
769
  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);
770
+ var count2 = () => z._default(z.number().check(z.refine((value) => Number.isInteger(value) && value >= 0, "invalid counter")), 0);
760
771
  var HISTORY_PATH = "/referrals/history";
761
772
  var REGISTER_ROUTE = { method: "POST", path: "/referrals/register" };
762
773
  function maskEmail(value) {
@@ -892,9 +903,9 @@ var registeredSchema = /* @__PURE__ */ lazy(
892
903
  var positiveInt = (value, fallback) => typeof value === "number" && Number.isSafeInteger(value) && value >= 1 ? value : fallback;
893
904
  function registerInputProblem(input) {
894
905
  if (typeof input !== "object" || input === null || Array.isArray(input))
895
- return "referrals.register: o input precisa ser um objeto { code }.";
906
+ return "referrals.register: input must be an object { code }.";
896
907
  const { code } = input;
897
- if (typeof code !== "string" || code.trim() === "") return "referrals.register: code precisa ser um texto n\xE3o vazio.";
908
+ if (typeof code !== "string" || code.trim() === "") return "referrals.register: code must be non-empty text.";
898
909
  return void 0;
899
910
  }
900
911
  function createReferralsApi(transport) {
@@ -943,11 +954,11 @@ function createReferralsApi(transport) {
943
954
  }
944
955
  };
945
956
  }
946
- var HTTP_URL = "Esperava uma URL absoluta http(s)";
957
+ var HTTP_URL = "Expected an absolute http(s) URL";
947
958
  var sessionSchema2 = /* @__PURE__ */ lazy(
948
959
  () => z.pipe(
949
960
  wire({
950
- // O token separado só existe no fio: o schema o declara (contrato estrito) e a saída o descarta.
961
+ // The separate token only exists on the wire: the schema declares it (strict contract) and the output drops it.
951
962
  operator_token: z.string(),
952
963
  launch_url: z.string().check(
953
964
  z.refine(
@@ -964,7 +975,7 @@ var sessionSchema2 = /* @__PURE__ */ lazy(
964
975
  ),
965
976
  expires_in_seconds: z.number().check(z.refine((n) => Number.isFinite(n) && n > 0, { message: "Esperava > 0" }))
966
977
  }),
967
- // O relógio é lido quando a resposta é interpretada (= momento da resposta).
978
+ // The clock is read when the response is interpreted (= moment of the response).
968
979
  z.transform(({ launchUrl, expiresInSeconds }) => ({
969
980
  launchUrl,
970
981
  expiresInSeconds,
@@ -978,8 +989,8 @@ function createSportsbookApi(transport) {
978
989
  method: "GET",
979
990
  path: "/first/session",
980
991
  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`).
992
+ // The response carries the URL with the operator token: never through `warn` mode's recovery
993
+ // (which would deliver a raw field and the response to `onValidationIssue`).
983
994
  validation: "strict",
984
995
  schema: sessionSchema2(),
985
996
  options
@@ -1002,7 +1013,7 @@ function createIgaming(client) {
1002
1013
  throw new EnginexError({
1003
1014
  code: "CONFIGURATION_ERROR",
1004
1015
  status: 0,
1005
- message: `createIgaming exige @getenginex/sdk >=0.5.0 <1.0.0 (peer): atualize o core instalado.`
1016
+ message: `createIgaming requires @getenginex/sdk >=0.5.0 <1.0.0 (peer): update the installed core.`
1006
1017
  });
1007
1018
  }
1008
1019
  extension.registerProductClient(igaming, client);