@veritree/services 2.28.0 → 2.29.1
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.
- package/package.json +1 -1
- package/src/helpers/api.js +18 -16
package/package.json
CHANGED
package/src/helpers/api.js
CHANGED
|
@@ -217,29 +217,33 @@ export default class Api {
|
|
|
217
217
|
getUrlParams(args) {
|
|
218
218
|
this.setOrg();
|
|
219
219
|
let isOrgLess = false;
|
|
220
|
-
let
|
|
220
|
+
let isOrgIdAs = false;
|
|
221
|
+
let isOrgTypeAs = false;
|
|
221
222
|
let orgIdParam = "";
|
|
222
223
|
let orgTypeParam = "";
|
|
224
|
+
let argsClone = structuredClone(args); // avoids mutating object
|
|
223
225
|
|
|
224
226
|
// while most of endpoints require an org id and type, some endpoints do not
|
|
225
|
-
if (
|
|
226
|
-
isOrgLess = Object.hasOwn(
|
|
227
|
-
|
|
228
|
-
|
|
227
|
+
if (argsClone) {
|
|
228
|
+
isOrgLess = Object.hasOwn(argsClone, "orgless");
|
|
229
|
+
isOrgIdAs = Object.hasOwn(argsClone, "org_id_as");
|
|
230
|
+
isOrgTypeAs = Object.hasOwn(argsClone, "org_type_as");
|
|
229
231
|
}
|
|
230
232
|
|
|
231
233
|
// a super admin user can create/edit data from other orgs
|
|
232
234
|
// and for that, we can't use the org id and type in
|
|
233
235
|
// the session.
|
|
234
|
-
if (
|
|
235
|
-
|
|
236
|
-
|
|
236
|
+
if (isOrgIdAs) {
|
|
237
|
+
this.orgId = argsClone.org_id_as;
|
|
238
|
+
delete argsClone.org_id_as;
|
|
239
|
+
}
|
|
237
240
|
|
|
238
|
-
|
|
239
|
-
|
|
241
|
+
if (isOrgTypeAs) {
|
|
242
|
+
this.orgType = argsClone.org_type_as;
|
|
243
|
+
delete argsClone.org_type_as;
|
|
240
244
|
}
|
|
241
245
|
|
|
242
|
-
if (!isOrgLess
|
|
246
|
+
if (!isOrgLess) {
|
|
243
247
|
if (this.orgId) {
|
|
244
248
|
orgIdParam = `org_id=${this.orgId}`;
|
|
245
249
|
}
|
|
@@ -247,13 +251,11 @@ export default class Api {
|
|
|
247
251
|
if (this.orgType) {
|
|
248
252
|
orgTypeParam = `&org_type=${this.orgType}`;
|
|
249
253
|
}
|
|
250
|
-
|
|
251
|
-
if (args && args.orgType) {
|
|
252
|
-
orgTypeParam = `&org_type=${args.orgType}`;
|
|
253
|
-
}
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
return `?${orgIdParam}${orgTypeParam}${createParamsStringFromArgs(
|
|
256
|
+
return `?${orgIdParam}${orgTypeParam}${createParamsStringFromArgs(
|
|
257
|
+
argsClone
|
|
258
|
+
)}`;
|
|
257
259
|
}
|
|
258
260
|
|
|
259
261
|
/**
|