@ysgroup/core 0.1.14 → 0.1.15

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/rest.ts +26 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ysgroup/core",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
package/src/rest.ts CHANGED
@@ -229,6 +229,29 @@ export class YsRest {
229
229
  portalApps() {
230
230
  return this.request<Record<string, unknown>[]>("GET", "/api/portal/apps");
231
231
  }
232
+ uploadAppLogo(appId: string, file: File) {
233
+ return this.upload<{
234
+ file_id: string;
235
+ usage: string;
236
+ size: number;
237
+ has_logo: boolean;
238
+ }>(`/api/apps/${appId}/logo`, file);
239
+ }
240
+ async downloadAppLogo(appId: string) {
241
+ if (this.rpcCall) {
242
+ const result = await this.request<{
243
+ base64: string;
244
+ content_type: string;
245
+ }>("GET", `/api/apps/${appId}/logo`);
246
+ return base64ToBlob(result.base64, result.content_type);
247
+ }
248
+ return fetch(`${this.baseUrl}/api/apps/${appId}/logo`, {
249
+ headers: { Authorization: `Bearer ${this.getToken()}` },
250
+ }).then(async (resp) => {
251
+ if (!resp.ok) throw new YsRestError(resp.status, await resp.text());
252
+ return resp.blob();
253
+ });
254
+ }
232
255
  async createUser(body: Record<string, unknown>) {
233
256
  const password =
234
257
  typeof body.password === "string"
@@ -402,11 +425,13 @@ function base64ToBlob(value: string, contentType: string): Blob {
402
425
  }
403
426
 
404
427
  export interface TopologyNode {
428
+ _id?: string;
405
429
  name: string;
406
430
  title: string;
407
431
  kind: "service" | "link";
408
432
  status: string;
409
- logo_url?: string;
433
+ has_logo?: boolean;
434
+ logo?: string;
410
435
  online: boolean;
411
436
  last_heartbeat_at: number;
412
437
  authorization_version: number;