@opexa/portal-sdk 0.59.87 → 0.59.89
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/README.md +1634 -1634
- package/dist/{chunk-5WRVWQBT.js → chunk-7APXFZ5G.js} +3 -3
- package/dist/chunk-7APXFZ5G.js.map +1 -0
- package/dist/{chunk-QIUE5GTM.js → chunk-TC4UBBE5.js} +136 -3
- package/dist/chunk-TC4UBBE5.js.map +1 -0
- package/dist/{chunk-ROBGEUSE.js → chunk-WVFSGB7Y.js} +2 -2
- package/dist/chunk-WVFSGB7Y.js.map +1 -0
- package/dist/index.cjs +229 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -3
- package/dist/index.d.ts +53 -3
- package/dist/index.js +99 -7
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +133 -0
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.d.cts +7 -3
- package/dist/services/index.d.ts +7 -3
- package/dist/services/index.js +2 -2
- package/dist/{types-CHjedE6P.d.cts → types-84uzU3iN.d.cts} +109 -1
- package/dist/{types-yuha_bQI.d.ts → types-X-tWWFKj.d.ts} +109 -1
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-5WRVWQBT.js.map +0 -1
- package/dist/chunk-QIUE5GTM.js.map +0 -1
- package/dist/chunk-ROBGEUSE.js.map +0 -1
|
@@ -39,5 +39,5 @@ function callIfFn(value, ...args) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export { callIfFn, gql, statusCodeToOperationError };
|
|
42
|
-
//# sourceMappingURL=chunk-
|
|
43
|
-
//# sourceMappingURL=chunk-
|
|
42
|
+
//# sourceMappingURL=chunk-WVFSGB7Y.js.map
|
|
43
|
+
//# sourceMappingURL=chunk-WVFSGB7Y.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/gql.ts","../src/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,uBAAA;AAClD,CAAA;;;ACtBA,SAAS,WACR,KAAA,EACuC;AACvC,EAAA,OAAO,OAAO,KAAA,KAAU,UAAA;AACzB;AAEO,SAAS,QAAA,CACf,UACG,IAAA,EACF;AACD,EAAA,IAAI,UAAA,CAAyB,KAAK,CAAA,EAAG;AACpC,IAAA,OAAO,KAAA,CAAM,GAAG,IAAI,CAAA;AAAA,EACrB,CAAA,MAAO;AACN,IAAA,OAAO,KAAA;AAAA,EACR;AACD","file":"chunk-WVFSGB7Y.js","sourcesContent":["export function gql(strings: TemplateStringsArray, ...values: unknown[]) {\r\n\tlet result = '';\r\n\r\n\tfor (const [index, string] of strings.entries()) {\r\n\t\tconst value = values.at(index) ?? '';\r\n\r\n\t\tresult = `${result}${string}${value}`;\r\n\t}\r\n\r\n\treturn result.trim();\r\n}\r\n","import type { HttpError, OperationError } from '../types/index.js';\r\n\r\nexport function statusCodeToOperationError(\r\n\tvalue: number,\r\n\tmessage?: string,\r\n): OperationError<HttpError> {\r\n\tconst e = ERROR_MAP[value] ? ERROR_MAP[value] : ERROR_MAP[500];\r\n\r\n\treturn {\r\n\t\tname: e.name,\r\n\t\tmessage: message ?? e.message,\r\n\t};\r\n}\r\n\r\nconst ERROR_MAP: Record<number, OperationError<HttpError>> = {\r\n\t400: { name: 'HttpBadRequest', message: 'Bad Request' },\r\n\t401: { name: 'HttpUnauthorized', message: 'Unauthorized' },\r\n\t403: { name: 'HttpForbidden', message: 'Forbidden' },\r\n\t404: { name: 'HttpNotFound', message: 'Not Found' },\r\n\t408: { name: 'HttpRequestTimeout', message: 'Request Timeout' },\r\n\t429: { name: 'HttpTooManyRequests', message: 'Too Many Requests' },\r\n\t500: { name: 'HttpInternalServerError', message: 'Internal Server Error' },\r\n};\r\n","function isFunction<Return, Args = never>(\r\n\tvalue: unknown | ((...args: Args[]) => Return),\r\n): value is (...args: Args[]) => Return {\r\n\treturn typeof value === 'function';\r\n}\r\n\r\nexport function callIfFn<Return, Args = never>(\r\n\tvalue: Return | ((...args: Args[]) => Return),\r\n\t...args: Args[]\r\n) {\r\n\tif (isFunction<Return, Args>(value)) {\r\n\t\treturn value(...args);\r\n\t} else {\r\n\t\treturn value;\r\n\t}\r\n}\r\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -3838,6 +3838,79 @@ var MEMBER_FREE_BET_DROPS_QUERY = gql`
|
|
|
3838
3838
|
}
|
|
3839
3839
|
}
|
|
3840
3840
|
`;
|
|
3841
|
+
var _GAMES_QUERY = gql`
|
|
3842
|
+
query _Games($first: Int, $after: Cursor, $filter: GameFilterInput) {
|
|
3843
|
+
games(first: $first, after: $after, filter: $filter) {
|
|
3844
|
+
edges {
|
|
3845
|
+
cursor
|
|
3846
|
+
node {
|
|
3847
|
+
... on Game {
|
|
3848
|
+
id
|
|
3849
|
+
name
|
|
3850
|
+
displayName
|
|
3851
|
+
type
|
|
3852
|
+
provider
|
|
3853
|
+
reference
|
|
3854
|
+
hidden
|
|
3855
|
+
image
|
|
3856
|
+
}
|
|
3857
|
+
}
|
|
3858
|
+
}
|
|
3859
|
+
pageInfo {
|
|
3860
|
+
hasNextPage
|
|
3861
|
+
endCursor
|
|
3862
|
+
}
|
|
3863
|
+
}
|
|
3864
|
+
}
|
|
3865
|
+
`;
|
|
3866
|
+
var _GAME_GROUPS_QUERY = gql`
|
|
3867
|
+
query _GameGroups {
|
|
3868
|
+
gameGroups {
|
|
3869
|
+
id
|
|
3870
|
+
name
|
|
3871
|
+
}
|
|
3872
|
+
}
|
|
3873
|
+
`;
|
|
3874
|
+
var _GAME_GROUP_NODE_QUERY = gql`
|
|
3875
|
+
query _GameGroupNode($id: ObjectId!, $limit: Int, $offset: Int) {
|
|
3876
|
+
node(id: $id) {
|
|
3877
|
+
... on GameGroup {
|
|
3878
|
+
id
|
|
3879
|
+
name
|
|
3880
|
+
games(limit: $limit, offset: $offset) {
|
|
3881
|
+
id
|
|
3882
|
+
name
|
|
3883
|
+
displayName
|
|
3884
|
+
type
|
|
3885
|
+
provider
|
|
3886
|
+
reference
|
|
3887
|
+
hidden
|
|
3888
|
+
image
|
|
3889
|
+
}
|
|
3890
|
+
}
|
|
3891
|
+
}
|
|
3892
|
+
}
|
|
3893
|
+
`;
|
|
3894
|
+
var _GAME_NODE_QUERY = gql`
|
|
3895
|
+
query _GameNode($id: ObjectId!) {
|
|
3896
|
+
node(id: $id) {
|
|
3897
|
+
... on Game {
|
|
3898
|
+
id
|
|
3899
|
+
name
|
|
3900
|
+
displayName
|
|
3901
|
+
type
|
|
3902
|
+
provider
|
|
3903
|
+
reference
|
|
3904
|
+
hidden
|
|
3905
|
+
image
|
|
3906
|
+
groups {
|
|
3907
|
+
id
|
|
3908
|
+
name
|
|
3909
|
+
}
|
|
3910
|
+
}
|
|
3911
|
+
}
|
|
3912
|
+
}
|
|
3913
|
+
`;
|
|
3841
3914
|
|
|
3842
3915
|
// src/services/utils.ts
|
|
3843
3916
|
function createOperationError(code) {
|
|
@@ -5242,6 +5315,66 @@ var PortalService = class {
|
|
|
5242
5315
|
data: res.data
|
|
5243
5316
|
};
|
|
5244
5317
|
}
|
|
5318
|
+
async _games(variables) {
|
|
5319
|
+
const res = await this.client.request(
|
|
5320
|
+
_GAMES_QUERY,
|
|
5321
|
+
variables
|
|
5322
|
+
);
|
|
5323
|
+
if (!res.ok) return res;
|
|
5324
|
+
if (!res.data.games) {
|
|
5325
|
+
return {
|
|
5326
|
+
ok: false,
|
|
5327
|
+
error: {
|
|
5328
|
+
name: "UnknownError",
|
|
5329
|
+
message: "Something went wrong."
|
|
5330
|
+
}
|
|
5331
|
+
};
|
|
5332
|
+
}
|
|
5333
|
+
return {
|
|
5334
|
+
ok: true,
|
|
5335
|
+
data: res.data.games
|
|
5336
|
+
};
|
|
5337
|
+
}
|
|
5338
|
+
async _gameGroups() {
|
|
5339
|
+
const res = await this.client.request(
|
|
5340
|
+
_GAME_GROUPS_QUERY
|
|
5341
|
+
);
|
|
5342
|
+
if (!res.ok) return res;
|
|
5343
|
+
if (!res.data.gameGroups) {
|
|
5344
|
+
return {
|
|
5345
|
+
ok: false,
|
|
5346
|
+
error: {
|
|
5347
|
+
name: "UnknownError",
|
|
5348
|
+
message: "Something went wrong."
|
|
5349
|
+
}
|
|
5350
|
+
};
|
|
5351
|
+
}
|
|
5352
|
+
return {
|
|
5353
|
+
ok: true,
|
|
5354
|
+
data: res.data.gameGroups
|
|
5355
|
+
};
|
|
5356
|
+
}
|
|
5357
|
+
async _gameGroupNode(id, limit, offset) {
|
|
5358
|
+
const res = await this.client.request(
|
|
5359
|
+
_GAME_GROUP_NODE_QUERY,
|
|
5360
|
+
{ id, limit, offset }
|
|
5361
|
+
);
|
|
5362
|
+
if (!res.ok) return res;
|
|
5363
|
+
return {
|
|
5364
|
+
ok: true,
|
|
5365
|
+
data: res.data.node
|
|
5366
|
+
};
|
|
5367
|
+
}
|
|
5368
|
+
async _gameNode(id) {
|
|
5369
|
+
const res = await this.client.request(_GAME_NODE_QUERY, {
|
|
5370
|
+
id
|
|
5371
|
+
});
|
|
5372
|
+
if (!res.ok) return res;
|
|
5373
|
+
return {
|
|
5374
|
+
ok: true,
|
|
5375
|
+
data: res.data.node
|
|
5376
|
+
};
|
|
5377
|
+
}
|
|
5245
5378
|
async recommendedGames() {
|
|
5246
5379
|
const res = await this.client.request(
|
|
5247
5380
|
RECOMMENDED_GAMES_QUERY
|
|
@@ -7606,7 +7739,6 @@ var SessionManager = class {
|
|
|
7606
7739
|
if (!res.ok) {
|
|
7607
7740
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
7608
7741
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
7609
|
-
localStorage.removeItem(this.storageKey);
|
|
7610
7742
|
this.v4AccessToken = null;
|
|
7611
7743
|
this.v4AccessTokenExpiresAt = null;
|
|
7612
7744
|
}
|
|
@@ -7659,7 +7791,11 @@ var SessionManager = class {
|
|
|
7659
7791
|
if (val) {
|
|
7660
7792
|
try {
|
|
7661
7793
|
const stored = JSON.parse(val);
|
|
7662
|
-
if (stored.version === 4)
|
|
7794
|
+
if (stored.version === 4) {
|
|
7795
|
+
const valid = await this.verifyV4(stored.session);
|
|
7796
|
+
if (!valid) localStorage.removeItem(this.storageKey);
|
|
7797
|
+
return valid;
|
|
7798
|
+
}
|
|
7663
7799
|
} catch {
|
|
7664
7800
|
}
|
|
7665
7801
|
}
|
|
@@ -8037,7 +8173,6 @@ var SessionManagerCookie = class {
|
|
|
8037
8173
|
if (!res.ok) {
|
|
8038
8174
|
this.logger.error(`Failed to refresh session: ${res.error.message}`);
|
|
8039
8175
|
if (res.error.name === "InvalidTokenError" || res.error.name === "AccountBlacklistedError" || res.error.name === "VerificationLockedError") {
|
|
8040
|
-
cookies__default.default.remove(this.storageKey);
|
|
8041
8176
|
this.v4AccessToken = null;
|
|
8042
8177
|
this.v4AccessTokenExpiresAt = null;
|
|
8043
8178
|
}
|
|
@@ -8090,7 +8225,11 @@ var SessionManagerCookie = class {
|
|
|
8090
8225
|
if (val) {
|
|
8091
8226
|
try {
|
|
8092
8227
|
const stored = JSON.parse(val);
|
|
8093
|
-
if (stored.version === 4)
|
|
8228
|
+
if (stored.version === 4) {
|
|
8229
|
+
const valid = await this.verifyV4(stored.session);
|
|
8230
|
+
if (!valid) cookies__default.default.remove(this.storageKey);
|
|
8231
|
+
return valid;
|
|
8232
|
+
}
|
|
8094
8233
|
} catch {
|
|
8095
8234
|
}
|
|
8096
8235
|
}
|
|
@@ -11805,6 +11944,92 @@ var Sdk = class {
|
|
|
11805
11944
|
data: res.data ?? null
|
|
11806
11945
|
};
|
|
11807
11946
|
}
|
|
11947
|
+
/**
|
|
11948
|
+
* Fetches platform-scoped games from the Portal GraphQL API.
|
|
11949
|
+
*
|
|
11950
|
+
* Portal `Game.id` values are platform-game IDs, distinct from Wallet
|
|
11951
|
+
* global-game IDs. Never pass them to Wallet game-management mutations.
|
|
11952
|
+
*
|
|
11953
|
+
* The Portal `games` resolver does not supply `totalCount`, so the
|
|
11954
|
+
* result does not include it. Use `hasNextPage` and `endCursor` for
|
|
11955
|
+
* cursor pagination.
|
|
11956
|
+
*
|
|
11957
|
+
* For player-facing catalogs, pass `filter: { hidden: { equal: false } }`.
|
|
11958
|
+
*
|
|
11959
|
+
* Portal is eventually consistent — refetch or poll after Wallet writes.
|
|
11960
|
+
*/
|
|
11961
|
+
async _games(input) {
|
|
11962
|
+
const res = await this.portalService._games(input);
|
|
11963
|
+
if (!res.ok) return res;
|
|
11964
|
+
return {
|
|
11965
|
+
ok: true,
|
|
11966
|
+
data: {
|
|
11967
|
+
_games: res.data.edges.map(({ cursor, node }) => ({
|
|
11968
|
+
...node,
|
|
11969
|
+
cursor
|
|
11970
|
+
})),
|
|
11971
|
+
hasNextPage: res.data.pageInfo.hasNextPage,
|
|
11972
|
+
endCursor: res.data.pageInfo.endCursor ?? void 0
|
|
11973
|
+
}
|
|
11974
|
+
};
|
|
11975
|
+
}
|
|
11976
|
+
/**
|
|
11977
|
+
* Fetches all game groups for the current platform.
|
|
11978
|
+
*
|
|
11979
|
+
* Portal sorts the result by name ascending. There is no pagination.
|
|
11980
|
+
* An empty array is a valid result (platform with no configured groups).
|
|
11981
|
+
*/
|
|
11982
|
+
async _gameGroups() {
|
|
11983
|
+
const res = await this.portalService._gameGroups();
|
|
11984
|
+
if (!res.ok) return res;
|
|
11985
|
+
return {
|
|
11986
|
+
ok: true,
|
|
11987
|
+
data: res.data
|
|
11988
|
+
};
|
|
11989
|
+
}
|
|
11990
|
+
/**
|
|
11991
|
+
* Fetches a single game group and its ordered games via `node(id)`.
|
|
11992
|
+
*
|
|
11993
|
+
* The returned `games` array preserves the Wallet-managed group order.
|
|
11994
|
+
* Missing projected platform games are filtered out by the resolver.
|
|
11995
|
+
* Omit `limit` and `offset` to load the whole group (Wallet caps at 100).
|
|
11996
|
+
*
|
|
11997
|
+
* Returns `{ ok: true, data: null }` when the group is missing, belongs
|
|
11998
|
+
* to another platform, or the platform context is invalid.
|
|
11999
|
+
*/
|
|
12000
|
+
async _gameGroup(id, opts) {
|
|
12001
|
+
const res = await this.portalService._gameGroupNode(
|
|
12002
|
+
id,
|
|
12003
|
+
opts?.limit,
|
|
12004
|
+
opts?.offset
|
|
12005
|
+
);
|
|
12006
|
+
if (!res.ok) return res;
|
|
12007
|
+
return {
|
|
12008
|
+
ok: true,
|
|
12009
|
+
data: res.data
|
|
12010
|
+
};
|
|
12011
|
+
}
|
|
12012
|
+
/**
|
|
12013
|
+
* Fetches a single game by Portal platform-game ID via `node(id)`.
|
|
12014
|
+
*
|
|
12015
|
+
* Requires a Portal `Game.id` (platform-game ID). Passing a Wallet
|
|
12016
|
+
* global-game ID returns `null`.
|
|
12017
|
+
*
|
|
12018
|
+
* Includes reverse group membership via `Game.groups`. Legacy Portal
|
|
12019
|
+
* game rows may return an empty `groups` array — treat this as no
|
|
12020
|
+
* known memberships, not a request failure.
|
|
12021
|
+
*
|
|
12022
|
+
* Returns `{ ok: true, data: null }` when the game is missing, belongs
|
|
12023
|
+
* to another platform, or the platform context is invalid.
|
|
12024
|
+
*/
|
|
12025
|
+
async _game(id) {
|
|
12026
|
+
const res = await this.portalService._gameNode(id);
|
|
12027
|
+
if (!res.ok) return res;
|
|
12028
|
+
return {
|
|
12029
|
+
ok: true,
|
|
12030
|
+
data: res.data
|
|
12031
|
+
};
|
|
12032
|
+
}
|
|
11808
12033
|
async games__next(input) {
|
|
11809
12034
|
const res = await this.cmsPortalService.games__next(input);
|
|
11810
12035
|
if (!res.ok) return res;
|