@etsoo/appscript 1.5.83 → 1.5.85

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.
@@ -165,7 +165,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
165
165
  /**
166
166
  * Get persisted fields
167
167
  */
168
- protected get persistedFields(): string[];
168
+ protected readonly persistedFields: string[];
169
169
  /**
170
170
  * Protected constructor
171
171
  * @param settings Settings
@@ -598,7 +598,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
598
598
  * @param props Props
599
599
  * @param callback Callback
600
600
  */
601
- refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
601
+ refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult | [U, string]) => boolean | void | Promise<boolean>): Promise<void>;
602
602
  /**
603
603
  * Setup callback
604
604
  */
@@ -133,17 +133,6 @@ class CoreApp {
133
133
  set isTryingLogin(value) {
134
134
  this._isTryingLogin = value;
135
135
  }
136
- /**
137
- * Get persisted fields
138
- */
139
- get persistedFields() {
140
- return [
141
- this.fields.deviceId,
142
- this.fields.devicePassphrase,
143
- this.fields.serversideDeviceId,
144
- this.fields.keepLogin
145
- ];
146
- }
147
136
  /**
148
137
  * Protected constructor
149
138
  * @param settings Settings
@@ -219,6 +208,13 @@ class CoreApp {
219
208
  this.debug = debug;
220
209
  // Fields, attach with the name identifier
221
210
  this.fields = IApp_1.appFields.reduce((a, v) => ({ ...a, [v]: "smarterp-" + v + "-" + name }), {});
211
+ // Persisted fields
212
+ this.persistedFields = [
213
+ this.fields.deviceId,
214
+ this.fields.devicePassphrase,
215
+ this.fields.serversideDeviceId,
216
+ this.fields.keepLogin
217
+ ];
222
218
  // Device id
223
219
  this._deviceId = storage.getData(this.fields.deviceId, "");
224
220
  // Embedded
@@ -1424,10 +1420,16 @@ class CoreApp {
1424
1420
  };
1425
1421
  }
1426
1422
  else {
1423
+ // Callback first
1424
+ if (callback && (await callback([result.data, token])) === false) {
1425
+ return;
1426
+ }
1427
1427
  // User login
1428
1428
  this.userLogin(result.data, token);
1429
- if (callback)
1430
- callback(true);
1429
+ // Callback after
1430
+ if (callback) {
1431
+ await callback(true);
1432
+ }
1431
1433
  // Exit
1432
1434
  return;
1433
1435
  }
@@ -552,7 +552,7 @@ export interface IApp {
552
552
  * @param callback Callback
553
553
  * @param api API
554
554
  */
555
- refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
555
+ refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult | [IUser, string]) => boolean | void): Promise<void>;
556
556
  /**
557
557
  * Setup Api error handler
558
558
  * @param api Api
@@ -165,7 +165,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
165
165
  /**
166
166
  * Get persisted fields
167
167
  */
168
- protected get persistedFields(): string[];
168
+ protected readonly persistedFields: string[];
169
169
  /**
170
170
  * Protected constructor
171
171
  * @param settings Settings
@@ -598,7 +598,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
598
598
  * @param props Props
599
599
  * @param callback Callback
600
600
  */
601
- refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
601
+ refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult | [U, string]) => boolean | void | Promise<boolean>): Promise<void>;
602
602
  /**
603
603
  * Setup callback
604
604
  */
