@getenginex/sdk-igaming 0.10.1 → 0.12.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.
@@ -66,8 +66,8 @@ var SEED = [
66
66
  function pageOf(req, items) {
67
67
  const q = req.url.searchParams;
68
68
  const page = Math.max(1, Number.parseInt(q.get("page") ?? "", 10) || 1);
69
- const raw = Number.parseInt(q.get("limit") ?? "", 10);
70
- const limit = raw >= 1 && raw <= 100 ? raw : 20;
69
+ const raw2 = Number.parseInt(q.get("limit") ?? "", 10);
70
+ const limit = raw2 >= 1 && raw2 <= 100 ? raw2 : 20;
71
71
  return {
72
72
  items: items.slice((page - 1) * limit, page * limit),
73
73
  meta: { page, per_page: limit, total_pages: Math.ceil(items.length / limit), total_items: items.length }
@@ -602,8 +602,8 @@ function json(body, status = 200) {
602
602
  function pageOf2(req, items) {
603
603
  const q = req.url.searchParams;
604
604
  const page = Math.max(1, Number.parseInt(q.get("page") ?? "", 10) || 1);
605
- const raw = Number.parseInt(q.get("limit") ?? "", 10);
606
- const limit = raw >= 1 && raw <= 100 ? raw : 20;
605
+ const raw2 = Number.parseInt(q.get("limit") ?? "", 10);
606
+ const limit = raw2 >= 1 && raw2 <= 100 ? raw2 : 20;
607
607
  return {
608
608
  items: items.slice((page - 1) * limit, page * limit),
609
609
  meta: { page, per_page: limit, total_pages: Math.ceil(items.length / limit), total_items: items.length }
@@ -722,12 +722,449 @@ function createCasinoRoutes() {
722
722
  return testing.ok(items, meta);
723
723
  },
724
724
  "GET /api/v1/games/biggest-winners": (req) => {
725
- const raw = Number.parseInt(req.url.searchParams.get("limit") ?? "", 10);
726
- return testing.ok(WINNERS.slice(0, raw >= 1 ? raw : 10));
725
+ const raw2 = Number.parseInt(req.url.searchParams.get("limit") ?? "", 10);
726
+ return testing.ok(WINNERS.slice(0, raw2 >= 1 ? raw2 : 10));
727
727
  }
728
728
  };
729
729
  }
730
+ function raw(body, status = 200) {
731
+ return new Response(JSON.stringify(body), { status, headers: { "content-type": "application/json" } });
732
+ }
733
+ var VERSION = "club-v1";
734
+ var TOURNAMENT_VERSION = "tour-v1";
735
+ var OWN = "tour-own-1";
736
+ var EXTERNAL = "ext_tlt_weekly_1";
737
+ var RELATED = "ext_tlt_weekly_2";
738
+ var GO_ZERO = "0001-01-01T00:00:00Z";
739
+ var BRL = (amount) => ({ currency: "BRL", amountMinor: String(amount), decimalPlaces: 2 });
740
+ var pt = (text) => ({ "pt-BR": text });
741
+ var at = (offsetMs) => new Date(Date.UTC(2026, 10, 24, 12) + offsetMs).toISOString().replace(/\.\d{3}Z$/, "Z");
742
+ var reward = (id, kind, quantity, extra = {}) => ({
743
+ id,
744
+ label: pt(id),
745
+ kind,
746
+ quantity: String(quantity),
747
+ ttlSeconds: "0",
748
+ editionId: "",
749
+ ...extra
750
+ });
751
+ var SLICES = [
752
+ { id: "slice-coins", reward: reward("r-coins-50", "coins", 50) },
753
+ { id: "slice-spins", reward: reward("r-spins-10", "free_spins", 10, { campaign: { spins: "10", gameId: "" } }) },
754
+ { id: "slice-bonus", reward: reward("r-bonus-10", "bonus_balance", 1, { money: BRL(1e3) }) }
755
+ ];
756
+ var CHEST = [reward("chest-coins", "coins", 100), reward("chest-spins", "free_spins", 5)];
757
+ var ITEMS = [
758
+ {
759
+ id: "item-spins",
760
+ label: pt("20 giros"),
761
+ terms: {},
762
+ costCoins: "200",
763
+ reward: reward("r-item-spins", "free_spins", 20),
764
+ coverUrl: ""
765
+ },
766
+ {
767
+ id: "item-cash",
768
+ label: pt("R$ 50"),
769
+ terms: {},
770
+ costCoins: "5000",
771
+ reward: reward("r-item-cash", "real_balance", 1, { money: BRL(5e3) }),
772
+ coverUrl: ""
773
+ }
774
+ ];
775
+ function hash(text) {
776
+ let h = 0;
777
+ for (const char of text) h = h * 31 + char.charCodeAt(0) >>> 0;
778
+ return h;
779
+ }
780
+ function createClubRoutes(options = {}) {
781
+ const mode = options.program ?? "active";
782
+ const active = mode === "active";
783
+ const state = {
784
+ joined: mode === "paused",
785
+ xp: 1200,
786
+ coins: 500,
787
+ wheelPlayed: false,
788
+ chestReceipt: null,
789
+ registration: null
790
+ };
791
+ const receipts = [];
792
+ const movements = [
793
+ { id: "mv-1", kind: "coins", units: "500", sourceId: "welcome", occurredAt: at(-864e5) },
794
+ { id: "mv-2", kind: "xp", units: "1200", sourceId: "welcome", occurredAt: at(-864e5) }
795
+ ];
796
+ const replays = /* @__PURE__ */ new Map();
797
+ const seenInFlight = /* @__PURE__ */ new Set();
798
+ const lostOnce = /* @__PURE__ */ new Set();
799
+ let sequence = 0;
800
+ const program = () => mode === "disabled" ? {
801
+ enabled: false,
802
+ joined: false,
803
+ membershipRequired: false,
804
+ canJoin: false,
805
+ historyAvailable: false,
806
+ versionId: "",
807
+ locale: "",
808
+ termsLocale: "",
809
+ timeZone: "",
810
+ currency: "",
811
+ name: {},
812
+ terms: {},
813
+ coinName: {},
814
+ coverUrl: "",
815
+ levels: []
816
+ } : activeProgram();
817
+ const activeProgram = () => ({
818
+ enabled: active,
819
+ joined: state.joined,
820
+ membershipRequired: true,
821
+ canJoin: active && !state.joined,
822
+ historyAvailable: true,
823
+ versionId: VERSION,
824
+ locale: "pt-BR",
825
+ termsLocale: "pt-BR",
826
+ timeZone: "America/Sao_Paulo",
827
+ currency: "BRL",
828
+ name: pt("Clube"),
829
+ terms: pt("Termos do clube"),
830
+ coinName: pt("moedas"),
831
+ coverUrl: "",
832
+ levels: [
833
+ { id: "bronze", name: pt("Bronze"), minXp: "0", benefit: pt("Roleta di\xE1ria") },
834
+ { id: "silver", name: pt("Prata"), minXp: "5000", benefit: pt("Cashback semanal") }
835
+ ]
836
+ });
837
+ const pausedRewards = () => ({
838
+ xp: String(state.xp),
839
+ coins: String(state.coins),
840
+ levelId: "bronze",
841
+ activities: [],
842
+ storeItems: [],
843
+ missions: state.chestReceipt === null ? [
844
+ {
845
+ mission: {
846
+ id: "mission-login",
847
+ title: pt("Entre 3 dias"),
848
+ terms: {},
849
+ recurrence: "",
850
+ countBy: "",
851
+ target: "0",
852
+ coverUrl: ""
853
+ },
854
+ editionId: "",
855
+ progress: "0",
856
+ rightId: "right-1",
857
+ canClaim: false,
858
+ claimExpiresAt: at(6 * 864e5),
859
+ chestOptions: [],
860
+ rightVersionId: "club-v0",
861
+ stampedDays: []
862
+ }
863
+ ] : []
864
+ });
865
+ const rewards = () => {
866
+ if (mode === "paused") return pausedRewards();
867
+ const activity = {
868
+ activity: {
869
+ id: "wheel-daily",
870
+ kind: "wheel",
871
+ name: pt("Roleta di\xE1ria"),
872
+ terms: {},
873
+ coverUrl: "",
874
+ wheelTheme: "emerald",
875
+ playLabel: pt("Girar"),
876
+ slices: SLICES
877
+ },
878
+ canPlay: state.joined && !state.wheelPlayed,
879
+ unavailableReason: ""
880
+ };
881
+ if (state.wheelPlayed) {
882
+ activity.latestReceipt = receipts.find((r) => r.sourceKind === "activity");
883
+ activity.availableAt = at(864e5);
884
+ }
885
+ const chest = {
886
+ mission: {
887
+ id: "mission-login",
888
+ title: pt("Entre 3 dias"),
889
+ terms: {},
890
+ recurrence: "weekly",
891
+ countBy: "day",
892
+ target: "3",
893
+ coverUrl: ""
894
+ },
895
+ editionId: "2026-W48",
896
+ progress: "3",
897
+ rightId: "right-1",
898
+ rightVersionId: VERSION,
899
+ chestOptions: CHEST,
900
+ canClaim: state.joined && state.chestReceipt === null,
901
+ endsAt: at(5 * 864e5),
902
+ claimExpiresAt: at(6 * 864e5),
903
+ stampedDays: ["2026-11-22", "2026-11-23", "2026-11-24"]
904
+ };
905
+ if (state.chestReceipt) chest.receipt = state.chestReceipt;
906
+ return {
907
+ xp: String(state.xp),
908
+ coins: String(state.coins),
909
+ levelId: "bronze",
910
+ activities: [activity],
911
+ missions: [chest],
912
+ storeItems: ITEMS.map((item) => ({
913
+ item,
914
+ canRedeem: state.joined && state.coins >= Number(item.costCoins),
915
+ unavailableReason: state.coins >= Number(item.costCoins) ? "" : "insufficient_coins"
916
+ }))
917
+ };
918
+ };
919
+ const tournaments = () => {
920
+ const own = {
921
+ id: OWN,
922
+ source: "own",
923
+ versionId: TOURNAMENT_VERSION,
924
+ title: pt("Torneio da semana"),
925
+ terms: pt("Maior multiplicador vence"),
926
+ status: "live",
927
+ startsAt: at(-864e5),
928
+ endsAt: at(6 * 864e5),
929
+ updatedAt: at(0),
930
+ scoringRule: "round_multiplier",
931
+ tieBreak: "earliest",
932
+ currency: "BRL",
933
+ timeZone: "America/Sao_Paulo",
934
+ gameIds: [],
935
+ prizes: [
936
+ { fromRank: 1, toRank: 1, reward: reward("prize-1", "real_balance", 1, { money: BRL(5e4) }), terms: {} },
937
+ { fromRank: 2, toRank: 10, reward: reward("prize-2", "free_spins", 50), terms: {} }
938
+ ],
939
+ joinMode: "registration",
940
+ locale: "pt-BR",
941
+ rankingAvailable: true,
942
+ canRegister: state.joined && state.registration === null,
943
+ requiresTicket: false,
944
+ stale: false,
945
+ registrationStartsAt: at(-864e5),
946
+ registrationEndsAt: at(5 * 864e5),
947
+ coverUrl: ""
948
+ };
949
+ if (state.registration) own.registration = state.registration;
950
+ const external = {
951
+ id: EXTERNAL,
952
+ source: "external",
953
+ versionId: "",
954
+ title: pt("Torneio do provedor"),
955
+ terms: {},
956
+ status: "live",
957
+ startsAt: at(-36e5),
958
+ endsAt: at(864e5),
959
+ updatedAt: at(0),
960
+ scoringRule: "",
961
+ tieBreak: "",
962
+ currency: "BRL",
963
+ timeZone: "",
964
+ gameIds: [],
965
+ prizes: [{ fromRank: 1, toRank: 3, announcedAmount: BRL(1e5) }],
966
+ joinMode: "",
967
+ locale: "",
968
+ rankingAvailable: false,
969
+ canRegister: false,
970
+ requiresTicket: false,
971
+ stale: false,
972
+ coverUrl: ""
973
+ };
974
+ return [own, external];
975
+ };
976
+ function keyOf(req) {
977
+ const header = req.headers.get("idempotency-key") ?? "";
978
+ const body = req.body?.idempotencyKey;
979
+ const key = typeof body === "string" && body !== "" ? body : header;
980
+ if (key === "" || key.length > 128 || key !== key.trim() || header !== "" && header !== key) return void 0;
981
+ return key;
982
+ }
983
+ function once(req, scope, run) {
984
+ const key = keyOf(req);
985
+ if (key === void 0) return testing.fail(400, "INVALID_ARGUMENT", "invalid club request");
986
+ if (key.startsWith("inflight-") && !seenInFlight.has(`${scope}:${key}`)) {
987
+ seenInFlight.add(`${scope}:${key}`);
988
+ return testing.fail(
989
+ 409,
990
+ "ALREADY_EXISTS",
991
+ "club action conflicts with the current version, availability, or account state"
992
+ );
993
+ }
994
+ const body = req.body ?? {};
995
+ const { idempotencyKey, ...payload } = body;
996
+ const fingerprint = JSON.stringify([req.url.pathname, payload]);
997
+ const id = `${scope}:${key}`;
998
+ const replay = replays.get(id);
999
+ if (replay) {
1000
+ if (replay.fingerprint !== fingerprint)
1001
+ return testing.fail(
1002
+ 409,
1003
+ "ALREADY_EXISTS",
1004
+ "club action conflicts with the current version, availability, or account state"
1005
+ );
1006
+ return replay.status < 400 ? raw(replay.body, replay.status) : testing.fail(replay.status, "ALREADY_EXISTS", "club conflict");
1007
+ }
1008
+ const result = run(payload, key);
1009
+ if (result instanceof Response) return result;
1010
+ replays.set(id, { fingerprint, ...result });
1011
+ if (key.startsWith("lost-") && !lostOnce.has(id)) {
1012
+ lostOnce.add(id);
1013
+ return testing.fail(503, "UNAVAILABLE", "club service temporarily unavailable");
1014
+ }
1015
+ return result.status < 400 ? raw(result.body, result.status) : testing.fail(result.status, "ALREADY_EXISTS", "club conflict");
1016
+ }
1017
+ const conflict = { status: 409, body: null };
1018
+ const receipt = (fields) => {
1019
+ sequence += 1;
1020
+ const row = {
1021
+ id: `rcpt-${sequence}`,
1022
+ status: "delivered",
1023
+ costCoins: "0",
1024
+ acceptedAt: at(sequence * 1e3),
1025
+ deliveredAt: at(sequence * 1e3),
1026
+ ticketConsumed: false,
1027
+ ...fields
1028
+ };
1029
+ receipts.unshift(row);
1030
+ return row;
1031
+ };
1032
+ const credit = (kind, units, sourceId) => {
1033
+ if (kind !== "coins") return;
1034
+ state.coins += units;
1035
+ movements.unshift({
1036
+ id: `mv-${movements.length + 1}`,
1037
+ kind: "coins",
1038
+ units: String(units),
1039
+ sourceId,
1040
+ occurredAt: at(0)
1041
+ });
1042
+ };
1043
+ return {
1044
+ // Disabled without history: the gateway writes the program alone (protojson omits the unset `rewards`).
1045
+ "GET /api/v1/casino/club": () => raw(mode === "disabled" ? { program: program() } : { program: program(), rewards: rewards() }),
1046
+ "PUT /api/v1/casino/club/membership": (req) => {
1047
+ const body = req.body ?? {};
1048
+ if (typeof body.joined !== "boolean")
1049
+ return testing.fail(400, "INVALID_ARGUMENT", "club membership requires an explicit joined value");
1050
+ if (body.joined && !body.termsLocale)
1051
+ return testing.fail(400, "INVALID_ARGUMENT", "club membership requires the displayed terms locale");
1052
+ return once(req, "membership", (payload) => {
1053
+ if (!active || payload.versionId !== VERSION) return conflict;
1054
+ state.joined = payload.joined === true;
1055
+ return { status: 200, body: program() };
1056
+ });
1057
+ },
1058
+ "GET /api/v1/casino/club/history": (req) => {
1059
+ const q = req.url.searchParams;
1060
+ const limitText = q.get("limit");
1061
+ const limit = limitText === null ? 20 : Number(limitText);
1062
+ if (!Number.isInteger(limit) || limit < 1 || limit > 100)
1063
+ return testing.fail(400, "INVALID_ARGUMENT", "invalid club request");
1064
+ const cursor = q.get("cursor") ?? "";
1065
+ const start = cursor === "" ? 0 : Number(cursor.replace(/^c/, ""));
1066
+ if (!Number.isInteger(start) || start < 0) return testing.fail(400, "INVALID_ARGUMENT", "invalid club request");
1067
+ const page = receipts.slice(start, start + limit);
1068
+ const end = start + page.length;
1069
+ return raw({
1070
+ receipts: page,
1071
+ movements: start === 0 ? movements : [],
1072
+ nextCursor: end < receipts.length ? `c${end}` : ""
1073
+ });
1074
+ },
1075
+ "POST /api/v1/casino/club/activities/:activityId/plays": (req) => once(req, "play", (payload, key) => {
1076
+ const activityId = req.params?.activityId;
1077
+ const version = mode === "paused" && activityId === "right-1" ? "club-v0" : VERSION;
1078
+ if (mode === "disabled" || mode === "paused" && activityId !== "right-1") return conflict;
1079
+ if (!state.joined || payload.versionId !== version) return conflict;
1080
+ if (activityId === "wheel-daily") {
1081
+ if (state.wheelPlayed) return conflict;
1082
+ const slice = SLICES[hash(key) % SLICES.length];
1083
+ const won = slice.reward;
1084
+ state.wheelPlayed = true;
1085
+ credit(String(won.kind), Number(won.quantity), "wheel-daily");
1086
+ const row = receipt({ sourceKind: "activity", sourceId: "wheel-daily", sliceId: slice.id, reward: won });
1087
+ return { status: 200, body: { receipt: row, sliceId: slice.id, rewards: rewards() } };
1088
+ }
1089
+ if (activityId === "right-1") {
1090
+ const option = CHEST.find((o) => o.id === payload.optionId);
1091
+ if (state.chestReceipt || !option) return conflict;
1092
+ credit(String(option.kind), Number(option.quantity), "right-1");
1093
+ state.chestReceipt = receipt({ sourceKind: "chest", sourceId: "right-1", reward: option });
1094
+ return { status: 200, body: { receipt: state.chestReceipt, sliceId: "", rewards: rewards() } };
1095
+ }
1096
+ return testing.fail(404, "NOT_FOUND", "club resource not found");
1097
+ }),
1098
+ "POST /api/v1/casino/club/rewards/:rewardId/redemptions": (req) => once(req, "redeem", (payload) => {
1099
+ const item = ITEMS.find((i) => i.id === req.params?.rewardId);
1100
+ if (!item) return testing.fail(404, "NOT_FOUND", "club resource not found");
1101
+ const cost = Number(item.costCoins);
1102
+ if (!active || !state.joined || payload.versionId !== VERSION || state.coins < cost) return conflict;
1103
+ state.coins -= cost;
1104
+ movements.unshift({
1105
+ id: `mv-${movements.length + 1}`,
1106
+ kind: "coins",
1107
+ units: String(-cost),
1108
+ sourceId: item.id,
1109
+ occurredAt: at(0)
1110
+ });
1111
+ const row = receipt({ sourceKind: "store", sourceId: item.id, reward: item.reward, costCoins: item.costCoins });
1112
+ return { status: 200, body: row };
1113
+ }),
1114
+ "GET /api/v1/casino/club/tournaments": (req) => {
1115
+ if (!active) return testing.fail(404, "NOT_FOUND", "club resource not found");
1116
+ const related = req.url.searchParams.get("relatedTo");
1117
+ if (related !== null) {
1118
+ if (related !== EXTERNAL) return testing.fail(404, "NOT_FOUND", "club resource not found");
1119
+ return raw({
1120
+ relatedTo: EXTERNAL,
1121
+ items: [
1122
+ {
1123
+ id: RELATED,
1124
+ title: pt("Torneio do provedor"),
1125
+ status: "upcoming",
1126
+ startsAt: at(864e5),
1127
+ endsAt: at(2 * 864e5)
1128
+ },
1129
+ // A nil title map and zero `time.Time` values, as `encoding/json` writes them.
1130
+ { id: "ext_tlt_weekly_3", title: null, status: "upcoming", startsAt: GO_ZERO, endsAt: GO_ZERO }
1131
+ ],
1132
+ nextCursor: ""
1133
+ });
1134
+ }
1135
+ return raw({ items: tournaments(), externalAvailable: true, externalStale: false, nextCursor: "" });
1136
+ },
1137
+ "GET /api/v1/casino/club/tournaments/:editionId": (req) => {
1138
+ if (!active) return testing.fail(404, "NOT_FOUND", "club resource not found");
1139
+ const tournament = tournaments().find((t) => t.id === req.params?.editionId);
1140
+ return tournament ? raw(tournament) : testing.fail(404, "NOT_FOUND", "club resource not found");
1141
+ },
1142
+ "GET /api/v1/casino/club/tournaments/:editionId/ranking": (req) => {
1143
+ if (!active) return testing.fail(404, "NOT_FOUND", "club resource not found");
1144
+ const editionId = req.params?.editionId;
1145
+ if (editionId === EXTERNAL)
1146
+ return testing.fail(404, "CLUB_RANKING_UNAVAILABLE", "ranking is unavailable for this edition");
1147
+ if (editionId !== OWN) return testing.fail(404, "NOT_FOUND", "club resource not found");
1148
+ const entries = [
1149
+ { position: 1, displayName: "Ma\u2022\u2022\u2022 R.", score: "152.5" },
1150
+ { position: 2, displayName: "Jo\u2022\u2022\u2022 S.", score: "98" },
1151
+ { position: 3, displayName: "An\u2022\u2022\u2022 P.", score: "71.25" }
1152
+ ];
1153
+ const body = { entries, updatedAt: at(0), final: false };
1154
+ if (state.registration) body.personal = { position: 4, displayName: "Voc\xEA", score: "12" };
1155
+ return raw(body);
1156
+ },
1157
+ "POST /api/v1/casino/club/tournaments/:editionId/registrations": (req) => once(req, "register", (payload) => {
1158
+ if (!active) return conflict;
1159
+ if (req.params?.editionId !== OWN) return testing.fail(404, "NOT_FOUND", "club resource not found");
1160
+ if (!state.joined || payload.versionId !== TOURNAMENT_VERSION || state.registration) return conflict;
1161
+ state.registration = { id: "reg-1", editionId: OWN, versionId: TOURNAMENT_VERSION, joinedAt: at(0) };
1162
+ return { status: 200, body: state.registration };
1163
+ })
1164
+ };
1165
+ }
730
1166
  var POINT_VALUE_CENTS = 5;
1167
+ var MIN_REDEMPTION = 100;
731
1168
  function createLoyaltyRoutes() {
732
1169
  const state = { total: 5200, current: 1500, redeemed: 3700 };
733
1170
  return {
@@ -740,7 +1177,13 @@ function createLoyaltyRoutes() {
740
1177
  lifetime_wagered: 125e4,
741
1178
  lifetime_deposited: 8e5,
742
1179
  tier_benefits_json: JSON.stringify({ cashback_percent: 5, perks: ["vip_support"] }),
743
- tier_expires_at: "2027-01-01T00:00:00Z"
1180
+ tier_expires_at: "2027-01-01T00:00:00Z",
1181
+ available: true,
1182
+ program_active: true,
1183
+ history_available: true,
1184
+ min_redemption: MIN_REDEMPTION,
1185
+ point_value_cents: POINT_VALUE_CENTS,
1186
+ ...state.current >= MIN_REDEMPTION ? { can_redeem: true, redemption_currency: "BRL", redemption_decimal_places: 2 } : { can_redeem: false }
744
1187
  }),
745
1188
  "POST /api/v1/loyalty/redeem": (req) => {
746
1189
  const body = req.body ?? {};
@@ -750,6 +1193,7 @@ function createLoyaltyRoutes() {
750
1193
  if (typeof body.redemption_type !== "string" || body.redemption_type === "")
751
1194
  return testing.fail(400, "INVALID_ARGUMENT", "redemption_type is required");
752
1195
  if (points > state.current) return testing.fail(422, "INSUFFICIENT_BALANCE", "insufficient loyalty points");
1196
+ if (points < MIN_REDEMPTION) return testing.fail(422, "FAILED_PRECONDITION", "below the minimum redemption");
753
1197
  state.current -= points;
754
1198
  state.redeemed += points;
755
1199
  const bonus = body.redemption_type === "bonus";
@@ -757,7 +1201,9 @@ function createLoyaltyRoutes() {
757
1201
  success: true,
758
1202
  redeemed_points: points,
759
1203
  value: points * POINT_VALUE_CENTS,
1204
+ value_minor: String(points * POINT_VALUE_CENTS),
760
1205
  currency: "BRL",
1206
+ currency_decimal_places: 2,
761
1207
  ...bonus ? { bonus_id: `mock-loyalty-bonus-${state.redeemed}` } : {}
762
1208
  });
763
1209
  }
@@ -831,14 +1277,51 @@ var USER_MISSIONS = [
831
1277
  completed_at: "2026-10-02T15:30:00Z"
832
1278
  }
833
1279
  ];
1280
+ var HISTORY_FIELDS = {
1281
+ "mock-mission-1": { description: "Descri\xE7\xE3o da miss\xE3o 1", mission_type: "daily", objective_type: "wager" },
1282
+ "mock-mission-4": { description: "Descri\xE7\xE3o da miss\xE3o 4", mission_type: "permanent", objective_type: "deposit" }
1283
+ };
1284
+ var PAST_MISSION = {
1285
+ id: "mock-user-mission-0",
1286
+ mission_id: "mock-mission-0",
1287
+ mission_name: "Semana de boas-vindas",
1288
+ current_progress: 3,
1289
+ target_value: 3,
1290
+ progress_percentage: 100,
1291
+ status: "claimed",
1292
+ reward_type: "points",
1293
+ reward_value: 200,
1294
+ completed_at: "2026-09-20T18:00:00Z",
1295
+ claimed_at: "2026-09-20T18:00:05Z",
1296
+ offer_active: false,
1297
+ target_game_category: "",
1298
+ description: "Fa\xE7a 3 dep\xF3sitos na semana",
1299
+ mission_type: "weekly",
1300
+ objective_type: "deposit"
1301
+ };
1302
+ function myMissions(req) {
1303
+ if (req.url.searchParams.get("include_history") !== "true") return testing.ok({ missions: USER_MISSIONS });
1304
+ const missions = USER_MISSIONS.map((row) => ({
1305
+ ...row,
1306
+ offer_active: true,
1307
+ target_game_category: "",
1308
+ ...HISTORY_FIELDS[row.mission_id]
1309
+ }));
1310
+ return testing.ok({
1311
+ missions: [...missions, PAST_MISSION],
1312
+ available: true,
1313
+ offers_available: true,
1314
+ history_available: true
1315
+ });
1316
+ }
834
1317
  function json2(body) {
835
1318
  return new Response(JSON.stringify(body), { status: 200, headers: { "content-type": "application/json" } });
836
1319
  }
837
1320
  function listMissions(req) {
838
1321
  const q = req.url.searchParams;
839
1322
  const page = Math.max(1, Number.parseInt(q.get("page") ?? "", 10) || 1);
840
- const raw = Number.parseInt(q.get("limit") ?? "", 10);
841
- const limit = raw >= 1 && raw <= 100 ? raw : 20;
1323
+ const raw2 = Number.parseInt(q.get("limit") ?? "", 10);
1324
+ const limit = raw2 >= 1 && raw2 <= 100 ? raw2 : 20;
842
1325
  return json2({
843
1326
  success: true,
844
1327
  data: MISSIONS.slice((page - 1) * limit, page * limit),
@@ -848,7 +1331,7 @@ function listMissions(req) {
848
1331
  function createMissionsRoutes() {
849
1332
  return {
850
1333
  "GET /api/v1/missions": listMissions,
851
- "GET /api/v1/my/missions": () => testing.ok({ missions: USER_MISSIONS })
1334
+ "GET /api/v1/my/missions": myMissions
852
1335
  };
853
1336
  }
854
1337
  var money = (minor) => ({ minor_units: String(minor), currency: "BRL" });
@@ -893,8 +1376,8 @@ var CODE = "MOCK123";
893
1376
  function listHistory(req) {
894
1377
  const q = req.url.searchParams;
895
1378
  const page = Math.max(1, Number.parseInt(q.get("page") ?? "", 10) || 1);
896
- const raw = Number.parseInt(q.get("limit") ?? "", 10);
897
- const limit = raw >= 1 ? Math.min(raw, 100) : 20;
1379
+ const raw2 = Number.parseInt(q.get("limit") ?? "", 10);
1380
+ const limit = raw2 >= 1 ? Math.min(raw2, 100) : 20;
898
1381
  return testing.ok({
899
1382
  referral_code: CODE,
900
1383
  referrals: REFERRALS.slice((page - 1) * limit, page * limit),
@@ -927,9 +1410,10 @@ function createSportsbookRoutes() {
927
1410
  }
928
1411
 
929
1412
  // src/testing/index.ts
930
- function createIgamingRoutes() {
1413
+ function createIgamingRoutes(options = {}) {
931
1414
  return {
932
1415
  ...createCasinoRoutes(),
1416
+ ...createClubRoutes(options.club),
933
1417
  ...createBonusRoutes(),
934
1418
  ...createSportsbookRoutes(),
935
1419
  ...createMissionsRoutes(),
@@ -939,7 +1423,8 @@ function createIgamingRoutes() {
939
1423
  };
940
1424
  }
941
1425
  function withIgamingRoutes(options = {}) {
942
- return { ...options, routes: { ...createIgamingRoutes(), ...options.routes } };
1426
+ const { club, ...core } = options;
1427
+ return { ...core, routes: { ...createIgamingRoutes({ club }), ...core.routes } };
943
1428
  }
944
1429
 
945
1430
  exports.createIgamingRoutes = createIgamingRoutes;