@etsoo/appscript 1.5.20 → 1.5.22

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.
@@ -1,31 +1,32 @@
1
1
  /**
2
- * External settings items
2
+ * External endpoint
3
3
  */
4
- export interface IExternalSettings {
4
+ export type ExternalEndpoint = {
5
5
  /**
6
- * Core system API endpoint
6
+ * API endpoint
7
7
  */
8
8
  readonly endpoint: string;
9
+ /**
10
+ * Web url
11
+ */
12
+ readonly webUrl: string;
13
+ };
14
+ /**
15
+ * External settings items
16
+ */
17
+ export interface IExternalSettings extends ExternalEndpoint {
9
18
  /**
10
19
  * Message hub endpoint
11
20
  */
12
21
  readonly messageHub?: string;
13
22
  /**
14
- * Core system app root url
23
+ * App root url
15
24
  */
16
25
  readonly homepage: string;
17
26
  /**
18
- * Core system web url
19
- */
20
- readonly webUrl: string;
21
- /**
22
- * Service API endpoint
23
- */
24
- readonly serviceEndpoint?: string;
25
- /**
26
- * Service web Url
27
+ * Endpoints to other services
27
28
  */
28
- readonly serviceUrl?: string;
29
+ readonly endpoints?: Record<'core' | 'accounting' | 'crm' | 'calandar' | 'task' | string, ExternalEndpoint>;
29
30
  }
30
31
  /**
31
32
  * External settings namespace
@@ -32,6 +32,9 @@ export var ExternalSettings;
32
32
  if (typeof value === 'string') {
33
33
  settings[key] = value.replace('{hostname}', hostname);
34
34
  }
35
+ else if (typeof value === 'object') {
36
+ format(value, hostname);
37
+ }
35
38
  }
36
39
  return settings;
37
40
  }
@@ -7,6 +7,7 @@ import { IAppSettings } from './AppSettings';
7
7
  import { UserRole } from './UserRole';
8
8
  import { EntityStatus } from '../business/EntityStatus';
9
9
  import { Currency } from '../business/Currency';
10
+ import { ExternalEndpoint } from './ExternalSettings';
10
11
  /**
11
12
  * Detect IP callback interface
12
13
  */
@@ -54,7 +55,7 @@ export interface RefreshTokenProps {
54
55
  /**
55
56
  * App fields
56
57
  */
57
- export declare const appFields: readonly ["headerToken", "serversideDeviceId", "deviceId", "devices", "devicePassphrase"];
58
+ export declare const appFields: readonly ["headerToken", "serversideDeviceId", "deviceId", "devices", "devicePassphrase", "cachedUrl"];
58
59
  /**
59
60
  * Basic type template
60
61
  */
@@ -129,6 +130,10 @@ export interface IApp {
129
130
  * Is debug mode
130
131
  */
131
132
  readonly debug: boolean;
133
+ /**
134
+ * Cached URL
135
+ */
136
+ cachedUrl: string | undefined | null;
132
137
  /**
133
138
  * IP data
134
139
  */
@@ -155,6 +160,12 @@ export interface IApp {
155
160
  * @returns Result
156
161
  */
157
162
  addRootUrl(url: string): string;
163
+ /**
164
+ * Add scheduled task
165
+ * @param task Task, return false to stop
166
+ * @param interval Interval in milliseconds
167
+ */
168
+ addTask(task: () => PromiseLike<void | false>, interval: number): void;
158
169
  /**
159
170
  * Alert result
160
171
  * @param result Result message
@@ -209,6 +220,13 @@ export interface IApp {
209
220
  * Clear device id
210
221
  */
211
222
  clearDeviceId(): void;
223
+ /**
224
+ * Create API client, override to implement custom client creation by name
225
+ * @param name Client name
226
+ * @param item External endpoint item
227
+ * @returns Result
228
+ */
229
+ createApi(name: string, item: ExternalEndpoint, refresh?: (api: IApi, token: string) => Promise<[string, number] | undefined>): IApi;
212
230
  /**
213
231
  * Decrypt message
214
232
  * @param messageEncrypted Encrypted message
@@ -252,6 +270,18 @@ export interface IApp {
252
270
  * @returns Result
253
271
  */
254
272
  encryptEnhanced(message: string, passphrase?: string, iterations?: number): string;
273
+ /**
274
+ * Exchange token data
275
+ * @param api API
276
+ * @param token Core system's refresh token to exchange
277
+ * @returns Result
278
+ */
279
+ exchangeToken(api: IApi, token: string): Promise<void>;
280
+ /**
281
+ * Exchange intergration tokens for all APIs
282
+ * @param token Core system's refresh token to exchange
283
+ */
284
+ exchangeTokenAll(token: string): void;
255
285
  /**
256
286
  * Format date to string
257
287
  * @param input Input date
@@ -508,6 +538,13 @@ export interface IApp {
508
538
  * @param showLoading Show loading bar or not
509
539
  */
510
540
  tryLogin(showLoading?: boolean): Promise<boolean>;
541
+ /**
542
+ * Update API token and expires
543
+ * @param name Api name
544
+ * @param token Refresh token
545
+ * @param seconds Access token expires in seconds
546
+ */
547
+ updateApi(name: string, token: string | undefined, seconds: number): void;
511
548
  /**
512
549
  * User login
513
550
  * @param user User data
@@ -6,5 +6,6 @@ export const appFields = [
6
6
  'serversideDeviceId',
7
7
  'deviceId',
8
8
  'devices',
9
- 'devicePassphrase'
9
+ 'devicePassphrase',
10
+ 'cachedUrl'
10
11
  ];
@@ -51,7 +51,7 @@ export class AuthApi extends BaseApi {
51
51
  const url = await this.getLogInUrl();
52
52
  if (url == null)
53
53
  return;
54
- window.location.replace(url);
54
+ globalThis.location.replace(url);
55
55
  }
56
56
  /**
57
57
  * Reset password
@@ -0,0 +1,21 @@
1
+ /**
2
+ * API refresh token data
3
+ */
4
+ export type ApiRefreshTokenDto = {
5
+ /**
6
+ * Refresh token
7
+ */
8
+ readonly refreshToken: string;
9
+ /**
10
+ * Access token
11
+ */
12
+ readonly accessToken: string;
13
+ /**
14
+ * Token type
15
+ */
16
+ readonly tokenType: string;
17
+ /**
18
+ * Expires in
19
+ */
20
+ readonly expiresIn: number;
21
+ };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.20",
3
+ "version": "1.5.22",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -52,17 +52,17 @@
52
52
  },
53
53
  "homepage": "https://github.com/ETSOO/AppScript#readme",
54
54
  "dependencies": {
55
- "@etsoo/notificationbase": "^1.1.47",
56
- "@etsoo/restclient": "^1.1.8",
57
- "@etsoo/shared": "^1.2.44",
55
+ "@etsoo/notificationbase": "^1.1.48",
56
+ "@etsoo/restclient": "^1.1.10",
57
+ "@etsoo/shared": "^1.2.46",
58
58
  "crypto-js": "^4.2.0"
59
59
  },
60
60
  "devDependencies": {
61
- "@babel/cli": "^7.25.6",
62
- "@babel/core": "^7.25.2",
63
- "@babel/plugin-transform-runtime": "^7.25.4",
64
- "@babel/preset-env": "^7.25.4",
65
- "@babel/runtime-corejs3": "^7.25.6",
61
+ "@babel/cli": "^7.25.7",
62
+ "@babel/core": "^7.25.7",
63
+ "@babel/plugin-transform-runtime": "^7.25.7",
64
+ "@babel/preset-env": "^7.25.7",
65
+ "@babel/runtime-corejs3": "^7.25.7",
66
66
  "@types/crypto-js": "^4.2.2",
67
67
  "@types/jest": "^29.5.13",
68
68
  "jest": "^29.7.0",