a36c7fe752254775d263345113c7956a015c25e3
[ccsdk/cds.git] / cds-ui / server / src / services / resource-dictionary.service.ts
1 import {getService} from '@loopback/service-proxy';
2 import {inject, Provider} from '@loopback/core';
3 import {ResourceDictionaryDataSource} from '../datasources';
4
5 export interface ResourceDictionaryService {
6   getByName(name: string): Promise<JSON>;
7   getSourceMapping(): Promise<JSON>;
8   getByTags(tags: string): Promise<JSON>;
9   save(resourceDictionary: JSON): Promise<JSON>;
10   searchbyNames(resourceDictionaryList: JSON): Promise<JSON>;
11   getModelType(source: string): Promise<JSON>;
12   getDataTypes(): Promise<JSON>;
13   getResourceDictionaryByType(type: string): Promise<JSON>;
14 }
15
16 export class ResourceDictionaryServiceProvider implements Provider<ResourceDictionaryService> {
17   constructor(
18     // resourceDictionary must match the name property in the datasource json file
19     @inject('datasources.resourceDictionary')
20     protected dataSource: ResourceDictionaryDataSource = new ResourceDictionaryDataSource(),
21   ) {}
22
23   value(): Promise<ResourceDictionaryService> {
24     return getService(this.dataSource);
25   }
26 }