mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 16:42:56 +00:00
refactor: update openstapps packages
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Client} from '@openstapps/api/lib/client';
|
||||
import {
|
||||
SCIndexableThings,
|
||||
SCMultiSearchRequest,
|
||||
SCMultiSearchResponse,
|
||||
SCSearchRequest,
|
||||
@@ -148,23 +149,18 @@ export class DataProvider {
|
||||
/**
|
||||
* Provides a savable thing from the local database using the provided UID
|
||||
*/
|
||||
async get(
|
||||
uid: string,
|
||||
scope: DataScope.Local,
|
||||
): Promise<SCSaveableThing<SCThings>>;
|
||||
async get(uid: string, scope: DataScope.Local): Promise<SCSaveableThing>;
|
||||
/**
|
||||
* Provides a thing from the backend
|
||||
*/
|
||||
async get(
|
||||
uid: string,
|
||||
scope: DataScope.Remote,
|
||||
): Promise<SCThings | SCSaveableThing<SCThings>>;
|
||||
): Promise<SCThings | SCSaveableThing>;
|
||||
/**
|
||||
* Provides a thing from both local database and backend
|
||||
*/
|
||||
async get(
|
||||
uid: string,
|
||||
): Promise<Map<DataScope, SCThings | SCSaveableThing<SCThings>>>;
|
||||
async get(uid: string): Promise<Map<DataScope, SCThings | SCSaveableThing>>;
|
||||
|
||||
/**
|
||||
* Provides a thing from the local database only, backend only or both, depending on the scope
|
||||
@@ -176,19 +172,15 @@ export class DataProvider {
|
||||
uid: string,
|
||||
scope?: DataScope,
|
||||
): Promise<
|
||||
| SCThings
|
||||
| SCSaveableThing<SCThings>
|
||||
| Map<DataScope, SCThings | SCSaveableThing<SCThings>>
|
||||
SCThings | SCSaveableThing | Map<DataScope, SCThings | SCSaveableThing>
|
||||
> {
|
||||
if (scope === DataScope.Local) {
|
||||
return this.storageProvider.get<SCSaveableThing<SCThings>>(
|
||||
this.getDataKey(uid),
|
||||
);
|
||||
return this.storageProvider.get<SCSaveableThing>(this.getDataKey(uid));
|
||||
}
|
||||
if (scope === DataScope.Remote) {
|
||||
return this.client.getThing(uid);
|
||||
}
|
||||
const map: Map<DataScope, SCThings | SCSaveableThing<SCThings>> = new Map();
|
||||
const map: Map<DataScope, SCThings | SCSaveableThing> = new Map();
|
||||
map.set(DataScope.Local, await this.get(uid, DataScope.Local));
|
||||
map.set(DataScope.Remote, await this.get(uid, DataScope.Remote));
|
||||
|
||||
@@ -198,10 +190,8 @@ export class DataProvider {
|
||||
/**
|
||||
* Provides all things saved in the local database
|
||||
*/
|
||||
async getAll(): Promise<Map<string, SCSaveableThing<SCThings>>> {
|
||||
return this.storageProvider.search<SCSaveableThing<SCThings>>(
|
||||
this.storagePrefix,
|
||||
);
|
||||
async getAll(): Promise<Map<string, SCSaveableThing>> {
|
||||
return this.storageProvider.search<SCSaveableThing>(this.storagePrefix);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,10 +238,10 @@ export class DataProvider {
|
||||
* @param [type] Savable type (e.g. 'favorite'); if nothing is provided then type of the thing is used
|
||||
*/
|
||||
async put(
|
||||
item: SCThings,
|
||||
item: SCIndexableThings,
|
||||
type?: SCThingType,
|
||||
): Promise<SCSaveableThing<SCThings>> {
|
||||
const savableItem: SCSaveableThing<SCThings> = {
|
||||
): Promise<SCSaveableThing> {
|
||||
const savableItem: SCSaveableThing = {
|
||||
data: item,
|
||||
name: item.name,
|
||||
origin: {
|
||||
@@ -263,7 +253,7 @@ export class DataProvider {
|
||||
};
|
||||
|
||||
// @TODO: Implementation for saving item into the backend (user's account)
|
||||
return this.storageProvider.put<SCSaveableThing<SCThings>>(
|
||||
return this.storageProvider.put<SCSaveableThing>(
|
||||
this.getDataKey(item.uid),
|
||||
savableItem,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user