@etsoo/appscript 1.1.52 → 1.1.53

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.
@@ -178,6 +178,11 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
178
178
  * @param apiUrl Signout API URL
179
179
  */
180
180
  signout(apiUrl?: string): Promise<void>;
181
+ /**
182
+ * Switch organization
183
+ * @param apiOrOrg API URL or organization id
184
+ */
185
+ switchOrg(apiOrOrg: string | number): Promise<boolean | undefined>;
181
186
  /**
182
187
  * Go to the login page
183
188
  */
@@ -426,6 +431,11 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
426
431
  * @param apiUrl Signout API URL
427
432
  */
428
433
  signout(apiUrl?: string): Promise<void>;
434
+ /**
435
+ * Switch organization
436
+ * @param apiOrOrg API URL or organization id
437
+ */
438
+ switchOrg(apiOrOrg: string | number): Promise<boolean | undefined>;
429
439
  /**
430
440
  * Go to the login page
431
441
  */
@@ -424,6 +424,19 @@ class CoreApp {
424
424
  // Go to login page
425
425
  this.toLoginPage();
426
426
  }
427
+ /**
428
+ * Switch organization
429
+ * @param apiOrOrg API URL or organization id
430
+ */
431
+ async switchOrg(apiOrOrg) {
432
+ const api = typeof apiOrOrg === 'number'
433
+ ? `Organization/Switch/${apiOrOrg}`
434
+ : apiOrOrg;
435
+ const result = await this.api.put(api);
436
+ if (result)
437
+ return await this.refreshToken();
438
+ return result;
439
+ }
427
440
  /**
428
441
  * Go to the login page
429
442
  */
@@ -178,6 +178,11 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
178
178
  * @param apiUrl Signout API URL
179
179
  */
180
180
  signout(apiUrl?: string): Promise<void>;
181
+ /**
182
+ * Switch organization
183
+ * @param apiOrOrg API URL or organization id
184
+ */
185
+ switchOrg(apiOrOrg: string | number): Promise<boolean | undefined>;
181
186
  /**
182
187
  * Go to the login page
183
188
  */
@@ -426,6 +431,11 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
426
431
  * @param apiUrl Signout API URL
427
432
  */
428
433
  signout(apiUrl?: string): Promise<void>;
434
+ /**
435
+ * Switch organization
436
+ * @param apiOrOrg API URL or organization id
437
+ */
438
+ switchOrg(apiOrOrg: string | number): Promise<boolean | undefined>;
429
439
  /**
430
440
  * Go to the login page
431
441
  */
@@ -421,6 +421,19 @@ export class CoreApp {
421
421
  // Go to login page
422
422
  this.toLoginPage();
423
423
  }
424
+ /**
425
+ * Switch organization
426
+ * @param apiOrOrg API URL or organization id
427
+ */
428
+ async switchOrg(apiOrOrg) {
429
+ const api = typeof apiOrOrg === 'number'
430
+ ? `Organization/Switch/${apiOrOrg}`
431
+ : apiOrOrg;
432
+ const result = await this.api.put(api);
433
+ if (result)
434
+ return await this.refreshToken();
435
+ return result;
436
+ }
424
437
  /**
425
438
  * Go to the login page
426
439
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.1.52",
3
+ "version": "1.1.53",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -240,6 +240,12 @@ export interface ICoreApp<
240
240
  */
241
241
  signout(apiUrl?: string): Promise<void>;
242
242
 
243
+ /**
244
+ * Switch organization
245
+ * @param apiOrOrg API URL or organization id
246
+ */
247
+ switchOrg(apiOrOrg: string | number): Promise<boolean | undefined>;
248
+
243
249
  /**
244
250
  * Go to the login page
245
251
  */
@@ -847,6 +853,20 @@ export abstract class CoreApp<
847
853
  this.toLoginPage();
848
854
  }
849
855
 
856
+ /**
857
+ * Switch organization
858
+ * @param apiOrOrg API URL or organization id
859
+ */
860
+ async switchOrg(apiOrOrg: string | number) {
861
+ const api =
862
+ typeof apiOrOrg === 'number'
863
+ ? `Organization/Switch/${apiOrOrg}`
864
+ : apiOrOrg;
865
+ const result = await this.api.put<boolean>(api);
866
+ if (result) return await this.refreshToken();
867
+ return result;
868
+ }
869
+
850
870
  /**
851
871
  * Go to the login page
852
872
  */