import { Service } from "../decorators" ; import { Metadata } from "./common" ; import { EventMetadata } from "./event" ; import { BindingMetadata , HttpMetadata } from "./http" ; import { RemoteMetadata } from "./remote" ; import { PermissionMetadata } from "./security" ; export interface ServiceMetadata extends Metadata { service : string ; permissions : Record < string , PermissionMetadata > ; remoteMetadata : Record < string , RemoteMetadata > ; httpMetadata : Record < string , HttpMetadata > ; eventMetadata : Record < string , EventMetadata [ ] > ; bindingMetadata : Record < string , BindingMetadata > ; } export namespace ServiceMetadata { export function has ( target ) { let meta = get ( target , false ) ; return ! ! ( meta && meta . service ) ; } export function get ( target , init ? ) { let meta = Metadata . get ( target , init ) as ServiceMetadata ; if ( init !== false ) { meta . permissions = meta . permissions || { } ; meta . remoteMetadata = meta . remoteMetadata || { } ; meta . httpMetadata = meta . httpMetadata || { } ; meta . eventMetadata = meta . eventMetadata || { } ; meta . bindingMetadata = meta . bindingMetadata || { } ; } return meta ; } export function service ( target ) { return get ( target ) . service ; } export function remoteMetadata ( target ) { return get ( target ) . remoteMetadata || { } ; } export function httpMetadata ( target ) { return get ( target ) . httpMetadata || { } ; } export function eventMetadata ( target ) { return get ( target ) . eventMetadata || { } ; } export function bindingMetadata ( target ) { return get ( target ) . bindingMetadata || { } ; } export function permissions ( target ) { return get ( target ) . permissions || { } ; } }