@opexa/portal-sdk 0.59.71 → 0.59.72
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-7APXFZ5G.js → chunk-5WRVWQBT.js} +3 -3
- package/dist/chunk-5WRVWQBT.js.map +1 -0
- package/dist/{chunk-YZWPC2FD.js → chunk-MQC7EE6J.js} +95 -3
- package/dist/chunk-MQC7EE6J.js.map +1 -0
- package/dist/{chunk-WVFSGB7Y.js → chunk-ROBGEUSE.js} +2 -2
- package/dist/chunk-ROBGEUSE.js.map +1 -0
- package/dist/index.cjs +152 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +63 -3
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +92 -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-CEPxVuIs.d.ts → types-B8RFcTu9.d.ts} +29 -1
- package/dist/{types-FjtMTuKB.d.cts → types-BqFODW6R.d.cts} +29 -1
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-7APXFZ5G.js.map +0 -1
- package/dist/chunk-WVFSGB7Y.js.map +0 -1
- package/dist/chunk-YZWPC2FD.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-ROBGEUSE.js.map
|
|
43
|
+
//# sourceMappingURL=chunk-ROBGEUSE.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-ROBGEUSE.js","sourcesContent":["export function gql(strings: TemplateStringsArray, ...values: unknown[]) {\n\tlet result = '';\n\n\tfor (const [index, string] of strings.entries()) {\n\t\tconst value = values.at(index) ?? '';\n\n\t\tresult = `${result}${string}${value}`;\n\t}\n\n\treturn result.trim();\n}\n","import type { HttpError, OperationError } from '../types/index.js';\n\nexport function statusCodeToOperationError(\n\tvalue: number,\n\tmessage?: string,\n): OperationError<HttpError> {\n\tconst e = ERROR_MAP[value] ? ERROR_MAP[value] : ERROR_MAP[500];\n\n\treturn {\n\t\tname: e.name,\n\t\tmessage: message ?? e.message,\n\t};\n}\n\nconst ERROR_MAP: Record<number, OperationError<HttpError>> = {\n\t400: { name: 'HttpBadRequest', message: 'Bad Request' },\n\t401: { name: 'HttpUnauthorized', message: 'Unauthorized' },\n\t403: { name: 'HttpForbidden', message: 'Forbidden' },\n\t404: { name: 'HttpNotFound', message: 'Not Found' },\n\t408: { name: 'HttpRequestTimeout', message: 'Request Timeout' },\n\t429: { name: 'HttpTooManyRequests', message: 'Too Many Requests' },\n\t500: { name: 'HttpInternalServerError', message: 'Internal Server Error' },\n};\n","function isFunction<Return, Args = never>(\n\tvalue: unknown | ((...args: Args[]) => Return),\n): value is (...args: Args[]) => Return {\n\treturn typeof value === 'function';\n}\n\nexport function callIfFn<Return, Args = never>(\n\tvalue: Return | ((...args: Args[]) => Return),\n\t...args: Args[]\n) {\n\tif (isFunction<Return, Args>(value)) {\n\t\treturn value(...args);\n\t} else {\n\t\treturn value;\n\t}\n}\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -3340,6 +3340,30 @@ var FAVORITE_GAMES_QUERY = gql`
|
|
|
3340
3340
|
}
|
|
3341
3341
|
}
|
|
3342
3342
|
`;
|
|
3343
|
+
var FAVORITE_GAMES_QUERY__NEXT = gql`
|
|
3344
|
+
query FavoriteGames {
|
|
3345
|
+
favoriteGames {
|
|
3346
|
+
id
|
|
3347
|
+
}
|
|
3348
|
+
}
|
|
3349
|
+
`;
|
|
3350
|
+
var RECENT_GAMES_QUERY = gql`
|
|
3351
|
+
query RecentGames {
|
|
3352
|
+
recentGames {
|
|
3353
|
+
id
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
`;
|
|
3357
|
+
var ADD_FAVORITE_GAME_MUTATION = gql`
|
|
3358
|
+
mutation AddFavoriteGame($game: ObjectId!) {
|
|
3359
|
+
addFavoriteGame(input: { game: $game })
|
|
3360
|
+
}
|
|
3361
|
+
`;
|
|
3362
|
+
var REMOVE_FAVORITE_GAME_MUTATION = gql`
|
|
3363
|
+
mutation RemoveFavoriteGame($game: ObjectId!) {
|
|
3364
|
+
removeFavoriteGame(input: { game: $game })
|
|
3365
|
+
}
|
|
3366
|
+
`;
|
|
3343
3367
|
var WALLET_GAMES_QUERY = gql`
|
|
3344
3368
|
query Games($first: Int $after: Cursor, $filter: GameFilterInput) {
|
|
3345
3369
|
games(first: $first, after: $after, filter: $filter) {
|
|
@@ -5078,6 +5102,74 @@ var PortalService = class {
|
|
|
5078
5102
|
data: res.data.recommendedGames
|
|
5079
5103
|
};
|
|
5080
5104
|
}
|
|
5105
|
+
async favoriteGames() {
|
|
5106
|
+
const res = await this.client.request(
|
|
5107
|
+
FAVORITE_GAMES_QUERY__NEXT
|
|
5108
|
+
);
|
|
5109
|
+
if (!res.ok) return res;
|
|
5110
|
+
if (!res.data.favoriteGames) {
|
|
5111
|
+
return {
|
|
5112
|
+
ok: false,
|
|
5113
|
+
error: {
|
|
5114
|
+
name: "UnknownError",
|
|
5115
|
+
message: "Something went wrong."
|
|
5116
|
+
}
|
|
5117
|
+
};
|
|
5118
|
+
}
|
|
5119
|
+
return {
|
|
5120
|
+
ok: true,
|
|
5121
|
+
data: res.data.favoriteGames
|
|
5122
|
+
};
|
|
5123
|
+
}
|
|
5124
|
+
async recentGames() {
|
|
5125
|
+
const res = await this.client.request(RECENT_GAMES_QUERY);
|
|
5126
|
+
if (!res.ok) return res;
|
|
5127
|
+
if (!res.data.recentGames) {
|
|
5128
|
+
return {
|
|
5129
|
+
ok: false,
|
|
5130
|
+
error: {
|
|
5131
|
+
name: "UnknownError",
|
|
5132
|
+
message: "Something went wrong."
|
|
5133
|
+
}
|
|
5134
|
+
};
|
|
5135
|
+
}
|
|
5136
|
+
return {
|
|
5137
|
+
ok: true,
|
|
5138
|
+
data: res.data.recentGames
|
|
5139
|
+
};
|
|
5140
|
+
}
|
|
5141
|
+
async addFavoriteGame(variables) {
|
|
5142
|
+
const res = await this.client.request(ADD_FAVORITE_GAME_MUTATION, variables);
|
|
5143
|
+
if (!res.ok) return res;
|
|
5144
|
+
if (!res.data.addFavoriteGame) {
|
|
5145
|
+
return {
|
|
5146
|
+
ok: false,
|
|
5147
|
+
error: {
|
|
5148
|
+
name: "UnknownError",
|
|
5149
|
+
message: "Something went wrong."
|
|
5150
|
+
}
|
|
5151
|
+
};
|
|
5152
|
+
}
|
|
5153
|
+
return {
|
|
5154
|
+
ok: true
|
|
5155
|
+
};
|
|
5156
|
+
}
|
|
5157
|
+
async removeFavoriteGame(variables) {
|
|
5158
|
+
const res = await this.client.request(REMOVE_FAVORITE_GAME_MUTATION, variables);
|
|
5159
|
+
if (!res.ok) return res;
|
|
5160
|
+
if (!res.data.removeFavoriteGame) {
|
|
5161
|
+
return {
|
|
5162
|
+
ok: false,
|
|
5163
|
+
error: {
|
|
5164
|
+
name: "UnknownError",
|
|
5165
|
+
message: "Something went wrong."
|
|
5166
|
+
}
|
|
5167
|
+
};
|
|
5168
|
+
}
|
|
5169
|
+
return {
|
|
5170
|
+
ok: true
|
|
5171
|
+
};
|
|
5172
|
+
}
|
|
5081
5173
|
async onboardingStatus() {
|
|
5082
5174
|
const res = await this.client.request(
|
|
5083
5175
|
ONBOARDING_STATUS_QUERY
|
|
@@ -11501,6 +11593,66 @@ var Sdk = class {
|
|
|
11501
11593
|
}).filter(Boolean) ?? []
|
|
11502
11594
|
};
|
|
11503
11595
|
}
|
|
11596
|
+
async favoriteGames__next() {
|
|
11597
|
+
const res0 = await this.portalService.favoriteGames();
|
|
11598
|
+
const ids = res0.data?.length ? [...new Set(res0.data.map((e) => e.id))] : [];
|
|
11599
|
+
if (ids.length <= 0) {
|
|
11600
|
+
return {
|
|
11601
|
+
ok: true,
|
|
11602
|
+
data: []
|
|
11603
|
+
};
|
|
11604
|
+
}
|
|
11605
|
+
const res1 = await this.cmsPortalService.games({
|
|
11606
|
+
filter: {
|
|
11607
|
+
reference: {
|
|
11608
|
+
in: ids
|
|
11609
|
+
}
|
|
11610
|
+
}
|
|
11611
|
+
});
|
|
11612
|
+
if (!res1.ok) return res1;
|
|
11613
|
+
return {
|
|
11614
|
+
ok: true,
|
|
11615
|
+
data: res0.data?.map(({ id }) => {
|
|
11616
|
+
const game = res1.data.edges.find(
|
|
11617
|
+
(e) => id === e.node.reference
|
|
11618
|
+
)?.node;
|
|
11619
|
+
return game ? this.transformer.transform.game(game) : null;
|
|
11620
|
+
}).filter(Boolean) ?? []
|
|
11621
|
+
};
|
|
11622
|
+
}
|
|
11623
|
+
async recentGames() {
|
|
11624
|
+
const res0 = await this.portalService.recentGames();
|
|
11625
|
+
const ids = res0.data?.length ? [...new Set(res0.data.map((e) => e.id))] : [];
|
|
11626
|
+
if (ids.length <= 0) {
|
|
11627
|
+
return {
|
|
11628
|
+
ok: true,
|
|
11629
|
+
data: []
|
|
11630
|
+
};
|
|
11631
|
+
}
|
|
11632
|
+
const res1 = await this.cmsPortalService.games({
|
|
11633
|
+
filter: {
|
|
11634
|
+
reference: {
|
|
11635
|
+
in: ids
|
|
11636
|
+
}
|
|
11637
|
+
}
|
|
11638
|
+
});
|
|
11639
|
+
if (!res1.ok) return res1;
|
|
11640
|
+
return {
|
|
11641
|
+
ok: true,
|
|
11642
|
+
data: res0.data?.map(({ id }) => {
|
|
11643
|
+
const game = res1.data.edges.find(
|
|
11644
|
+
(e) => id === e.node.reference
|
|
11645
|
+
)?.node;
|
|
11646
|
+
return game ? this.transformer.transform.game(game) : null;
|
|
11647
|
+
}).filter(Boolean) ?? []
|
|
11648
|
+
};
|
|
11649
|
+
}
|
|
11650
|
+
async addFavoriteGame(input) {
|
|
11651
|
+
return await this.portalService.addFavoriteGame(input);
|
|
11652
|
+
}
|
|
11653
|
+
async removeFavoriteGame(input) {
|
|
11654
|
+
return await this.portalService.removeFavoriteGame(input);
|
|
11655
|
+
}
|
|
11504
11656
|
/*
|
|
11505
11657
|
*=============================================
|
|
11506
11658
|
* FILE
|