@etsoo/appscript 1.5.13 → 1.5.15
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/__tests__/app/CoreApp.ts +0 -3
- package/lib/cjs/app/AppSettings.d.ts +0 -5
- package/lib/cjs/app/CoreApp.d.ts +3 -2
- package/lib/cjs/app/CoreApp.js +8 -6
- package/lib/cjs/app/IApp.d.ts +3 -2
- package/lib/cjs/erp/AuthApi.d.ts +9 -0
- package/lib/cjs/erp/AuthApi.js +19 -0
- package/lib/cjs/erp/PublicApi.d.ts +0 -9
- package/lib/cjs/erp/PublicApi.js +0 -11
- package/lib/cjs/i18n/en.json +1 -0
- package/lib/cjs/i18n/zh-Hans.json +1 -0
- package/lib/cjs/i18n/zh-Hant.json +1 -0
- package/lib/cjs/index.d.ts +0 -1
- package/lib/cjs/index.js +0 -1
- package/lib/cjs/state/User.d.ts +5 -0
- package/lib/mjs/app/AppSettings.d.ts +0 -5
- package/lib/mjs/app/CoreApp.d.ts +3 -2
- package/lib/mjs/app/CoreApp.js +8 -6
- package/lib/mjs/app/IApp.d.ts +3 -2
- package/lib/mjs/erp/AuthApi.d.ts +9 -0
- package/lib/mjs/erp/AuthApi.js +19 -0
- package/lib/mjs/erp/PublicApi.d.ts +0 -9
- package/lib/mjs/erp/PublicApi.js +0 -11
- package/lib/mjs/i18n/en.json +1 -0
- package/lib/mjs/i18n/zh-Hans.json +1 -0
- package/lib/mjs/i18n/zh-Hant.json +1 -0
- package/lib/mjs/index.d.ts +0 -1
- package/lib/mjs/index.js +0 -1
- package/lib/mjs/state/User.d.ts +5 -0
- package/package.json +3 -3
- package/src/app/AppSettings.ts +0 -6
- package/src/app/CoreApp.ts +8 -6
- package/src/app/IApp.ts +3 -2
- package/src/erp/AuthApi.ts +20 -0
- package/src/erp/PublicApi.ts +0 -23
- package/src/i18n/en.json +1 -0
- package/src/i18n/zh-Hans.json +1 -0
- package/src/i18n/zh-Hant.json +1 -0
- package/src/index.ts +0 -1
- package/src/state/User.ts +6 -0
- package/lib/cjs/erp/dto/PublicProductDto.d.ts +0 -40
- package/lib/cjs/erp/dto/PublicProductDto.js +0 -2
- package/lib/mjs/erp/dto/PublicProductDto.d.ts +0 -40
- package/lib/mjs/erp/dto/PublicProductDto.js +0 -1
- package/src/erp/dto/PublicProductDto.ts +0 -47
package/__tests__/app/CoreApp.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ApiAuthorizationScheme } from '@etsoo/restclient';
|
|
2
1
|
import { DataTypes } from '@etsoo/shared';
|
|
3
2
|
import { AddressRegion } from '../address/AddressRegion';
|
|
4
3
|
import { IExternalSettings } from './ExternalSettings';
|
|
@@ -6,10 +5,6 @@ import { IExternalSettings } from './ExternalSettings';
|
|
|
6
5
|
* App settings interface
|
|
7
6
|
*/
|
|
8
7
|
export interface IAppSettings extends IExternalSettings {
|
|
9
|
-
/**
|
|
10
|
-
* Authorization scheme
|
|
11
|
-
*/
|
|
12
|
-
readonly authScheme: ApiAuthorizationScheme | string;
|
|
13
8
|
/**
|
|
14
9
|
* Supported country/region ids
|
|
15
10
|
*/
|
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -249,10 +249,11 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
249
249
|
alertResult(result: IActionResult, callback?: NotificationReturn<void>, forceToLocal?: FormatResultCustomCallback): void;
|
|
250
250
|
/**
|
|
251
251
|
* Authorize
|
|
252
|
-
* @param token New token
|
|
252
|
+
* @param token New access token
|
|
253
|
+
* @param schema Access token schema
|
|
253
254
|
* @param refreshToken Refresh token
|
|
254
255
|
*/
|
|
255
|
-
authorize(token?: string, refreshToken?: string): void;
|
|
256
|
+
authorize(token?: string, schema?: string, refreshToken?: string): void;
|
|
256
257
|
/**
|
|
257
258
|
* Change country or region
|
|
258
259
|
* @param regionId New country or region
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -534,14 +534,16 @@ class CoreApp {
|
|
|
534
534
|
}
|
|
535
535
|
/**
|
|
536
536
|
* Authorize
|
|
537
|
-
* @param token New token
|
|
537
|
+
* @param token New access token
|
|
538
|
+
* @param schema Access token schema
|
|
538
539
|
* @param refreshToken Refresh token
|
|
539
540
|
*/
|
|
540
|
-
authorize(token, refreshToken) {
|
|
541
|
+
authorize(token, schema, refreshToken) {
|
|
541
542
|
// State, when token is null, means logout
|
|
542
543
|
this.authorized = token != null;
|
|
543
544
|
// Token
|
|
544
|
-
|
|
545
|
+
schema ?? (schema = 'Bearer');
|
|
546
|
+
this.api.authorize(schema, token);
|
|
545
547
|
// Overwrite the current value
|
|
546
548
|
if (refreshToken !== '') {
|
|
547
549
|
if (refreshToken != null)
|
|
@@ -1391,11 +1393,11 @@ class CoreApp {
|
|
|
1391
1393
|
// Cache the encrypted serverside device id
|
|
1392
1394
|
this.storage.setData(this.fields.serversideDeviceId, user.deviceId);
|
|
1393
1395
|
if (keep) {
|
|
1394
|
-
this.authorize(user.token, refreshToken);
|
|
1396
|
+
this.authorize(user.token, user.tokenScheme, refreshToken);
|
|
1395
1397
|
}
|
|
1396
1398
|
else {
|
|
1397
1399
|
this.cachedRefreshToken = this.encrypt(refreshToken);
|
|
1398
|
-
this.authorize(user.token, undefined);
|
|
1400
|
+
this.authorize(user.token, user.tokenScheme, undefined);
|
|
1399
1401
|
}
|
|
1400
1402
|
}
|
|
1401
1403
|
/**
|
|
@@ -1404,7 +1406,7 @@ class CoreApp {
|
|
|
1404
1406
|
* @param noTrigger No trigger for state change
|
|
1405
1407
|
*/
|
|
1406
1408
|
userLogout(clearToken = true, noTrigger = false) {
|
|
1407
|
-
this.authorize(undefined, clearToken ? undefined : '');
|
|
1409
|
+
this.authorize(undefined, undefined, clearToken ? undefined : '');
|
|
1408
1410
|
}
|
|
1409
1411
|
/**
|
|
1410
1412
|
* User unauthorized
|
package/lib/cjs/app/IApp.d.ts
CHANGED
|
@@ -178,10 +178,11 @@ export interface IApp {
|
|
|
178
178
|
alertResult(result: IActionResult, callback?: NotificationReturn<void>, forceToLocal?: FormatResultCustomCallback): void;
|
|
179
179
|
/**
|
|
180
180
|
* Authorize
|
|
181
|
-
* @param token New token
|
|
181
|
+
* @param token New access token
|
|
182
|
+
* @param schema Access token schema
|
|
182
183
|
* @param refreshToken Refresh token
|
|
183
184
|
*/
|
|
184
|
-
authorize(token?: string, refreshToken?: string): void;
|
|
185
|
+
authorize(token?: string, schema?: string, refreshToken?: string): void;
|
|
185
186
|
/**
|
|
186
187
|
* Change country or region
|
|
187
188
|
* @param region New country or region
|
package/lib/cjs/erp/AuthApi.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ export declare class AuthApi extends BaseApi {
|
|
|
17
17
|
* @returns Result
|
|
18
18
|
*/
|
|
19
19
|
protected loginBase<T extends IUser>(rq: LoginRQ, payload?: IApiPayload<IActionResult<T>>, tokenKey?: string): Promise<[IActionResult<T> | undefined, string | null]>;
|
|
20
|
+
/**
|
|
21
|
+
* Get log in url
|
|
22
|
+
* @returns Url
|
|
23
|
+
*/
|
|
24
|
+
getLogInUrl(): Promise<string | undefined>;
|
|
20
25
|
/**
|
|
21
26
|
* Login id check
|
|
22
27
|
* @param id Check id
|
|
@@ -24,6 +29,10 @@ export declare class AuthApi extends BaseApi {
|
|
|
24
29
|
* @returns Result
|
|
25
30
|
*/
|
|
26
31
|
loginId(id: string, payload?: ResultPayload): Promise<IActionResult<{}> | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* Redirect to log in url
|
|
34
|
+
*/
|
|
35
|
+
redirectToLogInUrl(): Promise<void>;
|
|
27
36
|
/**
|
|
28
37
|
* Reset password
|
|
29
38
|
* @param rq Request data
|
package/lib/cjs/erp/AuthApi.js
CHANGED
|
@@ -21,6 +21,16 @@ class AuthApi extends BaseApi_1.BaseApi {
|
|
|
21
21
|
: null;
|
|
22
22
|
return [result, refreshToken];
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Get log in url
|
|
26
|
+
* @returns Url
|
|
27
|
+
*/
|
|
28
|
+
getLogInUrl() {
|
|
29
|
+
return this.api.get('Auth/GetLogInUrl', {
|
|
30
|
+
region: this.app.region,
|
|
31
|
+
device: this.app.deviceId
|
|
32
|
+
});
|
|
33
|
+
}
|
|
24
34
|
/**
|
|
25
35
|
* Login id check
|
|
26
36
|
* @param id Check id
|
|
@@ -37,6 +47,15 @@ class AuthApi extends BaseApi_1.BaseApi {
|
|
|
37
47
|
};
|
|
38
48
|
return this.api.post('Auth/LoginId', rq, payload);
|
|
39
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Redirect to log in url
|
|
52
|
+
*/
|
|
53
|
+
async redirectToLogInUrl() {
|
|
54
|
+
const url = await this.getLogInUrl();
|
|
55
|
+
if (url == null)
|
|
56
|
+
return;
|
|
57
|
+
window.location.replace(url);
|
|
58
|
+
}
|
|
40
59
|
/**
|
|
41
60
|
* Reset password
|
|
42
61
|
* @param rq Request data
|
|
@@ -7,7 +7,6 @@ import { CurrencyDto } from './dto/CurrencyDto';
|
|
|
7
7
|
import { ExchangeRateDto } from './dto/ExchangeRateDto';
|
|
8
8
|
import { ExchangeRateHistoryDto } from './dto/ExchangeRateHistoryDto';
|
|
9
9
|
import { PinDto } from './dto/PinDto';
|
|
10
|
-
import { PublicOrgProductDto, PublicProductDto } from './dto/PublicProductDto';
|
|
11
10
|
import { ParsePinRQ } from './rq/ParsePinRQ';
|
|
12
11
|
/**
|
|
13
12
|
* Public API
|
|
@@ -98,14 +97,6 @@ export declare class PublicApi extends BaseApi {
|
|
|
98
97
|
* @returns Result
|
|
99
98
|
*/
|
|
100
99
|
parsePin(input: ParsePinRQ | string, payload?: IApiPayload<PinDto>): Promise<PinDto | undefined>;
|
|
101
|
-
/**
|
|
102
|
-
* Get public and valid product data
|
|
103
|
-
* @param id Product/Service Id or Uid
|
|
104
|
-
* @param culture Language
|
|
105
|
-
* @param payload Payload
|
|
106
|
-
* @returns Result
|
|
107
|
-
*/
|
|
108
|
-
product<T extends number | string>(id: T, culture?: string, payload?: IApiPayload<T extends number ? PublicProductDto : PublicOrgProductDto>): Promise<(T extends number ? PublicProductDto : PublicOrgProductDto) | undefined>;
|
|
109
100
|
/**
|
|
110
101
|
*
|
|
111
102
|
* Get all repeat options
|
package/lib/cjs/erp/PublicApi.js
CHANGED
|
@@ -172,17 +172,6 @@ class PublicApi extends BaseApi_1.BaseApi {
|
|
|
172
172
|
rq.language ?? (rq.language = this.app.culture);
|
|
173
173
|
return this.api.post('Public/ParsePin', rq, payload);
|
|
174
174
|
}
|
|
175
|
-
/**
|
|
176
|
-
* Get public and valid product data
|
|
177
|
-
* @param id Product/Service Id or Uid
|
|
178
|
-
* @param culture Language
|
|
179
|
-
* @param payload Payload
|
|
180
|
-
* @returns Result
|
|
181
|
-
*/
|
|
182
|
-
product(id, culture, payload) {
|
|
183
|
-
culture = this.app.checkLanguage(culture);
|
|
184
|
-
return this.api.get(`Public/Product/${id}/${culture}`, undefined, payload);
|
|
185
|
-
}
|
|
186
175
|
/**
|
|
187
176
|
*
|
|
188
177
|
* Get all repeat options
|
package/lib/cjs/i18n/en.json
CHANGED
package/lib/cjs/index.d.ts
CHANGED
|
@@ -40,7 +40,6 @@ export * from './erp/dto/OrgQueryDto';
|
|
|
40
40
|
export * from './erp/dto/OrgViewDto';
|
|
41
41
|
export * from './erp/dto/PinDto';
|
|
42
42
|
export * from './erp/dto/PlaceParsedDto';
|
|
43
|
-
export * from './erp/dto/PublicProductDto';
|
|
44
43
|
export * from './erp/dto/ResponseActionMessageDto';
|
|
45
44
|
export * from './erp/dto/ResultPayload';
|
|
46
45
|
export * from './erp/rq/LoginIdRQ';
|
package/lib/cjs/index.js
CHANGED
|
@@ -64,7 +64,6 @@ __exportStar(require("./erp/dto/OrgQueryDto"), exports);
|
|
|
64
64
|
__exportStar(require("./erp/dto/OrgViewDto"), exports);
|
|
65
65
|
__exportStar(require("./erp/dto/PinDto"), exports);
|
|
66
66
|
__exportStar(require("./erp/dto/PlaceParsedDto"), exports);
|
|
67
|
-
__exportStar(require("./erp/dto/PublicProductDto"), exports);
|
|
68
67
|
__exportStar(require("./erp/dto/ResponseActionMessageDto"), exports);
|
|
69
68
|
__exportStar(require("./erp/dto/ResultPayload"), exports);
|
|
70
69
|
// erp rq
|
package/lib/cjs/state/User.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ApiAuthorizationScheme } from '@etsoo/restclient';
|
|
2
1
|
import { DataTypes } from '@etsoo/shared';
|
|
3
2
|
import { AddressRegion } from '../address/AddressRegion';
|
|
4
3
|
import { IExternalSettings } from './ExternalSettings';
|
|
@@ -6,10 +5,6 @@ import { IExternalSettings } from './ExternalSettings';
|
|
|
6
5
|
* App settings interface
|
|
7
6
|
*/
|
|
8
7
|
export interface IAppSettings extends IExternalSettings {
|
|
9
|
-
/**
|
|
10
|
-
* Authorization scheme
|
|
11
|
-
*/
|
|
12
|
-
readonly authScheme: ApiAuthorizationScheme | string;
|
|
13
8
|
/**
|
|
14
9
|
* Supported country/region ids
|
|
15
10
|
*/
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -249,10 +249,11 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
249
249
|
alertResult(result: IActionResult, callback?: NotificationReturn<void>, forceToLocal?: FormatResultCustomCallback): void;
|
|
250
250
|
/**
|
|
251
251
|
* Authorize
|
|
252
|
-
* @param token New token
|
|
252
|
+
* @param token New access token
|
|
253
|
+
* @param schema Access token schema
|
|
253
254
|
* @param refreshToken Refresh token
|
|
254
255
|
*/
|
|
255
|
-
authorize(token?: string, refreshToken?: string): void;
|
|
256
|
+
authorize(token?: string, schema?: string, refreshToken?: string): void;
|
|
256
257
|
/**
|
|
257
258
|
* Change country or region
|
|
258
259
|
* @param regionId New country or region
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -531,14 +531,16 @@ export class CoreApp {
|
|
|
531
531
|
}
|
|
532
532
|
/**
|
|
533
533
|
* Authorize
|
|
534
|
-
* @param token New token
|
|
534
|
+
* @param token New access token
|
|
535
|
+
* @param schema Access token schema
|
|
535
536
|
* @param refreshToken Refresh token
|
|
536
537
|
*/
|
|
537
|
-
authorize(token, refreshToken) {
|
|
538
|
+
authorize(token, schema, refreshToken) {
|
|
538
539
|
// State, when token is null, means logout
|
|
539
540
|
this.authorized = token != null;
|
|
540
541
|
// Token
|
|
541
|
-
|
|
542
|
+
schema ?? (schema = 'Bearer');
|
|
543
|
+
this.api.authorize(schema, token);
|
|
542
544
|
// Overwrite the current value
|
|
543
545
|
if (refreshToken !== '') {
|
|
544
546
|
if (refreshToken != null)
|
|
@@ -1388,11 +1390,11 @@ export class CoreApp {
|
|
|
1388
1390
|
// Cache the encrypted serverside device id
|
|
1389
1391
|
this.storage.setData(this.fields.serversideDeviceId, user.deviceId);
|
|
1390
1392
|
if (keep) {
|
|
1391
|
-
this.authorize(user.token, refreshToken);
|
|
1393
|
+
this.authorize(user.token, user.tokenScheme, refreshToken);
|
|
1392
1394
|
}
|
|
1393
1395
|
else {
|
|
1394
1396
|
this.cachedRefreshToken = this.encrypt(refreshToken);
|
|
1395
|
-
this.authorize(user.token, undefined);
|
|
1397
|
+
this.authorize(user.token, user.tokenScheme, undefined);
|
|
1396
1398
|
}
|
|
1397
1399
|
}
|
|
1398
1400
|
/**
|
|
@@ -1401,7 +1403,7 @@ export class CoreApp {
|
|
|
1401
1403
|
* @param noTrigger No trigger for state change
|
|
1402
1404
|
*/
|
|
1403
1405
|
userLogout(clearToken = true, noTrigger = false) {
|
|
1404
|
-
this.authorize(undefined, clearToken ? undefined : '');
|
|
1406
|
+
this.authorize(undefined, undefined, clearToken ? undefined : '');
|
|
1405
1407
|
}
|
|
1406
1408
|
/**
|
|
1407
1409
|
* User unauthorized
|
package/lib/mjs/app/IApp.d.ts
CHANGED
|
@@ -178,10 +178,11 @@ export interface IApp {
|
|
|
178
178
|
alertResult(result: IActionResult, callback?: NotificationReturn<void>, forceToLocal?: FormatResultCustomCallback): void;
|
|
179
179
|
/**
|
|
180
180
|
* Authorize
|
|
181
|
-
* @param token New token
|
|
181
|
+
* @param token New access token
|
|
182
|
+
* @param schema Access token schema
|
|
182
183
|
* @param refreshToken Refresh token
|
|
183
184
|
*/
|
|
184
|
-
authorize(token?: string, refreshToken?: string): void;
|
|
185
|
+
authorize(token?: string, schema?: string, refreshToken?: string): void;
|
|
185
186
|
/**
|
|
186
187
|
* Change country or region
|
|
187
188
|
* @param region New country or region
|
package/lib/mjs/erp/AuthApi.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ export declare class AuthApi extends BaseApi {
|
|
|
17
17
|
* @returns Result
|
|
18
18
|
*/
|
|
19
19
|
protected loginBase<T extends IUser>(rq: LoginRQ, payload?: IApiPayload<IActionResult<T>>, tokenKey?: string): Promise<[IActionResult<T> | undefined, string | null]>;
|
|
20
|
+
/**
|
|
21
|
+
* Get log in url
|
|
22
|
+
* @returns Url
|
|
23
|
+
*/
|
|
24
|
+
getLogInUrl(): Promise<string | undefined>;
|
|
20
25
|
/**
|
|
21
26
|
* Login id check
|
|
22
27
|
* @param id Check id
|
|
@@ -24,6 +29,10 @@ export declare class AuthApi extends BaseApi {
|
|
|
24
29
|
* @returns Result
|
|
25
30
|
*/
|
|
26
31
|
loginId(id: string, payload?: ResultPayload): Promise<IActionResult<{}> | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* Redirect to log in url
|
|
34
|
+
*/
|
|
35
|
+
redirectToLogInUrl(): Promise<void>;
|
|
27
36
|
/**
|
|
28
37
|
* Reset password
|
|
29
38
|
* @param rq Request data
|
package/lib/mjs/erp/AuthApi.js
CHANGED
|
@@ -18,6 +18,16 @@ export class AuthApi extends BaseApi {
|
|
|
18
18
|
: null;
|
|
19
19
|
return [result, refreshToken];
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Get log in url
|
|
23
|
+
* @returns Url
|
|
24
|
+
*/
|
|
25
|
+
getLogInUrl() {
|
|
26
|
+
return this.api.get('Auth/GetLogInUrl', {
|
|
27
|
+
region: this.app.region,
|
|
28
|
+
device: this.app.deviceId
|
|
29
|
+
});
|
|
30
|
+
}
|
|
21
31
|
/**
|
|
22
32
|
* Login id check
|
|
23
33
|
* @param id Check id
|
|
@@ -34,6 +44,15 @@ export class AuthApi extends BaseApi {
|
|
|
34
44
|
};
|
|
35
45
|
return this.api.post('Auth/LoginId', rq, payload);
|
|
36
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Redirect to log in url
|
|
49
|
+
*/
|
|
50
|
+
async redirectToLogInUrl() {
|
|
51
|
+
const url = await this.getLogInUrl();
|
|
52
|
+
if (url == null)
|
|
53
|
+
return;
|
|
54
|
+
window.location.replace(url);
|
|
55
|
+
}
|
|
37
56
|
/**
|
|
38
57
|
* Reset password
|
|
39
58
|
* @param rq Request data
|
|
@@ -7,7 +7,6 @@ import { CurrencyDto } from './dto/CurrencyDto';
|
|
|
7
7
|
import { ExchangeRateDto } from './dto/ExchangeRateDto';
|
|
8
8
|
import { ExchangeRateHistoryDto } from './dto/ExchangeRateHistoryDto';
|
|
9
9
|
import { PinDto } from './dto/PinDto';
|
|
10
|
-
import { PublicOrgProductDto, PublicProductDto } from './dto/PublicProductDto';
|
|
11
10
|
import { ParsePinRQ } from './rq/ParsePinRQ';
|
|
12
11
|
/**
|
|
13
12
|
* Public API
|
|
@@ -98,14 +97,6 @@ export declare class PublicApi extends BaseApi {
|
|
|
98
97
|
* @returns Result
|
|
99
98
|
*/
|
|
100
99
|
parsePin(input: ParsePinRQ | string, payload?: IApiPayload<PinDto>): Promise<PinDto | undefined>;
|
|
101
|
-
/**
|
|
102
|
-
* Get public and valid product data
|
|
103
|
-
* @param id Product/Service Id or Uid
|
|
104
|
-
* @param culture Language
|
|
105
|
-
* @param payload Payload
|
|
106
|
-
* @returns Result
|
|
107
|
-
*/
|
|
108
|
-
product<T extends number | string>(id: T, culture?: string, payload?: IApiPayload<T extends number ? PublicProductDto : PublicOrgProductDto>): Promise<(T extends number ? PublicProductDto : PublicOrgProductDto) | undefined>;
|
|
109
100
|
/**
|
|
110
101
|
*
|
|
111
102
|
* Get all repeat options
|
package/lib/mjs/erp/PublicApi.js
CHANGED
|
@@ -169,17 +169,6 @@ export class PublicApi extends BaseApi {
|
|
|
169
169
|
rq.language ?? (rq.language = this.app.culture);
|
|
170
170
|
return this.api.post('Public/ParsePin', rq, payload);
|
|
171
171
|
}
|
|
172
|
-
/**
|
|
173
|
-
* Get public and valid product data
|
|
174
|
-
* @param id Product/Service Id or Uid
|
|
175
|
-
* @param culture Language
|
|
176
|
-
* @param payload Payload
|
|
177
|
-
* @returns Result
|
|
178
|
-
*/
|
|
179
|
-
product(id, culture, payload) {
|
|
180
|
-
culture = this.app.checkLanguage(culture);
|
|
181
|
-
return this.api.get(`Public/Product/${id}/${culture}`, undefined, payload);
|
|
182
|
-
}
|
|
183
172
|
/**
|
|
184
173
|
*
|
|
185
174
|
* Get all repeat options
|
package/lib/mjs/i18n/en.json
CHANGED
package/lib/mjs/index.d.ts
CHANGED
|
@@ -40,7 +40,6 @@ export * from './erp/dto/OrgQueryDto';
|
|
|
40
40
|
export * from './erp/dto/OrgViewDto';
|
|
41
41
|
export * from './erp/dto/PinDto';
|
|
42
42
|
export * from './erp/dto/PlaceParsedDto';
|
|
43
|
-
export * from './erp/dto/PublicProductDto';
|
|
44
43
|
export * from './erp/dto/ResponseActionMessageDto';
|
|
45
44
|
export * from './erp/dto/ResultPayload';
|
|
46
45
|
export * from './erp/rq/LoginIdRQ';
|
package/lib/mjs/index.js
CHANGED
|
@@ -47,7 +47,6 @@ export * from './erp/dto/OrgQueryDto';
|
|
|
47
47
|
export * from './erp/dto/OrgViewDto';
|
|
48
48
|
export * from './erp/dto/PinDto';
|
|
49
49
|
export * from './erp/dto/PlaceParsedDto';
|
|
50
|
-
export * from './erp/dto/PublicProductDto';
|
|
51
50
|
export * from './erp/dto/ResponseActionMessageDto';
|
|
52
51
|
export * from './erp/dto/ResultPayload';
|
|
53
52
|
// erp rq
|
package/lib/mjs/state/User.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/appscript",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.15",
|
|
4
4
|
"description": "Applications shared TypeScript framework",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -64,10 +64,10 @@
|
|
|
64
64
|
"@babel/preset-env": "^7.25.4",
|
|
65
65
|
"@babel/runtime-corejs3": "^7.25.6",
|
|
66
66
|
"@types/crypto-js": "^4.2.2",
|
|
67
|
-
"@types/jest": "^29.5.
|
|
67
|
+
"@types/jest": "^29.5.13",
|
|
68
68
|
"jest": "^29.7.0",
|
|
69
69
|
"jest-environment-jsdom": "^29.7.0",
|
|
70
70
|
"ts-jest": "^29.2.5",
|
|
71
|
-
"typescript": "^5.
|
|
71
|
+
"typescript": "^5.6.2"
|
|
72
72
|
}
|
|
73
73
|
}
|
package/src/app/AppSettings.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ApiAuthorizationScheme } from '@etsoo/restclient';
|
|
2
1
|
import { DataTypes } from '@etsoo/shared';
|
|
3
2
|
import { AddressRegion } from '../address/AddressRegion';
|
|
4
3
|
import { IExternalSettings } from './ExternalSettings';
|
|
@@ -7,11 +6,6 @@ import { IExternalSettings } from './ExternalSettings';
|
|
|
7
6
|
* App settings interface
|
|
8
7
|
*/
|
|
9
8
|
export interface IAppSettings extends IExternalSettings {
|
|
10
|
-
/**
|
|
11
|
-
* Authorization scheme
|
|
12
|
-
*/
|
|
13
|
-
readonly authScheme: ApiAuthorizationScheme | string;
|
|
14
|
-
|
|
15
9
|
/**
|
|
16
10
|
* Supported country/region ids
|
|
17
11
|
*/
|
package/src/app/CoreApp.ts
CHANGED
|
@@ -847,15 +847,17 @@ export abstract class CoreApp<
|
|
|
847
847
|
|
|
848
848
|
/**
|
|
849
849
|
* Authorize
|
|
850
|
-
* @param token New token
|
|
850
|
+
* @param token New access token
|
|
851
|
+
* @param schema Access token schema
|
|
851
852
|
* @param refreshToken Refresh token
|
|
852
853
|
*/
|
|
853
|
-
authorize(token?: string, refreshToken?: string) {
|
|
854
|
+
authorize(token?: string, schema?: string, refreshToken?: string) {
|
|
854
855
|
// State, when token is null, means logout
|
|
855
856
|
this.authorized = token != null;
|
|
856
857
|
|
|
857
858
|
// Token
|
|
858
|
-
|
|
859
|
+
schema ??= 'Bearer';
|
|
860
|
+
this.api.authorize(schema, token);
|
|
859
861
|
|
|
860
862
|
// Overwrite the current value
|
|
861
863
|
if (refreshToken !== '') {
|
|
@@ -1892,10 +1894,10 @@ export abstract class CoreApp<
|
|
|
1892
1894
|
this.storage.setData(this.fields.serversideDeviceId, user.deviceId);
|
|
1893
1895
|
|
|
1894
1896
|
if (keep) {
|
|
1895
|
-
this.authorize(user.token, refreshToken);
|
|
1897
|
+
this.authorize(user.token, user.tokenScheme, refreshToken);
|
|
1896
1898
|
} else {
|
|
1897
1899
|
this.cachedRefreshToken = this.encrypt(refreshToken);
|
|
1898
|
-
this.authorize(user.token, undefined);
|
|
1900
|
+
this.authorize(user.token, user.tokenScheme, undefined);
|
|
1899
1901
|
}
|
|
1900
1902
|
}
|
|
1901
1903
|
|
|
@@ -1905,7 +1907,7 @@ export abstract class CoreApp<
|
|
|
1905
1907
|
* @param noTrigger No trigger for state change
|
|
1906
1908
|
*/
|
|
1907
1909
|
userLogout(clearToken: boolean = true, noTrigger: boolean = false) {
|
|
1908
|
-
this.authorize(undefined, clearToken ? undefined : '');
|
|
1910
|
+
this.authorize(undefined, undefined, clearToken ? undefined : '');
|
|
1909
1911
|
}
|
|
1910
1912
|
|
|
1911
1913
|
/**
|
package/src/app/IApp.ts
CHANGED
|
@@ -243,10 +243,11 @@ export interface IApp {
|
|
|
243
243
|
|
|
244
244
|
/**
|
|
245
245
|
* Authorize
|
|
246
|
-
* @param token New token
|
|
246
|
+
* @param token New access token
|
|
247
|
+
* @param schema Access token schema
|
|
247
248
|
* @param refreshToken Refresh token
|
|
248
249
|
*/
|
|
249
|
-
authorize(token?: string, refreshToken?: string): void;
|
|
250
|
+
authorize(token?: string, schema?: string, refreshToken?: string): void;
|
|
250
251
|
|
|
251
252
|
/**
|
|
252
253
|
* Change country or region
|
package/src/erp/AuthApi.ts
CHANGED
|
@@ -31,6 +31,17 @@ export class AuthApi extends BaseApi {
|
|
|
31
31
|
return [result, refreshToken];
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Get log in url
|
|
36
|
+
* @returns Url
|
|
37
|
+
*/
|
|
38
|
+
getLogInUrl() {
|
|
39
|
+
return this.api.get<string>('Auth/GetLogInUrl', {
|
|
40
|
+
region: this.app.region,
|
|
41
|
+
device: this.app.deviceId
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
34
45
|
/**
|
|
35
46
|
* Login id check
|
|
36
47
|
* @param id Check id
|
|
@@ -48,6 +59,15 @@ export class AuthApi extends BaseApi {
|
|
|
48
59
|
return this.api.post('Auth/LoginId', rq, payload);
|
|
49
60
|
}
|
|
50
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Redirect to log in url
|
|
64
|
+
*/
|
|
65
|
+
async redirectToLogInUrl() {
|
|
66
|
+
const url = await this.getLogInUrl();
|
|
67
|
+
if (url == null) return;
|
|
68
|
+
window.location.replace(url);
|
|
69
|
+
}
|
|
70
|
+
|
|
51
71
|
/**
|
|
52
72
|
* Reset password
|
|
53
73
|
* @param rq Request data
|
package/src/erp/PublicApi.ts
CHANGED
|
@@ -8,7 +8,6 @@ import { CurrencyDto } from './dto/CurrencyDto';
|
|
|
8
8
|
import { ExchangeRateDto } from './dto/ExchangeRateDto';
|
|
9
9
|
import { ExchangeRateHistoryDto } from './dto/ExchangeRateHistoryDto';
|
|
10
10
|
import { PinDto } from './dto/PinDto';
|
|
11
|
-
import { PublicOrgProductDto, PublicProductDto } from './dto/PublicProductDto';
|
|
12
11
|
import { ParsePinRQ } from './rq/ParsePinRQ';
|
|
13
12
|
|
|
14
13
|
const cachedCurrencyRates: {
|
|
@@ -224,28 +223,6 @@ export class PublicApi extends BaseApi {
|
|
|
224
223
|
return this.api.post('Public/ParsePin', rq, payload);
|
|
225
224
|
}
|
|
226
225
|
|
|
227
|
-
/**
|
|
228
|
-
* Get public and valid product data
|
|
229
|
-
* @param id Product/Service Id or Uid
|
|
230
|
-
* @param culture Language
|
|
231
|
-
* @param payload Payload
|
|
232
|
-
* @returns Result
|
|
233
|
-
*/
|
|
234
|
-
product<T extends number | string>(
|
|
235
|
-
id: T,
|
|
236
|
-
culture?: string,
|
|
237
|
-
payload?: IApiPayload<
|
|
238
|
-
T extends number ? PublicProductDto : PublicOrgProductDto
|
|
239
|
-
>
|
|
240
|
-
) {
|
|
241
|
-
culture = this.app.checkLanguage(culture);
|
|
242
|
-
return this.api.get(
|
|
243
|
-
`Public/Product/${id}/${culture}`,
|
|
244
|
-
undefined,
|
|
245
|
-
payload
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
226
|
/**
|
|
250
227
|
*
|
|
251
228
|
* Get all repeat options
|
package/src/i18n/en.json
CHANGED
package/src/i18n/zh-Hans.json
CHANGED
package/src/i18n/zh-Hant.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -53,7 +53,6 @@ export * from './erp/dto/OrgQueryDto';
|
|
|
53
53
|
export * from './erp/dto/OrgViewDto';
|
|
54
54
|
export * from './erp/dto/PinDto';
|
|
55
55
|
export * from './erp/dto/PlaceParsedDto';
|
|
56
|
-
export * from './erp/dto/PublicProductDto';
|
|
57
56
|
export * from './erp/dto/ResponseActionMessageDto';
|
|
58
57
|
export * from './erp/dto/ResultPayload';
|
|
59
58
|
|
package/src/state/User.ts
CHANGED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { IdType } from '@etsoo/shared';
|
|
2
|
-
import { EntityStatus } from '../../business/EntityStatus';
|
|
3
|
-
/**
|
|
4
|
-
* Public product data
|
|
5
|
-
*/
|
|
6
|
-
export type PublicProductDto = {
|
|
7
|
-
/**
|
|
8
|
-
* Id
|
|
9
|
-
*/
|
|
10
|
-
id: number;
|
|
11
|
-
/**
|
|
12
|
-
* Name
|
|
13
|
-
*/
|
|
14
|
-
name: string;
|
|
15
|
-
/**
|
|
16
|
-
* Logo
|
|
17
|
-
*/
|
|
18
|
-
logo?: string;
|
|
19
|
-
/**
|
|
20
|
-
* Web URL for access
|
|
21
|
-
*/
|
|
22
|
-
webUrl: string;
|
|
23
|
-
/**
|
|
24
|
-
* Query id for service Id / service Uid
|
|
25
|
-
*/
|
|
26
|
-
queryId?: IdType;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Public product with organization data
|
|
30
|
-
*/
|
|
31
|
-
export type PublicOrgProductDto = PublicProductDto & {
|
|
32
|
-
/**
|
|
33
|
-
* Purchased service status
|
|
34
|
-
*/
|
|
35
|
-
serviceEntityStatus?: EntityStatus;
|
|
36
|
-
/**
|
|
37
|
-
* Purchased service expiry
|
|
38
|
-
*/
|
|
39
|
-
serviceExpiry?: string | Date;
|
|
40
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { IdType } from '@etsoo/shared';
|
|
2
|
-
import { EntityStatus } from '../../business/EntityStatus';
|
|
3
|
-
/**
|
|
4
|
-
* Public product data
|
|
5
|
-
*/
|
|
6
|
-
export type PublicProductDto = {
|
|
7
|
-
/**
|
|
8
|
-
* Id
|
|
9
|
-
*/
|
|
10
|
-
id: number;
|
|
11
|
-
/**
|
|
12
|
-
* Name
|
|
13
|
-
*/
|
|
14
|
-
name: string;
|
|
15
|
-
/**
|
|
16
|
-
* Logo
|
|
17
|
-
*/
|
|
18
|
-
logo?: string;
|
|
19
|
-
/**
|
|
20
|
-
* Web URL for access
|
|
21
|
-
*/
|
|
22
|
-
webUrl: string;
|
|
23
|
-
/**
|
|
24
|
-
* Query id for service Id / service Uid
|
|
25
|
-
*/
|
|
26
|
-
queryId?: IdType;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Public product with organization data
|
|
30
|
-
*/
|
|
31
|
-
export type PublicOrgProductDto = PublicProductDto & {
|
|
32
|
-
/**
|
|
33
|
-
* Purchased service status
|
|
34
|
-
*/
|
|
35
|
-
serviceEntityStatus?: EntityStatus;
|
|
36
|
-
/**
|
|
37
|
-
* Purchased service expiry
|
|
38
|
-
*/
|
|
39
|
-
serviceExpiry?: string | Date;
|
|
40
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { IdType } from '@etsoo/shared';
|
|
2
|
-
import { EntityStatus } from '../../business/EntityStatus';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Public product data
|
|
6
|
-
*/
|
|
7
|
-
export type PublicProductDto = {
|
|
8
|
-
/**
|
|
9
|
-
* Id
|
|
10
|
-
*/
|
|
11
|
-
id: number;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Name
|
|
15
|
-
*/
|
|
16
|
-
name: string;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Logo
|
|
20
|
-
*/
|
|
21
|
-
logo?: string;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Web URL for access
|
|
25
|
-
*/
|
|
26
|
-
webUrl: string;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Query id for service Id / service Uid
|
|
30
|
-
*/
|
|
31
|
-
queryId?: IdType;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Public product with organization data
|
|
36
|
-
*/
|
|
37
|
-
export type PublicOrgProductDto = PublicProductDto & {
|
|
38
|
-
/**
|
|
39
|
-
* Purchased service status
|
|
40
|
-
*/
|
|
41
|
-
serviceEntityStatus?: EntityStatus;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Purchased service expiry
|
|
45
|
-
*/
|
|
46
|
-
serviceExpiry?: string | Date;
|
|
47
|
-
};
|