@etsoo/appscript 1.1.83 → 1.1.84

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.
@@ -129,6 +129,18 @@ test('Tests for encrypt / decrypt', () => {
129
129
  expect(plain).toEqual(input);
130
130
  });
131
131
 
132
+ test('Tests for encryptEnhanced / decryptEnhanced', () => {
133
+ // Arrange
134
+ const input = 'Hello, world!';
135
+ const passphrase = 'My password';
136
+
137
+ // Act
138
+ const encrypted = app.encryptEnhanced(input, passphrase);
139
+ console.log(encrypted);
140
+ const plain = app.decryptEnhanced(encrypted, passphrase);
141
+ expect(plain).toEqual(input);
142
+ });
143
+
132
144
  test('Tests for initCallUpdateLocal', () => {
133
145
  // Act
134
146
  const passphrase = app.initCallUpdateLocal(
@@ -2,6 +2,7 @@ import { INotifier, NotificationAlign, NotificationCallProps, NotificationConten
2
2
  import { ApiDataError, IApi, IPData } from '@etsoo/restclient';
3
3
  import { DataTypes, DateUtils } from '@etsoo/shared';
4
4
  import { AddressRegion } from '../address/AddressRegion';
5
+ import { IdLabelDto } from '../dto/IdLabelDto';
5
6
  import { InitCallDto } from '../dto/InitCallDto';
6
7
  import { IActionResult } from '../result/IActionResult';
7
8
  import { InitCallResult, InitCallResultData } from '../result/InitCallResult';
@@ -278,6 +279,13 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
278
279
  * @param apiUrl Signout API URL
279
280
  */
280
281
  signout(apiUrl?: string): Promise<void>;
282
+ /**
283
+ * Get organization list
284
+ * @param items Max items
285
+ * @param serviceId Service id
286
+ * @returns Result
287
+ */
288
+ orgList(items?: number, serviceId?: number): Promise<IdLabelDto[] | undefined>;
281
289
  /**
282
290
  * Switch organization
283
291
  * @param apiOrOrg API URL or organization id
@@ -637,11 +645,18 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
637
645
  * @param apiUrl Signout API URL
638
646
  */
639
647
  signout(apiUrl?: string): Promise<void>;
648
+ /**
649
+ * Get organization list
650
+ * @param items Max items
651
+ * @param serviceId Service id
652
+ * @returns Result
653
+ */
654
+ orgList(items?: number, serviceId?: number): Promise<IdLabelDto<number>[] | undefined>;
640
655
  /**
641
656
  * Switch organization
642
- * @param apiOrOrg API URL or organization id
657
+ * @param id Organization id
643
658
  */
644
- switchOrg(apiOrOrg: string | number): Promise<boolean | undefined>;
659
+ switchOrg(id: number): Promise<boolean | undefined>;
645
660
  /**
646
661
  * Go to the login page
647
662
  */
@@ -723,14 +723,24 @@ class CoreApp {
723
723
  // Go to login page
724
724
  this.toLoginPage();
725
725
  }
726
+ /**
727
+ * Get organization list
728
+ * @param items Max items
729
+ * @param serviceId Service id
730
+ * @returns Result
731
+ */
732
+ async orgList(items, serviceId) {
733
+ return await this.api.post('Organization/List', {
734
+ items,
735
+ serviceId
736
+ }, { defaultValue: [], showLoading: false });
737
+ }
726
738
  /**
727
739
  * Switch organization
728
- * @param apiOrOrg API URL or organization id
740
+ * @param id Organization id
729
741
  */
730
- async switchOrg(apiOrOrg) {
731
- const api = typeof apiOrOrg === 'number'
732
- ? `Organization/Switch/${apiOrOrg}`
733
- : apiOrOrg;
742
+ async switchOrg(id) {
743
+ const api = `Organization/Switch/${id}`;
734
744
  const result = await this.api.put(api);
735
745
  if (result)
736
746
  return await this.refreshToken();
@@ -2,6 +2,7 @@ import { INotifier, NotificationAlign, NotificationCallProps, NotificationConten
2
2
  import { ApiDataError, IApi, IPData } from '@etsoo/restclient';
3
3
  import { DataTypes, DateUtils } from '@etsoo/shared';
4
4
  import { AddressRegion } from '../address/AddressRegion';
5
+ import { IdLabelDto } from '../dto/IdLabelDto';
5
6
  import { InitCallDto } from '../dto/InitCallDto';
6
7
  import { IActionResult } from '../result/IActionResult';
7
8
  import { InitCallResult, InitCallResultData } from '../result/InitCallResult';
@@ -278,6 +279,13 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
278
279
  * @param apiUrl Signout API URL
279
280
  */
280
281
  signout(apiUrl?: string): Promise<void>;
282
+ /**
283
+ * Get organization list
284
+ * @param items Max items
285
+ * @param serviceId Service id
286
+ * @returns Result
287
+ */
288
+ orgList(items?: number, serviceId?: number): Promise<IdLabelDto[] | undefined>;
281
289
  /**
282
290
  * Switch organization
283
291
  * @param apiOrOrg API URL or organization id
@@ -637,11 +645,18 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
637
645
  * @param apiUrl Signout API URL
638
646
  */
639
647
  signout(apiUrl?: string): Promise<void>;
648
+ /**
649
+ * Get organization list
650
+ * @param items Max items
651
+ * @param serviceId Service id
652
+ * @returns Result
653
+ */
654
+ orgList(items?: number, serviceId?: number): Promise<IdLabelDto<number>[] | undefined>;
640
655
  /**
641
656
  * Switch organization
642
- * @param apiOrOrg API URL or organization id
657
+ * @param id Organization id
643
658
  */
644
- switchOrg(apiOrOrg: string | number): Promise<boolean | undefined>;
659
+ switchOrg(id: number): Promise<boolean | undefined>;
645
660
  /**
646
661
  * Go to the login page
647
662
  */
@@ -720,14 +720,24 @@ export class CoreApp {
720
720
  // Go to login page
721
721
  this.toLoginPage();
722
722
  }
723
+ /**
724
+ * Get organization list
725
+ * @param items Max items
726
+ * @param serviceId Service id
727
+ * @returns Result
728
+ */
729
+ async orgList(items, serviceId) {
730
+ return await this.api.post('Organization/List', {
731
+ items,
732
+ serviceId
733
+ }, { defaultValue: [], showLoading: false });
734
+ }
723
735
  /**
724
736
  * Switch organization
725
- * @param apiOrOrg API URL or organization id
737
+ * @param id Organization id
726
738
  */
727
- async switchOrg(apiOrOrg) {
728
- const api = typeof apiOrOrg === 'number'
729
- ? `Organization/Switch/${apiOrOrg}`
730
- : apiOrOrg;
739
+ async switchOrg(id) {
740
+ const api = `Organization/Switch/${id}`;
731
741
  const result = await this.api.put(api);
732
742
  if (result)
733
743
  return await this.refreshToken();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.1.83",
3
+ "version": "1.1.84",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -28,6 +28,7 @@ import {
28
28
  } from 'crypto-js';
29
29
  import { AddressRegion } from '../address/AddressRegion';
30
30
  import { AddressUtils } from '../address/AddressUtils';
31
+ import { IdLabelDto } from '../dto/IdLabelDto';
31
32
  import { InitCallDto } from '../dto/InitCallDto';
32
33
  import { ActionResultError } from '../result/ActionResultError';
33
34
  import { IActionResult } from '../result/IActionResult';
@@ -382,6 +383,17 @@ export interface ICoreApp<
382
383
  */
383
384
  signout(apiUrl?: string): Promise<void>;
384
385
 
386
+ /**
387
+ * Get organization list
388
+ * @param items Max items
389
+ * @param serviceId Service id
390
+ * @returns Result
391
+ */
392
+ orgList(
393
+ items?: number,
394
+ serviceId?: number
395
+ ): Promise<IdLabelDto[] | undefined>;
396
+
385
397
  /**
386
398
  * Switch organization
387
399
  * @param apiOrOrg API URL or organization id
@@ -1350,15 +1362,29 @@ export abstract class CoreApp<
1350
1362
  this.toLoginPage();
1351
1363
  }
1352
1364
 
1365
+ /**
1366
+ * Get organization list
1367
+ * @param items Max items
1368
+ * @param serviceId Service id
1369
+ * @returns Result
1370
+ */
1371
+ async orgList(items?: number, serviceId?: number) {
1372
+ return await this.api.post<IdLabelDto[]>(
1373
+ 'Organization/List',
1374
+ {
1375
+ items,
1376
+ serviceId
1377
+ },
1378
+ { defaultValue: [], showLoading: false }
1379
+ );
1380
+ }
1381
+
1353
1382
  /**
1354
1383
  * Switch organization
1355
- * @param apiOrOrg API URL or organization id
1384
+ * @param id Organization id
1356
1385
  */
1357
- async switchOrg(apiOrOrg: string | number) {
1358
- const api =
1359
- typeof apiOrOrg === 'number'
1360
- ? `Organization/Switch/${apiOrOrg}`
1361
- : apiOrOrg;
1386
+ async switchOrg(id: number) {
1387
+ const api = `Organization/Switch/${id}`;
1362
1388
  const result = await this.api.put<boolean>(api);
1363
1389
  if (result) return await this.refreshToken();
1364
1390
  return result;