@etsoo/appscript 1.5.14 → 1.5.16

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.
@@ -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
@@ -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
@@ -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
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Application authentication request object
3
+ * 程序认证请求对象
4
+ */
5
+ export type AuthRequest = {
6
+ /**
7
+ * Application ID
8
+ * 应用编号
9
+ */
10
+ appId: number;
11
+ /**
12
+ * Application key
13
+ * 应用键值
14
+ */
15
+ appKey: string;
16
+ /**
17
+ * login hint (user login name)
18
+ * 登录提示(个人登录名)
19
+ */
20
+ loginHint?: string;
21
+ /**
22
+ * Redirect URI
23
+ * 重定向URI
24
+ */
25
+ redirectUri: string;
26
+ /**
27
+ * Response type, code or token
28
+ * 响应类型,代码或令牌
29
+ */
30
+ responseType: 'code' | 'token';
31
+ /**
32
+ * Scope
33
+ * 作用域
34
+ */
35
+ scope: string;
36
+ /**
37
+ * State value
38
+ * 状态值
39
+ */
40
+ state: string;
41
+ /**
42
+ * Signature
43
+ * 签名
44
+ */
45
+ sign: string;
46
+ };
@@ -1,5 +1,5 @@
1
- import { IdType } from '@etsoo/shared';
2
1
  import { LoginIdRQ } from './LoginIdRQ';
2
+ import { AuthRequest } from './AuthRequest';
3
3
  /**
4
4
  * Login request data
5
5
  */
@@ -17,7 +17,7 @@ export type LoginRQ = LoginIdRQ & {
17
17
  */
18
18
  timezone?: string;
19
19
  /**
20
- * Service id or uid
20
+ * Authorization request data
21
21
  */
22
- serviceId?: IdType;
22
+ auth?: AuthRequest;
23
23
  };
@@ -40,9 +40,9 @@ 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';
45
+ export * from './erp/rq/AuthRequest';
46
46
  export * from './erp/rq/LoginIdRQ';
47
47
  export * from './erp/rq/LoginRQ';
48
48
  export * from './erp/rq/MemberListRQ';
package/lib/cjs/index.js CHANGED
@@ -64,10 +64,10 @@ __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
70
+ __exportStar(require("./erp/rq/AuthRequest"), exports);
71
71
  __exportStar(require("./erp/rq/LoginIdRQ"), exports);
72
72
  __exportStar(require("./erp/rq/LoginRQ"), exports);
73
73
  __exportStar(require("./erp/rq/MemberListRQ"), exports);
@@ -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
@@ -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
@@ -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
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Application authentication request object
3
+ * 程序认证请求对象
4
+ */
5
+ export type AuthRequest = {
6
+ /**
7
+ * Application ID
8
+ * 应用编号
9
+ */
10
+ appId: number;
11
+ /**
12
+ * Application key
13
+ * 应用键值
14
+ */
15
+ appKey: string;
16
+ /**
17
+ * login hint (user login name)
18
+ * 登录提示(个人登录名)
19
+ */
20
+ loginHint?: string;
21
+ /**
22
+ * Redirect URI
23
+ * 重定向URI
24
+ */
25
+ redirectUri: string;
26
+ /**
27
+ * Response type, code or token
28
+ * 响应类型,代码或令牌
29
+ */
30
+ responseType: 'code' | 'token';
31
+ /**
32
+ * Scope
33
+ * 作用域
34
+ */
35
+ scope: string;
36
+ /**
37
+ * State value
38
+ * 状态值
39
+ */
40
+ state: string;
41
+ /**
42
+ * Signature
43
+ * 签名
44
+ */
45
+ sign: string;
46
+ };
@@ -1,5 +1,5 @@
1
- import { IdType } from '@etsoo/shared';
2
1
  import { LoginIdRQ } from './LoginIdRQ';
2
+ import { AuthRequest } from './AuthRequest';
3
3
  /**
4
4
  * Login request data
5
5
  */
@@ -17,7 +17,7 @@ export type LoginRQ = LoginIdRQ & {
17
17
  */
18
18
  timezone?: string;
19
19
  /**
20
- * Service id or uid
20
+ * Authorization request data
21
21
  */
22
- serviceId?: IdType;
22
+ auth?: AuthRequest;
23
23
  };
@@ -40,9 +40,9 @@ 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';
45
+ export * from './erp/rq/AuthRequest';
46
46
  export * from './erp/rq/LoginIdRQ';
47
47
  export * from './erp/rq/LoginRQ';
48
48
  export * from './erp/rq/MemberListRQ';
package/lib/mjs/index.js CHANGED
@@ -47,10 +47,10 @@ 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
53
+ export * from './erp/rq/AuthRequest';
54
54
  export * from './erp/rq/LoginIdRQ';
55
55
  export * from './erp/rq/LoginRQ';
56
56
  export * from './erp/rq/MemberListRQ';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.14",
3
+ "version": "1.5.16",
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.12",
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.5.4"
71
+ "typescript": "^5.6.2"
72
72
  }
73
73
  }
@@ -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
@@ -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
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Application authentication request object
3
+ * 程序认证请求对象
4
+ */
5
+ export type AuthRequest = {
6
+ /**
7
+ * Application ID
8
+ * 应用编号
9
+ */
10
+ appId: number;
11
+
12
+ /**
13
+ * Application key
14
+ * 应用键值
15
+ */
16
+ appKey: string;
17
+
18
+ /**
19
+ * login hint (user login name)
20
+ * 登录提示(个人登录名)
21
+ */
22
+ loginHint?: string;
23
+
24
+ /**
25
+ * Redirect URI
26
+ * 重定向URI
27
+ */
28
+ redirectUri: string;
29
+
30
+ /**
31
+ * Response type, code or token
32
+ * 响应类型,代码或令牌
33
+ */
34
+ responseType: 'code' | 'token';
35
+
36
+ /**
37
+ * Scope
38
+ * 作用域
39
+ */
40
+ scope: string;
41
+
42
+ /**
43
+ * State value
44
+ * 状态值
45
+ */
46
+ state: string;
47
+
48
+ /**
49
+ * Signature
50
+ * 签名
51
+ */
52
+ sign: string;
53
+ };
@@ -1,5 +1,5 @@
1
- import { IdType } from '@etsoo/shared';
2
1
  import { LoginIdRQ } from './LoginIdRQ';
2
+ import { AuthRequest } from './AuthRequest';
3
3
 
4
4
  /**
5
5
  * Login request data
@@ -21,7 +21,7 @@ export type LoginRQ = LoginIdRQ & {
21
21
  timezone?: string;
22
22
 
23
23
  /**
24
- * Service id or uid
24
+ * Authorization request data
25
25
  */
26
- serviceId?: IdType;
26
+ auth?: AuthRequest;
27
27
  };
package/src/index.ts CHANGED
@@ -53,11 +53,11 @@ 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
 
60
59
  // erp rq
60
+ export * from './erp/rq/AuthRequest';
61
61
  export * from './erp/rq/LoginIdRQ';
62
62
  export * from './erp/rq/LoginRQ';
63
63
  export * from './erp/rq/MemberListRQ';
@@ -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,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
- };