diff --git a/src/endpoints/logs.ts b/src/endpoints/logs.ts index 08168ed..f147437 100644 --- a/src/endpoints/logs.ts +++ b/src/endpoints/logs.ts @@ -19,7 +19,7 @@ export const LogSchema = z.object({ }), // Text content of the log - message: z.string(), + message: z.string().optional(), // Metadata specific to this log line kv: LogKVSchema.optional(), diff --git a/tests/logs.test.ts b/tests/logs.test.ts index e7e194f..d5bba71 100644 --- a/tests/logs.test.ts +++ b/tests/logs.test.ts @@ -285,7 +285,7 @@ test("with both kv", async () => { }); }); -test('with undefined kv values', async () => { +test("with undefined kv values", async () => { const res = await logs .ship( { @@ -320,7 +320,42 @@ test('with undefined kv values', async () => { }, ], }); -}) +}); + +test("with no message", async () => { + const res = await logs + .ship( + { + success: true, + data: { + service: "blob-city", + environment: "production", + kv: { common: undefined }, + logs: [ + { + level: "info", + timestamp: { p: "ns", v: "001" }, + }, + ], + }, + }, + env, + ) + .then((r) => r.json()); + + expect(res).toStrictEqual({ + streams: [ + { + stream: { + environment: "production", + service: "blob-city", + level: "info", + }, + values: [["001", ""]], + }, + ], + }); +}); test("multiple logs", async () => { const res = await logs