react-memory-optimization 0.0.117 → 0.0.119
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/dist/bundle.js +1 -1
- package/dist/lib/service/requestAdapter/index.d.ts +17 -0
- package/dist/lib/service/requestAdapter/types.d.ts +7 -0
- package/dist/lib/service/requestAdapter/types.js +2 -0
- package/dist/lib/socket/index.d.ts +4 -0
- package/dist/lib/socket/types/socket.d.ts +2 -0
- package/dist/lib/store/new-flow/index.d.ts +8 -0
- package/dist/lib/store/new-flow/store/Currencies/index.d.ts +19 -0
- package/dist/lib/store/new-flow/store/Currencies/service/index.d.ts +6 -0
- package/dist/lib/store/new-flow/store/Currencies/types.d.ts +11 -0
- package/dist/lib/store/new-flow/store/Currencies/types.js +2 -0
- package/dist/lib/store/new-flow/store/User/index.d.ts +19 -0
- package/dist/lib/store/new-flow/store/User/service/index.d.ts +6 -0
- package/dist/lib/store/new-flow/store/User/types.d.ts +14 -0
- package/dist/lib/store/new-flow/store/User/types.js +2 -0
- package/dist/lib/store/new-flow/transport/api-transport.d.ts +13 -0
- package/dist/lib/store/new-flow/transport/api-transport.js +84 -4
- package/dist/lib/store/new-flow/transport/constants.d.ts +2 -0
- package/dist/lib/store/new-flow/transport/constants.js +5 -0
- package/dist/lib/store/new-flow/transport/types.d.ts +12 -1
- package/dist/lib/store/new-flow/transport/types.js +5 -0
- package/dist/lib/store/operations/utils.js +0 -1
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { NewFlowEntity } from 'store/new-flow';
|
|
3
|
+
import { RequestQueue } from './types';
|
|
4
|
+
export declare class RequestAdapter {
|
|
5
|
+
_requestQueue: RequestQueue[];
|
|
6
|
+
_newFlowEntity: NewFlowEntity;
|
|
7
|
+
timer: NodeJS.Timeout | null;
|
|
8
|
+
constructor(newFlowEntity: NewFlowEntity);
|
|
9
|
+
get requestQueue(): RequestQueue[];
|
|
10
|
+
set requestQueue(requestQueue: RequestQueue[]);
|
|
11
|
+
addToRequestQueue(request: RequestQueue): void;
|
|
12
|
+
removeFromRequestQueue(request: RequestQueue): void;
|
|
13
|
+
tick(): void;
|
|
14
|
+
processRequestQueue(): Promise<void>;
|
|
15
|
+
init(): void;
|
|
16
|
+
private getRequestInfo;
|
|
17
|
+
}
|
|
@@ -31,6 +31,7 @@ import { PromotionSubscribeProps } from 'store/casino/entities/promotions/types'
|
|
|
31
31
|
import { UIEntitiesSettings } from 'store/ui/types';
|
|
32
32
|
import { TournamentSubscribeProps } from 'store/casino/entities/casinoTournaments/types';
|
|
33
33
|
import { NewFlowEntity } from 'store/new-flow';
|
|
34
|
+
import { RequestAdapter } from 'service/requestAdapter';
|
|
34
35
|
export declare class Socket implements SocketInterface {
|
|
35
36
|
socketServices: SocketServices;
|
|
36
37
|
initialSettings: ISocketSettings;
|
|
@@ -53,6 +54,7 @@ export declare class Socket implements SocketInterface {
|
|
|
53
54
|
result: any;
|
|
54
55
|
}[];
|
|
55
56
|
newFlowEntity: NewFlowEntity;
|
|
57
|
+
requestAdapter: RequestAdapter;
|
|
56
58
|
constructor(settings: ISocketSettings);
|
|
57
59
|
set socketStatus(s: ESocketCallbackStep);
|
|
58
60
|
get socketStatus(): ESocketCallbackStep;
|
|
@@ -182,6 +184,8 @@ export declare class Socket implements SocketInterface {
|
|
|
182
184
|
subscribeTicketInfo(props: SubscribeTicketInfoProps): boolean;
|
|
183
185
|
subscribeHistoryTickets(props: SubscribeHistoryTicketsInfoProps): boolean;
|
|
184
186
|
unsubscribeTicketsEntity(uid: string): boolean;
|
|
187
|
+
subscribeUserCurrenciesEntity(props: BaseObservableSubscriber): boolean;
|
|
188
|
+
unsubscribeUserCurrenciesEntity(uid: string): boolean;
|
|
185
189
|
ticketCashOut(props: CashOutTicketProps): boolean;
|
|
186
190
|
subscribeBettingBetSlipCounter(props: SubscribeBettingBetSlipCounterProps): boolean;
|
|
187
191
|
subscribeSelectedOdd(props: SubscribeSelectedOdd): boolean;
|
|
@@ -144,6 +144,8 @@ export interface SocketInterface {
|
|
|
144
144
|
unsubscribeBalanceEntity: (uid: string) => boolean;
|
|
145
145
|
subscribeCasinoCategories: (data: SubscribeCasinoCategoriesInfoProps) => boolean;
|
|
146
146
|
unsubscribeCasinoCategories: (uid: string) => boolean;
|
|
147
|
+
subscribeUserCurrenciesEntity: (props: BaseObservableSubscriber) => boolean;
|
|
148
|
+
unsubscribeUserCurrenciesEntity: (uid: string) => boolean;
|
|
147
149
|
subscribeHomeBanners: (props: BaseObservableSubscriber) => boolean;
|
|
148
150
|
unsubscribeHomeBanners: (uid: string) => boolean;
|
|
149
151
|
subscribeJackpotsEntity: (props: JackpotSubscribes) => boolean;
|
|
@@ -2,17 +2,25 @@ import { Socket } from 'index';
|
|
|
2
2
|
import { UIEntities } from './store/UI';
|
|
3
3
|
import { ApiTransport } from './transport/api-transport';
|
|
4
4
|
import { ShadowIntegrationSettings } from './types';
|
|
5
|
+
import { Currencies } from './store/Currencies';
|
|
6
|
+
import { User } from './store/User';
|
|
5
7
|
export declare class NewFlowEntity {
|
|
6
8
|
_settings: ShadowIntegrationSettings;
|
|
7
9
|
_uiEntities: UIEntities | null;
|
|
8
10
|
_apiTransport: ApiTransport;
|
|
9
11
|
_socketInstance: Socket;
|
|
12
|
+
_currencies: Currencies | null;
|
|
13
|
+
_user: User | null;
|
|
10
14
|
constructor(socketInstance: Socket, settings?: ShadowIntegrationSettings);
|
|
15
|
+
set user(user: User);
|
|
16
|
+
get user(): User | null;
|
|
11
17
|
set apiTransport(apiTransport: ApiTransport);
|
|
12
18
|
get apiTransport(): ApiTransport;
|
|
13
19
|
set settings(settings: ShadowIntegrationSettings);
|
|
14
20
|
get settings(): ShadowIntegrationSettings;
|
|
15
21
|
set uiEntities(uiEntities: UIEntities);
|
|
16
22
|
get uiEntities(): UIEntities | null;
|
|
23
|
+
set currencies(currencies: Currencies);
|
|
24
|
+
get currencies(): Currencies | null;
|
|
17
25
|
init(): void;
|
|
18
26
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ObservableEntity } from 'service/observableEntity';
|
|
2
|
+
import { CurrenciesService } from './service';
|
|
3
|
+
import { CurrenciesRequestStatus, Currency } from './types';
|
|
4
|
+
import { BaseObservableSubscriber, UpdateData } from 'service/observable/type';
|
|
5
|
+
import { NewFlowEntity } from 'store/new-flow';
|
|
6
|
+
export declare class Currencies extends ObservableEntity<undefined> {
|
|
7
|
+
_currencies: Currency[];
|
|
8
|
+
currenciesService: CurrenciesService;
|
|
9
|
+
_status: CurrenciesRequestStatus;
|
|
10
|
+
rootParent: NewFlowEntity;
|
|
11
|
+
constructor(newFlowEntity: NewFlowEntity);
|
|
12
|
+
set status(status: CurrenciesRequestStatus);
|
|
13
|
+
get status(): CurrenciesRequestStatus;
|
|
14
|
+
get currencies(): Currency[];
|
|
15
|
+
set currencies(currencies: Currency[]);
|
|
16
|
+
sendUpdateEntity(d: BaseObservableSubscriber & {
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}): UpdateData | null;
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type Currency = {
|
|
2
|
+
id: string;
|
|
3
|
+
currencyId: string;
|
|
4
|
+
code: string;
|
|
5
|
+
symbol: string;
|
|
6
|
+
symbolNative: string;
|
|
7
|
+
decimalDigits: number;
|
|
8
|
+
rounding: number;
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
export type CurrenciesRequestStatus = 'unknown' | 'idle' | 'loading' | 'success' | 'error';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ObservableEntity } from 'service/observableEntity';
|
|
2
|
+
import { UserInfo, UserRequestStatus } from './types';
|
|
3
|
+
import { NewFlowEntity } from 'store/new-flow';
|
|
4
|
+
import { BaseObservableSubscriber, UpdateData } from 'service/observable/type';
|
|
5
|
+
import { UserService } from './service';
|
|
6
|
+
export declare class User extends ObservableEntity<undefined> {
|
|
7
|
+
_userInfo: UserInfo | null;
|
|
8
|
+
root: NewFlowEntity;
|
|
9
|
+
_status: UserRequestStatus;
|
|
10
|
+
service: UserService;
|
|
11
|
+
constructor(root: NewFlowEntity);
|
|
12
|
+
set userInfo(userInfo: UserInfo);
|
|
13
|
+
get userInfo(): UserInfo | null;
|
|
14
|
+
set status(status: UserRequestStatus);
|
|
15
|
+
get status(): UserRequestStatus;
|
|
16
|
+
sendUpdateEntity(d: BaseObservableSubscriber & {
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}): UpdateData | null;
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type UserInfo = {
|
|
2
|
+
id: string;
|
|
3
|
+
operatorId: string | null;
|
|
4
|
+
brandId: string;
|
|
5
|
+
currencyId: string;
|
|
6
|
+
countryId: string | null;
|
|
7
|
+
role: string;
|
|
8
|
+
registrationDomain: string;
|
|
9
|
+
isActive: boolean;
|
|
10
|
+
isDeleted: boolean;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
updatedAt: string;
|
|
13
|
+
};
|
|
14
|
+
export type UserRequestStatus = 'unknown' | 'idle' | 'loading' | 'success' | 'error';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UserInfo } from '../store/User/types';
|
|
1
2
|
import { ShadowIntegrationSettings } from '../types';
|
|
2
3
|
import { RequestQueue } from './types';
|
|
3
4
|
export declare class ApiTransport {
|
|
@@ -5,15 +6,27 @@ export declare class ApiTransport {
|
|
|
5
6
|
_isConfigured: boolean;
|
|
6
7
|
baseHeaders: Record<string, string>;
|
|
7
8
|
_requestQueue: RequestQueue[];
|
|
9
|
+
_accessToken: string;
|
|
10
|
+
_refreshToken: string;
|
|
11
|
+
_meInfo: UserInfo | null;
|
|
8
12
|
constructor();
|
|
13
|
+
set meInfo(meInfo: UserInfo);
|
|
14
|
+
get meInfo(): UserInfo | null;
|
|
15
|
+
set accessToken(accessToken: string);
|
|
16
|
+
get accessToken(): string;
|
|
17
|
+
set refreshToken(refreshToken: string);
|
|
18
|
+
get refreshToken(): string;
|
|
9
19
|
set requestQueue(requestQueue: RequestQueue[]);
|
|
10
20
|
get requestQueue(): RequestQueue[];
|
|
11
21
|
set isConfigured(isConfigured: boolean);
|
|
12
22
|
get isConfigured(): boolean;
|
|
13
23
|
set baseUrl(baseUrl: string);
|
|
14
24
|
get baseUrl(): string;
|
|
25
|
+
me(): Promise<void>;
|
|
26
|
+
private refreshingToken;
|
|
15
27
|
get<T>(path: string): Promise<T | null>;
|
|
16
28
|
post<T>(path: string, data: any): Promise<T | null>;
|
|
29
|
+
private authFlow;
|
|
17
30
|
configure(settings: ShadowIntegrationSettings): void;
|
|
18
31
|
subscribe(props: RequestQueue): void;
|
|
19
32
|
processRequestQueue(): void;
|
|
@@ -1,16 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.apiTransport = exports.ApiTransport = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const types_1 = require("./types");
|
|
4
6
|
class ApiTransport {
|
|
5
7
|
constructor() {
|
|
8
|
+
this._accessToken = '';
|
|
9
|
+
this._refreshToken = '';
|
|
6
10
|
this._baseUrl = '';
|
|
7
11
|
this.baseHeaders = {
|
|
8
12
|
'Content-Type': 'application/json',
|
|
9
13
|
// Notice: move to settings
|
|
10
|
-
'x-brand-prefix': '
|
|
14
|
+
'x-brand-prefix': 'gb-ad918334',
|
|
15
|
+
'x-forwarded-host': window.location.origin,
|
|
16
|
+
'x-refresh-token': '',
|
|
17
|
+
Authorization: '',
|
|
11
18
|
};
|
|
19
|
+
this.accessToken = localStorage.getItem(constants_1.ACCESS_TOKEN_KEY) || '';
|
|
20
|
+
this.refreshToken = localStorage.getItem(constants_1.REFRESH_TOKEN_KEY) || '';
|
|
12
21
|
this._isConfigured = false;
|
|
13
22
|
this._requestQueue = [];
|
|
23
|
+
this._meInfo = null;
|
|
24
|
+
}
|
|
25
|
+
set meInfo(meInfo) {
|
|
26
|
+
this._meInfo = meInfo;
|
|
27
|
+
}
|
|
28
|
+
get meInfo() {
|
|
29
|
+
return this._meInfo;
|
|
30
|
+
}
|
|
31
|
+
set accessToken(accessToken) {
|
|
32
|
+
this._accessToken = accessToken;
|
|
33
|
+
this.baseHeaders.Authorization = `Bearer ${accessToken}`;
|
|
34
|
+
localStorage.setItem(constants_1.ACCESS_TOKEN_KEY, accessToken);
|
|
35
|
+
}
|
|
36
|
+
get accessToken() {
|
|
37
|
+
return this._accessToken;
|
|
38
|
+
}
|
|
39
|
+
set refreshToken(refreshToken) {
|
|
40
|
+
this._refreshToken = refreshToken;
|
|
41
|
+
this.baseHeaders['x-refresh-token'] = refreshToken;
|
|
42
|
+
localStorage.setItem(constants_1.REFRESH_TOKEN_KEY, refreshToken);
|
|
43
|
+
}
|
|
44
|
+
get refreshToken() {
|
|
45
|
+
return this._refreshToken;
|
|
14
46
|
}
|
|
15
47
|
set requestQueue(requestQueue) {
|
|
16
48
|
this._requestQueue = requestQueue;
|
|
@@ -20,24 +52,57 @@ class ApiTransport {
|
|
|
20
52
|
}
|
|
21
53
|
set isConfigured(isConfigured) {
|
|
22
54
|
this._isConfigured = isConfigured;
|
|
23
|
-
|
|
55
|
+
if (isConfigured) {
|
|
56
|
+
this.me();
|
|
57
|
+
this.processRequestQueue();
|
|
58
|
+
}
|
|
24
59
|
}
|
|
25
60
|
get isConfigured() {
|
|
26
61
|
return this._isConfigured;
|
|
27
62
|
}
|
|
28
63
|
set baseUrl(baseUrl) {
|
|
29
|
-
this.isConfigured = true;
|
|
30
64
|
this._baseUrl = baseUrl;
|
|
65
|
+
this.isConfigured = true;
|
|
31
66
|
}
|
|
32
67
|
get baseUrl() {
|
|
33
68
|
return this._baseUrl;
|
|
34
69
|
}
|
|
70
|
+
async me() {
|
|
71
|
+
if (!this.accessToken || !this.refreshToken) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const res = await this.get(types_1.ETransportPath.TokenSignIn);
|
|
75
|
+
if (!res) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this.meInfo = res;
|
|
79
|
+
}
|
|
80
|
+
async refreshingToken() {
|
|
81
|
+
// eslint-disable-next-line no-debugger
|
|
82
|
+
debugger;
|
|
83
|
+
const response = await this.post(types_1.ETransportPath.RefreshToken, {
|
|
84
|
+
refreshToken: this.refreshToken,
|
|
85
|
+
});
|
|
86
|
+
if (!response) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
this.accessToken = response.accessToken;
|
|
90
|
+
this.refreshToken = response.refreshToken;
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
35
93
|
async get(path) {
|
|
36
94
|
try {
|
|
37
95
|
const response = await fetch(`${this._baseUrl}${path}`, {
|
|
38
96
|
method: 'GET',
|
|
39
97
|
headers: Object.assign(Object.assign({}, this.baseHeaders), { 'Content-Type': 'application/json' }),
|
|
40
98
|
});
|
|
99
|
+
if (response.status === 401) {
|
|
100
|
+
const responseRefresh = this.refreshingToken();
|
|
101
|
+
if (!responseRefresh) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
return this.get(path);
|
|
105
|
+
}
|
|
41
106
|
if (!response.ok) {
|
|
42
107
|
return null;
|
|
43
108
|
}
|
|
@@ -55,13 +120,28 @@ class ApiTransport {
|
|
|
55
120
|
body: JSON.stringify(data),
|
|
56
121
|
headers: Object.assign(Object.assign({}, this.baseHeaders), { 'Content-Type': 'application/json' }),
|
|
57
122
|
});
|
|
58
|
-
|
|
123
|
+
if (!response.ok) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
const json = await response.json();
|
|
127
|
+
if (path === types_1.ETransportPath.SignUp) {
|
|
128
|
+
this.authFlow(data);
|
|
129
|
+
}
|
|
130
|
+
return json;
|
|
59
131
|
}
|
|
60
132
|
catch (error) {
|
|
61
133
|
console.error(error);
|
|
62
134
|
return null;
|
|
63
135
|
}
|
|
64
136
|
}
|
|
137
|
+
async authFlow(data) {
|
|
138
|
+
const res = await exports.apiTransport.post(types_1.ETransportPath.SignIn, data);
|
|
139
|
+
if (!res) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
this.accessToken = res.accessToken;
|
|
143
|
+
this.refreshToken = res.refreshToken;
|
|
144
|
+
}
|
|
65
145
|
configure(settings) {
|
|
66
146
|
this.baseUrl = settings.baseUrl;
|
|
67
147
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UserInfo } from 'store/user/types';
|
|
1
2
|
export type RequestQueue = {
|
|
2
3
|
uid: string;
|
|
3
4
|
fn: (fnProps?: any) => any;
|
|
@@ -5,5 +6,15 @@ export type RequestQueue = {
|
|
|
5
6
|
};
|
|
6
7
|
export declare enum ETransportPath {
|
|
7
8
|
HomeBanners = "/casino/banners",
|
|
8
|
-
Categories = "/casino/categories"
|
|
9
|
+
Categories = "/casino/categories",
|
|
10
|
+
Currencies = "/casino/currencies",
|
|
11
|
+
SignUp = "/auth/sign-up",
|
|
12
|
+
SignIn = "/auth/sign-in/client",
|
|
13
|
+
TokenSignIn = "/auth/sign-in/token",
|
|
14
|
+
RefreshToken = "/auth/sign-in/refresh-token"
|
|
9
15
|
}
|
|
16
|
+
export type SignInResponse = {
|
|
17
|
+
accessToken: string;
|
|
18
|
+
refreshToken: string;
|
|
19
|
+
user: UserInfo;
|
|
20
|
+
};
|
|
@@ -5,4 +5,9 @@ var ETransportPath;
|
|
|
5
5
|
(function (ETransportPath) {
|
|
6
6
|
ETransportPath["HomeBanners"] = "/casino/banners";
|
|
7
7
|
ETransportPath["Categories"] = "/casino/categories";
|
|
8
|
+
ETransportPath["Currencies"] = "/casino/currencies";
|
|
9
|
+
ETransportPath["SignUp"] = "/auth/sign-up";
|
|
10
|
+
ETransportPath["SignIn"] = "/auth/sign-in/client";
|
|
11
|
+
ETransportPath["TokenSignIn"] = "/auth/sign-in/token";
|
|
12
|
+
ETransportPath["RefreshToken"] = "/auth/sign-in/refresh-token";
|
|
8
13
|
})(ETransportPath || (exports.ETransportPath = ETransportPath = {}));
|
|
@@ -6,7 +6,6 @@ const types_1 = require("./types");
|
|
|
6
6
|
// TODO Types
|
|
7
7
|
const adaptedWithdrawOrDeposit = (o) => {
|
|
8
8
|
const { amount, completionTimestamp, creationTimestamp, direction, id, status, type, } = o;
|
|
9
|
-
console.log('oOPERATION', JSON.stringify(o, null, 2));
|
|
10
9
|
return {
|
|
11
10
|
amount,
|
|
12
11
|
completionTimestamp,
|