@@ -130,17 +130,6 @@ export class CoreApp {
130
130
  set isTryingLogin(value) {
131
131
  this._isTryingLogin = value;
132
132
  }
133
- /**
134
- * Get persisted fields
135
- */
136
- get persistedFields() {
137
- return [
138
- this.fields.deviceId,
139
- this.fields.devicePassphrase,
140
- this.fields.serversideDeviceId,
141
- this.fields.keepLogin
142
- ];
143
- }
144
133
  /**
145
134
  * Protected constructor
146
135
  * @param settings Settings
@@ -216,6 +205,13 @@ export class CoreApp {
216
205
  this.debug = debug;
217
206
  // Fields, attach with the name identifier
218
207
  this.fields = appFields.reduce((a, v) => ({ ...a, [v]: "smarterp-" + v + "-" + name }), {});
208
+ // Persisted fields
209
+ this.persistedFields = [
210
+ this.fields.deviceId,
211
+ this.fields.devicePassphrase,
212
+ this.fields.serversideDeviceId,
213
+ this.fields.keepLogin
214
+ ];
219
215
  // Device id
220
216
  this._deviceId = storage.getData(this.fields.deviceId, "");
221
217
  // Embedded
@@ -1421,10 +1417,16 @@ export class CoreApp {
1421
1417
  };
1422
1418
  }
1423
1419
  else {
1420
+ // Callback first
1421
+ if (callback && (await callback([result.data, token])) === false) {
1422
+ return;
1423
+ }
1424
1424
  // User login
1425
1425
  this.userLogin(result.data, token);
1426
- if (callback)
1427
- callback(true);
1426
+ // Callback after
1427
+ if (callback) {
1428
+ await callback(true);
1429
+ }
1428
1430
  // Exit
1429
1431
  return;
1430
1432
  }
@@ -552,7 +552,7 @@ export interface IApp {
552
552
  * @param callback Callback
553
553
  * @param api API
554
554
  */
555
- refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
555
+ refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult | [IUser, string]) => boolean | void): Promise<void>;
556
556
  /**
557
557
  * Setup Api error handler
558
558
  * @param api Api
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.83",
3
+ "version": "1.5.85",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -317,14 +317,7 @@ export abstract class CoreApp<
317
317
  /**
318
318
  * Get persisted fields
319
319
  */
320
- protected get persistedFields() {
321
- return [
322
- this.fields.deviceId,
323
- this.fields.devicePassphrase,
324
- this.fields.serversideDeviceId,
325
- this.fields.keepLogin
326
- ];
327
- }
320
+ protected readonly persistedFields: string[];
328
321
 
329
322
  /**
330
323
  * Protected constructor
@@ -400,6 +393,14 @@ export abstract class CoreApp<
400
393
  {} as any
401
394
  );
402
395
 
396
+ // Persisted fields
397
+ this.persistedFields = [
398
+ this.fields.deviceId,
399
+ this.fields.devicePassphrase,
400
+ this.fields.serversideDeviceId,
401
+ this.fields.keepLogin
402
+ ];
403
+
403
404
  // Device id
404
405
  this._deviceId = storage.getData(this.fields.deviceId, "");
405
406
 
@@ -1907,7 +1908,9 @@ export abstract class CoreApp<
1907
1908
  */
1908
1909
  async refreshToken(
1909
1910
  props?: RefreshTokenProps,
1910
- callback?: (result?: boolean | IActionResult) => boolean | void
1911
+ callback?: (
1912
+ result?: boolean | IActionResult | [U, string]
1913
+ ) => boolean | void | Promise<boolean>
1911
1914
  ) {
1912
1915
  // Check props
1913
1916
  props ??= {};
@@ -1935,10 +1938,18 @@ export abstract class CoreApp<
1935
1938
  title: this.get("noData")
1936
1939
  };
1937
1940
  } else {
1941
+ // Callback first
1942
+ if (callback && (await callback([result.data, token])) === false) {
1943
+ return;
1944
+ }
1945
+
1938
1946
  // User login
1939
1947
  this.userLogin(result.data, token);
1940
1948
 
1941
- if (callback) callback(true);
1949
+ // Callback after
1950
+ if (callback) {
1951
+ await callback(true);
1952
+ }
1942
1953
 
1943
1954
  // Exit
1944
1955
  return;
package/src/app/IApp.ts CHANGED
@@ -734,7 +734,9 @@ export interface IApp {
734
734
  */
735
735
  refreshToken(
736
736
  props?: RefreshTokenProps,
737
- callback?: (result?: boolean | IActionResult) => boolean | void
737
+ callback?: (
738
+ result?: boolean | IActionResult | [IUser, string]
739
+ ) => boolean | void
738
740
  ): Promise<void>;
739
741
 
740
742
  /**