@getenginex/sdk-igaming 0.7.0 → 0.8.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 +16 -0
- package/dist/index.cjs +100 -155
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +124 -101
- package/dist/index.d.ts +124 -101
- package/dist/index.js +101 -156
- package/dist/index.js.map +1 -1
- package/dist/query/index.cjs +0 -1
- package/dist/query/index.cjs.map +1 -1
- package/dist/query/index.d.cts +3 -5
- package/dist/query/index.d.ts +3 -5
- package/dist/query/index.js +0 -1
- package/dist/query/index.js.map +1 -1
- package/dist/testing/index.cjs +35 -66
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +3 -4
- package/dist/testing/index.d.ts +3 -4
- package/dist/testing/index.js +36 -67
- package/dist/testing/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @getenginex/sdk-igaming
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f1f6b32: `referrals` follows the gateway's current contract (`GET /referrals` and `GET /referrals/history`).
|
|
8
|
+
|
|
9
|
+
**Breaking changes (code changes needed when upgrading):**
|
|
10
|
+
|
|
11
|
+
- `referrals.register` was removed, with `RegisterReferralInput`, `RegisteredReferral` and the `referrals.register` mutation of `createIgamingMutations`: the gateway no longer has `POST /referrals/register`. The code is only entered at sign-up, with the core's `auth.register({ referralCode })`.
|
|
12
|
+
- `referrals.get()` returns `ReferralInfo` `{ enabled, code, rules, totals }`. Gone: `link` (build the invitation link in the app), `totalReferrals`, `completedReferrals`, `pendingReferrals`, `totalEarned`, `bonusPerReferral` and `minDeposit`. `rules` (`ReferralRules`: `reward`, `minimumRealNetLoss`, `refereeWindowDays`, `holdHours`, `wageringMultiplier`, `maximumConversion`) is `null` without an active campaign; `totals` (`ReferralTotals`) counts the referrals per status.
|
|
13
|
+
- `referrals.listHistory()` items are `Referral` `{ id, refereeName, status, createdAt, deadlineAt, progress }`. Gone: `refereeEmailMasked` (the gateway no longer sends the email; `refereeName` arrives already masked by the bonus service), `code`, `referrerBonus`, `refereeBonus`, `completedAt` and `expiresAt`. The page has `code` (the player's referral code) instead of `completedCount` and `totalEarned`.
|
|
14
|
+
- `ReferralStatus` has the bonus service's values: `registered`, `deposited`, `in_hold`, `paid`, `not_eligible`, `expired`, `cancelled` (open union). It is read from `player_status`; against an older gateway that only sends the legacy `status`, `COMPLETED` becomes `paid`, `EXPIRED` `expired` and anything else `registered`.
|
|
15
|
+
- Money is `ReferralMoney` `{ amount, currency }` in minor units, read from the gateway's `{ minor_units, currency }` (integer as text, strict even in `'warn'`), instead of a major-unit float without a currency.
|
|
16
|
+
|
|
17
|
+
**New:** `ReferralProgress` `{ depositDone, realNetLoss, target, remaining }` on each referral (`remaining` computed as `max(0, target - realNetLoss)` when the gateway leaves it out). The `/testing` mock answers the new shapes (an active campaign and three referrals: `paid`, `deposited`, `expired`) and no longer answers `POST /referrals/register`. Docs: the Referrals page and an "iGaming 0.7 to 0.8" section in Upgrading (EN/PT/ES).
|
|
18
|
+
|
|
3
19
|
## 0.7.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -68,20 +68,6 @@ function durationSeconds() {
|
|
|
68
68
|
mini.z.transform((value) => Number(value.slice(0, -1)))
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
|
-
var MAJOR_UNITS = "Expected a value in major units (a finite number) that fits in whole minor units";
|
|
72
|
-
function majorToMinorUnits(value) {
|
|
73
|
-
const minor = Math.sign(value) * Math.round(Math.abs(value) * 100);
|
|
74
|
-
return minor === 0 ? 0 : minor;
|
|
75
|
-
}
|
|
76
|
-
function majorUnits() {
|
|
77
|
-
return mini.z.pipe(
|
|
78
|
-
extension.strictValue(
|
|
79
|
-
(value) => typeof value === "number" && Number.isSafeInteger(majorToMinorUnits(value)),
|
|
80
|
-
MAJOR_UNITS
|
|
81
|
-
),
|
|
82
|
-
mini.z.transform((value) => majorToMinorUnits(value))
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
71
|
|
|
86
72
|
// src/modules/bonus.ts
|
|
87
73
|
var campaignCurrency = () => mini.z._default(currencyOrEmpty(), "");
|
|
@@ -898,150 +884,122 @@ function createMissionsApi(transport) {
|
|
|
898
884
|
})
|
|
899
885
|
};
|
|
900
886
|
}
|
|
901
|
-
var STATUSES = ["pending", "qualified", "completed", "expired", "unspecified"];
|
|
902
|
-
var status = () => mini.z.pipe(protoEnum("REFERRAL_STATUS_"), mini.z.enum(STATUSES));
|
|
903
887
|
var DEFAULT_PER_PAGE = 20;
|
|
904
|
-
var count2 = () => mini.z._default(mini.z.number().check(mini.z.refine((value) => Number.isInteger(value) && value >= 0, "invalid counter")), 0);
|
|
905
888
|
var HISTORY_PATH = "/referrals/history";
|
|
906
|
-
var
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
889
|
+
var count2 = () => mini.z._default(mini.z.number().check(mini.z.refine((value) => Number.isSafeInteger(value) && value >= 0, "invalid counter")), 0);
|
|
890
|
+
var money3 = () => mini.z.pipe(
|
|
891
|
+
mini.z.nullish(extension.wire({ minor_units: minorUnits(), currency: mini.z._default(currencyOrEmpty(), "") })),
|
|
892
|
+
mini.z.transform(
|
|
893
|
+
(value) => value == null ? null : { amount: value.minorUnits, currency: value.currency }
|
|
894
|
+
)
|
|
895
|
+
);
|
|
896
|
+
var rulesSchema = () => mini.z.pipe(
|
|
897
|
+
mini.z.nullish(
|
|
898
|
+
extension.wire({
|
|
899
|
+
reward: money3(),
|
|
900
|
+
minimum_real_net_loss: money3(),
|
|
901
|
+
referee_window_days: count2(),
|
|
902
|
+
hold_hours: count2(),
|
|
903
|
+
wagering_multiplier: mini.z._default(mini.z.string(), ""),
|
|
904
|
+
maximum_conversion: money3()
|
|
905
|
+
})
|
|
906
|
+
),
|
|
907
|
+
mini.z.transform((rules) => {
|
|
908
|
+
if (rules == null || rules.reward === null || rules.minimumRealNetLoss === null) return null;
|
|
909
|
+
return {
|
|
910
|
+
reward: rules.reward,
|
|
911
|
+
minimumRealNetLoss: rules.minimumRealNetLoss,
|
|
912
|
+
refereeWindowDays: rules.refereeWindowDays,
|
|
913
|
+
holdHours: rules.holdHours,
|
|
914
|
+
wageringMultiplier: rules.wageringMultiplier,
|
|
915
|
+
maximumConversion: rules.maximumConversion
|
|
916
|
+
};
|
|
917
|
+
})
|
|
918
|
+
);
|
|
917
919
|
var infoSchema = /* @__PURE__ */ extension.lazy(
|
|
918
920
|
() => mini.z.pipe(
|
|
919
921
|
extension.wire({
|
|
922
|
+
enabled: mini.z._default(mini.z.boolean(), false),
|
|
920
923
|
referral_code: optionalText(),
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
924
|
+
rules: rulesSchema(),
|
|
925
|
+
totals: mini.z._default(
|
|
926
|
+
extension.wire({
|
|
927
|
+
registered: count2(),
|
|
928
|
+
deposited: count2(),
|
|
929
|
+
in_hold: count2(),
|
|
930
|
+
paid: count2(),
|
|
931
|
+
not_eligible: count2(),
|
|
932
|
+
expired: count2(),
|
|
933
|
+
cancelled: count2()
|
|
934
|
+
}),
|
|
935
|
+
{ registered: 0, deposited: 0, inHold: 0, paid: 0, notEligible: 0, expired: 0, cancelled: 0 }
|
|
936
|
+
)
|
|
928
937
|
}),
|
|
929
938
|
mini.z.transform(
|
|
930
|
-
({ referralCode,
|
|
931
|
-
code: referralCode,
|
|
932
|
-
link: referralLink,
|
|
933
|
-
...rest
|
|
934
|
-
})
|
|
939
|
+
({ enabled, referralCode, rules, totals }) => ({ enabled, code: referralCode, rules, totals })
|
|
935
940
|
)
|
|
936
941
|
)
|
|
937
942
|
);
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
var minorAmount = () => mini.z.pipe(
|
|
945
|
-
majorUnits(),
|
|
946
|
-
mini.z.transform((value) => new MinorAmount(value))
|
|
947
|
-
);
|
|
948
|
-
var BUILT = /* @__PURE__ */ new WeakSet();
|
|
949
|
-
var referralSchema = /* @__PURE__ */ extension.lazy(
|
|
950
|
-
() => mini.z.pipe(
|
|
943
|
+
function remainingOf(target, loss) {
|
|
944
|
+
const missing = BigInt(target.amount) - BigInt(loss.amount);
|
|
945
|
+
return { amount: missing > 0n ? Number(missing) : 0, currency: target.currency };
|
|
946
|
+
}
|
|
947
|
+
var progressSchema = () => mini.z.pipe(
|
|
948
|
+
mini.z.nullish(
|
|
951
949
|
extension.wire({
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
referral_code: mini.z._default(mini.z.string(), ""),
|
|
957
|
-
status: status(),
|
|
958
|
-
referrer_bonus: minorAmount(),
|
|
959
|
-
referee_bonus: minorAmount(),
|
|
960
|
-
created_at: optionalTimestamp(),
|
|
961
|
-
completed_at: optionalTimestamp(),
|
|
962
|
-
expires_at: optionalTimestamp()
|
|
963
|
-
}),
|
|
964
|
-
mini.z.transform((r) => {
|
|
965
|
-
const referrerBonus = r.referrerBonus;
|
|
966
|
-
const refereeBonus = r.refereeBonus;
|
|
967
|
-
if (!(referrerBonus instanceof MinorAmount) || !(refereeBonus instanceof MinorAmount)) return null;
|
|
968
|
-
const item = {
|
|
969
|
-
id: r.id,
|
|
970
|
-
refereeName: r.refereeName,
|
|
971
|
-
refereeEmailMasked: maskEmail(r.refereeEmail),
|
|
972
|
-
code: r.referralCode,
|
|
973
|
-
status: r.status,
|
|
974
|
-
referrerBonus: referrerBonus.value,
|
|
975
|
-
refereeBonus: refereeBonus.value,
|
|
976
|
-
createdAt: r.createdAt,
|
|
977
|
-
completedAt: r.completedAt,
|
|
978
|
-
expiresAt: r.expiresAt
|
|
979
|
-
};
|
|
980
|
-
BUILT.add(item);
|
|
981
|
-
return item;
|
|
950
|
+
deposit_done: mini.z._default(mini.z.boolean(), false),
|
|
951
|
+
real_net_loss: money3(),
|
|
952
|
+
target: money3(),
|
|
953
|
+
remaining: money3()
|
|
982
954
|
})
|
|
983
|
-
)
|
|
955
|
+
),
|
|
956
|
+
mini.z.transform((progress) => {
|
|
957
|
+
if (progress == null || progress.target === null) return null;
|
|
958
|
+
const { target } = progress;
|
|
959
|
+
const realNetLoss = progress.realNetLoss ?? { amount: 0, currency: target.currency };
|
|
960
|
+
return {
|
|
961
|
+
depositDone: progress.depositDone,
|
|
962
|
+
realNetLoss,
|
|
963
|
+
target,
|
|
964
|
+
remaining: progress.remaining ?? remainingOf(target, realNetLoss)
|
|
965
|
+
};
|
|
966
|
+
})
|
|
984
967
|
);
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
const result = referralSchema().safeParse(snake);
|
|
990
|
-
return result.success ? result.data : null;
|
|
968
|
+
var LEGACY_STATUS = { COMPLETED: "paid", EXPIRED: "expired", PENDING: "registered" };
|
|
969
|
+
function statusOf(playerStatus, legacy) {
|
|
970
|
+
if (playerStatus !== null) return playerStatus.replace(/^CAMPAIGN_REFERRAL_STATUS_/, "").toLowerCase();
|
|
971
|
+
return LEGACY_STATUS[(legacy ?? "").toUpperCase()] ?? "registered";
|
|
991
972
|
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
973
|
+
var referralSchema = () => mini.z.pipe(
|
|
974
|
+
extension.wire({
|
|
975
|
+
id: mini.z.string(),
|
|
976
|
+
referee_name: optionalText(),
|
|
977
|
+
status: optionalText(),
|
|
978
|
+
player_status: optionalText(),
|
|
979
|
+
created_at: optionalTimestamp(),
|
|
980
|
+
deadline_at: optionalTimestamp(),
|
|
981
|
+
progress: progressSchema()
|
|
982
|
+
}),
|
|
983
|
+
mini.z.transform(
|
|
984
|
+
(r) => ({
|
|
985
|
+
id: r.id,
|
|
986
|
+
refereeName: r.refereeName,
|
|
987
|
+
status: statusOf(r.playerStatus, r.status),
|
|
988
|
+
createdAt: r.createdAt,
|
|
989
|
+
deadlineAt: r.deadlineAt,
|
|
990
|
+
progress: r.progress
|
|
991
|
+
})
|
|
992
|
+
)
|
|
993
|
+
);
|
|
1002
994
|
var historySchema = /* @__PURE__ */ extension.lazy(
|
|
1003
995
|
() => extension.wire({
|
|
996
|
+
referral_code: optionalText(),
|
|
1004
997
|
referrals: nullableList(referralSchema()),
|
|
1005
|
-
|
|
1006
|
-
total_earned: majorUnits(),
|
|
1007
|
-
pagination: mini.z.optional(
|
|
1008
|
-
extension.wire({
|
|
1009
|
-
page: count2(),
|
|
1010
|
-
page_size: count2(),
|
|
1011
|
-
total_items: count2(),
|
|
1012
|
-
total_pages: count2()
|
|
1013
|
-
})
|
|
1014
|
-
)
|
|
998
|
+
pagination: mini.z.optional(extension.wire({ page: count2(), limit: count2(), total_items: count2() }))
|
|
1015
999
|
})
|
|
1016
1000
|
);
|
|
1017
|
-
var registeredSchema = /* @__PURE__ */ extension.lazy(
|
|
1018
|
-
() => mini.z.pipe(
|
|
1019
|
-
extension.wire({
|
|
1020
|
-
id: mini.z.string(),
|
|
1021
|
-
referral_code: mini.z._default(mini.z.string(), ""),
|
|
1022
|
-
status: status(),
|
|
1023
|
-
referee_bonus: mini.z._default(majorUnits(), 0),
|
|
1024
|
-
created_at: optionalTimestamp()
|
|
1025
|
-
}),
|
|
1026
|
-
mini.z.transform(
|
|
1027
|
-
(r) => ({
|
|
1028
|
-
id: r.id,
|
|
1029
|
-
code: r.referralCode,
|
|
1030
|
-
status: r.status,
|
|
1031
|
-
refereeBonus: r.refereeBonus,
|
|
1032
|
-
createdAt: r.createdAt
|
|
1033
|
-
})
|
|
1034
|
-
)
|
|
1035
|
-
)
|
|
1036
|
-
);
|
|
1037
1001
|
var positiveInt = (value, fallback) => typeof value === "number" && Number.isSafeInteger(value) && value >= 1 ? value : fallback;
|
|
1038
|
-
|
|
1039
|
-
if (typeof input !== "object" || input === null || Array.isArray(input))
|
|
1040
|
-
return "referrals.register: input must be an object { code }.";
|
|
1041
|
-
const { code } = input;
|
|
1042
|
-
if (typeof code !== "string" || code.trim() === "") return "referrals.register: code must be non-empty text.";
|
|
1043
|
-
return void 0;
|
|
1044
|
-
}
|
|
1002
|
+
var reportedTotal = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : 0;
|
|
1045
1003
|
function createReferralsApi(transport) {
|
|
1046
1004
|
return {
|
|
1047
1005
|
get: (_params, options) => transport.request({ method: "GET", path: "/referrals", auth: "required", schema: infoSchema(), options }),
|
|
@@ -1057,12 +1015,11 @@ function createReferralsApi(transport) {
|
|
|
1057
1015
|
auth: "required",
|
|
1058
1016
|
schema: historySchema(),
|
|
1059
1017
|
options
|
|
1060
|
-
}).then(({
|
|
1061
|
-
const items =
|
|
1062
|
-
const received = Array.isArray(referrals) ? referrals.length : 0;
|
|
1018
|
+
}).then(({ referralCode, referrals, pagination }) => {
|
|
1019
|
+
const items = Array.isArray(referrals) ? referrals : [];
|
|
1063
1020
|
const page = positiveInt(pagination?.page, requestedPage ?? 1);
|
|
1064
|
-
const perPage = positiveInt(pagination?.
|
|
1065
|
-
const seen =
|
|
1021
|
+
const perPage = positiveInt(pagination?.limit, requestedPerPage ?? DEFAULT_PER_PAGE);
|
|
1022
|
+
const seen = items.length > 0 ? (page - 1) * perPage + items.length : 0;
|
|
1066
1023
|
const totalItems = Math.max(reportedTotal(pagination?.totalItems), seen);
|
|
1067
1024
|
return {
|
|
1068
1025
|
items,
|
|
@@ -1070,21 +1027,9 @@ function createReferralsApi(transport) {
|
|
|
1070
1027
|
perPage,
|
|
1071
1028
|
totalItems,
|
|
1072
1029
|
totalPages: totalItems > 0 ? Math.ceil(totalItems / perPage) : 0,
|
|
1073
|
-
|
|
1074
|
-
totalEarned
|
|
1030
|
+
code: referralCode
|
|
1075
1031
|
};
|
|
1076
1032
|
});
|
|
1077
|
-
},
|
|
1078
|
-
register: (input, options) => {
|
|
1079
|
-
const problem = registerInputProblem(input);
|
|
1080
|
-
if (problem !== void 0) return rejectInput(transport, problem, REGISTER_ROUTE);
|
|
1081
|
-
return transport.request({
|
|
1082
|
-
...REGISTER_ROUTE,
|
|
1083
|
-
body: { referral_code: input.code.trim() },
|
|
1084
|
-
auth: "required",
|
|
1085
|
-
schema: registeredSchema(),
|
|
1086
|
-
options
|
|
1087
|
-
});
|
|
1088
1033
|
}
|
|
1089
1034
|
};
|
|
1090
1035
|
}
|