@etsoo/appscript 1.5.79 → 1.5.80

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.
@@ -93,7 +93,8 @@ export declare class AuthApi extends BaseApi {
93
93
  /**
94
94
  * Switch organization
95
95
  * @param rq Request data
96
+ * @param tokenKey Refresh token key
96
97
  * @param payload Payload
97
98
  */
98
- switchOrg(rq: SwitchOrgRQ, payload?: ResultPayload): Promise<IActionResult<{}> | undefined>;
99
+ switchOrg<T extends IUser>(rq: SwitchOrgRQ, payload?: IApiPayload<IActionResult<T>>, tokenKey?: string): Promise<(string | IActionResult<T> | null | undefined)[]>;
99
100
  }
@@ -163,10 +163,21 @@ class AuthApi extends BaseApi_1.BaseApi {
163
163
  /**
164
164
  * Switch organization
165
165
  * @param rq Request data
166
+ * @param tokenKey Refresh token key
166
167
  * @param payload Payload
167
168
  */
168
- switchOrg(rq, payload) {
169
- return this.app.api.put("Auth/SwitchOrg", rq, payload);
169
+ async switchOrg(rq, payload, tokenKey) {
170
+ // Default values
171
+ payload ?? (payload = {});
172
+ tokenKey ?? (tokenKey = AuthApi.HeaderTokenField);
173
+ // Call the API
174
+ const result = await this.api.post("Auth/SwitchOrg", rq, payload);
175
+ // Get the refresh token
176
+ const refreshToken = result?.ok
177
+ ? this.app.getResponseToken(payload.response, tokenKey)
178
+ : null;
179
+ // Return the result
180
+ return [result, refreshToken];
170
181
  }
171
182
  }
172
183
  exports.AuthApi = AuthApi;
@@ -9,5 +9,5 @@ export type SwitchOrgRQ = {
9
9
  /**
10
10
  * From organization id
11
11
  */
12
- fromOrganizationId: number;
12
+ fromOrganizationId?: number;
13
13
  };
@@ -93,7 +93,8 @@ export declare class AuthApi extends BaseApi {
93
93
  /**
94
94
  * Switch organization
95
95
  * @param rq Request data
96
+ * @param tokenKey Refresh token key
96
97
  * @param payload Payload
97
98
  */
98
- switchOrg(rq: SwitchOrgRQ, payload?: ResultPayload): Promise<IActionResult<{}> | undefined>;
99
+ switchOrg<T extends IUser>(rq: SwitchOrgRQ, payload?: IApiPayload<IActionResult<T>>, tokenKey?: string): Promise<(string | IActionResult<T> | null | undefined)[]>;
99
100
  }
@@ -160,10 +160,21 @@ export class AuthApi extends BaseApi {
160
160
  /**
161
161
  * Switch organization
162
162
  * @param rq Request data
163
+ * @param tokenKey Refresh token key
163
164
  * @param payload Payload
164
165
  */
165
- switchOrg(rq, payload) {
166
- return this.app.api.put("Auth/SwitchOrg", rq, payload);
166
+ async switchOrg(rq, payload, tokenKey) {
167
+ // Default values
168
+ payload ?? (payload = {});
169
+ tokenKey ?? (tokenKey = AuthApi.HeaderTokenField);
170
+ // Call the API
171
+ const result = await this.api.post("Auth/SwitchOrg", rq, payload);
172
+ // Get the refresh token
173
+ const refreshToken = result?.ok
174
+ ? this.app.getResponseToken(payload.response, tokenKey)
175
+ : null;
176
+ // Return the result
177
+ return [result, refreshToken];
167
178
  }
168
179
  }
169
180
  /**
@@ -9,5 +9,5 @@ export type SwitchOrgRQ = {
9
9
  /**
10
10
  * From organization id
11
11
  */
12
- fromOrganizationId: number;
12
+ fromOrganizationId?: number;
13
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.79",
3
+ "version": "1.5.80",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -218,9 +218,27 @@ export class AuthApi extends BaseApi {
218
218
  /**
219
219
  * Switch organization
220
220
  * @param rq Request data
221
+ * @param tokenKey Refresh token key
221
222
  * @param payload Payload
222
223
  */
223
- switchOrg(rq: SwitchOrgRQ, payload?: ResultPayload) {
224
- return this.app.api.put("Auth/SwitchOrg", rq, payload);
224
+ async switchOrg<T extends IUser>(
225
+ rq: SwitchOrgRQ,
226
+ payload?: IApiPayload<IActionResult<T>>,
227
+ tokenKey?: string
228
+ ) {
229
+ // Default values
230
+ payload ??= {};
231
+ tokenKey ??= AuthApi.HeaderTokenField;
232
+
233
+ // Call the API
234
+ const result = await this.api.post("Auth/SwitchOrg", rq, payload);
235
+
236
+ // Get the refresh token
237
+ const refreshToken = result?.ok
238
+ ? this.app.getResponseToken(payload.response, tokenKey)
239
+ : null;
240
+
241
+ // Return the result
242
+ return [result, refreshToken];
225
243
  }
226
244
  }
@@ -10,5 +10,5 @@ export type SwitchOrgRQ = {
10
10
  /**
11
11
  * From organization id
12
12
  */
13
- fromOrganizationId: number;
13
+ fromOrganizationId?: number;
14
14
  };