nope/test/testFile.ts

80 lines
2.1 KiB
TypeScript
Raw Normal View History

2020-09-07 18:12:28 +00:00
import { exportFunctionToDispatcher, exportMethodToDispatcher, exportPropertyToDispatcher, exportsElementsToDispatcher } from "../lib/dispatcher/nopeDispatcherDecorators";
2020-10-13 16:22:04 +00:00
import { NopeObservable } from "../lib/observables/NopeObservable";
2020-09-07 21:23:55 +00:00
import { exportFunctionToOpenAPI, exportMethodToOpenAPI, exportsElementsToOpenAPI } from "../lib/openapi/nopeOpenAPIDecorators";
2020-08-23 07:28:03 +00:00
import { IF01 } from "./testExternalDescriptor";
import { IF02 } from "./testExternalDescriptorReference";
2020-08-23 09:23:38 +00:00
export interface IF00 {
2020-08-24 07:39:55 +00:00
// Test property
2020-08-23 09:23:38 +00:00
hello: 'world'
}
2020-08-25 10:33:33 +00:00
@exportsElementsToOpenAPI({})
@exportsElementsToDispatcher({})
2020-08-23 07:28:03 +00:00
export class CLWithInterface {
2020-08-25 10:33:33 +00:00
@exportPropertyToDispatcher({})
2020-10-13 16:22:04 +00:00
exportedAttributeSimple = new NopeObservable<boolean>();
2020-08-24 11:35:32 +00:00
2020-08-25 10:33:33 +00:00
@exportPropertyToDispatcher({})
2020-10-13 16:22:04 +00:00
exportedAttributeComplex = new NopeObservable<{
2020-08-24 07:39:55 +00:00
element01: IF00,
2020-08-23 07:28:03 +00:00
num: number
}>({
2020-08-24 07:39:55 +00:00
element01: {
2020-08-24 11:35:32 +00:00
hello: "world"
2020-08-24 07:39:55 +00:00
},
2020-08-23 07:28:03 +00:00
num: 0
});
@exportMethodToOpenAPI({})
2020-08-25 10:33:33 +00:00
@exportMethodToDispatcher({})
async exportedFunctionShouldBeHosted(/* COMMENT */ a: IF00, b?: IF01) {
return a + b
}
2020-08-24 07:39:55 +00:00
/**
*
* Function which will add two Nodes.
* @param a Parameter a
* @param b Parameter b
*/
2020-08-24 21:09:26 +00:00
@exportMethodToOpenAPI({})
2020-08-25 10:33:33 +00:00
@exportMethodToDispatcher({})
2020-08-24 11:35:32 +00:00
async exportedFunctionShouldNotBeHosted(/* COMMENT */ a: number, b: IF00, operator: (a: number, b: IF01) => Promise<{
2020-08-24 07:39:55 +00:00
test: IF02,
x: string
2020-08-24 11:35:32 +00:00
}>) {
// Comment etc.
return await operator(a, b);
}
2020-08-23 07:28:03 +00:00
2020-08-24 11:35:32 +00:00
2020-08-24 07:39:55 +00:00
/**
* Function which will add two Nodes.
* @param a Parameter a
* @param b Parameter b
*/
2020-08-25 10:33:33 +00:00
@exportMethodToDispatcher({})
2020-08-24 11:35:32 +00:00
async exportedStringFunction(a: string, b: string) {
2020-08-24 07:39:55 +00:00
// Comment etc.
return "";
}
2020-08-24 11:35:32 +00:00
exportedFunctionWithError(a: number, b: number, operator: (a: number, b: number) => Promise<number>) {
return operator(a, b);
2020-08-23 07:28:03 +00:00
}
2020-09-07 18:12:28 +00:00
}
export function test(a: number, b: number) {
2020-09-07 18:12:28 +00:00
return a + b
}
2020-09-07 21:23:55 +00:00
export async function exportedFunc(a: number, b: IF00) {
2020-09-07 18:12:28 +00:00
2020-09-07 21:23:55 +00:00
}
export const test2 = exportFunctionToOpenAPI(exportFunctionToDispatcher(exportedFunc, {
2020-09-07 18:12:28 +00:00
uri: 'test2'
2020-09-07 21:23:55 +00:00
}), {});