@api-client/core 0.3.8 → 0.3.11
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/build/browser.d.ts +4 -1
- package/build/browser.js +2 -3
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +5 -2
- package/build/index.js +2 -3
- package/build/index.js.map +1 -1
- package/build/src/models/Application.d.ts +19 -0
- package/build/src/models/Application.js +2 -0
- package/build/src/models/Application.js.map +1 -0
- package/build/src/models/HttpHistory.d.ts +96 -0
- package/build/src/models/HttpHistory.js +162 -0
- package/build/src/models/HttpHistory.js.map +1 -0
- package/build/src/models/HttpProject.js +2 -2
- package/build/src/models/HttpProject.js.map +1 -1
- package/build/src/models/ProjectFolder.js +2 -2
- package/build/src/models/ProjectFolder.js.map +1 -1
- package/build/src/models/User.d.ts +25 -9
- package/build/src/models/Workspace.js +2 -2
- package/build/src/models/Workspace.js.map +1 -1
- package/build/src/runtime/store/StoreSdk.d.ts +12 -0
- package/build/src/runtime/store/StoreSdk.js +57 -0
- package/build/src/runtime/store/StoreSdk.js.map +1 -1
- package/package.json +1 -1
- package/src/models/Application.ts +19 -0
- package/src/models/HttpHistory.ts +197 -0
- package/src/models/HttpProject.ts +2 -2
- package/src/models/ProjectFolder.ts +2 -2
- package/src/models/User.ts +26 -9
- package/src/models/Workspace.ts +2 -2
- package/src/runtime/store/StoreSdk.ts +57 -0
package/src/models/Workspace.ts
CHANGED
|
@@ -144,7 +144,7 @@ export class Workspace {
|
|
|
144
144
|
this.info = new Thing({ kind: ThingKind, name: '' });
|
|
145
145
|
}
|
|
146
146
|
if (Array.isArray(users)) {
|
|
147
|
-
this.users = users;
|
|
147
|
+
this.users = [...users];
|
|
148
148
|
} else {
|
|
149
149
|
this.users = [];
|
|
150
150
|
}
|
|
@@ -175,7 +175,7 @@ export class Workspace {
|
|
|
175
175
|
owner,
|
|
176
176
|
};
|
|
177
177
|
if (Array.isArray(users) && users.length) {
|
|
178
|
-
result.users = users;
|
|
178
|
+
result.users = [...users];
|
|
179
179
|
}
|
|
180
180
|
return result;
|
|
181
181
|
}
|
|
@@ -474,6 +474,36 @@ class SpacesSdk extends SdkBase {
|
|
|
474
474
|
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Lists uses having access to the user space.
|
|
480
|
+
*
|
|
481
|
+
* @param key The user space key
|
|
482
|
+
*/
|
|
483
|
+
async listUsers(key: string): Promise<IListResponse> {
|
|
484
|
+
const { token } = this.sdk;
|
|
485
|
+
const url = this.sdk.getUrl(`/spaces/${key}/users`);
|
|
486
|
+
const result = await this.sdk.http.get(url.toString(), { token });
|
|
487
|
+
this.inspectCommonStatusCodes(result.status);
|
|
488
|
+
const E_PREFIX = 'Unable to list users in the space. ';
|
|
489
|
+
if (result.status !== 200) {
|
|
490
|
+
this.logInvalidResponse(result);
|
|
491
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
492
|
+
}
|
|
493
|
+
if (!result.body) {
|
|
494
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
495
|
+
}
|
|
496
|
+
let data: IListResponse;
|
|
497
|
+
try {
|
|
498
|
+
data = JSON.parse(result.body);
|
|
499
|
+
} catch (e) {
|
|
500
|
+
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
501
|
+
}
|
|
502
|
+
if (!Array.isArray(data.data)) {
|
|
503
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
504
|
+
}
|
|
505
|
+
return data;
|
|
506
|
+
}
|
|
477
507
|
}
|
|
478
508
|
|
|
479
509
|
class HttpClient extends SdkBase {
|
|
@@ -835,4 +865,31 @@ class UsersSdk extends SdkBase {
|
|
|
835
865
|
}
|
|
836
866
|
return data;
|
|
837
867
|
}
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* Reads a user information from the store.
|
|
871
|
+
* @param key The user key.
|
|
872
|
+
* @returns The user object
|
|
873
|
+
*/
|
|
874
|
+
async read(key: string): Promise<IUser> {
|
|
875
|
+
const { token } = this.sdk;
|
|
876
|
+
const url = this.sdk.getUrl(`/users/${key}`);
|
|
877
|
+
const result = await this.sdk.http.get(url.toString(), { token });
|
|
878
|
+
this.inspectCommonStatusCodes(result.status);
|
|
879
|
+
const E_PREFIX = 'Unable to read the user info. ';
|
|
880
|
+
if (result.status !== 200) {
|
|
881
|
+
this.logInvalidResponse(result);
|
|
882
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
883
|
+
}
|
|
884
|
+
if (!result.body) {
|
|
885
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
886
|
+
}
|
|
887
|
+
let data: IUser;
|
|
888
|
+
try {
|
|
889
|
+
data = JSON.parse(result.body);
|
|
890
|
+
} catch (e) {
|
|
891
|
+
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
892
|
+
}
|
|
893
|
+
return data;
|
|
894
|
+
}
|
|
838
895
|
}
|