nope/lib/templates/backendClassInterface.handlebars

66 lines
1.9 KiB
Handlebars
Raw Normal View History

2020-08-24 07:38:40 +00:00
// Automatic Genearted File for Backendclass: "{{className}}"
// To update run `npm run build:backend`
2020-08-25 10:33:33 +00:00
import { nopeDispatcher } from "../dispatcher/nopeDispatcher"
import { nopeRemoteObservable } from "../observables/nopeRemoteObservable"
2020-08-24 07:38:40 +00:00
{{!--
/**
* Interface for the Analyzing Result
*/
export interface IAnalyzeResult {
// Name of the Class
className: string,
// Decorators of the Class
classDecorator: DecoratorInformation,
// Methods of the Class
methods: (MethodInformation & DecoratorInformation)[],
// Properties of the Class
properties: (PropertyInformation & DecoratorInformation)[],
// Imports of the Class (contians external Files)
imports: {
content: string,
required: boolean,
}
}
--}}
{{#if imports.required}}
{{{imports.content}}}
{{/if}}
export class {{className}} {
2020-08-25 10:33:33 +00:00
{{#each properties}}
public {{name}}: nopeRemoteObservable<{{{simplifiedSubType}}}>
{{/each}}
public readonly uri: string;
2020-09-08 08:46:52 +00:00
/**
* Creates an instance of the Class.
* @param _dispatcher The Dispatcher to use.
*/
constructor(protected _dispatcher: nopeDispatcher, uri?: string){
this.uri = typeof uri === "string" ? uri : '{{classUri}}'
2020-08-25 10:33:33 +00:00
{{#each properties}}
2020-08-25 10:33:33 +00:00
this.{{name}} = new nopeRemoteObservable(_dispatcher,{
path: {{{uri}}}
2020-08-25 10:33:33 +00:00
})
{{/each}}
2020-08-24 07:38:40 +00:00
}
{{!--
2020-09-08 08:46:52 +00:00
Iterate over the Methods and create the Function Interface
2020-08-24 07:38:40 +00:00
--}}
{{#each methods}}
2020-09-08 08:46:52 +00:00
{{!-- Use the Docu of the Author --}}
2020-08-24 07:38:40 +00:00
{{{authorDescription}}}
public async {{name}}{{{head}}}{
2020-09-08 08:46:52 +00:00
// Perform the Method via the Dispatcher.
{{!-- Perform the Dispather-Call --}}
return await this._dispatcher.performCall<{{{returnType.simplifiedSubType}}}>({{{uri}}}, [{{#each params}}{{name}}{{#unless @last}}, {{/unless}}{{/each}}])
2020-08-24 07:38:40 +00:00
}
{{/each}}
}