@mondaycom/apps-cli
Version:
A cli tool to manage apps (and monday-code projects) in monday.com
31 lines (30 loc) • 1.36 kB
JavaScript
import { StatusCodes } from 'http-status-codes';
import { getLogsStreamForAppVersionIdUrl } from '../consts/urls.js';
import { execute } from './api-service.js';
import { clientChannelSchema } from './schemas/notification-schema.js';
import { HttpError } from '../types/errors/index.js';
import { HttpMethodTypes } from '../types/services/api-service.js';
import logger from '../utils/logger.js';
import { appsUrlBuilder } from '../utils/urls-builder.js';
export const logsStream = async (appVersionId, logsType, logsFilterCriteria, region) => {
try {
const logsStreamForUrl = getLogsStreamForAppVersionIdUrl(appVersionId, logsType, logsFilterCriteria, region);
const url = appsUrlBuilder(logsStreamForUrl);
logger.debug(`fetching logs url: ${url}`);
const response = await execute({
url,
headers: { Accept: 'application/json' },
method: HttpMethodTypes.GET,
}, clientChannelSchema);
return response;
}
catch (error) {
if (error instanceof HttpError) {
const finalHttpError = error.code === StatusCodes.NOT_FOUND
? new Error('monday-code deployment not found for the requested app-version')
: error;
throw finalHttpError;
}
throw new Error('Failed to open logs channel.');
}
};