nope/test/testFile.ts

80 lines
2.1 KiB
TypeScript

import { exportFunctionToDispatcher, exportMethodToDispatcher, exportPropertyToDispatcher, exportsElementsToDispatcher } from "../lib/dispatcher/nopeDispatcherDecorators";
import { nopeObservable } from "../lib/observables/nopeObservable";
import { exportFunctionToOpenAPI, exportMethodToOpenAPI, exportsElementsToOpenAPI } from "../lib/openapi/nopeOpenAPIDecorators";
import { IF01 } from "./testExternalDescriptor";
import { IF02 } from "./testExternalDescriptorReference";
export interface IF00 {
// Test property
hello: 'world'
}
@exportsElementsToOpenAPI({})
@exportsElementsToDispatcher({})
export class CLWithInterface {
@exportPropertyToDispatcher({})
exportedAttributeSimple = new nopeObservable<boolean>();
@exportPropertyToDispatcher({})
exportedAttributeComplex = new nopeObservable<{
element01: IF00,
num: number
}>({
element01: {
hello: "world"
},
num: 0
});
@exportMethodToOpenAPI({})
@exportMethodToDispatcher({})
async exportedFunctionShouldBeHosted(/* COMMENT */ a: IF00, b?: IF01) {
return a + b
}
/**
*
* Function which will add two Nodes.
* @param a Parameter a
* @param b Parameter b
*/
@exportMethodToOpenAPI({})
@exportMethodToDispatcher({})
async exportedFunctionShouldNotBeHosted(/* COMMENT */ a: number, b: IF00, operator: (a: number, b: IF01) => Promise<{
test: IF02,
x: string
}>) {
// Comment etc.
return await operator(a, b);
}
/**
* Function which will add two Nodes.
* @param a Parameter a
* @param b Parameter b
*/
@exportMethodToDispatcher({})
async exportedStringFunction(a: string, b: string) {
// Comment etc.
return "";
}
exportedFunctionWithError(a: number, b: number, operator: (a: number, b: number) => Promise<number>) {
return operator(a, b);
}
}
export function test(a: number, b: number) {
return a + b
}
export async function exportedFunc(a: number, b: IF00) {
}
export const test2 = exportFunctionToOpenAPI(exportFunctionToDispatcher(exportedFunc, {
uri: 'test2'
}), {});