Skip to content

Commit

Permalink
Merge pull request #226 from HubSpot/cp/update-function-logs-response…
Browse files Browse the repository at this point in the history
…-types

Add types for CMS function logs API responses
  • Loading branch information
camden11 authored Jan 10, 2025
2 parents fb29b4f + 5b78413 commit 20d1a64
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
11 changes: 8 additions & 3 deletions api/functions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { http } from '../http';
import { HubSpotPromise, QueryParams } from '../types/Http';
import { GetBuildStatusResponse, GetRoutesResponse } from '../types/Functions';
import {
GetBuildStatusResponse,
FunctionLog,
GetRoutesResponse,
GetFunctionLogsResponse,
} from '../types/Functions';

const FUNCTION_API_PATH = 'cms/v3/functions';

Expand All @@ -16,7 +21,7 @@ export function getFunctionLogs(
accountId: number,
route: string,
params: QueryParams = {}
): HubSpotPromise {
): HubSpotPromise<GetFunctionLogsResponse> {
const { limit = 5 } = params;

return http.get(accountId, {
Expand All @@ -28,7 +33,7 @@ export function getFunctionLogs(
export function getLatestFunctionLog(
accountId: number,
route: string
): HubSpotPromise {
): HubSpotPromise<FunctionLog> {
return http.get(accountId, {
url: `${FUNCTION_API_PATH}/results/by-route/${encodeURIComponent(
route
Expand Down
28 changes: 28 additions & 0 deletions types/Functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,31 @@ export type FunctionInfo = {
export type FunctionOptions = {
allowExistingFile?: boolean;
};

export type FunctionLog = {
id: string;
executionTime: number;
log: string;
error: {
message: string;
type: string;
stackTrace: string[][];
};
status: string;
createdAt: number;
memory: string;
};

export type GetFunctionLogsResponse = {
results: FunctionLog[];
paging: {
next: {
after: string;
link: string;
};
prev: {
before: string;
link: string;
};
};
};

0 comments on commit 20d1a64

Please sign in to comment.