Skip to content

Commit 5f52292

Browse files
committed
managed run logger accepts nested props
1 parent 752770f commit 5f52292

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

packages/cli-v3/src/entryPoints/managed/logger.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import {
2+
DebugLogPropertiesInput,
23
WorkloadDebugLogRequestBody,
34
WorkloadHttpClient,
45
} from "@trigger.dev/core/v3/runEngineWorker";
56
import { RunnerEnv } from "./env.js";
7+
import { flattenAttributes } from "@trigger.dev/core/v3";
68

79
export type SendDebugLogOptions = {
810
runId?: string;
911
message: string;
1012
date?: Date;
11-
properties?: WorkloadDebugLogRequestBody["properties"];
13+
properties?: DebugLogPropertiesInput;
1214
print?: boolean;
1315
};
1416

@@ -46,10 +48,14 @@ export class RunLogger {
4648
console.log(message, mergedProperties);
4749
}
4850

51+
const flattenedProperties = flattenAttributes(
52+
mergedProperties
53+
) satisfies WorkloadDebugLogRequestBody["properties"];
54+
4955
this.httpClient.sendDebugLog(runId, {
5056
message,
5157
time: date ?? new Date(),
52-
properties: mergedProperties,
58+
properties: flattenedProperties,
5359
});
5460
}
5561
}

packages/core/src/v3/runEngineWorker/supervisor/schemas.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,24 @@ export const DebugLogPropertiesValue = z.union([
130130
z.string(),
131131
z.number(),
132132
z.boolean(),
133-
z.array(z.string().nullable()),
134-
z.array(z.number().nullable()),
135-
z.array(z.boolean().nullable()),
133+
z.array(z.string().nullish()),
134+
z.array(z.number().nullish()),
135+
z.array(z.boolean().nullish()),
136136
]);
137137

138138
export const DebugLogProperties = z.record(z.string(), DebugLogPropertiesValue.optional());
139139
export type DebugLogProperties = z.infer<typeof DebugLogProperties>;
140140

141+
export const DebugLogPropertiesInput = z.record(z.string(), z.unknown());
142+
export type DebugLogPropertiesInput = z.infer<typeof DebugLogPropertiesInput>;
143+
144+
export const WorkerApiDebugLogBodyInput = z.object({
145+
time: z.coerce.date(),
146+
message: z.string(),
147+
properties: DebugLogPropertiesInput.optional(),
148+
});
149+
export type WorkerApiDebugLogBodyInput = z.infer<typeof WorkerApiDebugLogBodyInput>;
150+
141151
export const WorkerApiDebugLogBody = z.object({
142152
time: z.coerce.date(),
143153
message: z.string(),

packages/core/src/v3/schemas/messages.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
WaitReason,
1919
} from "./schemas.js";
2020
import { CompletedWaitpoint } from "./runEngine.js";
21-
import { DebugLogProperties } from "../runEngineWorker/index.js";
21+
import { DebugLogPropertiesInput } from "../runEngineWorker/index.js";
2222

2323
export const AckCallbackResult = z.discriminatedUnion("success", [
2424
z.object({
@@ -179,7 +179,7 @@ export const ExecutorToWorkerMessageCatalog = {
179179
message: z.object({
180180
version: z.literal("v1").default("v1"),
181181
message: z.string(),
182-
properties: DebugLogProperties.optional(),
182+
properties: DebugLogPropertiesInput.optional(),
183183
}),
184184
},
185185
};

0 commit comments

Comments
 (0)