@etsoo/appscript 1.4.8 → 1.4.10

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.
@@ -60,9 +60,9 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
60
60
  */
61
61
  readonly storage: IStorage;
62
62
  /**
63
- * Access token
63
+ * Pending actions
64
64
  */
65
- accessToken?: string;
65
+ readonly pendings: (() => any)[];
66
66
  private _culture;
67
67
  /**
68
68
  * Culture, like zh-CN
@@ -110,6 +110,12 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
110
110
  */
111
111
  get authorized(): boolean;
112
112
  private set authorized(value);
113
+ private _isReady;
114
+ /**
115
+ * Is the app ready
116
+ */
117
+ get isReady(): boolean;
118
+ private set isReady(value);
113
119
  private _isTryingLogin;
114
120
  /**
115
121
  * Last called with token refresh
@@ -96,6 +96,15 @@ class CoreApp {
96
96
  set authorized(value) {
97
97
  this._authorized = value;
98
98
  }
99
+ /**
100
+ * Is the app ready
101
+ */
102
+ get isReady() {
103
+ return this._isReady;
104
+ }
105
+ set isReady(value) {
106
+ this._isReady = value;
107
+ }
99
108
  /**
100
109
  * Get persisted fields
101
110
  */
@@ -117,7 +126,12 @@ class CoreApp {
117
126
  */
118
127
  constructor(settings, api, notifier, storage, name) {
119
128
  var _a;
129
+ /**
130
+ * Pending actions
131
+ */
132
+ this.pendings = [];
120
133
  this._authorized = false;
134
+ this._isReady = false;
121
135
  this._isTryingLogin = false;
122
136
  /**
123
137
  * Last called with token refresh
@@ -473,7 +487,6 @@ class CoreApp {
473
487
  authorize(token, refreshToken) {
474
488
  var _a;
475
489
  // State, when token is null, means logout
476
- this.accessToken = token;
477
490
  this.authorized = token != null;
478
491
  // Token
479
492
  this.api.authorize(this.settings.authScheme, token);
@@ -1208,8 +1221,12 @@ class CoreApp {
1208
1221
  * Setup callback
1209
1222
  */
1210
1223
  setup() {
1224
+ // Ready
1225
+ this.isReady = true;
1211
1226
  // Restore
1212
1227
  this.restore();
1228
+ // Pending actions
1229
+ this.pendings.forEach((p) => p());
1213
1230
  }
1214
1231
  /**
1215
1232
  * Signout
@@ -109,14 +109,18 @@ export interface IApp {
109
109
  * Is current authorized
110
110
  */
111
111
  readonly authorized: boolean;
112
+ /**
113
+ * Is the app ready
114
+ */
115
+ readonly isReady: boolean;
112
116
  /**
113
117
  * Application name
114
118
  */
115
119
  readonly name: string;
116
120
  /**
117
- * Access token
121
+ * Pending actions
118
122
  */
119
- accessToken?: string;
123
+ readonly pendings: (() => any)[];
120
124
  /**
121
125
  * IP data
122
126
  */
@@ -8,6 +8,7 @@ import { IdResultPayload } from './dto/ResultPayload';
8
8
  import { EntityApi } from './EntityApi';
9
9
  import { OrgListRQ } from './rq/OrgListRQ';
10
10
  import { OrgQueryRQ } from './rq/OrgQueryRQ';
11
+ import { SendActionMessageRQ } from './rq/SendActionMessageRQ';
11
12
  /**
12
13
  * Organization API
13
14
  */
@@ -41,6 +42,13 @@ export declare class OrgApi extends EntityApi {
41
42
  * @returns Result
42
43
  */
43
44
  read(id: number, payload?: IApiPayload<OrgViewDto>, reload?: boolean): Promise<OrgViewDto | undefined>;
45
+ /**
46
+ * Send action message
47
+ * @param rq Request data
48
+ * @param payload Payload
49
+ * @returns Result
50
+ */
51
+ sendActionMessage(rq: SendActionMessageRQ, payload?: IApiPayload<void>): Promise<void | undefined>;
44
52
  /**
45
53
  * Switch organization
46
54
  * @param id Organization id
@@ -51,6 +51,17 @@ class OrgApi extends EntityApi_1.EntityApi {
51
51
  }
52
52
  return data;
53
53
  }
54
+ /**
55
+ * Send action message
56
+ * @param rq Request data
57
+ * @param payload Payload
58
+ * @returns Result
59
+ */
60
+ sendActionMessage(rq, payload) {
61
+ const appId = 'serviceId' in this.app.settings ? this.app.settings.serviceId : 0;
62
+ payload !== null && payload !== void 0 ? payload : (payload = { showLoading: false });
63
+ return this.api.post('System/SendActionMessage', { ...rq, appId }, payload);
64
+ }
54
65
  /**
55
66
  * Switch organization
56
67
  * @param id Organization id
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Send action message request data
3
+ * 发送操作信息请求数据
4
+ */
5
+ export type SendActionMessageRQ = {
6
+ /**
7
+ * Kind
8
+ * 类型
9
+ */
10
+ kind: string;
11
+ /**
12
+ * Title
13
+ * 标题
14
+ */
15
+ title: string;
16
+ /**
17
+ * Related id
18
+ * 相关编号
19
+ */
20
+ relatedId?: number;
21
+ /**
22
+ * More data
23
+ * 更多数据
24
+ */
25
+ data?: Record<string, unknown>;
26
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -51,6 +51,7 @@ export * from './erp/rq/QueryRQ';
51
51
  export * from './erp/rq/RefreshTokenRQ';
52
52
  export * from './erp/rq/RegionsRQ';
53
53
  export * from './erp/rq/ResetPasswordRQ';
54
+ export * from './erp/rq/SendActionMessageRQ';
54
55
  export * from './erp/rq/TiplistRQ';
55
56
  export * from './erp/rq/UpdateStatusRQ';
56
57
  export * from './erp/AddressApi';
package/lib/cjs/index.js CHANGED
@@ -75,6 +75,7 @@ __exportStar(require("./erp/rq/QueryRQ"), exports);
75
75
  __exportStar(require("./erp/rq/RefreshTokenRQ"), exports);
76
76
  __exportStar(require("./erp/rq/RegionsRQ"), exports);
77
77
  __exportStar(require("./erp/rq/ResetPasswordRQ"), exports);
78
+ __exportStar(require("./erp/rq/SendActionMessageRQ"), exports);
78
79
  __exportStar(require("./erp/rq/TiplistRQ"), exports);
79
80
  __exportStar(require("./erp/rq/UpdateStatusRQ"), exports);
80
81
  // erp api
@@ -60,9 +60,9 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
60
60
  */
61
61
  readonly storage: IStorage;
62
62
  /**
63
- * Access token
63
+ * Pending actions
64
64
  */
65
- accessToken?: string;
65
+ readonly pendings: (() => any)[];
66
66
  private _culture;
67
67
  /**
68
68
  * Culture, like zh-CN
@@ -110,6 +110,12 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
110
110
  */
111
111
  get authorized(): boolean;
112
112
  private set authorized(value);
113
+ private _isReady;
114
+ /**
115
+ * Is the app ready
116
+ */
117
+ get isReady(): boolean;
118
+ private set isReady(value);
113
119
  private _isTryingLogin;
114
120
  /**
115
121
  * Last called with token refresh
@@ -70,6 +70,15 @@ export class CoreApp {
70
70
  set authorized(value) {
71
71
  this._authorized = value;
72
72
  }
73
+ /**
74
+ * Is the app ready
75
+ */
76
+ get isReady() {
77
+ return this._isReady;
78
+ }
79
+ set isReady(value) {
80
+ this._isReady = value;
81
+ }
73
82
  /**
74
83
  * Get persisted fields
75
84
  */
@@ -91,7 +100,12 @@ export class CoreApp {
91
100
  */
92
101
  constructor(settings, api, notifier, storage, name) {
93
102
  var _a;
103
+ /**
104
+ * Pending actions
105
+ */
106
+ this.pendings = [];
94
107
  this._authorized = false;
108
+ this._isReady = false;
95
109
  this._isTryingLogin = false;
96
110
  /**
97
111
  * Last called with token refresh
@@ -447,7 +461,6 @@ export class CoreApp {
447
461
  authorize(token, refreshToken) {
448
462
  var _a;
449
463
  // State, when token is null, means logout
450
- this.accessToken = token;
451
464
  this.authorized = token != null;
452
465
  // Token
453
466
  this.api.authorize(this.settings.authScheme, token);
@@ -1182,8 +1195,12 @@ export class CoreApp {
1182
1195
  * Setup callback
1183
1196
  */
1184
1197
  setup() {
1198
+ // Ready
1199
+ this.isReady = true;
1185
1200
  // Restore
1186
1201
  this.restore();
1202
+ // Pending actions
1203
+ this.pendings.forEach((p) => p());
1187
1204
  }
1188
1205
  /**
1189
1206
  * Signout
@@ -109,14 +109,18 @@ export interface IApp {
109
109
  * Is current authorized
110
110
  */
111
111
  readonly authorized: boolean;
112
+ /**
113
+ * Is the app ready
114
+ */
115
+ readonly isReady: boolean;
112
116
  /**
113
117
  * Application name
114
118
  */
115
119
  readonly name: string;
116
120
  /**
117
- * Access token
121
+ * Pending actions
118
122
  */
119
- accessToken?: string;
123
+ readonly pendings: (() => any)[];
120
124
  /**
121
125
  * IP data
122
126
  */
@@ -8,6 +8,7 @@ import { IdResultPayload } from './dto/ResultPayload';
8
8
  import { EntityApi } from './EntityApi';
9
9
  import { OrgListRQ } from './rq/OrgListRQ';
10
10
  import { OrgQueryRQ } from './rq/OrgQueryRQ';
11
+ import { SendActionMessageRQ } from './rq/SendActionMessageRQ';
11
12
  /**
12
13
  * Organization API
13
14
  */
@@ -41,6 +42,13 @@ export declare class OrgApi extends EntityApi {
41
42
  * @returns Result
42
43
  */
43
44
  read(id: number, payload?: IApiPayload<OrgViewDto>, reload?: boolean): Promise<OrgViewDto | undefined>;
45
+ /**
46
+ * Send action message
47
+ * @param rq Request data
48
+ * @param payload Payload
49
+ * @returns Result
50
+ */
51
+ sendActionMessage(rq: SendActionMessageRQ, payload?: IApiPayload<void>): Promise<void | undefined>;
44
52
  /**
45
53
  * Switch organization
46
54
  * @param id Organization id
@@ -48,6 +48,17 @@ export class OrgApi extends EntityApi {
48
48
  }
49
49
  return data;
50
50
  }
51
+ /**
52
+ * Send action message
53
+ * @param rq Request data
54
+ * @param payload Payload
55
+ * @returns Result
56
+ */
57
+ sendActionMessage(rq, payload) {
58
+ const appId = 'serviceId' in this.app.settings ? this.app.settings.serviceId : 0;
59
+ payload !== null && payload !== void 0 ? payload : (payload = { showLoading: false });
60
+ return this.api.post('System/SendActionMessage', { ...rq, appId }, payload);
61
+ }
51
62
  /**
52
63
  * Switch organization
53
64
  * @param id Organization id
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Send action message request data
3
+ * 发送操作信息请求数据
4
+ */
5
+ export type SendActionMessageRQ = {
6
+ /**
7
+ * Kind
8
+ * 类型
9
+ */
10
+ kind: string;
11
+ /**
12
+ * Title
13
+ * 标题
14
+ */
15
+ title: string;
16
+ /**
17
+ * Related id
18
+ * 相关编号
19
+ */
20
+ relatedId?: number;
21
+ /**
22
+ * More data
23
+ * 更多数据
24
+ */
25
+ data?: Record<string, unknown>;
26
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -51,6 +51,7 @@ export * from './erp/rq/QueryRQ';
51
51
  export * from './erp/rq/RefreshTokenRQ';
52
52
  export * from './erp/rq/RegionsRQ';
53
53
  export * from './erp/rq/ResetPasswordRQ';
54
+ export * from './erp/rq/SendActionMessageRQ';
54
55
  export * from './erp/rq/TiplistRQ';
55
56
  export * from './erp/rq/UpdateStatusRQ';
56
57
  export * from './erp/AddressApi';
package/lib/mjs/index.js CHANGED
@@ -58,6 +58,7 @@ export * from './erp/rq/QueryRQ';
58
58
  export * from './erp/rq/RefreshTokenRQ';
59
59
  export * from './erp/rq/RegionsRQ';
60
60
  export * from './erp/rq/ResetPasswordRQ';
61
+ export * from './erp/rq/SendActionMessageRQ';
61
62
  export * from './erp/rq/TiplistRQ';
62
63
  export * from './erp/rq/UpdateStatusRQ';
63
64
  // erp api
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.4.8",
3
+ "version": "1.4.10",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -114,9 +114,9 @@ export abstract class CoreApp<
114
114
  readonly storage: IStorage;
115
115
 
116
116
  /**
117
- * Access token
117
+ * Pending actions
118
118
  */
119
- accessToken?: string;
119
+ readonly pendings: (() => any)[] = [];
120
120
 
121
121
  private _culture!: string;
122
122
  /**
@@ -199,6 +199,18 @@ export abstract class CoreApp<
199
199
  this._authorized = value;
200
200
  }
201
201
 
202
+ private _isReady: boolean = false;
203
+ /**
204
+ * Is the app ready
205
+ */
206
+ get isReady() {
207
+ return this._isReady;
208
+ }
209
+
210
+ private set isReady(value: boolean) {
211
+ this._isReady = value;
212
+ }
213
+
202
214
  private _isTryingLogin = false;
203
215
 
204
216
  /**
@@ -683,7 +695,6 @@ export abstract class CoreApp<
683
695
  */
684
696
  authorize(token?: string, refreshToken?: string) {
685
697
  // State, when token is null, means logout
686
- this.accessToken = token;
687
698
  this.authorized = token != null;
688
699
 
689
700
  // Token
@@ -1548,8 +1559,14 @@ export abstract class CoreApp<
1548
1559
  * Setup callback
1549
1560
  */
1550
1561
  setup() {
1562
+ // Ready
1563
+ this.isReady = true;
1564
+
1551
1565
  // Restore
1552
1566
  this.restore();
1567
+
1568
+ // Pending actions
1569
+ this.pendings.forEach((p) => p());
1553
1570
  }
1554
1571
 
1555
1572
  /**
package/src/app/IApp.ts CHANGED
@@ -151,15 +151,20 @@ export interface IApp {
151
151
  */
152
152
  readonly authorized: boolean;
153
153
 
154
+ /**
155
+ * Is the app ready
156
+ */
157
+ readonly isReady: boolean;
158
+
154
159
  /**
155
160
  * Application name
156
161
  */
157
162
  readonly name: string;
158
163
 
159
164
  /**
160
- * Access token
165
+ * Pending actions
161
166
  */
162
- accessToken?: string;
167
+ readonly pendings: (() => any)[];
163
168
 
164
169
  /**
165
170
  * IP data
package/src/erp/OrgApi.ts CHANGED
@@ -8,6 +8,7 @@ import { IdResultPayload } from './dto/ResultPayload';
8
8
  import { EntityApi } from './EntityApi';
9
9
  import { OrgListRQ } from './rq/OrgListRQ';
10
10
  import { OrgQueryRQ } from './rq/OrgQueryRQ';
11
+ import { SendActionMessageRQ } from './rq/SendActionMessageRQ';
11
12
 
12
13
  const cachedOrgs: { [P: number]: OrgViewDto | undefined | null } = {};
13
14
 
@@ -81,6 +82,23 @@ export class OrgApi extends EntityApi {
81
82
  return data;
82
83
  }
83
84
 
85
+ /**
86
+ * Send action message
87
+ * @param rq Request data
88
+ * @param payload Payload
89
+ * @returns Result
90
+ */
91
+ sendActionMessage(rq: SendActionMessageRQ, payload?: IApiPayload<void>) {
92
+ const appId =
93
+ 'serviceId' in this.app.settings ? this.app.settings.serviceId : 0;
94
+ payload ??= { showLoading: false };
95
+ return this.api.post(
96
+ 'System/SendActionMessage',
97
+ { ...rq, appId },
98
+ payload
99
+ );
100
+ }
101
+
84
102
  /**
85
103
  * Switch organization
86
104
  * @param id Organization id
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Send action message request data
3
+ * 发送操作信息请求数据
4
+ */
5
+ export type SendActionMessageRQ = {
6
+ /**
7
+ * Kind
8
+ * 类型
9
+ */
10
+ kind: string;
11
+
12
+ /**
13
+ * Title
14
+ * 标题
15
+ */
16
+ title: string;
17
+
18
+ /**
19
+ * Related id
20
+ * 相关编号
21
+ */
22
+ relatedId?: number;
23
+
24
+ /**
25
+ * More data
26
+ * 更多数据
27
+ */
28
+ data?: Record<string, unknown>;
29
+ };
package/src/index.ts CHANGED
@@ -64,6 +64,7 @@ export * from './erp/rq/QueryRQ';
64
64
  export * from './erp/rq/RefreshTokenRQ';
65
65
  export * from './erp/rq/RegionsRQ';
66
66
  export * from './erp/rq/ResetPasswordRQ';
67
+ export * from './erp/rq/SendActionMessageRQ';
67
68
  export * from './erp/rq/TiplistRQ';
68
69
  export * from './erp/rq/UpdateStatusRQ';
69
70