All files / blong-gogo/src/orchestrator/common openapi.ts

96.77% Statements 30/31
66.66% Branches 2/3
100% Functions 1/1
96.77% Lines 30/31

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 321x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import {orchestrator} from '@feasibleone/blong/types';
 
export default orchestrator<{api: {namespace: Record<string, string | string[]>}}>(
    ({registry}) => ({
        activation: {
            default: {
                type: 'openapi',
                namespace: ['openapi'],
                imports: [/(?<!codec)\.openapi$/],
                api: {
                    namespace: {},
                },
            },
        },
        async start() {
            super.connect();
            const result = await super.start({});
            const assets: {[namespace: string]: unknown} = {};
            for (const [key, value] of Object.entries(this.config.api.namespace))
                assets[key] = await (this as unknown as {link(s: string): Promise<unknown>}).link(
                    `${value as string}.asset`,
                );
            await registry.loadApi(
                'orchestrator.openapi.api',
                {namespace: assets as Record<string, string | string[]>},
                'assets',
            );
            return result;
        },
    }),
);