Skip to content

Commit 20d1a64

Browse files
authored
Merge pull request #226 from HubSpot/cp/update-function-logs-response-types
Add types for CMS function logs API responses
2 parents fb29b4f + 5b78413 commit 20d1a64

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

api/functions.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { http } from '../http';
22
import { HubSpotPromise, QueryParams } from '../types/Http';
3-
import { GetBuildStatusResponse, GetRoutesResponse } from '../types/Functions';
3+
import {
4+
GetBuildStatusResponse,
5+
FunctionLog,
6+
GetRoutesResponse,
7+
GetFunctionLogsResponse,
8+
} from '../types/Functions';
49

510
const FUNCTION_API_PATH = 'cms/v3/functions';
611

@@ -16,7 +21,7 @@ export function getFunctionLogs(
1621
accountId: number,
1722
route: string,
1823
params: QueryParams = {}
19-
): HubSpotPromise {
24+
): HubSpotPromise<GetFunctionLogsResponse> {
2025
const { limit = 5 } = params;
2126

2227
return http.get(accountId, {
@@ -28,7 +33,7 @@ export function getFunctionLogs(
2833
export function getLatestFunctionLog(
2934
accountId: number,
3035
route: string
31-
): HubSpotPromise {
36+
): HubSpotPromise<FunctionLog> {
3237
return http.get(accountId, {
3338
url: `${FUNCTION_API_PATH}/results/by-route/${encodeURIComponent(
3439
route

types/Functions.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,31 @@ export type FunctionInfo = {
6969
export type FunctionOptions = {
7070
allowExistingFile?: boolean;
7171
};
72+
73+
export type FunctionLog = {
74+
id: string;
75+
executionTime: number;
76+
log: string;
77+
error: {
78+
message: string;
79+
type: string;
80+
stackTrace: string[][];
81+
};
82+
status: string;
83+
createdAt: number;
84+
memory: string;
85+
};
86+
87+
export type GetFunctionLogsResponse = {
88+
results: FunctionLog[];
89+
paging: {
90+
next: {
91+
after: string;
92+
link: string;
93+
};
94+
prev: {
95+
before: string;
96+
link: string;
97+
};
98+
};
99+
};

0 commit comments

Comments
 (0)