All files / src/Batch GoogleCloudLoggingGetEntryListBatch.ts

94.44% Statements 17/18
62.5% Branches 5/8
100% Functions 2/2
94.44% Lines 17/18

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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 1461x 1x   1x   1x   1x     1x       1x   1x   1x   1x               1x 1x   1x   1x   1x   1x       1x                                                                                                                                                                                                                
import ABatchNode from '@orchesty/nodejs-sdk/dist/lib/Batch/ABatchNode';
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
import BatchProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/BatchProcessDto';
import { NAME as APPLICATION_NAME } from '../GoogleCloudLoggingApplication';
 
export const NAME = `${APPLICATION_NAME}-get-entry-list-batch`;
 
export default class GoogleCloudLoggingGetEntryListBatch extends ABatchNode {
 
    public getName(): string {
        return NAME;
    }
 
    public async processAction(dto: BatchProcessDto<IInput>): Promise<BatchProcessDto> {
        const cursor = dto.getBatchCursor();
 
        const pageToken = cursor ?? undefined;
 
        const body = { ...dto.getJsonData(), pageToken };
 
        const requestDto = await this.getApplication().getRequestDto(
            dto,
            await this.getApplicationInstallFromProcess(dto),
            HttpMethods.POST,
            '/v2/entries:list',
            body,
        );
 
        const responseDto = await this.getSender().send<IOutput>(requestDto, [200]);
        const response = responseDto.getJsonBody();
 
        const items = response?.entries ?? [];
 
        dto.setItemList(items);
 
        const { nextPageToken } = response;
 
        Iif (items.length && nextPageToken) {
            dto.setBatchCursor(nextPageToken);
        }
 
        return dto;
    }
 
}
 
export interface IInput {
    resourceNames: string[];
    /** @deprecated */projectIds?: string[];
    filter?: string,
    orderBy?: string,
    pageSize?: number,
    pageToken?: string
}
 
export interface IOutput {
    entries: LogEntry[];
    nextPageToken: string;
}
 
interface LogEntry {
    logName: string;
    resource: {
        type: string;
        labels: Record<string, string>;
    };
    receiveTimestamp: string;
    /** @deprecated */metadata: {
        systemLabels: object;
        userLabels: Record<string, string>;
    };
    errorGroups: {
        id: string;
    }[];
    apphub: AppHub;
    apphubDestination: AppHub;
    // eslint-disable-next-line @typescript-eslint/naming-convention
    protoPayload: { '@type': string } & Record<string, string>;
    textPayload: string;
    jsonPayload: object;
    timestamp?: string,
    severity?: 'DEFAULT'
    | 'DEBUG'
    | 'INFO'
    | 'NOTICE'
    | 'WARNING'
    | 'ERROR'
    | 'CRITICAL'
    | 'ALERT'
    | 'EMERGENCY';
    insertId?: string;
    httpRequest?: {
        requestMethod: string;
        requestUrl: string;
        requestSize: string;
        status: number;
        responseSize: string;
        userAgent: string;
        remoteIp: string;
        serverIp: string;
        referer: string;
        latency: string;
        cacheLookup: boolean;
        cacheHit: boolean;
        cacheValidatedWithOriginServer: boolean;
        cacheFillBytes: string;
        protocol: string;
    };
    labels?: Record<string, string>;
    operation?: {
        id?: string;
        producer?: string;
        first?: boolean;
        last?: boolean;
    };
    trace?: string;
    spanId?: string;
    traceSampled?: boolean;
    sourceLocation?: {
        file?: string;
        line?: string;
        function?: string;
    };
    split?: {
        uid: string;
        index: number;
        totalSplits: number;
    };
}
 
interface AppHub {
    application: {
        id: string;
        container: string;
        location: string;
    };
    service: AppHubService;
    workload: AppHubService;
}
 
interface AppHubService {
    id: string;
    environmentType: string;
    criticalityType: string;
}