// Copyright Abridged, Inc. 2023,2024. All Rights Reserved. // Node module: @collabland/sdk // This file is licensed under the MIT License. // License text available at https://opensource.org/license/mit/ import {inject, Provider} from '@loopback/core'; import {getService, RestDataSource} from '../datasources/index.js'; import {UserAuthorizationScopes} from '../models/user-authorization-scopes.model.js'; import {UserAuthorization} from '../models/user-authorization.model.js'; /** * The service interface is generated from OpenAPI spec with operations tagged * by UserAuthorizationController. */ export interface UserAuthorizationService { /** * @param slug * @param _requestBody * @returns OK */ createUserAuthorization( slug: string, _requestBody: UserAuthorizationScopes, ): Promise; /** * @param clientId * @returns OK */ getUserAuthorizationByClientId(clientId: string): Promise; /** * @param clientId */ deleteUserAuthorization(clientId: string): Promise; /** * @returns Result set of UserAuthorization model instances */ getUserAuthorizations(): Promise<{ paginationToken?: string; items?: UserAuthorization[]; }>; } export class UserAuthorizationServiceProvider implements Provider { constructor( // rest must match the name property in the datasource json file @inject('datasources.rest') protected dataSource: RestDataSource = new RestDataSource(), ) {} async value(): Promise { const service = await getService<{ apis: {UserAuthorizationController: UserAuthorizationService}; }>(this.dataSource); return service.apis['UserAuthorizationController']; } }