@getenginex/sdk-igaming 0.5.0 → 0.7.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 +40 -0
- package/README.md +44 -56
- package/dist/first-frame/index.cjs +4 -4
- package/dist/first-frame/index.cjs.map +1 -1
- package/dist/first-frame/index.d.cts +52 -52
- package/dist/first-frame/index.d.ts +52 -52
- package/dist/first-frame/index.js +4 -4
- package/dist/first-frame/index.js.map +1 -1
- package/dist/index.cjs +153 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +875 -692
- package/dist/index.d.ts +875 -692
- package/dist/index.js +153 -29
- package/dist/index.js.map +1 -1
- package/dist/query/index.cjs +1 -1
- package/dist/query/index.cjs.map +1 -1
- package/dist/query/index.d.cts +46 -46
- package/dist/query/index.d.ts +46 -46
- package/dist/query/index.js +1 -1
- package/dist/query/index.js.map +1 -1
- package/dist/testing/index.cjs +67 -5
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +37 -37
- package/dist/testing/index.d.ts +37 -37
- package/dist/testing/index.js +67 -5
- package/dist/testing/index.js.map +1 -1
- package/package.json +7 -7
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 = "
|
|
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: '
|
|
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 = "
|
|
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;
|
|
@@ -273,6 +273,39 @@ var offerSchema = /* @__PURE__ */ lazy(
|
|
|
273
273
|
content: z.optional(content())
|
|
274
274
|
})
|
|
275
275
|
);
|
|
276
|
+
function grantMoney(value, currency) {
|
|
277
|
+
return { amount: value?.amount ?? 0, currency: value?.currency || currency };
|
|
278
|
+
}
|
|
279
|
+
var rewardGrant = () => z.pipe(
|
|
280
|
+
wire({
|
|
281
|
+
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()) })
|
|
288
|
+
)
|
|
289
|
+
}),
|
|
290
|
+
z.transform(({ state, granted, balance, converted, expiresAt, wagering }) => {
|
|
291
|
+
const currency = [granted, balance, converted, wagering?.required, wagering?.accumulated].find((m) => m?.currency)?.currency ?? "";
|
|
292
|
+
const out = {
|
|
293
|
+
state,
|
|
294
|
+
granted: grantMoney(granted, currency),
|
|
295
|
+
balance: grantMoney(balance, currency),
|
|
296
|
+
converted: grantMoney(converted, currency)
|
|
297
|
+
};
|
|
298
|
+
if (expiresAt !== void 0) out.expiresAt = expiresAt;
|
|
299
|
+
if (wagering) {
|
|
300
|
+
out.wagering = {
|
|
301
|
+
required: grantMoney(wagering.required, currency),
|
|
302
|
+
accumulated: grantMoney(wagering.accumulated, currency)
|
|
303
|
+
};
|
|
304
|
+
if (wagering.completedAt !== void 0) out.wagering.completedAt = wagering.completedAt;
|
|
305
|
+
}
|
|
306
|
+
return out;
|
|
307
|
+
})
|
|
308
|
+
);
|
|
276
309
|
var participationSchema = /* @__PURE__ */ lazy(
|
|
277
310
|
() => z.pipe(
|
|
278
311
|
wire({
|
|
@@ -281,7 +314,7 @@ var participationSchema = /* @__PURE__ */ lazy(
|
|
|
281
314
|
campaign_version_id: text(),
|
|
282
315
|
reward_key: text(),
|
|
283
316
|
qualification_snapshot: z.optional(qualification()),
|
|
284
|
-
// oneof `state`:
|
|
317
|
+
// oneof `state`: only one of the cases is filled in.
|
|
285
318
|
enrolled: z.optional(empty()),
|
|
286
319
|
qualifying: z.optional(empty()),
|
|
287
320
|
qualified: z.optional(wire({ qualified_at: z.optional(z.string()) })),
|
|
@@ -290,6 +323,7 @@ var participationSchema = /* @__PURE__ */ lazy(
|
|
|
290
323
|
reward_failed: z.optional(empty()),
|
|
291
324
|
expired: z.optional(wire({ expired_at: z.optional(z.string()) })),
|
|
292
325
|
cancelled: z.optional(empty()),
|
|
326
|
+
reward_grant: z.optional(rewardGrant()),
|
|
293
327
|
snapshot: z.optional(
|
|
294
328
|
wire({
|
|
295
329
|
reward: z.optional(reward()),
|
|
@@ -305,7 +339,7 @@ var participationSchema = /* @__PURE__ */ lazy(
|
|
|
305
339
|
})
|
|
306
340
|
)
|
|
307
341
|
}),
|
|
308
|
-
//
|
|
342
|
+
// The oneof becomes `status` (+ the timestamp of the case); the oneof's keys are not passed on.
|
|
309
343
|
z.transform(
|
|
310
344
|
({ enrolled, qualifying, qualified, rewardPending, completed, rewardFailed, expired, cancelled, ...rest }) => {
|
|
311
345
|
const out = { ...rest, status: "unspecified" };
|
|
@@ -341,6 +375,66 @@ function toCursorPage(key, data) {
|
|
|
341
375
|
if (data.nextCursor) page.nextCursor = data.nextCursor;
|
|
342
376
|
return page;
|
|
343
377
|
}
|
|
378
|
+
var nullableDate = () => z.pipe(
|
|
379
|
+
z.nullish(z.string()),
|
|
380
|
+
z.transform((value) => value ?? void 0)
|
|
381
|
+
);
|
|
382
|
+
function compact(value) {
|
|
383
|
+
return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== void 0));
|
|
384
|
+
}
|
|
385
|
+
var overviewSchema = /* @__PURE__ */ lazy(
|
|
386
|
+
() => z.pipe(
|
|
387
|
+
wire({
|
|
388
|
+
currencies: list(
|
|
389
|
+
z.pipe(
|
|
390
|
+
wire({
|
|
391
|
+
currency: currencyOrEmpty(),
|
|
392
|
+
decimal_places: z.number(),
|
|
393
|
+
restricted_total: minorUnits(),
|
|
394
|
+
expiring_7d: minorUnits(),
|
|
395
|
+
open_positions: z.number(),
|
|
396
|
+
next_expires_at: nullableDate(),
|
|
397
|
+
converted: minorUnits(),
|
|
398
|
+
converted_campaigns: z.number()
|
|
399
|
+
}),
|
|
400
|
+
z.transform(compact)
|
|
401
|
+
)
|
|
402
|
+
),
|
|
403
|
+
as_of: nullableDate()
|
|
404
|
+
}),
|
|
405
|
+
z.transform(compact)
|
|
406
|
+
)
|
|
407
|
+
);
|
|
408
|
+
var positionsPage = /* @__PURE__ */ lazy(
|
|
409
|
+
() => wire({
|
|
410
|
+
rows: list(
|
|
411
|
+
z.pipe(
|
|
412
|
+
wire({
|
|
413
|
+
position_id: z.string(),
|
|
414
|
+
campaign_id: z.string(),
|
|
415
|
+
currency: currencyOrEmpty(),
|
|
416
|
+
decimal_places: z.number(),
|
|
417
|
+
granted: minorUnits(),
|
|
418
|
+
restricted: minorUnits(),
|
|
419
|
+
converted: minorUnits(),
|
|
420
|
+
required: minorUnits(),
|
|
421
|
+
wagered: minorUnits(),
|
|
422
|
+
remaining: minorUnits(),
|
|
423
|
+
state: z.string(),
|
|
424
|
+
// 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)
|
|
428
|
+
),
|
|
429
|
+
expires_at: nullableDate(),
|
|
430
|
+
created_at: nullableDate()
|
|
431
|
+
}),
|
|
432
|
+
z.transform((row) => compact(row))
|
|
433
|
+
)
|
|
434
|
+
),
|
|
435
|
+
next_cursor: z.optional(z.string())
|
|
436
|
+
})
|
|
437
|
+
);
|
|
344
438
|
var terms = (acceptance) => acceptance && { locale: acceptance.locale, terms_revision: acceptance.termsRevision };
|
|
345
439
|
function createBonusApi(transport) {
|
|
346
440
|
const listPage = (path, key, schema, auth, input, options) => transport.request({
|
|
@@ -408,7 +502,26 @@ function createBonusApi(transport) {
|
|
|
408
502
|
auth: "required",
|
|
409
503
|
schema: participationEnvelope(),
|
|
410
504
|
options
|
|
411
|
-
}).then((data) => data.participation)
|
|
505
|
+
}).then((data) => data.participation),
|
|
506
|
+
getOverview: (_params, options) => transport.request({
|
|
507
|
+
method: "GET",
|
|
508
|
+
path: "/bonus/overview",
|
|
509
|
+
auth: "required",
|
|
510
|
+
schema: overviewSchema(),
|
|
511
|
+
options
|
|
512
|
+
}),
|
|
513
|
+
listPositions: (input, options) => transport.request({
|
|
514
|
+
method: "GET",
|
|
515
|
+
path: "/bonus/positions",
|
|
516
|
+
query: { limit: input?.pageSize, cursor: input?.cursor, state: input?.state, currency: input?.currency },
|
|
517
|
+
auth: "required",
|
|
518
|
+
schema: positionsPage(),
|
|
519
|
+
options
|
|
520
|
+
}).then(({ rows, nextCursor }) => {
|
|
521
|
+
const page = { items: rows };
|
|
522
|
+
if (nextCursor) page.nextCursor = nextCursor;
|
|
523
|
+
return page;
|
|
524
|
+
})
|
|
412
525
|
};
|
|
413
526
|
}
|
|
414
527
|
var gameSchema = /* @__PURE__ */ lazy(
|
|
@@ -437,7 +550,19 @@ var providersSchema = /* @__PURE__ */ lazy(
|
|
|
437
550
|
() => z.array(wire({ id: z.string(), name: z.string(), game_count: z.number() }))
|
|
438
551
|
);
|
|
439
552
|
var launchSchema = /* @__PURE__ */ lazy(
|
|
440
|
-
() =>
|
|
553
|
+
() => z.pipe(
|
|
554
|
+
wire({
|
|
555
|
+
session_id: z.string().check(z.minLength(1)),
|
|
556
|
+
game_url: z.string().check(z.minLength(1)),
|
|
557
|
+
// 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())
|
|
561
|
+
}),
|
|
562
|
+
// Without a target (an older gateway, or a custom mock), the launch keeps the behavior the SDK documented
|
|
563
|
+
// before the field existed: an iframe.
|
|
564
|
+
z.transform(({ launchTarget, ...rest }) => ({ ...rest, launchTarget: launchTarget || "iframe" }))
|
|
565
|
+
)
|
|
441
566
|
);
|
|
442
567
|
var sessionSchema = /* @__PURE__ */ lazy(
|
|
443
568
|
() => wire({
|
|
@@ -509,8 +634,8 @@ function createCasinoApi(transport) {
|
|
|
509
634
|
path: `/games/${encodeURIComponent(gameId)}/launch`,
|
|
510
635
|
body: { is_demo: mode === "demo", is_mobile: isMobile === true, return_url: returnUrl, language },
|
|
511
636
|
auth: "required",
|
|
512
|
-
//
|
|
513
|
-
// (
|
|
637
|
+
// The response carries the URL with the game session token: never through `warn` mode's recovery
|
|
638
|
+
// (which would deliver a raw field and the response to `onValidationIssue`).
|
|
514
639
|
validation: "strict",
|
|
515
640
|
schema: launchSchema(),
|
|
516
641
|
options
|
|
@@ -554,18 +679,17 @@ function rejectInput(transport, message, route) {
|
|
|
554
679
|
}
|
|
555
680
|
function pageInputProblem(name, input) {
|
|
556
681
|
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.`;
|
|
682
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) return `${name}: input must be an object.`;
|
|
559
683
|
const { page, perPage } = input;
|
|
560
684
|
if (page !== void 0 && (typeof page !== "number" || !Number.isSafeInteger(page) || page < 1))
|
|
561
|
-
return `${name}: page
|
|
685
|
+
return `${name}: page must be an integer \u2265 1.`;
|
|
562
686
|
if (perPage !== void 0 && (typeof perPage !== "number" || !Number.isInteger(perPage) || perPage < 1 || perPage > 100))
|
|
563
|
-
return `${name}: perPage
|
|
687
|
+
return `${name}: perPage must be an integer from 1 to 100.`;
|
|
564
688
|
return void 0;
|
|
565
689
|
}
|
|
566
690
|
function optionalTimestamp() {
|
|
567
691
|
return z.pipe(
|
|
568
|
-
z.nullish(z.string().check(z.refine((value) => value === "" || !Number.isNaN(Date.parse(value)), "
|
|
692
|
+
z.nullish(z.string().check(z.refine((value) => value === "" || !Number.isNaN(Date.parse(value)), "invalid date"))),
|
|
569
693
|
z.transform((value) => value == null || value === "" || Date.parse(value) === 0 ? null : value)
|
|
570
694
|
);
|
|
571
695
|
}
|
|
@@ -595,7 +719,7 @@ var tierBenefits = () => z.pipe(
|
|
|
595
719
|
}
|
|
596
720
|
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed))
|
|
597
721
|
return parsed;
|
|
598
|
-
ctx.issues.push({ code: "custom", message: "tier_benefits_json
|
|
722
|
+
ctx.issues.push({ code: "custom", message: "tier_benefits_json is not a JSON object", input: void 0 });
|
|
599
723
|
return z.NEVER;
|
|
600
724
|
})
|
|
601
725
|
);
|
|
@@ -625,7 +749,7 @@ var redeemSchema = /* @__PURE__ */ lazy(
|
|
|
625
749
|
message: z.optional(z.string()),
|
|
626
750
|
redeemed_points: integerText(),
|
|
627
751
|
value: z.nullish(minorUnits()),
|
|
628
|
-
//
|
|
752
|
+
// Currency strict even in `'warn'`; absent, `null` and `''` still become `null`.
|
|
629
753
|
currency: z.pipe(
|
|
630
754
|
z.nullish(currencyOrEmpty()),
|
|
631
755
|
z.transform((value) => value == null || value === "" ? null : value)
|
|
@@ -642,16 +766,16 @@ var redeemSchema = /* @__PURE__ */ lazy(
|
|
|
642
766
|
}))
|
|
643
767
|
)
|
|
644
768
|
);
|
|
645
|
-
var UNCONFIRMED_REDEEM = "loyalty.redeem:
|
|
769
|
+
var UNCONFIRMED_REDEEM = "loyalty.redeem: the gateway did not confirm the redemption.";
|
|
646
770
|
var REDEEM_ROUTE = { method: "POST", path: "/loyalty/redeem" };
|
|
647
771
|
function redeemInputProblem(input) {
|
|
648
772
|
if (typeof input !== "object" || input === null || Array.isArray(input))
|
|
649
|
-
return "loyalty.redeem:
|
|
773
|
+
return "loyalty.redeem: input must be an object { points, redemptionType }.";
|
|
650
774
|
const { points, redemptionType } = input;
|
|
651
775
|
if (typeof points !== "number" || !Number.isSafeInteger(points) || points <= 0)
|
|
652
|
-
return "loyalty.redeem: points
|
|
776
|
+
return "loyalty.redeem: points must be an integer greater than 0.";
|
|
653
777
|
if (typeof redemptionType !== "string" || redemptionType.trim() === "")
|
|
654
|
-
return "loyalty.redeem: redemptionType
|
|
778
|
+
return "loyalty.redeem: redemptionType must be non-empty text.";
|
|
655
779
|
return void 0;
|
|
656
780
|
}
|
|
657
781
|
function createLoyaltyApi(transport) {
|
|
@@ -756,7 +880,7 @@ function createMissionsApi(transport) {
|
|
|
756
880
|
var STATUSES = ["pending", "qualified", "completed", "expired", "unspecified"];
|
|
757
881
|
var status = () => z.pipe(protoEnum("REFERRAL_STATUS_"), z.enum(STATUSES));
|
|
758
882
|
var DEFAULT_PER_PAGE = 20;
|
|
759
|
-
var count2 = () => z._default(z.number().check(z.refine((value) => Number.isInteger(value) && value >= 0, "
|
|
883
|
+
var count2 = () => z._default(z.number().check(z.refine((value) => Number.isInteger(value) && value >= 0, "invalid counter")), 0);
|
|
760
884
|
var HISTORY_PATH = "/referrals/history";
|
|
761
885
|
var REGISTER_ROUTE = { method: "POST", path: "/referrals/register" };
|
|
762
886
|
function maskEmail(value) {
|
|
@@ -892,9 +1016,9 @@ var registeredSchema = /* @__PURE__ */ lazy(
|
|
|
892
1016
|
var positiveInt = (value, fallback) => typeof value === "number" && Number.isSafeInteger(value) && value >= 1 ? value : fallback;
|
|
893
1017
|
function registerInputProblem(input) {
|
|
894
1018
|
if (typeof input !== "object" || input === null || Array.isArray(input))
|
|
895
|
-
return "referrals.register:
|
|
1019
|
+
return "referrals.register: input must be an object { code }.";
|
|
896
1020
|
const { code } = input;
|
|
897
|
-
if (typeof code !== "string" || code.trim() === "") return "referrals.register: code
|
|
1021
|
+
if (typeof code !== "string" || code.trim() === "") return "referrals.register: code must be non-empty text.";
|
|
898
1022
|
return void 0;
|
|
899
1023
|
}
|
|
900
1024
|
function createReferralsApi(transport) {
|
|
@@ -943,11 +1067,11 @@ function createReferralsApi(transport) {
|
|
|
943
1067
|
}
|
|
944
1068
|
};
|
|
945
1069
|
}
|
|
946
|
-
var HTTP_URL = "
|
|
1070
|
+
var HTTP_URL = "Expected an absolute http(s) URL";
|
|
947
1071
|
var sessionSchema2 = /* @__PURE__ */ lazy(
|
|
948
1072
|
() => z.pipe(
|
|
949
1073
|
wire({
|
|
950
|
-
//
|
|
1074
|
+
// The separate token only exists on the wire: the schema declares it (strict contract) and the output drops it.
|
|
951
1075
|
operator_token: z.string(),
|
|
952
1076
|
launch_url: z.string().check(
|
|
953
1077
|
z.refine(
|
|
@@ -964,7 +1088,7 @@ var sessionSchema2 = /* @__PURE__ */ lazy(
|
|
|
964
1088
|
),
|
|
965
1089
|
expires_in_seconds: z.number().check(z.refine((n) => Number.isFinite(n) && n > 0, { message: "Esperava > 0" }))
|
|
966
1090
|
}),
|
|
967
|
-
//
|
|
1091
|
+
// The clock is read when the response is interpreted (= moment of the response).
|
|
968
1092
|
z.transform(({ launchUrl, expiresInSeconds }) => ({
|
|
969
1093
|
launchUrl,
|
|
970
1094
|
expiresInSeconds,
|
|
@@ -978,8 +1102,8 @@ function createSportsbookApi(transport) {
|
|
|
978
1102
|
method: "GET",
|
|
979
1103
|
path: "/first/session",
|
|
980
1104
|
auth: "required",
|
|
981
|
-
//
|
|
982
|
-
// (
|
|
1105
|
+
// The response carries the URL with the operator token: never through `warn` mode's recovery
|
|
1106
|
+
// (which would deliver a raw field and the response to `onValidationIssue`).
|
|
983
1107
|
validation: "strict",
|
|
984
1108
|
schema: sessionSchema2(),
|
|
985
1109
|
options
|
|
@@ -1002,7 +1126,7 @@ function createIgaming(client) {
|
|
|
1002
1126
|
throw new EnginexError({
|
|
1003
1127
|
code: "CONFIGURATION_ERROR",
|
|
1004
1128
|
status: 0,
|
|
1005
|
-
message: `createIgaming
|
|
1129
|
+
message: `createIgaming requires @getenginex/sdk >=0.5.0 <1.0.0 (peer): update the installed core.`
|
|
1006
1130
|
});
|
|
1007
1131
|
}
|
|
1008
1132
|
extension.registerProductClient(igaming, client);
|