@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.
- package/CHANGELOG.md +61 -0
- package/README.md +4 -3
- package/dist/chunk-5ERRD3OA.js +648 -0
- package/dist/chunk-5ERRD3OA.js.map +1 -0
- package/dist/index.cjs +725 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +895 -8
- package/dist/index.d.ts +895 -8
- package/dist/index.js +427 -397
- package/dist/index.js.map +1 -1
- package/dist/query/index.cjs +73 -7
- package/dist/query/index.cjs.map +1 -1
- package/dist/query/index.d.cts +24 -5
- package/dist/query/index.d.ts +24 -5
- package/dist/query/index.js +61 -8
- package/dist/query/index.js.map +1 -1
- package/dist/testing/index.cjs +499 -14
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +42 -4
- package/dist/testing/index.d.ts +42 -4
- package/dist/testing/index.js +499 -14
- package/dist/testing/index.js.map +1 -1
- package/package.json +7 -7
package/dist/testing/index.d.cts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import { MockHandler, MockFetchOptions } from '@getenginex/sdk/testing';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Options of the club mock (`createIgamingRoutes({ club })`).
|
|
5
|
+
* @category Testing
|
|
6
|
+
*/
|
|
7
|
+
interface ClubMockOptions {
|
|
8
|
+
/**
|
|
9
|
+
* State of the program:
|
|
10
|
+
* - `active` (default): the player has not joined yet; wheel, chest, store and tournaments;
|
|
11
|
+
* - `paused`: `enabled: false` with the history readable; the overview keeps only the pending chest (`right-1`,
|
|
12
|
+
* with only its right and `rightVersionId: 'club-v0'`), activities and store come empty, tournaments 404;
|
|
13
|
+
* - `disabled`: `enabled: false` without history: the overview omits `rewards`, tournaments 404 and the writes are
|
|
14
|
+
* `ALREADY_EXISTS` (409).
|
|
15
|
+
*/
|
|
16
|
+
program?: 'active' | 'paused' | 'disabled';
|
|
17
|
+
}
|
|
18
|
+
|
|
3
19
|
/**
|
|
4
20
|
* iGaming mock routes to add to the `createMockFetch` of `@getenginex/sdk/testing`.
|
|
5
21
|
* @module @getenginex/sdk-igaming/testing
|
|
@@ -35,6 +51,19 @@ import { MockHandler, MockFetchOptions } from '@getenginex/sdk/testing';
|
|
|
35
51
|
* (80% of the potential return, only for the pending bet) and `POST /bets/:betId/cashout`, which requires
|
|
36
52
|
* `Idempotency-Key`, moves the bet to `cashed_out` and replays the first response for the same key.
|
|
37
53
|
*
|
|
54
|
+
* Covers the casino `club` (`/casino/club/*`, answered without the envelope, like the gateway): a program the
|
|
55
|
+
* player has not joined yet (`PUT /casino/club/membership` joins it), a daily wheel (`wheel-daily`, the slice drawn
|
|
56
|
+
* from the `Idempotency-Key`), a mission chest ready to open (`play({ activityId: 'right-1', optionId })`), a coin
|
|
57
|
+
* store (500 coins; `item-spins` costs 200, `item-cash` 5000), the history (receipts newest first, cursor-paginated
|
|
58
|
+
* by `limit`), an own tournament open for registration (`tour-own-1`, with a ranking) and an external one
|
|
59
|
+
* (`ext_tlt_weekly_1`, with one related edition and `CLUB_RANKING_UNAVAILABLE`). Every write requires
|
|
60
|
+
* `Idempotency-Key`: the same key with the same body replays the first answer, with another body (or a stale
|
|
61
|
+
* `versionId`, or before joining) it is `ALREADY_EXISTS` (409).
|
|
62
|
+
* `createIgamingRoutes({ club: { program: 'paused' | 'disabled' } })` switches the program state; a key starting
|
|
63
|
+
* with `inflight-` answers 409 once (a duplicate in flight) and one starting with `lost-` applies the write and
|
|
64
|
+
* answers 503 once (see {@link ClubMockOptions}). The related page has an edition with `title: null` and Go's zero
|
|
65
|
+
* times, as the gateway's `encoding/json` writes them.
|
|
66
|
+
*
|
|
38
67
|
* Covers the `sportsbook`: `GET /first/session` (requires login) returns a fictitious FIRST URL
|
|
39
68
|
* (`https://first.mock.local/sportsbook?operatorToken=...`) valid for 24 h.
|
|
40
69
|
*
|
|
@@ -49,6 +78,7 @@ import { MockHandler, MockFetchOptions } from '@getenginex/sdk/testing';
|
|
|
49
78
|
* the names already masked, paginated by `page`/`limit` inside `data`, like the gateway).
|
|
50
79
|
*
|
|
51
80
|
* All responses match the SDK schemas, even with `validation: 'strict'`.
|
|
81
|
+
* @param options - Mock states, e.g. `{ club: { program: 'paused' } }`. Default: an active club.
|
|
52
82
|
* @example
|
|
53
83
|
* import { createMockFetch } from '@getenginex/sdk/testing'
|
|
54
84
|
* import { createIgamingRoutes } from '@getenginex/sdk-igaming/testing'
|
|
@@ -56,13 +86,13 @@ import { MockHandler, MockFetchOptions } from '@getenginex/sdk/testing';
|
|
|
56
86
|
* const fetch = createMockFetch({ routes: { ...createIgamingRoutes(), ...myRoutes } })
|
|
57
87
|
* @category Testing
|
|
58
88
|
*/
|
|
59
|
-
declare function createIgamingRoutes(): Record<string, MockHandler>;
|
|
89
|
+
declare function createIgamingRoutes(options?: IgamingRoutesOptions): Record<string, MockHandler>;
|
|
60
90
|
/**
|
|
61
91
|
* Adds the iGaming mock routes ({@link createIgamingRoutes}) to the options of `createMockFetch` from
|
|
62
92
|
* `@getenginex/sdk/testing`. The core routes still apply; the ones in `options.routes` win over the
|
|
63
93
|
* iGaming ones (to simulate errors). The other options (`twoFactorRequired`, `withdrawalOtp`, `user`)
|
|
64
94
|
* pass through as they are, and `options` is not changed.
|
|
65
|
-
* @param options - The options you would pass to `createMockFetch
|
|
95
|
+
* @param options - The options you would pass to `createMockFetch`, plus `club` (see {@link IgamingRoutesOptions}).
|
|
66
96
|
* @example
|
|
67
97
|
* import { createEnginexClient } from '@getenginex/sdk'
|
|
68
98
|
* import { createMockFetch, fail } from '@getenginex/sdk/testing'
|
|
@@ -79,6 +109,14 @@ declare function createIgamingRoutes(): Record<string, MockHandler>;
|
|
|
79
109
|
* const igaming = createIgaming(enginex)
|
|
80
110
|
* @category Testing
|
|
81
111
|
*/
|
|
82
|
-
declare function withIgamingRoutes(options?: MockFetchOptions): MockFetchOptions;
|
|
112
|
+
declare function withIgamingRoutes(options?: MockFetchOptions & IgamingRoutesOptions): MockFetchOptions;
|
|
113
|
+
/**
|
|
114
|
+
* Options of {@link createIgamingRoutes} (and of {@link withIgamingRoutes}, next to the core's).
|
|
115
|
+
* @category Testing
|
|
116
|
+
*/
|
|
117
|
+
interface IgamingRoutesOptions {
|
|
118
|
+
/** State of the club mock (default: an active program the player has not joined). */
|
|
119
|
+
club?: ClubMockOptions;
|
|
120
|
+
}
|
|
83
121
|
|
|
84
|
-
export { createIgamingRoutes, withIgamingRoutes };
|
|
122
|
+
export { type ClubMockOptions, type IgamingRoutesOptions, createIgamingRoutes, withIgamingRoutes };
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import { MockHandler, MockFetchOptions } from '@getenginex/sdk/testing';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Options of the club mock (`createIgamingRoutes({ club })`).
|
|
5
|
+
* @category Testing
|
|
6
|
+
*/
|
|
7
|
+
interface ClubMockOptions {
|
|
8
|
+
/**
|
|
9
|
+
* State of the program:
|
|
10
|
+
* - `active` (default): the player has not joined yet; wheel, chest, store and tournaments;
|
|
11
|
+
* - `paused`: `enabled: false` with the history readable; the overview keeps only the pending chest (`right-1`,
|
|
12
|
+
* with only its right and `rightVersionId: 'club-v0'`), activities and store come empty, tournaments 404;
|
|
13
|
+
* - `disabled`: `enabled: false` without history: the overview omits `rewards`, tournaments 404 and the writes are
|
|
14
|
+
* `ALREADY_EXISTS` (409).
|
|
15
|
+
*/
|
|
16
|
+
program?: 'active' | 'paused' | 'disabled';
|
|
17
|
+
}
|
|
18
|
+
|
|
3
19
|
/**
|
|
4
20
|
* iGaming mock routes to add to the `createMockFetch` of `@getenginex/sdk/testing`.
|
|
5
21
|
* @module @getenginex/sdk-igaming/testing
|
|
@@ -35,6 +51,19 @@ import { MockHandler, MockFetchOptions } from '@getenginex/sdk/testing';
|
|
|
35
51
|
* (80% of the potential return, only for the pending bet) and `POST /bets/:betId/cashout`, which requires
|
|
36
52
|
* `Idempotency-Key`, moves the bet to `cashed_out` and replays the first response for the same key.
|
|
37
53
|
*
|
|
54
|
+
* Covers the casino `club` (`/casino/club/*`, answered without the envelope, like the gateway): a program the
|
|
55
|
+
* player has not joined yet (`PUT /casino/club/membership` joins it), a daily wheel (`wheel-daily`, the slice drawn
|
|
56
|
+
* from the `Idempotency-Key`), a mission chest ready to open (`play({ activityId: 'right-1', optionId })`), a coin
|
|
57
|
+
* store (500 coins; `item-spins` costs 200, `item-cash` 5000), the history (receipts newest first, cursor-paginated
|
|
58
|
+
* by `limit`), an own tournament open for registration (`tour-own-1`, with a ranking) and an external one
|
|
59
|
+
* (`ext_tlt_weekly_1`, with one related edition and `CLUB_RANKING_UNAVAILABLE`). Every write requires
|
|
60
|
+
* `Idempotency-Key`: the same key with the same body replays the first answer, with another body (or a stale
|
|
61
|
+
* `versionId`, or before joining) it is `ALREADY_EXISTS` (409).
|
|
62
|
+
* `createIgamingRoutes({ club: { program: 'paused' | 'disabled' } })` switches the program state; a key starting
|
|
63
|
+
* with `inflight-` answers 409 once (a duplicate in flight) and one starting with `lost-` applies the write and
|
|
64
|
+
* answers 503 once (see {@link ClubMockOptions}). The related page has an edition with `title: null` and Go's zero
|
|
65
|
+
* times, as the gateway's `encoding/json` writes them.
|
|
66
|
+
*
|
|
38
67
|
* Covers the `sportsbook`: `GET /first/session` (requires login) returns a fictitious FIRST URL
|
|
39
68
|
* (`https://first.mock.local/sportsbook?operatorToken=...`) valid for 24 h.
|
|
40
69
|
*
|
|
@@ -49,6 +78,7 @@ import { MockHandler, MockFetchOptions } from '@getenginex/sdk/testing';
|
|
|
49
78
|
* the names already masked, paginated by `page`/`limit` inside `data`, like the gateway).
|
|
50
79
|
*
|
|
51
80
|
* All responses match the SDK schemas, even with `validation: 'strict'`.
|
|
81
|
+
* @param options - Mock states, e.g. `{ club: { program: 'paused' } }`. Default: an active club.
|
|
52
82
|
* @example
|
|
53
83
|
* import { createMockFetch } from '@getenginex/sdk/testing'
|
|
54
84
|
* import { createIgamingRoutes } from '@getenginex/sdk-igaming/testing'
|
|
@@ -56,13 +86,13 @@ import { MockHandler, MockFetchOptions } from '@getenginex/sdk/testing';
|
|
|
56
86
|
* const fetch = createMockFetch({ routes: { ...createIgamingRoutes(), ...myRoutes } })
|
|
57
87
|
* @category Testing
|
|
58
88
|
*/
|
|
59
|
-
declare function createIgamingRoutes(): Record<string, MockHandler>;
|
|
89
|
+
declare function createIgamingRoutes(options?: IgamingRoutesOptions): Record<string, MockHandler>;
|
|
60
90
|
/**
|
|
61
91
|
* Adds the iGaming mock routes ({@link createIgamingRoutes}) to the options of `createMockFetch` from
|
|
62
92
|
* `@getenginex/sdk/testing`. The core routes still apply; the ones in `options.routes` win over the
|
|
63
93
|
* iGaming ones (to simulate errors). The other options (`twoFactorRequired`, `withdrawalOtp`, `user`)
|
|
64
94
|
* pass through as they are, and `options` is not changed.
|
|
65
|
-
* @param options - The options you would pass to `createMockFetch
|
|
95
|
+
* @param options - The options you would pass to `createMockFetch`, plus `club` (see {@link IgamingRoutesOptions}).
|
|
66
96
|
* @example
|
|
67
97
|
* import { createEnginexClient } from '@getenginex/sdk'
|
|
68
98
|
* import { createMockFetch, fail } from '@getenginex/sdk/testing'
|
|
@@ -79,6 +109,14 @@ declare function createIgamingRoutes(): Record<string, MockHandler>;
|
|
|
79
109
|
* const igaming = createIgaming(enginex)
|
|
80
110
|
* @category Testing
|
|
81
111
|
*/
|
|
82
|
-
declare function withIgamingRoutes(options?: MockFetchOptions): MockFetchOptions;
|
|
112
|
+
declare function withIgamingRoutes(options?: MockFetchOptions & IgamingRoutesOptions): MockFetchOptions;
|
|
113
|
+
/**
|
|
114
|
+
* Options of {@link createIgamingRoutes} (and of {@link withIgamingRoutes}, next to the core's).
|
|
115
|
+
* @category Testing
|
|
116
|
+
*/
|
|
117
|
+
interface IgamingRoutesOptions {
|
|
118
|
+
/** State of the club mock (default: an active program the player has not joined). */
|
|
119
|
+
club?: ClubMockOptions;
|
|
120
|
+
}
|
|
83
121
|
|
|
84
|
-
export { createIgamingRoutes, withIgamingRoutes };
|
|
122
|
+
export { type ClubMockOptions, type IgamingRoutesOptions, createIgamingRoutes, withIgamingRoutes };
|